Jump to content

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

Link to comment
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

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...