Sign in to follow this  
Followers 0
unknown12

Buttons in GUI

5 posts in this topic

This is probably really easy, but how do i check if a button has been pressed?

Share this post


Link to post
Share on other sites



hope it helps

Opt ("GUINotifyMode", 1)
GUICreate("Select the Building:", 120, 100)

$OK = GUISetControl ("button", "OK", 10,10,50,20)
$Exit = GuisetControl ("button", "Exit", 10,40,50,20)

While 1
$N=GuiMsg ()


SELECT 
Case $n = $OK
Msgbox(0,0,"ok button has been pressed")

Case $n = $Exit
Msgbox(0,0,"EXIT button has been pressed")
   Exit
 EndSelect
WEnd
GUIHide()

Share this post


Link to post
Share on other sites

In the latest version you need a GuiShow() before the While loop so that the Gui comes up.

arctor

Share this post


Link to post
Share on other sites

Opt ("GUINotifyMode", 1)

GUICreate("Select the Building:", 120, 100)

$OK = GUISetControl ("button", "OK", 10,10,50,20)

$Exit = GuisetControl ("button", "Exit", 10,40,50,20)

While 1

$N=GuiMsg ()

SELECT

Case $n = $OK

Msgbox(0,0,"ok button has been pressed")

Case $n = $Exit

Msgbox(0,0,"EXIT button has been pressed")

  Exit

EndSelect

WEnd

GUIHide() 

When I try this $n always = '-2'.

Here is my code. The MsgBox's are there for me to see what's happening...

; NetMsg.au3
; August 5, 2004

; A NetSend Utility

GUICreate("NetMsg / A NetSend Utility", 300, 200)
  GUISetControl("Label", "Username:", 10, 10)
  $user = GUISetControl("Input", "Username", 10, 25)
  GUISetControl("Label", "Message:", 10, 60)
  $msg = GUISetControl("Input", "Type your message here", 10, 75, 280)
  $netsend = GUISetControl("Button", "Send", 10, 110, 100)
  $quit = GUISetControl("Button", "Exit", 190, 110, 100)
GUIShow()
GUIWaitClose()

While 1
  $x = GuiMsg()
  MsgBox(0, "$x", $x)

  Select
  Case $x = $netsend
    MsgBox(0, "$user", $user)
    MsgBox(0, "$msg", $msg)
    RunWait(@ComSpec & " /c " & "netsend " & $user & " " & $msg, "", @SW_HIDE)

  Case $x = $quit
    Exit
  EndSelect
WEnd

Thanks for any help,

Ian


"Blessed be the name of the Lord" - Job 1:21Check out Search IMF

Share this post


Link to post
Share on other sites

@ioliver:

You have to use:

Opt ("GUINotifyMode", 1)

Or should be use:

GUISetControlNotify() after setting the button controls.

One of these you sould take.

AND: delete the line with "GUIWaitCLose()"!!!

Regards Holger

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