Jump to content

buttons don't disapair


remco
 Share

Recommended Posts

I made a gui create box and it pops up with the buttons but I can press all I want on the buttons nothing happens.

can someone tell me what I do wrong. ?

and yes I'm a noob and trying to figure this one out for over 4 days by now

al it does is give me the gui and continues without waiting for the user input

it's a big script

but here is the portion I am strugling with

;################################

;### define country computer belongs to

;################################

If $varCompCountry <> "BE" And $varCompCountry <> "DE" And $varCompCountry <> "NL" then getCountry()

;EndIf

Func getCountry()

Local $msg

GUICreate("Select country", 400, 280)

$button_BE = GUICtrlCreateButton("BE", 30, 20, 50, 40)

$button_DE = GUICtrlCreateButton("DE", 80, 20, 50, 40)

$button_NL = GUICtrlCreateButton("NL",130, 20, 50, 40)

GUISetState()

while 1

$msg = GUIGetMsg()

sleep(50)

Select

Case $msg = $GUI_EVENT_CLOSE

Exit

Case $msg = $button_BE

return $varCompCountry = "BE"

ExitLoop

Case $msg = $button_DE

return $varCompCountry = "DE"

ExitLoop

Case $msg = $button_NL

return $varCompCountry = "NL"

ExitLoop

EndSelect

WEnd

EndFunc

Link to comment
Share on other sites

If NOT StringInStr("BE|DE|NL|", $varCompCountry & "|") Then $sRtn = getCountry()
MsgBox(0, "Result", $sRtn)

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

If NOT StringInStr("BE|DE|NL|", $varCompCountry & "|") Then $sRtn = getCountry()
MsgBox(0, "Result", $sRtn)
?? I still have the problem that the gui doesn`t disapear after it`s called upon.
Link to comment
Share on other sites

?? I still have the problem that the gui doesn`t disapear after it`s called upon.

You need to delete the gui in your function before you return from it. This is one way

#include <guiconstantsEx.au3>
ConsoleWrite(Getcountry() & @CRLF)
Func getCountry()
    Local $msg,$Result
    Local $G1 = GUICreate("Select country", 400, 280)
    $button_BE = GUICtrlCreateButton("BE", 30, 20, 50, 40)
    $button_DE = GUICtrlCreateButton("DE", 80, 20, 50, 40)
    $button_NL = GUICtrlCreateButton("NL", 130, 20, 50, 40)
    GUISetState()
    While 1
        $msg = GUIGetMsg()
       ;Sleep(50); better not have a sleep in a loop with GuiGetMsg as you can miss events IMO
        Select
            Case $msg = $GUI_EVENT_CLOSE
                ExitLoop
            Case $msg = $button_BE
                $Result = "BE"
                ExitLoop
            Case $msg = $button_DE
                $Result = "DE"
                ExitLoop
            Case $msg = $button_NL
                $Result = "NL"
                ExitLoop
        EndSelect
    WEnd
    GuiDelete($G1)
    Return $result
EndFunc  ;==>getCountry
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
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...