Moderators Melba23 Posted February 2, 2011 Moderators Share Posted February 2, 2011 heyhey,You have no loops to interrupt! What exactly are you trying to do here? It looks to me as if a simple HotKey would be all you need - no GUIs required: expandcollapse popup; Set a HotKey to do what you want HotKeySet("^q", "Interrupt") ; And another to exit HotKeySet("{ESC}", "On_Exit") ; Keep the script alive While 1 Sleep(10) WEnd ; When we press the HotKey we run this Func Interrupt() stopitunes() teamspeak() openmsn() EndFunc Func stopitunes() $title = WinGetTitle("[active]") WinActivate("iTunes") Send("{SPACE}") Sleep(100) WinActivate($title) EndFunc ;==>stopitunes Func teamspeak() Global $enable = 0 If ProcessExists("ts3client_win64.exe") Then $enable = 1 If $enable = 0 Then Run("C:\Program Files\TeamSpeak 3 Client\ts3client_win64") Sleep(1000) WinActivate("Teamspeak 3") Send("^s") Send("{ENTER}") Sleep(1000) Send("{ENTER}") EndIf If $enable = 1 Then MsgBox(0, "Error", "Je teamspeak staat al open.") EndIf EndFunc ;==>teamspeak Func openmsn() WinActivate("Live") EndFunc ;==>openmsn ; And this lets us exit gracefully Func On_Exit() Exit EndFuncYou might want to check the various windows are activated before sending or you could get some nasty surprises. Does that work for you? 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...
heyhey Posted February 2, 2011 Author Share Posted February 2, 2011 (edited) I just want it to be using a GUI , since I'm still just learning to script, this program isn't meant to be usefull to me nayways EDIT : the meaning of this program = when I'm for example on youtube, and I want to stop my music to listen to the commentary , I press control+E to pause my itunes, your script deleted that Thanks anyways. Edited February 2, 2011 by heyhey Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 2, 2011 Moderators Share Posted February 2, 2011 heyhey,Then look at this:expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Opt("WinTitleMatchMode", 2) $hgui = GUICreate("Boyenn's pc bot",100,200,@DesktopWidth / 2 , @DesktopHeight / 2) $button1 = GUICtrlCreateButton("Start",0,0,100,100) $button2 = GUICtrlCreateButton("Exit",0,100,100,100) GUISetState() While 1 Switch GUIGetMsg() case $button1 button1() Case $button2 button2() EndSwitch WEnd Func button1() stopitunes() teamspeak() openmsn() EndFunc Func stopitunes() $title = WinGetTitle("[active]") WinActivate("iTunes") ;Send("{SPACE}") Sleep(100) WinActivate($title) EndFunc ;==>stopitunes Func teamspeak() Global $enable = 0 If ProcessExists("ts3client_win64.exe") Then $enable = 1 If $enable = 0 Then Run("C:\Program Files\TeamSpeak 3 Client\ts3client_win64") Sleep(1000) WinActivate("Teamspeak 3") Send("^s") ;Send("{ENTER}") Sleep(1000) ;Send("{ENTER}") EndIf If $enable = 1 Then MsgBox(0, "Error", "Je teamspeak staat al open.") EndIf EndFunc ;==>teamspeak Func openmsn() WinActivate("Live") EndFunc ;==>openmsn ; And this lets us exit gracefully Func button2() Exit EndFuncI disabled the Send commands because if the other windows were not activated (and on my system they would not be) the SPACE and ENTER keys fire the focused button on the GUI so we end up in an eternal series of button presses! I told you that checking if the correct window was active was a good idea! 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...
heyhey Posted February 2, 2011 Author Share Posted February 2, 2011 After checking your post rapidly, I don't think you understand my problem. I'm trying to activate my programs using hotkeys, I would not press the hotkey if the program was open (except for teamspeak, but I did make a check active on that one) Let me explain it totally: the script is a script that is meant to run in the background and do a few functions, for example "open teamspeak, connect with server" or "open itunes, pause or resume, go back to previous windows" just to make stuff easyer. The GUI was meant as a disabler for the script : so if I press the "pause button" , my hotkeys will stop starting the functions, but if I pressed start on the GUI again, it would enable the hotkeys again. However, my GUI created on my own does not stop my hotkeys from pausing itunes / ... Thank you. Link to comment Share on other sites More sharing options...
Developers Jos Posted February 2, 2011 Developers Share Posted February 2, 2011 (edited) Yes , I did understand it , and I can see you used google translator , it's not ik hebt but ik heb, grammar mistake that google makes ♥Ik gebruik geen google translator en ben gewoon ook een nederlander.Volgens mij is het in dit geval niet "ik heb" maar "je bebt", maar het kan zijn dat mijn gramatica wat roestig is.ah het is de 2de "heb" waar het fout is.... "Shit Happens" Josoh, en ik speel over het algemeen een serieus spel wanneer het over dit soort zaken gaat. Het is maar dat je het weet. Edited February 2, 2011 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
heyhey Posted February 2, 2011 Author Share Posted February 2, 2011 No problem Jos , it just looked like & excuse me for thinking that you used trans Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 2, 2011 Moderators Share Posted February 2, 2011 heyhey, The GUI was meant as a disabler for the script : so if I press the "pause button" , my hotkeys will stop starting the functions, but if I pressed start on the GUI again, it would enable the hotkeys again.A light dawns! Here you go! expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> ; Set HotKeys HotKeySet("^b", "openmsn") HotKeySet("^t", "stopitunes") HotKeySet("^e", "teamspeak") Opt("WinTitleMatchMode", 2) $hgui = GUICreate("Boyenn's pc bot", 100, 200, @DesktopWidth / 2, @DesktopHeight / 2) $button1 = GUICtrlCreateButton("Start", 0, 0, 100, 100) $button2 = GUICtrlCreateButton("Pause", 0, 100, 100, 100) GUISetState() While 1 Switch GUIGetMsg() Case $button1 button1() Case $button2 button2() EndSwitch WEnd Func button1() ; Set HotKeys HotKeySet("^b", "openmsn") HotKeySet("^t", "stopitunes") HotKeySet("^e", "teamspeak") EndFunc ;==>button1 Func button2() ; Clear HotKeys HotKeySet("^b") HotKeySet("^t") HotKeySet("^e") EndFunc ;==>button2 Func stopitunes() $title = WinGetTitle("[active]") WinActivate("iTunes") Send("{SPACE}") Sleep(100) WinActivate($title) EndFunc ;==>stopitunes Func teamspeak() Global $enable = 0 If ProcessExists("ts3client_win64.exe") Then $enable = 1 If $enable = 0 Then Run("C:\Program Files\TeamSpeak 3 Client\ts3client_win64") Sleep(1000) WinActivate("Teamspeak 3") Send("^s") Send("{ENTER}") Sleep(1000) Send("{ENTER}") EndIf If $enable = 1 Then MsgBox(0, "Error", "Je teamspeak staat al open.") EndIf EndFunc ;==>teamspeak Func openmsn() WinActivate("Live") EndFunc ;==>openmsn 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...
heyhey Posted February 3, 2011 Author Share Posted February 3, 2011 (edited) Thanks alot, that's (almost) exactly what I want ! One more thing , I tryed binding a hotkey to the button functions, as in, I can pause it both by clicking the button or hotkeypresses , hotkey did not do anything, any ideas why not? I just added them at the set hotkeys, and moved from Opt to GuiSetState above the variables, so the hotkey would have a declared variable, this didnt work though. And also, when I run the script , and press a hotkey without pressing start, it will do the functions, is there any way I can put default = paused when starting the GUI? And thank alot for the script you gave me, after reading it I understand alot more now EDIT : I have fixed problem 2 now, after noticing that button 1 sets the hotkeys, it wasn't needed for me to have them at start, I feel so dumb for not seeing that before Edited February 3, 2011 by heyhey Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 3, 2011 Moderators Share Posted February 3, 2011 heyhey, Please post the code you tried - it makes it much easier to debug. 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...
heyhey Posted February 3, 2011 Author Share Posted February 3, 2011 I was thinking at school,(yes,history was boring), I think I know how to do it, I will attempt it right when I get home Thanks 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