Jump to content

Retrive Button Pressed in MSGBOX or InputBox


 Share

Recommended Posts

I'm trying to capture what button is pressed on a MSGBOx or Input Box.

Why won't this script exit upon hitting cancel like i told it to on the line 8?

If $Ddrive == "Fixed" AND $DPROE2001 = 1 AND $CPROE2001 = 1 Then

Do

PromptForDrive()

;(the above line calls a function that will prompt them to enter C: or D:)

If $destination <> "C:" Or $destination <> "D:" Then

$error = MsgBox(4096+5,"Invalid Drive Specified","The Entry Specified was invalid. Please Try Again.")

If @error = 2 Then Exit

EndIf

Until $destination == "C:" Or $destination == "D:"

EndIf

Exit

Func PromptForDrive( )

$destination = InputBox("Select Destination Drive", "Please Enter C: or D: for the destination drive", "C:", "")

EndFunc

Thanks,

Kenny

Edited by ken82m

 "I believe that when we leave a place, part of it goes with us and part of us remains... Go anywhere, when it is quiet, and just listen.. After a while, you will hear the echoes of all our conversations, every thought and word we've exchanged.... Long after we are gone our voices will linger in these walls for as long as this place remains."

Link to comment
Share on other sites

  • Developers

This should work...

$rc = MsgBox(4096+5,"Invalid Drive Specified","The Entry Specified was invalid. Please Try Again.")

If $rc = 2 Then Exit

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

damn it I'm sure i had tried that.....guess not lol

well thanks alot :whistle:

 "I believe that when we leave a place, part of it goes with us and part of us remains... Go anywhere, when it is quiet, and just listen.. After a while, you will hear the echoes of all our conversations, every thought and word we've exchanged.... Long after we are gone our voices will linger in these walls for as long as this place remains."

Link to comment
Share on other sites

One more thing, you'll see this in the code I pasted above:

If $destination <> "C:" Or $destination <> "D:" Then

MsgBox(4096,"Invalid Drive Specified","The Entry Specified was invalid. Please Try Again.")

EndIf

I get the message box even when $destination DOES equal C: or D: but I know the C: or D: is in their because as soon I hit OK the script continues because the UNTIL variable was met which just says keep going until $destination = C: or D:.

Did I miss a pace or something?

Thanks again,

Kenny

Edited by ken82m

 "I believe that when we leave a place, part of it goes with us and part of us remains... Go anywhere, when it is quiet, and just listen.. After a while, you will hear the echoes of all our conversations, every thought and word we've exchanged.... Long after we are gone our voices will linger in these walls for as long as this place remains."

Link to comment
Share on other sites

  • Developers

You need to add

$destination="" or Global $destination

to te top of the script.

Its now a LOCAL variable for the Func PromptForDrive( ) only.

And the OR needs to be and AND :whistle:

Alternative would be:

If $Ddrive == "Fixed" AND $DPROE2001 = 1 AND $CPROE2001 = 1 Then

Do

  $destination=PromptForDrive()

  ;(the above line calls a function that will prompt them to enter C: or D:)

  If $destination <> "C:" And $destination <> "D:" Then

        $error = MsgBox(4096+5,"Invalid Drive Specified","The Entry Specified was invalid. Please Try Again.")

        If @error = 2 Then Exit

  EndIf

Until $destination == "C:" Or $destination == "D:"

EndIf

Exit

Func PromptForDrive( )

Return InputBox("Select Destination Drive", "Please Enter C: or D: for the destination drive", "C:", "")

EndFunc

Jos

Edited by JdeB

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

It's the way you set the IF statement up. If it finds D, the first condition is true, if it's C, the second conditions is true. If it's any other drive letter, both conditions will be true. It's impossible to NOT get a true result with that construct.

Try to restructure it so that:

IF $drive = "C:" OR $drive = "D:" THEN
; Do stuff when the drive is found
ELSE
; Do stuff when the drive is NOT found
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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...