Sign in to follow this  
Followers 0
tonysing

pause the program until click the msgbox

10 posts in this topic

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.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

Thanks, but I am not familar with those hot key.

Can you tell more about how is it actually work?

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

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

Share this post


Link to post
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:

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

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 :(

[center]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.[/center]

Share this post


Link to post
Share on other sites

Perhaps I missed something, but doesn't it work if you just remove the 240 timeout in the MsgBox ?

MsgBox(0,"Software Installation","Voltage ....... installation.", 240)
ShellExecuteWait("Kill.exe", "", "", "open")

Without a timeout a msgbox is blocking...

1 person likes this

Share this post


Link to post
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.

Share this post


Link to post
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.

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  
Followers 0