mini Posted December 15, 2009 Share Posted December 15, 2009 Hello I've see some programs like my, but the codes they are using are not what I have. Can anyone help me on my coding please. this is what I have: expandcollapse popup#Region Global $Form1 = GuiCreate("Test stoping loop", 380, 270) Global $start=GuiCtrlCreateButton("Start",1,4,93,32) Global $Stop=GuiCtrlCreateButton("Stop",184,4,83,32) GuiSetState() #EndRegion While 1 $msg=GuiGetMsg() If $msg=-3 Then Exit If $msg=$start Then Start() ;Start If $msg=$stop then Stop() ;Stop Wend Func Stop();Stop sleep( 120000 ) EndFunc Func Start();Start Run("notepad.exe") if not WinActive( "Untitled - " ) Then WinActivate( "Untitled - " ) EndIf while 1 if not ProcessExists("notepad.exe") Then Run("notepad.exe") if not WinActive( "Untitled - " ) Then WinActivate( "Untitled - " ) sleep(2000) send("test123") send("{tab}") send("test456") send("{ENTER}") EndIf EndIf WEnd EndFunc the loop works perfectly, if i exit the notepad, he opens a new one and writes. the stoping button is my main prob now. thx for all replays [size="4"]My first work[/size], it checks if one prograrm is running and if not it closes all necessery windows and run them again.[size="4"]My second work[/size], Script Function: It saves a Client Info and creates a INI file for all clients with all the info.[size="4"]My third work[/size], Script Function: It change some INFO on a working program, every X min configured. Link to comment Share on other sites More sharing options...
Authenticity Posted December 15, 2009 Share Posted December 15, 2009 expandcollapse popup#include <GUIConstantsEx.au3> Opt("GUIOnEventMode", 1) Local $Form1, $start, $stop, $fRun #Region $Form1 = GUICreate("Test stoping loop", 380, 270) GUISetOnEvent($GUI_EVENT_CLOSE, "_Quit") $start = GUICtrlCreateButton("Start", 1, 4, 93, 32) GUICtrlSetOnEvent($start, "_Start") $stop = GUICtrlCreateButton("Stop", 184, 4, 83, 32) GUICtrlSetOnEvent($stop, "_Stop") GUISetState() #EndRegion $fRun = False While 1 If $fRun Then While $fRun If Not ProcessExists("notepad.exe") Then Run("notepad.exe") If Not WinActive("Untitled - ") Then WinActivate("Untitled - ") Sleep(2000) Send("test123") Send("{tab}") Send("test456") Send("{ENTER}") EndIf EndIf ToolTip("Still running", 0, 0) Sleep(1000) WEnd ToolTip("") EndIf Sleep(20) ; Idle around WEnd Func _Stop() $fRun = False EndFunc ;==>_Stop Func _Start();Start $fRun = True EndFunc ;==>Start Func _Quit() GUIDelete() Exit EndFunc Link to comment Share on other sites More sharing options...
ichigo325 Posted December 15, 2009 Share Posted December 15, 2009 (edited) Hi, i just trying to help. You can use HotKeySet to call the functions. Here is the example. Example: expandcollapse popup#Region Global $Form1 = GUICreate("Test stoping loop", 380, 270) Global $start = GUICtrlCreateButton("Start", 1, 4, 93, 32) Global $Stop = GUICtrlCreateButton("Stop", 184, 4, 83, 32) GUISetState() HotKeySet("{Insert}", "Start") HotKeySet("{DEL}", "Stop") ; You can use hotkeyset to call the stop function #EndRegion While 1 $msg = GUIGetMsg() If $msg = -3 Then Exit If $msg = $start Then Start() ;Start If $msg = $Stop Then Stop() ;Stop WEnd Func Stop();Stop MsgBox(0, "", "Stop function called!"&@CRLF&"Sleeping for 120 seconds... zzzz.. :P") ; Show that Stop function is successfully called Sleep(120000) EndFunc ;==>Stop Func Start();Start Run("notepad.exe") If Not WinActive("Untitled - Notepad") Then WinActivate("Untitled - Notepad") EndIf While 1 ; <-Stop btn is not functioning because of this loop replace loop before this If Not ProcessExists("notepad.exe") Then Run("notepad.exe") Else If Not WinActive("Untitled - Notepad") Then WinActivate("Untitled - Notepad") Else Sleep(2000) Send("test123") Send("{tab}") Send("test456") Send("{ENTER}") EndIf EndIf WEnd EndFunc ;==>Start Edited December 15, 2009 by ichigo325 [size="2"][font="Lucida Sans Unicode"][b][/b][/font][/size] 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