gcue Posted January 2, 2009 Share Posted January 2, 2009 (edited) i have set several hotkeys at the beginning of my script HotKeySet("^U", "User_Add_Gui") HotKeySet("^A", "Asset_Add_Gui") HotKeySet("^a", "Add_PC") HotKeySet("^e", "EditINI") HotKeySet("^p", "Prefs") HotKeySet("^l", "OpenLog") but i would ONLY like to trigger them IF my GUI is the active window... i see the help that hints towards using winactive - so i thought about if @scriptname is the active window then run but i dont want these hotkeys to reference my script at ALL if the script is not the active window... found this out because CTRL+A was not working in another application (even though it was active) any ideas? Edited January 2, 2009 by gcue Link to comment Share on other sites More sharing options...
gcue Posted January 2, 2009 Author Share Posted January 2, 2009 answered my own question.. doing it here... While 1 Sleep(10) If _IsPressed("74") And WinActive($ver) Then Refresh() EndIf If _IsPressed("11") And _IsPressed("55") And WinActive($ver) Then Check_Updates() EndIf WEnd Link to comment Share on other sites More sharing options...
gcue Posted January 2, 2009 Author Share Posted January 2, 2009 ok this isnt quite working.. its opening multiple instances for some folks - any idea why? ive tried doing a Return after the function is performed but that didnt work... While 1 Sleep(1) If _IsPressed("11") And _IsPressed("4C") And WinActive($ver) Then ;11=ctrl 4C=l OpenLOG() EndIf Wend Func OpenLOG() If FileExists($aLOG) Then ShellExecute($aLOG) Return Else MsgBox(0, "Dashboard", "A log has not yet been generated - probably because a loggable function hasn't been performed.") EndIf EndFunc ;==>OpenLOG Link to comment Share on other sites More sharing options...
ADSs Posted January 2, 2009 Share Posted January 2, 2009 http://www.autoitscript.com/autoit3/docs/f...ccelerators.htmGood Luck ^^ Link to comment Share on other sites More sharing options...
gcue Posted January 2, 2009 Author Share Posted January 2, 2009 (edited) thanks! how can use this without using select case? my script is using guictrlsetonevent Edited January 2, 2009 by gcue Link to comment Share on other sites More sharing options...
CodyBarrett Posted January 2, 2009 Share Posted January 2, 2009 use functions its basically the exact same thing.. also it would clear up some room in your while section [size="1"][font="Tahoma"][COMPLETED]-----[FAILED]-----[ONGOING]VolumeControl|Binary Converter|CPU Usage| Mouse Wrap |WinHide|Word Scrammbler|LOCKER|SCREEN FREEZE|Decisions Decisions|Version UDF|Recast Desktop Mask|TCP Multiclient EXAMPLE|BTCP|LANCR|UDP serverless|AIOCR|OECR|Recast Messenger|AU3C|Tik-Tak-Toe|Snakes & Ladders|BattleShips|TRON|SNAKE_____________________[u]I love the Helpfile it is my best friend.[/u][/font][/size] Link to comment Share on other sites More sharing options...
gcue Posted January 2, 2009 Author Share Posted January 2, 2009 (edited) so still use it in the while loop? hmm not sure what the script would look like if im not using case statements.. Edited January 2, 2009 by gcue Link to comment Share on other sites More sharing options...
PsaltyDS Posted January 2, 2009 Share Posted January 2, 2009 thanks! how can use this without using select case? my script is using guictrlsetonevent Notice that when you set up the accelerator the ID of the control is passed. When the accelerator event (i.e. Ctrl-y) happens, the event for that ID is triggered. Here is the help file demo redone in event mode: expandcollapse popup; A simple custom messagebox that uses the MessageLoop mode #include <GUIConstantsEx.au3> Opt("GuiOnEventMode", 1) GUICreate("Custom Msgbox", 210, 80) GUISetOnEvent($GUI_EVENT_CLOSE, "_Quit") GUICtrlCreateLabel("Please click a button!", 10, 10) $YesID = GUICtrlCreateButton("Yes", 10, 50, 50, 20) GUICtrlSetOnEvent(-1, "_ButtonHit") $NoID = GUICtrlCreateButton("No", 80, 50, 50, 20) GUICtrlSetOnEvent(-1, "_ButtonHit") $ExitID = GUICtrlCreateButton("Exit", 150, 50, 50, 20) GUICtrlSetOnEvent(-1, "_ButtonHit") ; Set accelerators for Ctrl+y and Ctrl+n Dim $AccelKeys[2][2]=[["^y", $YesID], ["^n", $NoID]] GUISetAccelerators($AccelKeys) GUISetState() ; display the GUI While 1 Sleep(20) WEnd Func _ButtonHit() Switch @GUI_CtrlId Case $YesID MsgBox(0, "You clicked on", "Yes") Case $NoID MsgBox(0, "You clicked on", "No") Case $ExitID MsgBox(0, "You clicked on", "Exit") EndSwitch EndFunc Func _Quit() Exit 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...
CodyBarrett Posted January 2, 2009 Share Posted January 2, 2009 guictrlsetonevent() it should lok like this EXAMPLE; $a = hotkeyset() guictrlsetonevent($a,'_Example') While 1 Wend Func _example() your data endfunc try that anyway it should work [size="1"][font="Tahoma"][COMPLETED]-----[FAILED]-----[ONGOING]VolumeControl|Binary Converter|CPU Usage| Mouse Wrap |WinHide|Word Scrammbler|LOCKER|SCREEN FREEZE|Decisions Decisions|Version UDF|Recast Desktop Mask|TCP Multiclient EXAMPLE|BTCP|LANCR|UDP serverless|AIOCR|OECR|Recast Messenger|AU3C|Tik-Tak-Toe|Snakes & Ladders|BattleShips|TRON|SNAKE_____________________[u]I love the Helpfile it is my best friend.[/u][/font][/size] Link to comment Share on other sites More sharing options...
gcue Posted January 2, 2009 Author Share Posted January 2, 2009 as always psalty.. u saved me thanks! Notice that when you set up the accelerator the ID of the control is passed. When the accelerator event (i.e. Ctrl-y) happens, the event for that ID is triggered. Here is the help file demo redone in event mode: expandcollapse popup; A simple custom messagebox that uses the MessageLoop mode #include <GUIConstantsEx.au3> Opt("GuiOnEventMode", 1) GUICreate("Custom Msgbox", 210, 80) GUISetOnEvent($GUI_EVENT_CLOSE, "_Quit") GUICtrlCreateLabel("Please click a button!", 10, 10) $YesID = GUICtrlCreateButton("Yes", 10, 50, 50, 20) GUICtrlSetOnEvent(-1, "_ButtonHit") $NoID = GUICtrlCreateButton("No", 80, 50, 50, 20) GUICtrlSetOnEvent(-1, "_ButtonHit") $ExitID = GUICtrlCreateButton("Exit", 150, 50, 50, 20) GUICtrlSetOnEvent(-1, "_ButtonHit") ; Set accelerators for Ctrl+y and Ctrl+n Dim $AccelKeys[2][2]=[["^y", $YesID], ["^n", $NoID]] GUISetAccelerators($AccelKeys) GUISetState(); display the GUI While 1 Sleep(20) WEnd Func _ButtonHit() Switch @GUI_CtrlId Case $YesID MsgBox(0, "You clicked on", "Yes") Case $NoID MsgBox(0, "You clicked on", "No") Case $ExitID MsgBox(0, "You clicked on", "Exit") EndSwitch EndFunc Func _Quit() Exit EndFunc Link to comment Share on other sites More sharing options...
Duijst Posted January 3, 2009 Share Posted January 3, 2009 Thanks, Psalty, saved me a lot of time. 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