Sign in to follow this  
Followers 0
sloppyjoe72

Help with Yes or No dialog box

6 posts in this topic

#1 ·  Posted (edited)

I'm trying to create a simple front end for the TZEdit tool. I know that one has already been created and posted on here, but I'm trying to write my own scripts to see how well I can do.

Here's the code:

CODE
Run("TZEdit.exe")

WinWaitActive("Windows Time Zone Editor" , "Daylight Saving Time")

Send("{TAB 2}")

Send("{ENTER}")

WinWaitActive("Edit Time Zone" , "Time Zone &Name:")

Send("{TAB 5}")

Send("{DOWN}")

Send("{TAB 2}")

Send("{UP}")

Send("{TAB 5}")

Send("{UP 4}")

Send("{TAB 2}")

Send("{DOWN}")

MsgBox(1, "Verify", "Please verify that the settings in the TZEDIT tool are correct. The Start Day should read the 2nd Sunday in March and the Last Day should be the 1st Sunday in November. Does TZEdit match these settings?")

$yes1 = GUICtrlCreateButton ("Yes", 10, 30, 50)

GUICtrlSetOnEvent(-1 , "affirm")

$no1 = GUICtrlCreateButton ( "No", 0, -1)

GUICtrlSetOnEvent(-1 , "deny")

GUISetState(@SW_SHOW)

; Just idle around

While 1

Sleep(10)

Wend

; END

Func affirm()

Send("{TAB 7}")

Send("{ENTER}")

Send("{TAB 4}")

Send("{ENTER}")

EndFunc

Func deny()

MsgBox(0, "Error", "Please manually change the information in the TZEdit tool. The Start Day should be the 2nd Sunday in March and the Last Day should be the 1st Sunday in November. Please change this information befopre clicking the OK button.")

EndFunc

exit

Everything works ok right up until I display the Yes or No dialog box. The box displays, but the buttons don't do anything and the script just stops.

I've figured out that I'm not getting the codes that are returned from pressing the yes or no buttons, but I don't know how to capture them. I've searched the help file, but can't find anything that points me in the right direction.

All of the keypresses are ok, and the program runs fine without the dialog box. I just want to put it in on the off chance that the machine's date and time setting aren't configured properly

Thanks again for the help, and if this was answered in another thread, just point me at it.

:-)

Edited by sloppyjoe72

Share this post


Link to post
Share on other sites



You need to save the result of the MsgBox into a variable and test that:

$ans = MsgBox(1,.,..)
If $ans = 6 then 
; yes clicked..
endif

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

#3 ·  Posted (edited)

Something like this?:

Run("TZEdit.exe")
WinWaitActive("Windows Time Zone Editor" , "Daylight Saving Time")
Send("{TAB 2}")
Send("{ENTER}")
WinWaitActive("Edit Time Zone" , "Time Zone &Name:")
Send("{TAB 5}")
Send("{DOWN}")
Send("{TAB 2}")
Send("{UP}")
Send("{TAB 5}")
Send("{UP 4}")
Send("{TAB 2}")
Send("{DOWN}")
MsgBox(4, "Verify", "Please verify that the settings in the TZEDIT tool are correct. The Start Day should read the 2nd Sunday in March and the Last Day should be the 1st Sunday in November. Does TZEdit match these settings?")
$ans = MsgBox(6,.,..)
If $ans = 6 then 
Send("{TAB 7}")
Send("{ENTER}")
Send("{TAB 4}")
Send("{ENTER}")
endif

If $ans = 7 then     
    MsgBox(0, "Error", "Please manually change the information in the TZEdit tool. The Start Day should be the 2nd Sunday in March and the Last Day should be the 1st Sunday in November. Please change this information befopre clicking the OK button.")  
    endif
exit

I now understand that I had parts of the script that were useless, though I can't seem to figure out what to put in for "$ans = MsgBox(6,.,..)"

I checked the help file, but can't find anything on this syntax

Thanks again, and I'm tryin'!

Edited by sloppyjoe72

Share this post


Link to post
Share on other sites

Does this then become and If...Elseif type statement?

I've tried them before without much success.

show what you tried and doesn't work ... :whistle:

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

show what you tried and doesn't work ... :whistle:

edited my above post to show the new code :-)

Share this post


Link to post
Share on other sites

edited my above post to show the new code :-)

$ans= MsgBox(4, "Verify", "Please verify that the settings in the TZEDIT tool are correct. The Start Day should read the 2nd Sunday in March and the Last Day should be the 1st Sunday in November. Does TZEdit match these settings?")
If $ans = 6 then 
Send("{TAB 7}")
Send("{ENTER}")
Send("{TAB 4}")
Send("{ENTER}")
endif

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

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