Sign in to follow this  
Followers 0
iagman

Close dialog

4 posts in this topic

I discovered AutoIt a couple days ago. I know how to script XML but not AutoIt. But, by copying code and hacking away until it works I've finally gotten a little stock calculator with input windows, output windows, and Calculate, Clear, and Cancel buttons. It works well except still have an elusive round-down problem with one of the calculations.

What I've not been able to figure out is how to click on the X at top, right of dialog box and close the application. My Cancel button works ok when clicked which is what I now use. Also, the Minimize button works, but not the X.

I tried reading values of the X button with the AutoIt3 Info tool but it doesn't really give me any information as it does for my own controls.

How do I connect up this X control so I have two ways of exiting the calculator?

Thanks,

iagman

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

If by X button you mean the GUI Close button on the top right of the Window Titlebar, then

#include <GUIConstants.au3>
; Your GUI and button definitions...
While 1
    $msg = GUIGetMsg() ;

    Switch $msg
    Case $GUI_EVENT_CLOSE, $ButtonCancel ; <- Change $ButtonCancel to what your Cancel Button is defined as
        ExitLoop
        ;Case $ButtonAdd ; Code for other buttons
        ;Case $ButtonSubtract
        EndSwitch
Wend
Exit

Edit: Added #include <GUIConstants.au3>

Edited by DaRam

Share this post


Link to post
Share on other sites

Thanks, got it working. The $GUI_EVENT_CLOSE was what I needed. I'm still foggy about all the commands and not sure how and when they get applied.

This is how I added it into my code;

Case $msg = $GUI_EVENT_CLOSE Or $msg = $CancelButton

There may be a more efficient way to write it, but for now I have to fall back on constructing code the way I know.

iagman

Share this post


Link to post
Share on other sites

I don't know about efficient, but this is simpler:

Case $GUI_EVENT_CLOSE,  $CancelButton

Thanks, got it working. The $GUI_EVENT_CLOSE was what I needed. I'm still foggy about all the commands and not sure how and when they get applied.

This is how I added it into my code;

Case $msg = $GUI_EVENT_CLOSE Or $msg = $CancelButton

There may be a more efficient way to write it, but for now I have to fall back on constructing code the way I know.

iagman

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