seres Posted November 13, 2007 Share Posted November 13, 2007 hello, i have been wondering how to deactivate a function when called (with the same hotkey), i searched in the help file, but i found nothing example: CODEHotKeySet("^1", "actideacti") func actideacti() endfunc it calls the function, but how to deactivate it with the same hotkey Link to comment Share on other sites More sharing options...
Nahuel Posted November 13, 2007 Share Posted November 13, 2007 I don't know what you mean by "deactivate it"... as in unset the hotkey? HotKeySet("^1") Or stop the function with the same hotkey? Link to comment Share on other sites More sharing options...
seres Posted November 13, 2007 Author Share Posted November 13, 2007 yes its to stop the function with the same key Link to comment Share on other sites More sharing options...
Klaatu Posted November 13, 2007 Share Posted November 13, 2007 (edited) Well, off the top of my head, I'd probably do something like this: global $stopit = False HotKeySet("^1", "actideacti") func actideacti() HotKeySet("^1", "actideacti2") $stopit = False If $stopit then HotKeySet("^1", "actideacti") return endif ; do some stuff If $stopit then HotKeySet("^1", "actideacti") return endif ; do more stuff If $stopit then HotKeySet("^1", "actideacti") return endif ; etc HotKeySet("^1", "actideacti") endfunc func actideacti2() $stopit = True endfunc Edited November 13, 2007 by Klaatu My Projects:DebugIt - Debug your AutoIt scripts with DebugIt! Link to comment Share on other sites More sharing options...
PsaltyDS Posted November 13, 2007 Share Posted November 13, 2007 hello, i have been wondering how to deactivate a function when called (with the same hotkey), i searched in the help file, but i found nothing it calls the function, but how to deactivate it with the same hotkey Like this: Global $fActive = False HotKeySet("^1", "actideacti") While 1 While $fActive _DoSomethingWhileActive() WEnd Sleep(20) WEnd func actideacti() $fActive = Not $fActive endfunc Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
seres Posted November 14, 2007 Author Share Posted November 14, 2007 Like this: Global $fActive = False HotKeySet("^1", "actideacti") While 1 While $fActive _DoSomethingWhileActive() WEnd Sleep(20) WEnd func actideacti() $fActive = Not $fActive endfunc it didnt worked for me cause it was repeating itself here is what i tried warning it will open a lot of note pads Global $fActive = False HotKeySet("^1", "actideacti") While 1 While $fActive run("notepad.exe") WEnd Sleep(20) WEnd func actideacti() $fActive = Not $fActive endfunc Link to comment Share on other sites More sharing options...
Achilles Posted November 14, 2007 Share Posted November 14, 2007 (edited) HotKeySet('^a', 'Testing') While 1 Sleep(2000) WEnd Func Testing() HotKeySet('^a') ToolTip('Hot key has been disabled') Sleep(3000) ToolTIp('Exiting in 5 seconds') Sleep(5000) Exit EndFunc Edited November 14, 2007 by Piano_Man My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list] Link to comment Share on other sites More sharing options...
seres Posted November 14, 2007 Author Share Posted November 14, 2007 HotKeySet('^a', 'Testing') While 1 Sleep(2000) WEnd Func Testing() HotKeySet('^a') ToolTip('Hot key has been disabled') Sleep(3000) ToolTIp('Exiting in 5 seconds') Sleep(5000) Exit EndFunc i didnt mean to disable the hotkey, i mean to stop/disable the function, but thanks anyway Link to comment Share on other sites More sharing options...
seres Posted November 14, 2007 Author Share Posted November 14, 2007 thanks the help guys, i tried them all but nothing, still thanks, the other way i knew to do it was to pick a diferent func that has the same keys, but i thought it will be better to yust deactivate it, or maybe i didnt find the way to stop it, thanks anyway. Link to comment Share on other sites More sharing options...
PsaltyDS Posted November 14, 2007 Share Posted November 14, 2007 thanks the help guys, i tried them all but nothing, still thanks, the other way i knew to do it was to pick a diferent func that has the same keys, but i thought it will be better to yust deactivate it, or maybe i didnt find the way to stop it, thanks anyway.You are still being absurdly vague, and haven't posted any code to explain what you want.What does your "Function" do when it is "activated"? Exactly what does it mean to "deactivate" your function? What does "a diferent func that has the same keys" mean? What does your script do while this function is "deactivated"? This has become another useless topic because it has gone on way too long without a clear statement of what is already done, and exactly what needs to be done. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
MuffettsMan Posted November 15, 2007 Share Posted November 15, 2007 on the same topic (i think) is there a clean way to enable / disable hotkeys? as in you click an option and then using hotkeys to start a function no longer works... click it again then hotkey use is enabled... snipits of my remidial logic / attempts: HotKeySet("+!e", "EnableUser") ;Shift-Alt-e $Togglekeys = TrayCreateItem("Disable Hotkeys") TrayItemSetOnEvent(-1,"TogleHotkeysEvent") Func TogleHotkeysEvent() if $HotKeyToggle == 1 then $HotKeyToggle = 0 FileWrite($logfile, Timestamp() & "CMS Auto: HotKey Toggle - Notice: HotKey Functionality has been turned OFF." & @CRLF) ;MsgBox(4096, "Hotkey Toggle:", "HotKey Functionality has been turned OFF.", 5) TrayItemDelete($Togglekeys) $Togglekeys = TrayCreateItem("Enable Hotkeys") TrayItemSetOnEvent(-1,"TogleHotkeysEvent") TrayTip("CMS Auto: HotKey Toggle", "Notice: HotKey Functionality has been turned OFF.", 5, 1) Else $HotKeyToggle = 1 ;MsgBox(4096, "Hotkey Toggle:", "HotKey Functionality has been turned ON.", 5) TrayItemDelete($Togglekeys) $Togglekeys = TrayCreateItem("Disable Hotkeys") TrayItemSetOnEvent(-1,"TogleHotkeysEvent") FileWrite($logfile, Timestamp() & "CMS Auto: HotKey Toggle - Notice: HotKey Functionality has been turned ON." & @CRLF) TrayTip("CMS Auto: HotKey Toggle", "Notice: HotKey Functionality has been turned ON.", 5, 1) EndIf EndFunc Func EnableUser() if $HotKeyToggle == 1 Then $MsgBoxVal = MsgBox(4, $title, "You are about to do stuff: " & $UID & " hotkeys are enabled....") ; etc etc etc.... Else;Hotkeys must be disabled so do nothing.... return EndIf EndFunc ; *********** basicly is setting a flag the best way to toggle? Don't let that status fool you, I am no advanced memeber! Link to comment Share on other sites More sharing options...
PsaltyDS Posted November 15, 2007 Share Posted November 15, 2007 on the same topic (i think) is there a clean way to enable / disable hotkeys? as in you click an option and then using hotkeys to start a function no longer works... click it again then hotkey use is enabled... snipits of my remidial logic / attempts: basicly is setting a flag the best way to toggle? It's simpler than you think: Opt("TrayOnEventMode", 1) Opt("TrayAutoPause", 0) Global $fHotKeys = False Global $Togglekeys = TrayCreateItem("Hotkeys Enabled", -1, 1) ; Enable MenuRadioItem TrayItemSetOnEvent(-1, "TogleHotkeysEvent") While 1 Sleep(20) WEnd Func TogleHotkeysEvent() $fHotKeys = Not $fHotKeys If $fHotKeys Then TrayItemSetState($Togglekeys, 1) ; 1 = $TRAY_CHECKED HotKeySet("+!e", "EnableUser") ; Shift-Alt-e Else TrayItemSetState($Togglekeys, 4) ; 4 = $TRAY_UNCHECKED HotKeySet("+!e") EndIf EndFunc ;==>TogleHotkeysEvent Func EnableUser() MsgBox(64, "Debug", "HotKey detected, EnableUser() running...") EndFunc ;==>EnableUser Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
MuffettsMan Posted November 15, 2007 Share Posted November 15, 2007 It's simpler than you think: nice nice niiiice now if i could simply quit doing things the hard way I guess limited knowledge = longer code Don't let that status fool you, I am no advanced memeber! Link to comment Share on other sites More sharing options...
MuffettsMan Posted November 15, 2007 Share Posted November 15, 2007 that also keeps my tray list from constantly getting reordered! <3 <3 Don't let that status fool you, I am no advanced memeber! 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