donhorn20 Posted July 1, 2013 Share Posted July 1, 2013 I currently have two functions, each being called out by a hotkeyset. In this case it is F4 calling out function1() and F6 calling out function2(). I would like to make it where if I press F4 two times it will execute function1(). If I press it three times it will execute function2(). If there is any other key stroke made then it will reset the count. This way I can then use F6 for something else. Is something like this even possible? Link to comment Share on other sites More sharing options...
Blue_Drache Posted July 1, 2013 Share Posted July 1, 2013 I currently have two functions, each being called out by a hotkeyset. In this case it is F4 calling out function1() and F6 calling out function2(). I would like to make it where if I press F4 two times it will execute function1(). If I press it three times it will execute function2(). If there is any other key stroke made then it will reset the count. This way I can then use F6 for something else. Is something like this even possible? You're asking for, in essence, a keylogger. Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache Link to comment Share on other sites More sharing options...
donhorn20 Posted July 1, 2013 Author Share Posted July 1, 2013 You're asking for, in essence, a keylogger. Are hotkeys not ok? We have samples all over the forum where functions are being called out by hotkeys. I am just looking to see if there is a way to consolidate my two hotkeys into 1. If so how would I go about doing it? Otherwise I will live with what I have and keep it one function per hotkey. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 1, 2013 Moderators Share Posted July 1, 2013 donhorn20, I do not see this as any form of keylogger at all - all it uses are HotKeys. I would do something like this: expandcollapse popupGlobal $iFlag = 0 HotKeySet("q", "_Function") HotKeySet("{ESC}", "On_Exit") While 1 Sleep(10) WEnd Func _Function() If $iFlag Then ; Increase flag count $iFlag += 1 ConsoleWrite("Flag = " & $iFlag & @CRLF) Else ; Set Check function to run in 500ms AdlibRegister("_Checker", 1000) ; Adjust the time to suit <<<<<<<<<< ConsoleWrite("Timer Started" & @CRLF) ; Set flag $iFlag = 1 ConsoleWrite("Flag = " & $iFlag & @CRLF) EndIf EndFunc Func _Checker() ; How many presses? Switch $iFlag Case 2 ConsoleWrite("Running Func_2" & @CRLF) ;_Function_2() Case 3 ConsoleWrite("Running Func_3" & @CRLF) ;_Function_3() EndSwitch ; Prevent Check function running again AdlibUnRegister("_Checker") ; Clear flag $iFlag = 0 ConsoleWrite("Timer and flag reset" & @CRLF) EndFunc Func On_Exit() Exit EndFunc All clear? 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...
donhorn20 Posted July 2, 2013 Author Share Posted July 2, 2013 donhorn20, I do not see this as any form of keylogger at all - all it uses are HotKeys. I would do something like this: expandcollapse popupGlobal $iFlag = 0 HotKeySet("q", "_Function") HotKeySet("{ESC}", "On_Exit") While 1 Sleep(10) WEnd Func _Function() If $iFlag Then ; Increase flag count $iFlag += 1 ConsoleWrite("Flag = " & $iFlag & @CRLF) Else ; Set Check function to run in 500ms AdlibRegister("_Checker", 1000) ; Adjust the time to suit <<<<<<<<<< ConsoleWrite("Timer Started" & @CRLF) ; Set flag $iFlag = 1 ConsoleWrite("Flag = " & $iFlag & @CRLF) EndIf EndFunc Func _Checker() ; How many presses? Switch $iFlag Case 2 ConsoleWrite("Running Func_2" & @CRLF) ;_Function_2() Case 3 ConsoleWrite("Running Func_3" & @CRLF) ;_Function_3() EndSwitch ; Prevent Check function running again AdlibUnRegister("_Checker") ; Clear flag $iFlag = 0 ConsoleWrite("Timer and flag reset" & @CRLF) EndFunc Func On_Exit() Exit EndFunc All clear? M23 @ Melba23, this works great and is exactly what I was looking for. If I add a "Case 1" I could have the Function key perform it's default function correct? I understand I would have to define it but it is possible is it not? Thanks for the useful template. It works great. Don Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 2, 2013 Moderators Share Posted July 2, 2013 donhorn20,You will probably have to disable the HotKeySet for the key, Send it, and then reenable the HotKeySet to get it to work - otherwise you just fire the HotKey again. Give it a try and let me now how you get on. 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...
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