keyboard

Just starting out? Need help? Post your questions and find answers here.
martin66119
User
User
Posts: 46
Joined: Sat Jan 08, 2005 7:46 pm

keyboard

Post by martin66119 »

Hi and good morning!

By using following simple code it is possible to check if a key (e.g. "A") was pressed. But it worked only if the program is running in "foreground" (active window).

May question is:Is it possible to modify the code that pressing a key (e.g. A) change to a specified window independent which window is the active window (foreground window).

I want to implement a function, if someone enter the room and he may not or should not see what I doing.

Thanks in adwance

Code: Select all


Structure keys 
  Wert.l 
  Name.s 
EndStructure 
NewList Keys.keys() 
AddElement(Keys()) 

ddElement(Keys()) 
Keys()\Wert = #VK_A 
Keys()\Name = "VK_A" 
AddElement(Keys()) 
Keys()\Wert = #VK_B 
Keys()\Name = "VK_B"

OpenWindow(0,0,0,400,300,"Test")

Repeat 
  ereignis.l = WaitWindowEvent() 
  
  If ereignis.l = #WM_KEYDOWN 
    If EventlParam() & %01000000000000000000000000000000 
      Debug Str(EventwParam()) + " ..." 
    Else 
      ForEach Keys() 
        If EventwParam() = Keys()\Wert 
          Debug Keys()\Name + " *was pressed*" 
        EndIf 
      Next 
    EndIf   
  EndIf 

Until ereignis.l = #PB_Event_CloseWindow 
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

The answer can you found in your other started thread:
http://www.purebasic.fr/german/viewtopi ... 843#163843
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
Post Reply