Luigi Posted July 4, 2015 Share Posted July 4, 2015 (edited) Hi forum!Is possible get when any arrow keys (right, up, left, down) is pressed by Windows Message Code?I have a piece of code with _IsPressed, and work very fine!But the diference is _IsPressed I need put in loop and by Windows Message Code no, is not necessary, is correct?In my search I cant found a example to do this...Some one can help me? Br, Luigi-snipped- Edited July 6, 2015 by Jos code removed Visit my repository Link to comment Share on other sites More sharing options...
Exit Posted July 4, 2015 Share Posted July 4, 2015 HotKeySet() does not burn cpu.See this sample_HotKey("{ESC}") _HotKey("{left}") _HotKey("{right}") _HotKey("{up}") _HotKey("{down}") Func _HotKey($hotkey = "") ; ! ALT + SHIFT ^ CONTROL # WinKey Switch @HotKeyPressed Case "{ESC}" Exit 0*MsgBox(64 + 262144, Default, "Exit", 1) Case "{left}" beep(1000,100) Case "{right}" beep(1500,100) Case "{up}" beep(2000,100) Case "{down}" beep(2500,100) Case Else If Not IsDeclared("hotkey") Then Return MsgBox(16 + 262144, Default, "No CASE statement defined for hotkey " & @HotKeyPressed) If HotKeySet($hotkey, "_Hotkey") = 0 Then Return MsgBox(16 + 262144, Default, "Hotkey " & $hotkey & " invalid or set by another application.") EndSwitch EndFunc ;==>_HotKey While Sleep(99999999) ; this takes minimalst cpu WEnd App: Au3toCmd UDF: _SingleScript() Link to comment Share on other sites More sharing options...
Luigi Posted July 4, 2015 Author Share Posted July 4, 2015 Two comand in same line? (o.O)Exit 0*MsgBox(64 + 262144, Default, "Exit", 1)Thank you Exit, your example work very well and burn low cpu, realy!But I need combine the keys:up, up+left, up+downdown, down+left, down+rightright, right+down, right+leftleft, left+down, left+rightMaybe your example not let do this... Visit my repository Link to comment Share on other sites More sharing options...
reb Posted July 4, 2015 Share Posted July 4, 2015 (edited) Try This Sory this does not work correctly. I will check later to find out what is wrong with it. Local $Out = 0 HotKeySet("{UP}{DOWN}","UPDOWN") do Sleep(10) Until $Out = 1 Func UPDOWN() MsgBox(0,"","UP Down Presses") $Out = 1 EndFunc Edited July 4, 2015 by reb MEASURE TWICE - CUT ONCE Link to comment Share on other sites More sharing options...
Exit Posted July 4, 2015 Share Posted July 4, 2015 Using multiple keysexpandcollapse popup#include <Misc.au3> _HotKey("{ESC}") _HotKey("{left}") _HotKey("{up}") _HotKey("{right}") _HotKey("{down}") Func _HotKey($hotkey = "") ; ! ALT + SHIFT ^ CONTROL # WinKey Switch @HotKeyPressed Case "{ESC}" Exit 0 * MsgBox(64 + 262144, Default, "Exit", 1) Case "{left}", "{up}", "{right}", "{down}" Sleep(100) ; allow other keys to be pressed $text = "" $text &= (_IsPressed(25) ? "Left " : "") $text &= (_IsPressed(26) ? "Up " : "") $text &= (_IsPressed(27) ? "Right " : "") $text &= (_IsPressed(28) ? "Down " : "") if $text > "" then MsgBox(262144, Default, $text, 1) Case Else If Not IsDeclared("hotkey") Then Return MsgBox(16 + 262144, Default, "No CASE statement defined for hotkey " & @HotKeyPressed) If HotKeySet($hotkey, "_Hotkey") = 0 Then Return MsgBox(16 + 262144, Default, "Hotkey " & $hotkey & " invalid or set by another application.") EndSwitch EndFunc ;==>_HotKey While Sleep(99999999) ; this takes minimalst cpu WEnd App: Au3toCmd UDF: _SingleScript() Link to comment Share on other sites More sharing options...
Luigi Posted July 4, 2015 Author Share Posted July 4, 2015 (edited) @Exit, I will try your example, thanks! ^^It is news for me!In time...If found this AZJIO's example:It cath/get arrow keys when you release it, when you press, not get the key... Any idea? -snip- Edited July 6, 2015 by Jos Visit my repository Link to comment Share on other sites More sharing options...
LarsJ Posted July 5, 2015 Share Posted July 5, 2015 (edited) WM_KEYDOWN does not fire when you press an arrow key in an empty GUI. Use a hook procedure:-snip- Edited July 6, 2015 by Jos Luigi 1 Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
Luigi Posted July 5, 2015 Author Share Posted July 5, 2015 Thank you @Larsj, work nice! It's not necessary a loop for detect when a keyup!WM_KEYDOWN does not fire when you press an arrow key in an empty GUI. Use a hook procedure:Hum...empty GUI? If have a element (button, label, any) it's work? Visit my repository Link to comment Share on other sites More sharing options...
LarsJ Posted July 5, 2015 Share Posted July 5, 2015 If you add an input control or an edit control and one of these controls has the keyboard focus I think it'll work. These controls are supposed to handle key down/up events. Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
mikell Posted July 5, 2015 Share Posted July 5, 2015 (edited) An alternative way to _IsPressed() is the use of WM_INPUT, interesting because it works even if the gui is not in the foregroundBefore use, Important : first fix the current $tagRAWKEYBOARD typo in WinAPISys.au3 as mentioned in the code-snipped - Edited July 6, 2015 by Jos Link to comment Share on other sites More sharing options...
Luigi Posted July 5, 2015 Author Share Posted July 5, 2015 @mikell, your code work too! Thank you!8D Visit my repository Link to comment Share on other sites More sharing options...
Developers Jos Posted July 6, 2015 Developers Share Posted July 6, 2015 This is getting close to a full keylogger which we have been clear about ...right?Code will be removed.Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Recommended Posts