yehia Posted September 6, 2008 Share Posted September 6, 2008 im trying to find a udf same as _istoggled but for ordinary letters like sends true if any key is held down until its up again can anyone help me with this? My Scripts:IE New UDFsElastic images moving under mouse (with a happy valentine's example)_FileRemoveLine Link to comment Share on other sites More sharing options...
Andreik Posted September 6, 2008 Share Posted September 6, 2008 im trying to find a udf same as _istoggled but for ordinary letters like sends true if any key is held down until its up again can anyone help me with this? Try this function: Func GetKeyState($VK_Code) Local $a_Return = DllCall("user32.dll","short","GetKeyState","int",$VK_Code) If $a_Return[0] < -126 Then Return 1 ;Key is pressed Else Return 0 ;Key is released EndIf EndFunc When the words fail... music speaks. Link to comment Share on other sites More sharing options...
yehia Posted September 7, 2008 Author Share Posted September 7, 2008 hmmm strange never returns 1 maybe its vista ? My Scripts:IE New UDFsElastic images moving under mouse (with a happy valentine's example)_FileRemoveLine Link to comment Share on other sites More sharing options...
Andreik Posted September 7, 2008 Share Posted September 7, 2008 hmmm strange never returns 1 maybe its vista ?Please post a part from your code to see when returns 1 and when returns 0. When the words fail... music speaks. Link to comment Share on other sites More sharing options...
yehia Posted September 7, 2008 Author Share Posted September 7, 2008 (edited) Msgbox(0,"",GetKeyState(41)) ;... for the A key Func GetKeyState($VK_Code) Local $a_Return = DllCall("user32.dll","short","GetKeyState","int",$VK_Code) If $a_Return[0] < -126 Then Return 1 ;Key is pressed Else Return 0 ;Key is released EndIf EndFunc oh found it it needs ASCII characters not HEX but still is there any function that tells that there is no key pressed now? Edited September 7, 2008 by yehia My Scripts:IE New UDFsElastic images moving under mouse (with a happy valentine's example)_FileRemoveLine Link to comment Share on other sites More sharing options...
Andreik Posted September 8, 2008 Share Posted September 8, 2008 Msgbox(0,"",GetKeyState(41)) ;... for the A key Func GetKeyState($VK_Code) Local $a_Return = DllCall("user32.dll","short","GetKeyState","int",$VK_Code) If $a_Return[0] < -126 Then Return 1 ;Key is pressed Else Return 0 ;Key is released EndIf EndFunc oh found it it needs ASCII characters not HEX but still is there any function that tells that there is no key pressed now? I write a simple example for you: While 1 If GetKeyState(65) = 1 Then; key A TrayTip("GetKeyState","PRESSED",1) Else TrayTip("GetKeyState","RELEASED",1) EndIf Sleep(20) WEnd Func GetKeyState($VK_Code) Local $a_Return = DllCall("user32.dll","short","GetKeyState","int",$VK_Code) If $a_Return[0] < -126 Then Return 1 ;Key is pressed Else Return 0 ;Key is released EndIf EndFunc When the words fail... music speaks. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now