Pain Posted June 14, 2008 Share Posted June 14, 2008 I know this can be done with GUIOnEventMode but first I want to try it this way since I've never used GUIOnEventMode. PS. I do NOT wanna use a hotkeyset to pause/start the script but a button. I've searched but most replies was to use GUIOnEventMode instead. expandcollapse popup#include <GUIConstants.au3> Global $Paused = 0 #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 120, 40, 505, 235, -1, BitOR($WS_EX_TOOLWINDOW,$WS_EX_TOPMOST,$WS_EX_WINDOWEDGE)) $start = GUICtrlCreateButton("Start", 5, 8, 49, 25, 0) $stop = GUICtrlCreateButton("Stop", 60, 8, 60, 25, 0) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $start start() Case $stop Pause() EndSwitch WEnd Func Start() If $Paused = 0 Then While $Paused = 0 send("test") sleep(2000) WEnd EndIf EndFunc Func Pause() $Paused = NOT $Paused While $Paused sleep(100) WEnd EndFunc The start button works but not the pause button and I can't close the script with "X" when it's running. I do not want to exit the script when I click on "pause", just pause it, and when I press "start" it should start again from the beginning. Link to comment Share on other sites More sharing options...
martin Posted June 14, 2008 Share Posted June 14, 2008 I know this can be done with GUIOnEventMode but first I want to try it this way since I've never used GUIOnEventMode. PS. I do NOT wanna use a hotkeyset to pause/start the script but a button. I've searched but most replies was to use GUIOnEventMode instead. Not tested, but maybe this does what you want. expandcollapse popup#include <GUIConstants.au3> Global $Paused = 0 #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 120, 40, 505, 235, -1, BitOR($WS_EX_TOOLWINDOW,$WS_EX_TOPMOST,$WS_EX_WINDOWEDGE)) $start = GUICtrlCreateButton("Start", 5, 8, 49, 25, 0) $stop = GUICtrlCreateButton("Stop", 60, 8, 60, 25, 0) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $start start() Case $stop Pause() EndSwitch WEnd Func Start() $Paused = 0 While $Paused = 0 send("test") sleep(2000) WEnd EndFunc Func Pause() $Paused = 1 EndFunc Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
Pain Posted June 14, 2008 Author Share Posted June 14, 2008 thanks for trying but it's still the same, it continue even if I've pressed Stop and I still can't exit the script by pressing on "X". Link to comment Share on other sites More sharing options...
ReaImDown Posted June 14, 2008 Share Posted June 14, 2008 thanks for trying but it's still the same, it continue even if I've pressed Stop and I still can't exit the script by pressing on "X".just use adlibenable() and have it check to see if the close button was pressed. [u][font="Century Gothic"]~я α и d γ ĵ . ċ . ѕ қ ϊ и и ε я~- My Programs -auto shutdownSleep funcdisallow programs[/font][/u] Link to comment Share on other sites More sharing options...
Pain Posted June 14, 2008 Author Share Posted June 14, 2008 I did like you said with AdlibEnable but I'm not sure how to make it start again when I press "start" again. I got the function but I don't know where to call it. expandcollapse popup#include <GUIConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 120, 40, 505, 235, -1, BitOR($WS_EX_TOOLWINDOW,$WS_EX_TOPMOST,$WS_EX_WINDOWEDGE)) $start = GUICtrlCreateButton("Start", 5, 8, 49, 25, 0) $stop = GUICtrlCreateButton("Stop", 60, 8, 60, 25, 0) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $start start() Case $stop Pause() EndSwitch WEnd Func Start() while 1 sleep (2000) send("test") WEnd EndFunc Func pause() AdlibEnable("pause") Sleep(250) EndFunc Func repeat() AdlibDisable() EndFunc Link to comment Share on other sites More sharing options...
ReaImDown Posted June 14, 2008 Share Posted June 14, 2008 I did like you said with AdlibEnable but I'm not sure how to make it start again when I press "start" again. I got the function but I don't know where to call it. expandcollapse popup#include <GUIConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 120, 40, 505, 235, -1, BitOR($WS_EX_TOOLWINDOW,$WS_EX_TOPMOST,$WS_EX_WINDOWEDGE)) $start = GUICtrlCreateButton("Start", 5, 8, 49, 25, 0) $stop = GUICtrlCreateButton("Stop", 60, 8, 60, 25, 0) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $start start() Case $stop Pause() EndSwitch WEnd Func Start() while 1 sleep (2000) send("test") WEnd EndFunc Func pause() AdlibEnable("pause") Sleep(250) EndFunc Func repeat() AdlibDisable() EndFunc [u][font="Century Gothic"]~я α и d γ ĵ . ċ . ѕ қ ϊ и и ε я~- My Programs -auto shutdownSleep funcdisallow programs[/font][/u] Link to comment Share on other sites More sharing options...
martin Posted June 14, 2008 Share Posted June 14, 2008 thanks for trying but it's still the same, it continue even if I've pressed Stop and I still can't exit the script by pressing on "X".What continues? If you mean that the function Start continues then you've not done what I said. Can you post what you tried? Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
Pain Posted June 14, 2008 Author Share Posted June 14, 2008 (edited) @martin this is the code I've tried (the one you posted) expandcollapse popup#include <GUIConstants.au3> Global $Paused = 0 #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 120, 40, 505, 235, -1, BitOR($WS_EX_TOOLWINDOW,$WS_EX_TOPMOST,$WS_EX_WINDOWEDGE)) $start = GUICtrlCreateButton("Start", 5, 8, 49, 25, 0) $stop = GUICtrlCreateButton("Stop", 60, 8, 60, 25, 0) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $start start() Case $stop Pause() EndSwitch WEnd Func Start() $Paused = 0 While $Paused = 0 send("test") sleep(2000) WEnd EndFunc Func Pause() $Paused = 1 EndFunc If I press on "Start" it send the word "test" just like it should but when I press on "Stop" nothing happens, it's still sending the word "test". I'm having the same problem with the code that ReaImDown posted. Edited June 14, 2008 by Pain Link to comment Share on other sites More sharing options...
ReaImDown Posted June 14, 2008 Share Posted June 14, 2008 @martin this is the code I've tried (the one you posted) expandcollapse popup#include <GUIConstants.au3> Global $Paused = 0 #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 120, 40, 505, 235, -1, BitOR($WS_EX_TOOLWINDOW,$WS_EX_TOPMOST,$WS_EX_WINDOWEDGE)) $start = GUICtrlCreateButton("Start", 5, 8, 49, 25, 0) $stop = GUICtrlCreateButton("Stop", 60, 8, 60, 25, 0) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $start start() Case $stop Pause() EndSwitch WEnd Func Start() $Paused = 0 While $Paused = 0 send("test") sleep(2000) WEnd EndFunc Func Pause() $Paused = 1 EndFunc If I press on "Start" it send the word "test" just like it should but when I press on "Stop" nothing happens, it's still sending the word "test". I'm having the same problem with the code that ReaImDown posted. haha, your lucky, the code I posted...my scite wont let me run [u][font="Century Gothic"]~я α и d γ ĵ . ċ . ѕ қ ϊ и и ε я~- My Programs -auto shutdownSleep funcdisallow programs[/font][/u] Link to comment Share on other sites More sharing options...
Pain Posted June 14, 2008 Author Share Posted June 14, 2008 (edited) Press "Start" and then click on Scite to activate it or open notepad and activate it and you should have the same result as I do. Don't forget to delete what the script just wrote or you will get a error next time if you let the script write to Scite. Edited June 14, 2008 by Pain Link to comment Share on other sites More sharing options...
martin Posted June 14, 2008 Share Posted June 14, 2008 @martin this is the code I've tried (the one you posted) expandcollapse popup#include <GUIConstants.au3> Global $Paused = 0 #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 120, 40, 505, 235, -1, BitOR($WS_EX_TOOLWINDOW,$WS_EX_TOPMOST,$WS_EX_WINDOWEDGE)) $start = GUICtrlCreateButton("Start", 5, 8, 49, 25, 0) $stop = GUICtrlCreateButton("Stop", 60, 8, 60, 25, 0) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $start start() Case $stop Pause() EndSwitch WEnd Func Start() $Paused = 0 While $Paused = 0 send("test") sleep(2000) WEnd EndFunc Func Pause() $Paused = 1 EndFunc If I press on "Start" it send the word "test" just like it should but when I press on "Stop" nothing happens, it's still sending the word "test". I'm having the same problem with the code that ReaImDown posted. Yes, it won't work because I was thinking of the HotKeys instead of buttons. I'll be back. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
martin Posted June 14, 2008 Share Posted June 14, 2008 Yes, it won't work because I was thinking of the HotKeys instead of buttons. I'll be back.I'm back, ReaImDown was close. (Tested this time) #include <GUIConstants.au3> Global $Paused = 0 #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 120, 40, 505, 235, -1, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST, $WS_EX_WINDOWEDGE)) $start = GUICtrlCreateButton("Start", 5, 8, 49, 25, 0) $stop = GUICtrlCreateButton("Stop", 60, 8, 60, 25, 0) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $start Start() Case $stop Pause() EndSwitch WEnd Func Start() AdlibEnable("dosend", 2000) EndFunc ;==>Start Func Dosend() Send("test") EndFunc ;==>Dosend Func Pause() AdlibDisable() EndFunc ;==>Pause Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
ReaImDown Posted June 14, 2008 Share Posted June 14, 2008 I'm back, ReaImDown was close. (Tested this time) #include <GUIConstants.au3> Global $Paused = 0 #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 120, 40, 505, 235, -1, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST, $WS_EX_WINDOWEDGE)) $start = GUICtrlCreateButton("Start", 5, 8, 49, 25, 0) $stop = GUICtrlCreateButton("Stop", 60, 8, 60, 25, 0) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $start Start() Case $stop Pause() EndSwitch WEnd Func Start() AdlibEnable("dosend", 2000) EndFunc ;==>Start Func Dosend() Send("test") EndFunc ;==>Dosend Func Pause() AdlibDisable() EndFunc ;==>Pauseknew it was some sort of dumb shit like that -.-' oh wells, cant win em all, nice work lol [u][font="Century Gothic"]~я α и d γ ĵ . ċ . ѕ қ ϊ и и ε я~- My Programs -auto shutdownSleep funcdisallow programs[/font][/u] Link to comment Share on other sites More sharing options...
Pain Posted June 14, 2008 Author Share Posted June 14, 2008 Oh, your using the send command with adlib, never thought about that in that way Thanks alot for your help both martin and ReaImDown, I really appreciate it 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