MrCreatoR Posted January 29, 2009 Share Posted January 29, 2009 (edited) First of all, i want to say thanks to Firefox, for the _IsPressed UDFs library. I took from there the whole concept for this “remake” and the needed helper functions.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. expandcollapse popup; #FUNCTION# =================================================================== ; Name: _UserInput_Read ; Description: Check user input. ; ; Parameter(s): $nHexStrKey - Hex or String key to check. ; [*] This parameter supports 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. ; [*] This parameter accepts special CLASS name, bellow is the list of supported classes: ; [:ALLKEYS:] - All possible keys (any key) except mouse events (combine with [:ALLMOUSE:] to read all inputs) ; [:ALPHA:] - Standard Alpha keys ; [:ALLNUM:] - Standard Numeric keys or Numpad keys ; [:NUMPAD:] - Numpad keys ; [:NUMERIC:] - Standard Numeric keys ; [:ALLFUNC:] - F1 -> F24 ; [:FUNC:] - F1 -> F12 ; [:FUNCSPEC:] - F13 -> F24 ; [:ARROW:] - Up, Down, Left, Right ; [:ALLMOUSE:] - All mouse buttons + Wheel scroll + Mouse Move ; [:MOUSEMOVE:] - Mouse move ; [:WHEELDOWN:] - Wheel button held down (pressed) ; [:WHEELSCROLL:] - Wheel scroll ; [:SPECIAL:] - BACKSPACE, TAB, ENTER etc. ; ; $iWait - [Optional] Wait untill the pressed key is released (default is 0, no wait). ; in this case the return will include time (in milliseconds) the key has been held down. ; NOTE: $iWait will fail on "+" operation and few mouse events (Wheel scroll and Mouse movement). ; ; Return Value(s): Always return array with 2 elements. The values in these elements depends on $iWait/$nHexStrKey parameters: ; [0] - If key(s) has been pressed, returns 1 or time representation if $iWait = 1, otherwise returns 0. ; [1] - If key(s) has been pressed, returns pressed key (see bellow exceptions list), otherwise returns empty string (""). ; * When using mouse classes ([:ALLMOUSE:]/[:MOUSEMOVE:]/[:WHEELDOWN:]/[:WHEELSCROLL:]), ; there is an exception in return value, here is the list of return values depending on specified class: ; [:ALLMOUSE:] - Returns: ; "MOUSE_MOVE" string if mouse has been moved ; "MOUSE_BUTTON" string if mouse wheel button has been pressed ; "MOUSE_SCROLL" string if mouse wheel has been scrolled ; [:MOUSEMOVE:] - Returns "MOUSE_MOVE" string if mouse has been moved ; [:WHEELDOWN:] - Returns "MOUSE_BUTTON" string if mouse wheel button has been pressed ; [:WHEELSCROLL:] - Returns "MOUSE_SCROLL" string if mouse wheel has been scrolled ; ; ; Author(s): G.Sandler (MrCreatoR) ; Note(s): See examples to get idea of proper usage. ;===============================================================================Simple example (Mixed keys usage):#include <UserInput.au3> HotKeySet('{ESC}', '_Quit') 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}. $aRead = _UserInput_Read('{CTRL}+S|20|[:ALPHA:]+[:ALLNUM:]|-|=|\|''|;|[QWERT]') If $aRead[0] Then _Output_Result($aRead[1]) EndIf Sleep(10) WEnd Func _Output_Result($iKey) Local $sKeys = '', $aKeys = StringSplit($iKey, '+') ;Formate the output For $i = 1 To $aKeys[0] $sKeys &= '{' & _UserInput_GetKeyString($aKeys[$i]) & '}' If $i < $aKeys[0] Then $sKeys &= '+' Next Local $sTT_Data = StringFormat('_UserInput_Read Return:\t%s (%s)', $iKey, $sKeys) ToolTip($sTT_Data) EndFunc Func _Quit() Exit EndFunc===============================================================================Attachments:UserInput.zipIsPressedEx_UDF.zipEnjoy! Edited February 10, 2015 by MrCreatoR Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team Link to comment Share on other sites More sharing options...
FireFox Posted January 29, 2009 Share Posted January 29, 2009 @MrCreator Nice job ! I like the way to use '{ESC}', its another way of _GetKeyByAlpha('ESC')... Cheers, FireFox. Link to comment Share on other sites More sharing options...
Kip Posted January 29, 2009 Share Posted January 29, 2009 Could be handy. MailSpons: Fake SMTP server for safe email testing Dutch postcode & address API. Link to comment Share on other sites More sharing options...
RWBaker Posted February 27, 2009 Share Posted February 27, 2009 Great job on the IsPressedEx script! In looking through it in detail, I have however found one minor problem. The script that I just copied from the above link, does not see apostrophes('). I have found that the fix for this involves only two changes: In IsPressedEx_UDF.au3: line 103 (which is within function: _IsPressedEx()) reads: $iKeysPressed = __KeysPressedCheck_Proc(1, 221, -1, $iWait, $iTFormat, $vDLL) should be: $iKeysPressed = __KeysPressedCheck_Proc(1, 222, -1, $iWait, $iTFormat, $vDLL) the same correction in: line 160 (which is within function: _IsPressedEx()) reads: $iKeysPressed = __KeysPressedCheck_Proc(136, 221, -1, $iWait, $iTFormat, $vDLL) should read: $iKeysPressed = __KeysPressedCheck_Proc(136, 222, -1, $iWait, $iTFormat, $vDLL) Thanks, RW Baker RW Baker Link to comment Share on other sites More sharing options...
MrCreatoR Posted March 9, 2009 Author Share Posted March 9, 2009 Great job on the IsPressedEx script! In looking through it in detail, I have however found one minor problem. The script that I just copied from the above link, does not see apostrophes('). I have found that the fix for this involves only two changes: In IsPressedEx_UDF.au3: line 103 (which is within function: _IsPressedEx()) reads: $iKeysPressed = __KeysPressedCheck_Proc(1, 221, -1, $iWait, $iTFormat, $vDLL) should be: $iKeysPressed = __KeysPressedCheck_Proc(1, 222, -1, $iWait, $iTFormat, $vDLL) the same correction in: line 160 (which is within function: _IsPressedEx()) reads: $iKeysPressed = __KeysPressedCheck_Proc(136, 221, -1, $iWait, $iTFormat, $vDLL) should read: $iKeysPressed = __KeysPressedCheck_Proc(136, 222, -1, $iWait, $iTFormat, $vDLL) Thanks, RW Baker Thanks, will be fixed (it's for [:ALLKEYS:] and [:SPECIAL:] classes, right?). Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team Link to comment Share on other sites More sharing options...
RWBaker Posted March 11, 2009 Share Posted March 11, 2009 Sorry...I've been away...Yes: [:ALLKEYS:] and [:SPECIAL:] classes. RW Baker RW Baker Link to comment Share on other sites More sharing options...
joseLB Posted November 9, 2009 Share Posted November 9, 2009 (edited) Hi Mr.Creator This is really a must. I just downloaded it, and by teh descripton it will help a lot. Sometime ago FireFox and others helped me in some similar solution, but what I implemented at the end was not so complete as yours. Thanks Jose Edited November 11, 2009 by joseLB Link to comment Share on other sites More sharing options...
lsakizada Posted November 11, 2009 Share Posted November 11, 2009 (edited) Hi nice work.How do I get this to be detected once? I meant that if the function _IsPressedEx return 1 then its wont be true again unless at least one of the keys is released and pressed back...EDIT: Disregards my question.I found that it is implemented already by monitoring the time of the pressed key.The __IsPressed_GetTime function helper helps here since the "$iWait" parameter can be set to very long time. Edited November 14, 2009 by lsakizada Be Green Now or Never (BGNN)! Link to comment Share on other sites More sharing options...
Deathboy Posted April 2, 2010 Share Posted April 2, 2010 Hi there, was wondering about this script. Is it possible to make it work so that there is a different key for mose scrolling each way? Now it is: If _IsPressedEx("[:WHEELSCROLL:]... That only detect if the scroll button is used, I need it to detect if it scroll one way or the other. Is it possible? Deathboy Link to comment Share on other sites More sharing options...
WeMartiansAreFriendly Posted April 2, 2010 Share Posted April 2, 2010 You probably know this already but dllcall("user32.dll", "...") would work the same as dllopen/close because 'user32.dll' and other common dlls are loaded in memory by AutoIt before the script is executed, and AutoIt will close the DLL itself when it exits. Also could also save a few bytes by just adding _IsPressed() by itself. Anyways nice script, good idea. Don't bother, It's inside your monitor!------GUISetOnEvent should behave more like HotKeySet() Link to comment Share on other sites More sharing options...
Igromanru Posted July 4, 2011 Share Posted July 4, 2011 Hi, i must say, its a very nice work. Tank you. But i have a question. How is it possible to found out what a key was pressed? I am aware that this can be used for a keylogger>_< , but i want to make a ComboBox where can be used each key as a hotkey and i can´t use Hotkeyset function on this place, becouse the Hotkeyset function blocks the key. This would be very nice if there are a way to use _IsPressedEx("[:ALLKEYS:]", $hDll) and founds out what the key was pressed. Sorry, for my bad english. I am russian, living in germany and have not so many practis in english. And normaly i am active in german AutoIt forums. I hope someone can help me. Link to comment Share on other sites More sharing options...
FireFox Posted July 4, 2011 Share Posted July 4, 2011 @IgromanruHi,You will find what you want here :Or maybe here :Br, FireFox. Link to comment Share on other sites More sharing options...
Igromanru Posted July 4, 2011 Share Posted July 4, 2011 (edited) Ty FireFox. But i have rewrote now the _IsPressedEx to _IsPressedExEx and now it returns the pressed key. I will test it one more time and if it alowed, i will made a _IsPressedExEx thread. Edited July 4, 2011 by Igromanru Link to comment Share on other sites More sharing options...
timmy2 Posted November 4, 2013 Share Posted November 4, 2013 What is a practical usage example of this UDF? All the included examples merely display a tooltip showing $iRet = 1 and the $iExtended value, also for which I see no useful purpose. Please enlighten me. Link to comment Share on other sites More sharing options...
JohnOne Posted November 4, 2013 Share Posted November 4, 2013 What you are asking for is clearly answered in the first post. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
timmy2 Posted November 4, 2013 Share Posted November 4, 2013 (edited) Thank you for replying, JohnOne, but I would not have asked if its usefulness was clear to me. I'm not trying to insult or question the author. I want to grasp its usefulness so I can perhaps use it. The functional results of the included examples is a tooltip that looks the same for almost every key pressed. It may be as plain as the nose on your face but I'm simply not seeing it. Please humor me with a real-world example. Edited November 4, 2013 by timmy2 Link to comment Share on other sites More sharing options...
JohnOne Posted November 4, 2013 Share Posted November 4, 2013 I want to test if a certain key class of key is pressed (any of them) "[:ALPHA:]". I use IsPressedEx_UDF. Could I do it with _Ispressed UDF? probably, but I don't need to, this UDF deals with it. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
MrCreatoR Posted February 10, 2015 Author Share Posted February 10, 2015 Update... v1.2 (09.02.2015) * UDF renamed to UserInput. * Better return handling (see examples). * Changed functions usage concept (see examples). * Many bug fixes. Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team 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