Jump to content

Restart from a preset point


Recommended Posts

  • Moderators

@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!

Link to comment
Share on other sites

  • Moderators

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!

Link to comment
Share on other sites

#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

Link to comment
Share on other sites

  • Moderators

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!

Link to comment
Share on other sites

21 hours ago, PINTO1927 said:

I have shown you the point of departure must start

Here the solution for your script:

#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 by AutoBert
Link to comment
Share on other sites

  • Moderators
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!

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...