The idea here is to make the concept of _IsPressed function to work with more options, such as OR/AND operations, [:CLASS:]es, keys as strings (i.e: "{ESC}"), or simple groups.
; #FUNCTION# =================================================================== ; Name: _IsPressedEx ; Description: Extended _IsPressed function to check if key has been pressed. ; ; Parameter(s): $nHexStrKey - Hex or String key to check. ; [*] This parameter supports a strings as used in HotKeySet() function. ; [*] To make an "OR" checking operation, use "|" delimiter between the keys/classes. ; [*] To make an "AND" checking operation, use "+" delimiter between the keys/classes. ; [*] And also have it's own CLASS list support: ; [:ALLKEYS:] - All possible keys (any key) - @Extended = 1 ; [:ALPHA:] - Standard Alpha keys - @Extended = 2 ; [:ALLNUM:] - Standard Numeric keys or Numpad keys - @Extended = 3-4 ; [:NUMPAD:] - Numpad keys - @Extended = 5 ; [:NUMERIC:] - Standard Numeric keys - @Extended = 6 ; [:ALLFUNC:] - F1 -> F24 - @Extended = 7 ; [:FUNC:] - F1 -> F12 - @Extended = 8 ; [:FUNCSPEC:] - F13 -> F24 - @Extended = 9 ; [:ARROW:] - Up, Down, Left, Right - @Extended = 10 ; [:ALLMOUSE:] - All mouse buttons+Wheel scroll+Mouse Move - @Extended = 11-14 ; [:MOUSEMOVE:] - Mouse move - @Extended = 15 ; [:WHEELDOWN:] - Wheel button held down (pressed) - @Extended = 16 ; [:WHEELSCROLL:] - Wheel scroll - @Extended = 17 ; [:SPECIAL:] - BACKSPACE, TAB, ENTER etc. - @Extended = 18-22 ; ; $vDLL - [Optional] Handle to dll or Default/-1 to user32.dll. ; ; $iWait - [Optional] Wait untill the pressed key is released, ; in this case the return will include time the key has been held down (pressed). ; (default is 0, no wait). ; [NOTE]: $iWait will fail on "+" operation and few mouse events (Wheel scroll and Mouse movement). ; ; $iTFormat - [Optional] Time format to use when $iWait parameter is <> 0: ; -1 - Return floating number of milliseconds (default). ; 1 - Return string with time format. ; ; Requirement(s): AutoIt v3.2.10.0 +. ; ; Return Value(s): On Success - Depending on $iWait/$nHexStrKey parameters, ; if it's 0, then return 1, otherwise check the parameter description. ; @extended is set in accordance with passed class or string/hex keys: ; @extended < 0 indicating on "+" operation, ; -N => Here 'N' is the occurence number where the "AND" keys was found ; (in the "OR" list, i.e: "{F1}|CTRL+P", here @extended = -2 if CTRL+P is pressed). ; @extended = 1 to 21, means the classes is used ; (the extended code will include the value of checked class ; in the same order as it's appearing in the $nHexStrKey parameter's description). ; @extended = 30 means that the key is non CLASS key, but one of the string/hex keys. ; ; On Failure - Returns 0. ; ; Author(s): MrCreatoR ; [Based on _IsPressed UDFs library by Firefox: http://www.autoitscript.com/forum/index.php?showtopic=86296]. ; ; Note(s): See examples to get idea of properly usage. ;===============================================================================
Simple example (Mixed keys usage):
#include <IsPressedEx_UDF.au3> HotKeySet("^q", "_Quit") $hU32_DllOpen = DllOpen("User32.dll") While 1 ;[QWERT] it's a Group, a set of characters (equivalent to "Q|W|E|R|T") ;20 is a hex-value, wich is {Spacebar}. $iRet = _IsPressedEx("{CTRL}+S|20|[:ALPHA:]+[:ALLNUM:]|-|=|\|'|;|[QWERT]", $hU32_DllOpen) If $iRet = 1 Then _Output_IsPressedEx_Result($iRet, @Extended) Sleep(50) WEnd Func _Output_IsPressedEx_Result($iRet, $iExtended) Local $sTT_Data = StringFormat("+ _IsPressedEx Return:\t%s\n! @Extended code:\t%i (see docs for details)", $iRet, $iExtended) ToolTip($sTT_Data) EndFunc Func _Quit() DllClose($hU32_DllOpen) Exit EndFunc
===============================================================================
Attachments:
IsPressedEx_UDF.zip 8.71KB
1119 downloadsEnjoy!









