Jump to content
Sign in to follow this  
Valuater

Regain script control from runwait?

Recommended Posts

If a user is in the middle of a script

( a script that normally waits for user to finish a process before continuing the script)

and the user would like to keep this process open AND continue the script...

(say it was in a runwait process) is this posible?

here is an example code i am working on

#include <GUIConstants.au3>
#include <File.au3>
#include <Array.au3>
#include <String.au3>>
#notrayicon
#include <GuiTab.au3>

$My_GUI=GUICreate("My GUI",400,200,50,50,"", $WS_EX_TOPMOST)

$Button1= GUICtrlCreateButton("Test", 30,30,100,30)
$Button2= GUICtrlCreateButton("Test RunWait", 30,90,100,30)
GUICtrlCreateLabel("Use Icon to ""Reset"" and to ""Exit"" this Program", 50,140)

GUISetState()

Opt("TrayOnEventMode",1)
Opt("TrayMenuMode",1); Default tray menu items (Script Paused/Exit) will not be shown.
TraySetClick (16)

$Resetitem = TrayCreateItem("Reset Focus on GUI")
TrayItemSetOnEvent(-1,"Reset")
TrayCreateItem("")
$exititem = TrayCreateItem("Exit")
TrayItemSetOnEvent(-1,"ExitScript")

TraySetState()

GUISetState(@SW_SHOW, $My_GUI)

While 1
  $msg = GUIGetMsg()

  Select
    Case $msg = $Button1
      MsgBox(0, "GUI Event", "Script has the Focus")

    Case $msg = $Button2
      $val = RunWait("Notepad.exe", "C:\WINDOWS", @SW_SHOWNORMAL)
  EndSelect
WEnd 

Exit


; Functions
Func Reset()
    Msgbox(0,"Reset Focus","Re-setting Focus on GUI from RunWait")
;_GUICtrlTabDeselectAll ($tab, 0); resets tab buttons
    WinSetState("My GUI", "", @SW_RESTORE)
    WinActivate("My GUI")
    ControlFocus ("My GUI", "",$My_GUI)
EndFunc


Func ExitScript()
    Exit
EndFunc

requires 3.1.1++

any help would be appreciated

thanks

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites

You could implement a While loop that checks in on the user every once in a while to see if they'd like more time with a MsgBox, or maybe even make a hotkey to interrupt the process if the user would like.

-Crim

Share this post


Link to post
Share on other sites

You would need to use Run instead of RunWait.

<{POST_SNAPBACK}>

I had a secondary use in mind for this... basically to handle a "lock-up" , "conflct" or "crash" and could use something like this to "reset" the script program

any ideas?

thanks again


NEWHeader1.png

Share this post


Link to post
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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...