Icy Posted May 21, 2012 Share Posted May 21, 2012 (edited) HotKeySet("a","XX") $C = 0 While 1 = 1 Sleep (5000) WEnd Func XX() $C = $C + 1 If $C = 1 Then While 1 = 1 Send ("cuss") Sleep (1000) WEnd Else $C = 0 EndIf EndFunc Hi. This is my simple function, which was supposed to start the function on the 1st key press and stop on the second press. But it doesn't work well. Any help please? Ps. use the most simple way to make my function work. =) Thx Edited May 21, 2012 by Icy Link to comment Share on other sites More sharing options...
water Posted May 21, 2012 Share Posted May 21, 2012 Please check the help file for function HotKeySet, parameter 2: "Not specifying this parameter will unset a previous hotkey." My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Icy Posted May 21, 2012 Author Share Posted May 21, 2012 No nononono, I did check that and that's not what I need. I need to stop the function by pressing that key. Link to comment Share on other sites More sharing options...
water Posted May 21, 2012 Share Posted May 21, 2012 But the title of this thread says "HotKeySet - how to UnSet?" My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Icy Posted May 21, 2012 Author Share Posted May 21, 2012 No problem, I figured that out - some other way =) Link to comment Share on other sites More sharing options...
Icy Posted May 21, 2012 Author Share Posted May 21, 2012 (edited) Awesome program btw! Edit: Although, if you could give me your solution for this, I would be happy. My is just improvised one... Edited May 21, 2012 by Icy Link to comment Share on other sites More sharing options...
Shaarad Posted May 21, 2012 Share Posted May 21, 2012 Maybe you can use a null parameter in the function itself so that next time it wont recognise that hotkey and serve the purpose. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Icy Posted May 21, 2012 Author Share Posted May 21, 2012 I noticed, that the function did loop forever because of the while 1=1 command. So I solved it with the IF function. Done and did it! Link to comment Share on other sites More sharing options...
water Posted May 21, 2012 Share Posted May 21, 2012 This toggles key "a" to send/stop writing text. HotKeySet("a", "XX") HotKeySet("{ESC}", "_Exit") $C = 0 While 1 = 1 Sleep(5000) WEnd Func XX() HotKeySet("a", "YY") While 1 = 1 IF $C = 0 Then Send("cuss") Sleep(1000) Else ExitLoop Endif WEnd $C = 0 EndFunc ;==>XX Func YY() $C = 1 HotKeySet("a", "XX") EndFunc ;==>YY Func _Exit() Exit EndFunc My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted May 21, 2012 Share Posted May 21, 2012 (edited) Or look at the TogglePause() function in the HotKeySet() example for how you can do it in one function instead of two (XX/YY). Edited May 21, 2012 by AdmiralAlkex .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
water Posted May 21, 2012 Share Posted May 21, 2012 Thanks. That's even better and easier to understand My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Icy Posted May 22, 2012 Author Share Posted May 22, 2012 Thanks for your help. 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