Jump to content

Understanding of GUI and loops


Recommended Posts

Hi,

sorry for the mysterious thread title, but the only one i catch...

When i create a GUI, there needs to be a loop to get the information which button was klicked... So, when this button is klicked an i start another programm with RunWait, i can't close the GUI, or do something, hope you understand what i mean... here is an example:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

GUICreate("Test", 115, 30,-1,-1, -1, $WS_EX_TOOLWINDOW+$WS_EX_TOPMOST )
$button_1 = GUICtrlCreateButton("Start",5,5,50,20)
$button_2 = GUICtrlCreateButton("Exit",60,5,50,20)

GUISetState()

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $button_1
            RunWait ("notepad.exe","",@SW_SHOWMINIMIZED)
        Case $msg = $button_2
            ExitLoop
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
   EndSelect
WEndoÝ÷ Ùh^z-z²Ö«¶Ë¢é]¢yr{­¶P!z{Û(ÚâyÛaÌÉ«­¢+Ø¥¹±Õ±ÐíU%
½¹ÍѹÑÍà¹ÔÌÐì(¥¹±Õ±Ðí]¥¹½ÝÍ
½¹ÍѹÑ̹ÔÌÐì()U%
ÉÑ ÅÕ½ÐíQÍÐÅÕ½Ðì°ÄÄÔ°ÌÀ°´Ä°´Ä°´Ä°ÀÌØí]M}a}Q==1]%9=¬ÀÌØí]M}a}Q=A5=MP¤(ÀÌØíÕÑѽ¹|ÄôU%
Ñɱ
ÉÑ    ÕÑѽ¸ ÅÕ½ÐíMÑÉÐÅÕ½Ðì°Ô°Ô°ÔÀ°ÈÀ¤(ÀÌØíÕÑѽ¹|ÈôU%
Ñɱ
ÉÑ    ÕÑѽ¸ ÅÕ½Ðíá¥ÐÅÕ½Ðì°ØÀ°Ô°ÔÀ°ÈÀ¤()U%MÑMÑÑ ¤()]¡¥±Ä(ÀÌØíµÍôU%Ñ5Í ¤(M±Ð(
ÍÀÌØíµÍôÀÌØíÕÑѽ¹|Ä(íø
!9
=(ÀÌØíÁ¥ôIÕ¸ ÅÕ½Ðí¹½ÑÁ¹áÅÕ½Ðì°ÅÕ½ÐìÅÕ½Ðì±M]}M!=]5%9%5%i¤(]¡¥±AɽÍÍá¥ÍÑÌ ÀÌØíÁ¥¤(ÀÌØíµÍôU%Ñ5Í ¤(M±Ð(
ÍÀÌØíµÍôÀÌØíÕÑѽ¹|È(á¥Ñ1½½ÀÈ(
ÍÀÌØíµÍôÀÌØíU%}Y9Q}
1=M(á¥Ñ1½½ÀÈ(¹M±Ð(]¹(íø
!9
=(
ÍÀÌØíµÍôÀÌØíÕÑѽ¹|È(á¥Ñ1½½À(
ÍÀÌØíµÍôÀÌØíU%}Y9Q}
1=M(á¥Ñ1½½À(¹M±Ð)]¹

Is this a good or the only solution, or do i have a bad programming style?

Thank u ^_^

Edited by yetrael
Link to comment
Share on other sites

Hi,

sorry for the mysterious thread title, but the only one i catch...

When i create a GUI, there needs to be a loop to get the information which button was klicked... So, when this button is klicked an i start another programm with RunWait, i can't close the GUI, or do something, hope you understand what i mean... here is an example:

Is this a good or the only solution, or do i have a bad programming style?

Thank u :)

In your first script you use RunWait to start Notepad. RunWait pauses execution of the AutoIt script as you have described.

If you do not want AutoIt script to pause, use Run command.

See help file for the differences between RunWait and Run.

The second solution script is unnecessarily complex. Although, any solution that works is a good solution.

All the Select Cases use $msg. Using Switch $msg would simplify the script.

Hope you find this helpful.

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...