myspacee Posted March 20, 2009 Posted March 20, 2009 hello, i use my wireless joypad as remote form my media center living room. I need to turn off pc from joypad (i can set every keyboard button to one joypad button) So i think to Autoit to detect if a keboard button is hold on for 5 second and then run a script that turn off my computer. In forum find most of post, speak about simulate a hold key, not detect it. Anyone can help me ? thank you, m.
Zedna Posted March 20, 2009 Posted March 20, 2009 Look at _IsPressed() Resources UDF ResourcesEx UDF AutoIt Forum Search
myspacee Posted March 20, 2009 Author Posted March 20, 2009 (edited) Thank you for reply, reading _IsPressed(), write this: #include <Misc.au3> dim $counter = 0 HotKeySet("{ESC}","_countdown") ;---------------- MAIN (your script) while 1 sleep(100) WEnd ;---------------- FUNCTION func _countdown() $dll = DllOpen("user32.dll") While 1 $counter = $counter + 1 If _IsPressed("1B", $dll) Then tooltip("Cicles : " & $counter) Sleep(1000) ToolTip("") if $counter > 100 Then msgbox(0,"","run your script after : " & $counter & " cicles") $counter = 0 EndIf Else $counter = 0 ExitLoop EndIf WEnd DllClose($dll) EndFunc Anyone can suggest me corrections ? thank you, m. Edited March 20, 2009 by myspacee
Aceguy Posted March 20, 2009 Posted March 20, 2009 Here is a crude working example. #include <Misc.au3> $counter=0 global $counter $dll = DllOpen("user32.dll") while 1 If _IsPressed("25", $dll) Then $counter+=0.25 sleep(250) ConsoleWrite("sleeping for "&$counter&@lf) Else $counter=0 EndIf if $counter=5 Then MsgBox(0,"Pressed","For 5 secs",0) $counter=0 EndIf WEnd DllClose($dll) [u]My Projects.[/u]Launcher - not just for games & Apps (Mp3's & Network Files)Mp3 File RenamerMy File Backup UtilityFFXI - Realtime to Vana time Clock
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