Jump to content

IF condition for message box to close or continue script


Eli_jahbot
 Share

Recommended Posts

my esteemed autoits,

i need your help once again. The bold and italics below are what i will be referring to. I need a message box to exit the script if Cancel is pressed and to continue the script if OK is pressed. I have tried multiple ways to do this to no avail. Can someone please breakdown how i go about this via Message box, and or Input box as I'm sure they will follow the same logic. I appreciate your time and assistance.

 

Example:

global $url, $username, $password, $sspassword

$url = "https://securegateway.fairview.org"
$username = "XXX"
$password = "YYY"
$sspassword = "ZZZ"

#include <Constants.au3>
#include <msgboxconstants.au3>

ShellExecute ($url)
WinWaitActive("window")
send($username)
send("{tab}")
send($password)
send("{enter}")
msgbox($mb_okcancel, "Wait for the page to load then select OK to continue script", "Wait for the page to load then select OK to continue script")
if($idok)
send("+{tab 8}")
send("{enter}")
if ($idcancel) then Exit
EndIf

Link to comment
Share on other sites

Try this.

MsgBox($mb_okcancel, "Wait for the page to load then select OK to continue script", "Wait for the page to load then select OK to continue script")
If ($idok) Then
    Send("+{tab 8}")
    Send("{enter}")
ElseIf ($idcancel) Then
    Exit
EndIf

 

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Sorry, went too fast, try this.

$ans = MsgBox($mb_okcancel, "Wait for the page to load then select OK to continue script", "Wait for the page to load then select OK to continue script")
If $ans = $idok Then
    Send("+{tab 8}")
    Send("{enter}")
ElseIf $ans = $idcancel Then
    Exit
EndIf

 

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

You may be a stranger but you sure as hell made my day! This is working as I hoped and now I can apply this logic to the other 50 or so scripts i have compiled that are missing this vital piece. Now the next thing I will tackle is adding input boxes into my scripts to handle user logins instead of tying those down to variables.  -cheers!

 

For those reading, here is the resolution for this:

ShellExecute ($url)
WinWaitActive("Super cool computer - Citrix Access Gateway - Internet Explorer")
send($username)
send("{tab}")
send($password)
send("{enter}")
$ans = MsgBox($mb_okcancel, "Wait for the page to load then select OK to continue script", "Wait for the page to load then select OK to continue script")
If $ans = $idok Then
    Send("+{tab 8}")
    ElseIf $ans = $idcancel Then
    Exit
EndIf

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

×
×
  • Create New...