microera Posted January 1, 2011 Share Posted January 1, 2011 I know about IsPressed() but this function is only to compare to check for specific key! I need function "if any of key is pressed" ..... ? Link to comment Share on other sites More sharing options...
UEZ Posted January 1, 2011 Share Posted January 1, 2011 Try this: expandcollapse popup$hGui = GUICreate("Press any key to exit...", 400, 100) GUISetState() $sKeyboardState = _WinAPI_GetKeyboardState(1) While _WinAPI_GetKeyboardState(1) = $sKeyboardState Sleep(100) WEnd GUIDelete($hGui) Exit ; #FUNCTION# ==================================================================================================================== ; Name...........: _WinAPI_GetKeyboardState ; Description ...: Returns the status of the 256 virtual keys ; Syntax.........: _WinAPI_GetKeyboardState($iFlag=0) ; Parameters ....: $iFlag - Return Type ; 0 Returns an array[256] ; 1 Returns a string ; Return values .: Success - Array[256] or String containing status of 256 virtual keys ; Failure - False ; Author ........: Eukalyptus ; Modified.......: ; Remarks .......: If the high-order bit is 1, the key is down; otherwise, it is up. ; If the key is a toggle key, for example CAPS LOCK, then the low-order bit is 1 ; when the key is toggled and is 0 if the key is untoggled ; Related .......: _IsPressed ; Link ..........; ; Example .......; ; =============================================================================================================================== Func _WinAPI_GetKeyboardState($iFlag = 0) Local $aDllRet, $lpKeyState = DllStructCreate("byte[256]") $aDllRet = DllCall("User32.dll", "int", "GetKeyboardState", "ptr", DllStructGetPtr($lpKeyState)) If @error Then Return SetError(@error, 0, 0) If $aDllRet[0] = 0 Then Return SetError(1, 0, 0) Else Switch $iFlag Case 0 Local $aReturn[256] For $i = 1 To 256 $aReturn[$i - 1] = DllStructGetData($lpKeyState, 1, $i) Next Return $aReturn Case Else Return DllStructGetData($lpKeyState, 1) EndSwitch EndIf EndFunc ;==>_WinAPI_GetKeyboardState Br, UEZ Xandy 1 Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
microera Posted January 1, 2011 Author Share Posted January 1, 2011 after searching I found another answer..... #include <WindowsConstants.au3> GUIRegisterMsg($WM_KEYDOWN, "IsPressed") $hGui = GUICreate("Press any key within 10s...", 400, 100) GUISetState() Sleep(10000) GUIDelete($hGui) Exit Func IsPressed() MsgBox(4096, "Test", "Key is pressed!", 2) EndFunc Link to comment Share on other sites More sharing options...
hench Posted January 1, 2011 Share Posted January 1, 2011 you mean this key???hehe yutijang 1 Link to comment Share on other sites More sharing options...
ALFJ Posted January 2, 2011 Share Posted January 2, 2011 you mean this key???heheAhh my keyboard is missing it LoL 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