Sign in to follow this  
Followers 0
ken82m

Retrive Button Pressed in MSGBOX or InputBox

6 posts in this topic

#1 ·  Posted (edited)

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

My Contributions _StringMultiReplace PC Builders Console - Secure PDF Creator - Cisco VPN Installer MS DNS Server Backup Script - MS DHCP Backup Script IT Admin Console - Toggle Admin Mode - MyMovies-Add Discs Script - IT Help Desk and System Information Tool - Set On Lid Close Power Option - Streaming Media Server & Website "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."

Share this post


Link to post
Share on other sites



This should work...

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

If $rc = 2 Then Exit


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

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

well thanks alot :whistle:


My Contributions _StringMultiReplace PC Builders Console - Secure PDF Creator - Cisco VPN Installer MS DNS Server Backup Script - MS DHCP Backup Script IT Admin Console - Toggle Admin Mode - MyMovies-Add Discs Script - IT Help Desk and System Information Tool - Set On Lid Close Power Option - Streaming Media Server & Website "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."

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

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

My Contributions _StringMultiReplace PC Builders Console - Secure PDF Creator - Cisco VPN Installer MS DNS Server Backup Script - MS DHCP Backup Script IT Admin Console - Toggle Admin Mode - MyMovies-Add Discs Script - IT Help Desk and System Information Tool - Set On Lid Close Power Option - Streaming Media Server & Website "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."

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

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

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


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

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