Fraggle Posted March 15, 2005 Posted March 15, 2005 Hi all, i want to make a GUI call by hotkey to be able to start other functions the first GUI function call works properly, i can click the butten and the other function is running. but when i press the hotkey again, the buttons seems to be inactive... it seems to me that the whileloop into the Func1 or Func2 block the 2nd GUI call, cause without it works, but i need the whileloops... any idea whats wrong ? expandcollapse popup#include <GUIConstants.au3> Opt("TrayIconDebug",1) Opt("GUICoordMode",2) Opt("GUIResizeMode", 1) Opt("GUIOnEventMode", 1) HotKeySet("{F5}", "activategui") while 1 Sleep(100) WEnd Func activategui() GuiDelete() $auswahl1 = GUICreate("Was liegt an?",225,40,-1,-1,$WS_CAPTION) $func1 = GUICtrlCreateButton ("Func1", 10, 10, 70, -1) GUICtrlSetOnEvent(-1, "func1") $func2 = GUICtrlCreateButton ("Func2", 0, -1) GUICtrlSetOnEvent(-1, "func2") $func3 = GUICtrlCreateButton ("Exit", 0, -1) GUICtrlSetOnEvent(-1, "func3") GuiSetState(@SW_SHOW) While 1 Sleep(100) WEnd EndFunc Func func1() GuiDelete() MsgBox(4096, "Test1", "Func1") While 1 SLeep(100) WEnd EndFunc Func func2() GuiDelete() MsgBox(4096, "Test2", "Func2") While 1 SLeep(100) WEnd EndFunc Func func3() Exit EndFunc
steveR Posted March 15, 2005 Posted March 15, 2005 (edited) you have infinite loops in your functions While 1 SLeep(100) WEnd that just loops over and over so it never returns out of your function it's saying : while 1, well, 1=1 always, so it just sleeps and sleeps zzzz.... why do you need the while loops?? expandcollapse popup#include <GUIConstants.au3> Opt("TrayIconDebug",1) Opt("GUICoordMode",2) Opt("GUIResizeMode", 1) Opt("GUIOnEventMode", 1) HotKeySet("{F5}", "activategui") while 1 Sleep(100) WEnd Func activategui() $auswahl1 = GUICreate("Was liegt an?",225,40,-1,-1,$WS_CAPTION) $func1 = GUICtrlCreateButton ("Func1", 10, 10, 70, -1) GUICtrlSetOnEvent(-1, "func1") $func2 = GUICtrlCreateButton ("Func2", 0, -1) GUICtrlSetOnEvent(-1, "func2") $func3 = GUICtrlCreateButton ("Exit", 0, -1) GUICtrlSetOnEvent(-1, "func3") GuiSetState(@SW_SHOW) While 1 Sleep(100) WEnd EndFunc Func func1() MsgBox(4096, "Test1", "Func1") EndFunc Func func2() MsgBox(4096, "Test2", "Func2") EndFunc Func func3() Exit EndFunc Edited March 15, 2005 by steveR AutoIt3 online docs Use it... Know it... Live it...MSDN libraryglobal Help and SupportWindows: Just another pane in the glass.
Fraggle Posted March 15, 2005 Author Posted March 15, 2005 (edited) of course in this case its just a idle loop but the macro itself start with a idleloop too and the hotkey start the GUI function, and the GUI function itself has also a idle loop and it still work to start Func1 or Func2 the idleloops of Func1 and Func2 are just an example... my real macro is a bit more ;D i wrote some servereral single macros, mailcheck, ping check ect that need to be within a whileloop cause i want them to run nonstop. now i try to make a all-in-one macro where i can switch between the functions by a GUI button so i dont need to run lot of macros at the same time, or quit and start the macros when i need them. i just cant understand why it works only the first time... even if u click the hotkeys more then once without to click a button it works. and as u can c at the trayicon, the macro hold at the whileloop of the GUI function, like it did the first time u press the hotkey. it doesnt hold at the sleep(X) of the first clicked function. the simple question is: how to switch nonstop functions by a hotkey activated GUI Edited March 15, 2005 by Fraggle
steveR Posted March 15, 2005 Posted March 15, 2005 (edited) Oh, I'm sorry I misunderstood your example. I think the guiOnEventMode option only checks when it is in the main while loop. Maybe you can have the functions launch a seperate script? That way you have full control over the other scripts. I think this question has been asked before in one form or another. I don't think it's possible to have functions running at the same time in the same script. Edited March 15, 2005 by steveR AutoIt3 online docs Use it... Know it... Live it...MSDN libraryglobal Help and SupportWindows: Just another pane in the glass.
Fraggle Posted March 15, 2005 Author Posted March 15, 2005 (edited) This functions are not supposed to run togehter at the same time... I want them to run alone choosen by the GUI. It works if I set a Hotkey for every Function as u can c in the new example below. Cause the Hotkey Interrupt a running Function and i can start another one. The Gui Function ALSO interrupt the running function bevor too but the macro stuck then into the GUI funtion. You can use the Hotkeys first as much as u want and sometimes later u press the Hotkey that activate the GUI and the GUI works at this time too. But it only works the FIRST time and no more again... But i dont like to have a million hotkeys to remember if i only need one for the gui and then just click the function i want now. cause if i use a GUI i could use a slider to change ping intervall or what ever too. And AdlibEnable does the same but only for one function and again and again. expandcollapse popup#include <GUIConstants.au3> Opt("TrayIconDebug",1) Opt("GUICoordMode",2) Opt("GUIResizeMode", 1) Opt("GUIOnEventMode", 1) HotKeySet("{F5}", "activategui") HotKeySet("{F6}", "func1") HotKeySet("{F7}", "func2") HotKeySet("{F8}", "func3") Global $a, $b $a = 1 $b = 1000 while 1 Sleep(100) WEnd Func activategui() GuiDelete() $auswahl1 = GUICreate("Was liegt an?",225,40,-1,-1,$WS_CAPTION) $func1 = GUICtrlCreateButton ("Func1", 10, 10, 70, -1) GUICtrlSetOnEvent(-1, "func1") $func2 = GUICtrlCreateButton ("Func2", 0, -1) GUICtrlSetOnEvent(-1, "func2") $func3 = GUICtrlCreateButton ("Exit", 0, -1) GUICtrlSetOnEvent(-1, "func3") GuiSetState(@SW_SHOW) While 1 Sleep(100) WEnd EndFunc Func func1() GuiDelete() While 1 $a = $a+1 MsgBox(4096, "Test1", $a, 1) WEnd EndFunc Func func2() GuiDelete() While 1 $b = $b-1 MsgBox(4096, "Test2", $b, 1) WEnd EndFunc Func func3() Exit EndFunc Edited March 15, 2005 by Fraggle
Fraggle Posted March 15, 2005 Author Posted March 15, 2005 (edited) Hmm i tried it with GUIMesssageLoop Mode and this seems to work.... Look at the modification: This version is not that nice i wished but at least it works expandcollapse popup#include <GUIConstants.au3> Opt("TrayIconDebug",1) Opt("GUICoordMode",2) Opt("GUIResizeMode", 1) ; Opt("GUIOnEventMode", 1) HotKeySet("{F5}", "activategui") HotKeySet("{F6}", "func1") HotKeySet("{F7}", "func2") HotKeySet("{F8}", "func3") Global $a, $b $a = 1 $b = 1000 GUICreate("Was liegt an?",225,40,-1,-1,$WS_CAPTION) $func1 = GUICtrlCreateButton ("Func1", 10, 10, 70, -1) $func2 = GUICtrlCreateButton ("Func2", 0, -1) $func3 = GUICtrlCreateButton ("Exit", 0, -1) while 1 Sleep(100) WEnd Func activategui() GuiSetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg = $func1 Call("func1") Case $msg = $func2 Call("func2") Case $msg = $func3 Call("func3") EndSelect WEnd EndFunc Func func1() GuiSetState(@SW_HIDE) While 1 $a = $a+1 MsgBox(4096, "Test1", $a, 1) WEnd EndFunc Func func2() GuiSetState(@SW_HIDE) While 1 $b = $b-1 MsgBox(4096, "Test2", $b, 1) WEnd EndFunc Func func3() Exit EndFunc Edited March 15, 2005 by Fraggle
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