|
Post by larrybtoys on Aug 10, 2023 12:59:30 GMT 1
Is there a simple way to monitor the shift or ctrl keys? I would like to get a quick scan of these keys when getting to a certain part of a program in order to skip ahead...TIA
|
|
|
Post by scalion on Aug 10, 2023 13:37:32 GMT 1
HI,you can use getasynckeystate() with Vk_shift or other vk constants. An other way is the mousekb statement. A 3th is the shiftkeys statements.
Example with MouseKB :
$Library "gfawinx" $Library "UpdateRT" UpdateRuntime ' Patches GfaWin23.Ocx Global String info FullW 1 FontSize = 20 Ocx Label L_MouseKB = "", 10, 10, _X - 20, 150 L_MouseKB.MultiLine = True Do info = "Bin(MouseKB)=" & Bin(MouseKB, 32) & #13#10 If MouseKB And 1 info = info & "Shift " If MouseKB And 2 info = info & "Control " If MouseKB And 4 info = info & "Alt "// : Void SetFocus(Win_1.hWnd) L_MouseKB.Text = info Sleep Loop Until Me Is Nothing
Example with GetAsyncKeyState() :
$Library "gfawinx" $Library "UpdateRT" UpdateRuntime ' Patches GfaWin23.Ocx Global String info FullW 1 FontSize = 20 Ocx Label L_AsyncKey = "", 10, 10, _X - 20, 150 L_AsyncKey.MultiLine = True Do info = "" If GetAsyncKeyState(VK_LSHIFT) And &x1000000000000000 info = info & "Left Shift " If GetAsyncKeyState(VK_RSHIFT) And &x1000000000000000 info = info & "Right Shift " If GetAsyncKeyState(VK_LCONTROL) And &x1000000000000000 info = info & "Left Control " If GetAsyncKeyState(VK_RCONTROL) And &x1000000000000000 info = info & "Right Control " If GetAsyncKeyState(VK_LMENU) And &x1000000000000000 info = info & "Left Alt " If GetAsyncKeyState(VK_RMENU) And &x1000000000000000 info = info & "Right Alt " L_AsyncKey.Text = info Sleep Loop Until Me Is Nothing
Example with ShiftKeys :
$Library "gfawinx" $Library "UpdateRT" UpdateRuntime ' Patches GfaWin23.Ocx Global String Info Global Long K FullW 1 Ocx Label L_Shiftkeys = "", 10, 10, _X - 20, _Y - 20 L_Shiftkeys.MultiLine = True Do K = Screen.ShiftKeys Info = "Bin(Shiftkeys)=" & Bin(K, 32) If Btst(K, 0) Info = Info & #13#10"Shift" If Btst(K, 1) Info = Info & #13#10"Control" If Btst(K, 2) Info = Info & #13#10"Alternate" If Btst(K, 3) Info = Info & #13#10"Caps Lock" If Btst(K, 4) Info = Info & #13#10"Left Windows key" If Btst(K, 5) Info = Info & #13#10"Right Windows key" If Btst(K, 6) Info = Info & #13#10"Menu" If Btst(K, 8) Info = Info & #13#10"Left Shift" If Btst(K, 9) Info = Info & #13#10"Left Control" If Btst(K, 10) Info = Info & #13#10"Left Alt" If Btst(K, 12) Info = Info & #13#10"Right Shift" If Btst(K, 13) Info = Info & #13#10"Right Control" If Btst(K, 14) Info = Info & #13#10"Right Alt" If Btst(K, 16) Info = Info & #13#10"Insert" If Btst(K, 17) Info = Info & #13#10"Num Lock Active" If Btst(K, 18) Info = Info & #13#10"Scroll Lock Active" If Btst(K, 19) Info = Info & #13#10"Alt Active" If Btst(K, 20) Info = Info & #13#10"Left Windows key active" If Btst(K, 21) Info = Info & #13#10"Right Windows key active" If Btst(K, 22) Info = Info & #13#10"Application key active" L_Shiftkeys.Text = Info Sleep Loop Until Me Is Nothing
|
|
webu
Full Member
Posts: 149
|
Post by webu on Aug 10, 2023 16:43:30 GMT 1
Proc WaitKBshift(Status%) ' Status: ' -1 wait for key(s) ' 0 wait for release of the keys Do // If key ist pressed, in i& Bit 15 is set, that means, that the WORD is negative. // so please do not take LONG var for i Local i& = /* GetKeyState(VK_SHIFT) or */ GetKeyState(VK_CONTROL) /* Or GetKeyState(VK_MENU)*/ Exit If (i < 0) = Status Sleep Loop
|
|
|
Post by larrybtoys on Aug 10, 2023 20:32:04 GMT 1
Thank you...This worked great...
t& = Screen.ShiftKeys 'Needs to be a 4 byte variable to go above bit 16 If Btst(t&, 8) GoTo Play_Level_2 'This goes right to level 2 EndIf If Btst(t&, 12) GoTo Play_Level_3 'This goes right to level 3 EndIf
|
|