Stephen89 Posted October 31, 2010 Share Posted October 31, 2010 hi i just want to know if i can do if _ispressed() statement that will just toggle when i press a key 2 times... example if i press "{X}" key twice in 500 milli sec it will send "{Y}" so if i just hold down "{X}" it shouldn't send "{Y}" how can i do this? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 31, 2010 Moderators Share Posted October 31, 2010 Stephen89,Something along these lines should do the trick for you: expandcollapse popup#include <Misc.au3> ; Escape to exit HotKeySet("{ESC}", "On_Exit") Func On_Exit() DllClose($dll) Exit EndFunc $dll =DllOpen("user32.dll") While 1 ; Wait for X press If _IsPressed("58", $dll) Then ; Wait for X release While _IsPressed("58", $dll) Sleep(10) WEnd ; Clear flag $fDbl = False $iBegin = TimerInit() ; Wait for 500ms While TimerDiff($iBegin) < 500 ; If X pressed again within the 500ms If _IsPressed("58", $dll) Then ConsoleWrite("XX" & @CRLF) ; Set flag $fDbl = True ; Wait for X release While _IsPressed("58", $dll) Sleep(10) WEnd ; Leave the waiting loop ExitLoop EndIf WEnd ; If no second X within 500ms If $fDbl = False Then ConsoleWrite("X" & @CRLF) EndIf WEndYou will have to to change the ConsoleWrite lines to Send, of course. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Stephen89 Posted October 31, 2010 Author Share Posted October 31, 2010 Stephen89, Something along these lines should do the trick for you: expandcollapse popup#include <Misc.au3> ; Escape to exit HotKeySet("{ESC}", "On_Exit") Func On_Exit() DllClose($dll) Exit EndFunc $dll =DllOpen("user32.dll") While 1 ; Wait for X press If _IsPressed("58", $dll) Then ; Wait for X release While _IsPressed("58", $dll) Sleep(10) WEnd ; Clear flag $fDbl = False $iBegin = TimerInit() ; Wait for 500ms While TimerDiff($iBegin) < 500 ; If X pressed again within the 500ms If _IsPressed("58", $dll) Then ConsoleWrite("XX" & @CRLF) ; Set flag $fDbl = True ; Wait for X release While _IsPressed("58", $dll) Sleep(10) WEnd ; Leave the waiting loop ExitLoop EndIf WEnd ; If no second X within 500ms If $fDbl = False Then ConsoleWrite("X" & @CRLF) EndIf WEnd You will have to to change the ConsoleWrite lines to Send, of course. M23 thanks alot i will try it now and see if it works Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 31, 2010 Moderators Share Posted October 31, 2010 Stephen89,i will try it now and see if it worksOf course it works or I would not have posted it. But it might not work exactly as you want - so by all means try it and see! M23P.S. When you reply please use the "Add Reply" button at the top and bottom of the page rather then the "Reply" button in the post itself. That way you do not get the contents of the previous post quoted in your reply and the whole thread becomes easier to read. Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area 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