Jump to content
Sign in to follow this  
thecakeisalie

Declare MsgBox variable for later use

Recommended Posts

thecakeisalie

Hello everyone, just had a quick question. I've already searched the help file and forums regarding this question and was not able to find anything. I am sure someone has encountered this before. Perhaps it is the way I have worded it, but I having a bit of a problem. I was wondering if a MsgBox could be declared in a variable for later use? Currently, my script looks like this:

$domain = @LogonDomain
$add_to_domain= MsgBox(4, "Hey, listen!", "This computer is not in the domain, would you like to add it now?")

#cs
      code
#ce

If $domain <> "MYDOMAIN" Then

    If $add_to_domain == 6 Then
           ;more code

    Else
            ;more code
  
    EndIf
EndIf

The problem is, the MsgBox pops up as soon as it is declared. Would I have to create another function in order for this to work? It is more of a preference thing for me if I have to use the same MsgBox more than once. Any help would be much appreciate, thanks for your time.

Edited by thecakeisalie

Share this post


Link to post
Share on other sites
water

MsgBox is the name of an AutoIt function. That means it is executed where you place it in your code. What you can "declare in a variable for later use" are the parameters for function MsgBox.

Something like:

Global $iMB_Flag = 4
Global $sMB_Title = "Hey,listen!"
Global $sMB_Text = "This computer is not in the domain, would you like to add it now?"
;more code
MsgBox($iMB_Flag, $sMB_Title, $sMB_Text)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
thecakeisalie

MsgBox is the name of an AutoIt function. That means it is executed where you place it in your code. What you can "declare in a variable for later use" are the parameters for function MsgBox.

Something like:

Global $iMB_Flag = 4
Global $sMB_Title = "Hey,listen!"
Global $sMB_Text = "This computer is not in the domain, would you like to add it now?"
;more code
MsgBox($iMB_Flag, $sMB_Title, $sMB_Text)

Thanks for the reply ;) That makes way more sense to do it that way.

Share this post


Link to post
Share on other sites
water
;)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

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  

×