Jump to content

Question on pause function


blanked
 Share

Recommended Posts

Hi all,
 
I'm relatively new to AutoIT so hi all!

I have a question on a pause function. Say I use the Pause function below, when I toggle the pause off will it resume from the previous function that it was running from? What I'm doing is calling a series of functions that will help me perform some other duties. When I pause the script it should make some hidden/invisible windows visible with the IE.au3 and the reverse when I resume it.

It could be something wrong with my code but when I toggle the pause function and resume it, the functions (IEFunction1 and IEFunction2) that were running seems to have reset or have just plain stopped. So does such a pause function really resume from where it was running?

The $IEWin and $Notepad are handles to an Internet Explorer and Notepad window respectively.

Thank you so much in advance! :)

While 1
   Local $IEFunctionSuccess=IEFunction1()
   If $IEFunctionSuccess="success" Then
      $IEFunction2()
   Else
      ContinueLoop
   EndIf
Wend

Func Pause()

   $Paused = NOT $Paused
   ToolTip("")
   If $Paused = 1 Then
      ToolTip('Script is "Paused"',500,500)

      If Not ($IEWin = "") Then _IEAction($IEWin,"visible")
      If Not ($NotePad = "") Then WinSetState($NotePad,@SW_SHOW)
      Sleep(3000)
      ToolTip("")
   EndIf

   If $Paused = 0 Then
      If Not ($IEWin = "") Then _IEAction($IEWin,"invisible")
      If Not ($NotePad = "") Then WinSetState($NotePad,@SW_HIDE)
      Sleep(2000)
      ToolTip("")
   EndIf

   While $Paused
      sleep(100)
   WEnd

EndFunc
Link to comment
Share on other sites

Oh is that a more robust way of making the windows visible/invisible? I seemed to have reliability issues on the visible/invisible not working. Ok will try that out! Thank you so much! :)

Edit: Hmm..which property should I use to make the entire IE window visible/invisible? I read the autoit help site but can't seem to work it out myself.

How about the part about it continuing the previous function?

Edited by blanked
Link to comment
Share on other sites

I've tried the script below and it seems that when I resume the script it didn't carry on from where it left off. Is there any workaround to it?
The pause function seems to be messing up my loops or something.

#Include <Constants.au3>

Global $Pause
HotKeySet("^!w","Pause")
HotKeySet("^!q","Terminate")

test1()

Func test1()

While 1
For $Run=1 to 10
     Tooltip($Run)
     Sleep(1000)
Next
WEnd

EndFunc

Func Pause()
$Pause = NOT $Pause
If $Pause = 1 Then
     While 1
         Sleep(100)
     WEnd
EndIf

If $Pause = 0 Then
     Msgbox(0,"","Continue")
EndIf
EndFunc


Func Terminate()
Exit 0
EndFunc
Edited by blanked
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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...