Jump to content

pause the program until click the msgbox


 Share

Recommended Posts

I am writing a package to install a security plug in on Outlook.

Everything work fine, expect that I want the script start installing only after I close the message box.

MsgBox(0,"Software Installation","Voltage Encryption Client for Outlook will be installed on your computer. Please close Microsoft Outlook,Adobe Reader and IE and click OK to start the installation.",240)
ShellExecuteWait("Kill.exe", "", "", "open")
warn(5000)
.
.
.
.
.
.
If @error=0 Then
        Splashoff()
    MsgBox(0, "Software Installation", "Voltage Encryption Client for Outlook has been installed on your computer. Please manually restart your PC to complete INSTALLATION.")
Else
    Splashoff()
    MsgBox(0, "Software Installation", "The installation encounters problems and is failed."& @CRLF & "Please contact Helpdesk at +852-2678-6662 for further support.")
    Exit -1
EndIf

For now, the script will automatically run and install after the msgbox pops our for a while, no matter I have click the msgbox or not.

What should I set to achieve this?

As it seems that functions like runwait, shellexecutewait have no help for this.

Link to comment
Share on other sites

You could use a hotkeyset like this:

HotKeySet("{END}","StartScript");when you press or send the end key the script will do something

Func StartScript()
     Put your script code in here
EndFunc

When you want to start your script you can send("{END}")

EDIT- You could processclose all those programs as part of the program installation.

Edited by computergroove

Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html

Link to comment
Share on other sites

Here is an example I use all the time in most of my scripts:

Global $Paused
HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{ESC}", "Terminate")
$Paused = $Paused
send("{pause}")

While 1
     Sleep(100)
Wend

Func TogglePause()
    $Paused = NOT $Paused
    While $Paused
        sleep(100)
        ToolTip('Script is "Paused"',0,0)
    WEnd
    ToolTip("")
EndFunc

Func Terminate()
    Exit 0
EndFunc

It just tells autoit to listen for a keypress at all times and if the key is pressed then perform execute the function. Pause is a real good example. You  should put the hotkeyset lines near the top of your script.

Edited by computergroove

Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html

Link to comment
Share on other sites

Thanks a lot. :thumbsup:

It is nice, but that isn't really suit for my case.

As the script will be distrbuted by SCCM to many other user, it is impossible for me to teach them all about the hot key.

What I am looking for is the script is waiting for the message box to close. During that the script is pausing.

After the box is closed, the script will resume and run.

I was hope to get some return value from msgbox and do this.

But any other method that works is fine to me.

Anyway, thanks for your suggestion. I have learn a new skill from your post. :graduated:

Link to comment
Share on other sites

You dont need to actually press the key. You can use the autoit command:

Send("{END}")

to have autoit send the key that executed the code at the right time. Can you post your code?

Edit - Instead of using a msgbox you could make a gui. Its not too difficult if you use koda. Google it.

Edited by computergroove

Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html

Link to comment
Share on other sites

  • Moderators

1:

#include <MsgBoxConstants.au3>
Global $gnMsgBoxRet = MsgBox(64 + 262144, "Example", "I'm going to timeout, don't click me!", 3)
If $gnMsgBoxRet = $IDTIMEOUT Then
    MsgBox(16 + 262144, "Error", "Timeout, you only have so long to make a choice!")
    Exit 101
EndIf

2.  Use something like this for the process running (pseudo code):

Global $gnPID = Run("some.exe")
Global $gsTitle = "Some Title Here"
Global $gsText = "Please Wait"
SplashTextOn($gsTitle, $gsText)
Global $gsAdd = ""
Global $gnCount = 0
While ProcessExists($gnPID)
    ; change text
    Sleep(1000)
    $gnCount += 1
    $gsAdd = ""
    If $gnCount > 4 Then $gnCount = 0
    For $i = 0 To $gnCount
        $gsAdd &= "."
    Next
    ControlSetText($gsTitle, "", "Static1", $gsText & $gsAdd)
WEnd
SplashOff() 

If I understand you correctly, that should help.

Edited by SmOke_N
Fixed code tags :(

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

I must have missed something too because the msgbox is typically blocking execution of the rest of the script until it's dimissed. You can try this below. This will install the script if you press OK or wait for 15 seconds. If you hit Cancel it quits. 

Dim $iMsgBoxAnswer
$iMsgBoxAnswer = MsgBox(8513,"Software Installation","Voltage Encryption Client for Outlook will be installed on your computer. Please close Microsoft Outlook, Adobe Reader and IE and click OK to start the installation.",15)
Select
   Case $iMsgBoxAnswer = 1  ;OK
             _Install()
   Case $iMsgBoxAnswer = 2  ;Cancel
            Exit
   Case $iMsgBoxAnswer = -1 ;Timeout
            _Install()
EndSelect
 
Func _Install()
 
;Your script stuff in here
 
EndFunc
EndFuncAutoIt is the shiznit. I love it.
Link to comment
Share on other sites

I think I understand what is being asked.

Look at this example:

$msg = MsgBox(262144+1, "Button test", "clicking on the OK button will generate a second msgbox saying you clicked OK."& @CRLF _
                                &"clicking on CANCEL will generate a second msgbox saying you clicked CANCEL")
IF $msg = 1 then MsgBox(262144, "", "You clicked OK")
IF $msg = 2 then MsgBox(262144, "", "You clicked CANCEL")

As you can see, I'm reading the button pressed and when the desired button is pressed I then call a specific action. What you can do is replace where I use a msgbox and call your install function. Look at msgbox in the help file and you can see the list of what button return code is what.

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