Sign in to follow this  
Followers 0
anixon

MsgBox

9 posts in this topic

How do you read the return value for the button pressed as this does not work

msgbox(1,"sSentry","Alt+F1 Help" & @CRLF & _

"Alt+End Close sSentry" & @CRLF & _

"Alt+L Display Log File" & @CRLF & _

"Alt+I Edit INI File" & @CRLF & _

"Alt+R Restore Default INI File ", 10)

If @error = 1 Then

msgbox(0,"","Ok Pressed")

EndIf

Share this post


Link to post
Share on other sites



Dim $result = MsgBox(0, "", "")

If $result = ... Then

...

Share this post


Link to post
Share on other sites

A very nice tool is "hidden" in SciTe :)

... it is called "Code Wizard" (shortcut Alt-W)

You can play with various MessageBoxes and get the code for them :)

Give it a try.


SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Share this post


Link to post
Share on other sites

A very nice tool is "hidden" in SciTe :)

... it is called "Code Wizard" (shortcut Alt-W)

You can play with various MessageBoxes and get the code for them :)

Give it a try.

Thanks again :) so much to learn so little time...

This code works a treat

Local $iMBAns

$iMBAns = msgbox(1,"sSentry","Alt+F1 Help" & @CRLF & _

"Alt+End Close sSentry" & @CRLF & _

"Alt+L Display Log File" & @CRLF & _

"Alt+I Edit INI File" & @CRLF & _

"Alt+R Restore Default INI File ", 10)

Select

Case $iMBAns = 1 ;OK

Case $iMBAns = 2 ;Cancel

EndSelect

msgbox(0,"",$iMBAns)

Share this post


Link to post
Share on other sites

Dim $result = MsgBox(0, "", "")

If $result = ... Then

...

Two ways of doing it wow :) Thanks for your help and this is the code:

Dim $result = msgbox(1,"sSentry","Alt+F1 Help" & @CRLF & _

"Alt+End Close sSentry" & @CRLF & _

"Alt+L Display Log File" & @CRLF & _

"Alt+I Edit INI File" & @CRLF & _

"Alt+R Restore Default INI File ", 10)

If $result = 1 Then

Msgbox(0,"","OK Pressed")

elseif $result = 2 Then

Msgbox(0,"","Cancelled Pressed")

EndIf

Share this post


Link to post
Share on other sites

Two ways of doing it wow :) Thanks for your help and this is the code:

Another variation on the same theme if you don't actually need to store the result in a variable for later

If MsgBox(1,"test","Test") = 1 then 
    Msgbox(0,"","You clicked OK")
Else
    Msgbox(0,"","You clicked Cancel")
EndIf

Share this post


Link to post
Share on other sites

Another variation on the same theme if you don't actually need to store the result in a variable for later

If MsgBox(1,"test","Test") = 1 then 
    Msgbox(0,"","You clicked OK")
Else
    Msgbox(0,"","You clicked Cancel")
EndIf
Wow three different ways to do it that's cool. Thanks for the input

Share this post


Link to post
Share on other sites

Well, friend, it's programming. I have rarely seen a process that can only be done one way.

If you want another way to do a message box, you could write your own GUI code. But that's getting over-the-top.

Share this post


Link to post
Share on other sites

To those that helped with the Msgbox Return Value this is how I ended up using it:

CODE
;Keys Monitor

;

Func KeysMonitor()

$dll = DllOpen("user32.dll")

If _IsPressed('12', $dll) And _IsPressed('70', $dll) Then ; Alt + H to display Keys Monitor Help

DllClose($dll)

msgbox(262208,$Title & " Help","Alt+F1 Help" & @CRLF & _

"Alt+End Close sSentry" & @CRLF & _

"Alt+L Display Log File" & @CRLF & _

"Alt+I Edit INI File" & @CRLF & _

"Alt+R Restore Default INI File " & @CRLF & _

"Ctrl+End Close Skype", 10)

EndIf

If _IsPressed('12', $dll) And _IsPressed('23', $dll) Then ; Alt + End to Close sSentry

DllClose($dll)

If Msgbox(262161,$Title," CLOSE sSentry..") = 1 Then

ISExit()

EndIf

EndIf

If _IsPressed('12', $dll) And _IsPressed('4C', $dll) Then ; Alt + L to Display Current Log File

DllClose($dll)

ShellExecuteWait((@YDAY) & "sSentry.txt", "", @ScriptDir & "\LogFiles", "Open")

EndIf

If _IsPressed('12', $dll) And _IsPressed('49', $dll) Then ; Alt + I to Edit the INI File

DllClose($dll)

If Msgbox(262161,$Title," EDIT sSentry.ini..") = 1 Then

Global $DefaultPingID1 = IniRead(@ScriptDir & "\sSentry.ini", "PingID1", "value", "")

Global $DefaultPingID2 = IniRead(@ScriptDir & "\sSentry.ini", "PingID2", "value", "")

Global $DefaultSentry1 = IniRead(@ScriptDir & "\sSentry.ini", "AppSentry1", "value", "")

Global $DefaultSentry2 = IniRead(@ScriptDir & "\sSentry.ini", "AppSentry2", "value", "")

ShellExecuteWait("sSentry.ini", "", @ScriptDir, "Edit")

CheckConfig()

EndIf

EndIf

If _IsPressed('12', $dll) And _IsPressed('52', $dll) Then ; Alt + R to Restore INI to the Default

DllClose($dll)

If Msgbox(262161,$Title," RESTORE sSentryini..") = 1 Then

Run("sSInstall.exe", @ScriptDir)

Exit

EndIf

EndIf

If _IsPressed('11', $dll) And _IsPressed('23', $dll) Then ; Ctrl + End to Close Skype

DllClose($dll)

If Msgbox(262161,$Title," CLOSE Skype..") = 1 Then

$PID = ProcessExists("Skype.exe")

If $PID Then ProcessClose($PID)

EndIf

EndIf

EndFunc ;==>KeysMonitor

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