PINTO1927 Posted June 20, 2016 Posted June 20, 2016 (edited) Hi guys, I would like to create a button which restarts the script from a set point from me.. Unfortunately with: Run(FileGetShortName(@AutoItExe) & " " & FileGetShortName(@ScriptFullPath)) I repeated everything the script , however I need to do it again from a point that I imposed.. Thank's.. Edited June 20, 2016 by PINTO1927
Moderators JLogan3o13 Posted June 20, 2016 Moderators Posted June 20, 2016 @PINTO1927 it is a bit difficult to give more than generic advice as you didn't post your script, but why not break your script into functions, and then use the button to call the appropriate one? "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
PINTO1927 Posted June 20, 2016 Author Posted June 20, 2016 an example to call a function from a button?
Moderators JLogan3o13 Posted June 20, 2016 Moderators Posted June 20, 2016 Yes, in the help file for GUICtrlCreateButton. You can easily modify the example script to call your function. OR, you could post your script as I mentioned above, so we're not having to guess at what you're trying to do "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
PINTO1927 Posted June 20, 2016 Author Posted June 20, 2016 #include <Array.au3> Global $sFileToCheck = "C:\temp\test.txt" Global $bFileChanged = False Global $sFileDateTime = _ArrayToString(FileGetTime($sFileToCheck)) AdlibRegister("_CheckFile", 250) ; GUI creation etc goes here GUISetState(@SW_SHOW, $Form) While 1 If $bFileChanged Then MsgBox(0, "Info", "File has changed") $sFileDateTime = _ArrayToString(FileGetTime($sFileToCheck)) $bFileChanged = False EndIf ; It must start from here $nMsg = GUIGetMsg() Switch $nMsg Case... Case... Case... EndSwitch WEnd Func _CheckFile() If $sFileDateTime <> _ArrayToString(FileGetTime($sFileToCheck)) Then $bFileChanged = True EndFunc ;==>_CheckFile I have shown you the point of departure must start
Moderators JLogan3o13 Posted June 20, 2016 Moderators Posted June 20, 2016 That's great @PINTO1927, now how about showing what you have tried on your own, given the example I pointed you to in the help file? This is not a forum where you put in a request and someone barfs up the code for you. We're happy to help, but you need to at least try on your own. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
AutoBert Posted June 21, 2016 Posted June 21, 2016 (edited) 21 hours ago, PINTO1927 said: I have shown you the point of departure must start Here the solution for your script: expandcollapse popup#include <Array.au3> #include <GUIConstantsEx.au3> Global $sFileToCheck = "test.txt" Global $sFileDateTime = _ArrayToString(FileGetTime($sFileToCheck)) ; Create a GUI with various controls. Global $hGUI = GUICreate("Example", 300, 200) ; Create a button control. Global $idFast = GUICtrlCreateButton("Fast Restart", 210, 10, 190, 25) ; Display the GUI. GUISetState(@SW_SHOW, $hGUI) Global $bFileChanged = False While 1 If $bFileChanged Then MsgBox(0, "Info", "File has changed") $sFileDateTime = _ArrayToString(FileGetTime($sFileToCheck)) $bFileChanged = False MsgBox(0,'Restart needed','Fast restart will be done!',1) EndIf ; It continues here or did you see the MsgBox without changing file????? $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $idFast AdlibRegister("_CheckFile", 1000) EndSwitch WEnd Func _CheckFile() If $sFileDateTime <> _ArrayToString(FileGetTime($sFileToCheck)) Then $bFileChanged = True AdlibUnRegister('_CheckFile') EndFunc ;==>_CheckFile Making even as much sence as your script. Edited June 21, 2016 by AutoBert
Moderators JLogan3o13 Posted June 21, 2016 Moderators Posted June 21, 2016 22 hours ago, JLogan3o13 said: This is not a forum where you put in a request and someone barfs up the code for you. We're happy to help, but you need to at least try on your own. Look at me, wrong again "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
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