Sign in to follow this  
Followers 0
Damein

Problem with GUIGetMsg

3 posts in this topic

Alrighty, so I have a script with a basic GUI that when I press a button I want something to happen. I can get it to work in a different script.. but in this one it doesn't work.

This one works fine for me:

#include <StaticConstants.au3>
#include <GUIConstantsEx.au3>
HotKeySet("`", "ShowGUI")

Local $SearchFunction, $GoogleSearchButton

GUICreate("Quick Search", 200, 130)
GUICtrlCreateLabel("You are current searching: Google", 0, 0)
$SearchFunction = GUICtrlCreateEdit("What would you like to search for?", -1, 18, 200, 20)
$GoogleSearchButton = GUICTRLCreateButton("Submit", 60, 46, 60, 20)
GUISetState(@SW_SHOW)

While 1
        $msg = GUIGetMsg()
        If $msg = $GoogleSearchButton Then MsgBox(0, "Test", "GOOGLE!")
        WEnd

That was a test one to see if I could get it to work, and it works that whenever I press the submit button I get the MsgBox

Now this one, as soon as I choose a website from the menu I start getting the MsgBox's for the buttons, as if I was pressing them.

#include <StaticConstants.au3>
#include <GUIConstantsEx.au3>
HotKeySet("`", "ShowGUI")

Local $WebSite, $GoogleSearchButton, $YahooSearchButton, $BingSearchButton, $YouTubeSearchButton, $LyricsSearchButton, $msg


GUICreate("Quick Search", 200, 100)
$WebsiteMenu = GUICtrlCreateMenu("Websites")
$WebsiteItemGoogle = GUICtrlCreateMenuItem("Google", $WebsiteMenu)
$WebsiteItemYahoo = GUICtrlCreateMenuItem("Yahoo!", $WebsiteMenu)
$WebsiteItemBing = GUICtrlCreateMenuItem("Bing", $WebsiteMenu)
$WebsiteItemYouTube = GUICtrlCreateMenuItem("YouTube", $WebsiteMenu)
$WebsiteItemLyrics = GUICtrlCreateMenuItem("Lyrics", $WebsiteMenu)
GUICtrlCreateLabel("You are current searching: " & $WebSite, 0, 0)
$state = 1
While $WebSite = ""
    $msg = GUIGetMsg()
    If $msg = $WebsiteItemGoogle Then $WebSite = "Google"
    If $msg = $WebsiteItemYahoo Then $WebSite = "Yahoo"
    If $msg = $WebsiteItemBing Then $WebSite = "Bing"
    If $msg = $WebsiteItemYouTube Then $WebSite = "YouTube"
    If $msg = $WebsiteItemLyrics Then $WebSite = "Lyrics"
    if $msg = $GUI_EVENT_CLOSE then Exit
    WEnd
    
If $WebSite = "Google" Then
            GUIDelete()
GUICreate("Quick Search", 200, 130)
$WebsiteMenu = GUICtrlCreateMenu("Websites")
$WebsiteItemGoogle = GUICtrlCreateMenuItem("Google", $WebsiteMenu)
$WebsiteItemYahoo = GUICtrlCreateMenuItem("Yahoo!", $WebsiteMenu)
$WebsiteItemBing = GUICtrlCreateMenuItem("Bing", $WebsiteMenu)
$WebsiteItemYouTube = GUICtrlCreateMenuItem("YouTube", $WebsiteMenu)
$WebsiteItemLyrics = GUICtrlCreateMenuItem("Lyrics", $WebsiteMenu)
GUICtrlCreateLabel("You are current searching: Google", 0, 0)
$SearchFunction = GUICtrlCreateEdit("What would you like to search for?", -1, 18, 200, 20)
$GoogleSearchButton = GUICTRLCreateButton("Submit", 60, 46, 60, 20)
GUISetState(@SW_SHOW)
        EndIf
If $WebSite = "Yahoo" Then
            GUIDelete()
GUICreate("Quick Search", 200, 100)
$WebsiteMenu = GUICtrlCreateMenu("Websites")
$WebsiteItemGoogle = GUICtrlCreateMenuItem("Google", $WebsiteMenu)
$WebsiteItemYahoo = GUICtrlCreateMenuItem("Yahoo!", $WebsiteMenu)
$WebsiteItemBing = GUICtrlCreateMenuItem("Bing", $WebsiteMenu)
$WebsiteItemYouTube = GUICtrlCreateMenuItem("YouTube", $WebsiteMenu)
$WebsiteItemLyrics = GUICtrlCreateMenuItem("Lyrics", $WebsiteMenu)
GUICtrlCreateLabel("You are current searching: Yahoo!", -1, 18, 200, 20)
$YahooSearchButton = GUICTRLCreateButton("Submit", 60, 46, 60, 20)
GUISetState(@SW_SHOW)
        EndIf
If $WebSite = "Bing" Then
        GUIDelete()
GUICreate("Quick Search", 200, 100)
$WebsiteMenu = GUICtrlCreateMenu("Websites")
$WebsiteItemGoogle = GUICtrlCreateMenuItem("Google", $WebsiteMenu)
$WebsiteItemYahoo = GUICtrlCreateMenuItem("Yahoo!", $WebsiteMenu)
$WebsiteItemBing = GUICtrlCreateMenuItem("Bing", $WebsiteMenu)
$WebsiteItemYouTube = GUICtrlCreateMenuItem("YouTube", $WebsiteMenu)
$WebsiteItemLyrics = GUICtrlCreateMenuItem("Lyrics", $WebsiteMenu)
GUICtrlCreateLabel("You are current searching: Bing", -1, 18, 200, 20)
$BingSearchButton = GUICTRLCreateButton("Submit", 60, 46, 60, 20)
GUISetState(@SW_SHOW)
        EndIf
If $WebSite = "YouTube" Then
        GUIDelete()
GUICreate("Quick Search", 200, 100)
$WebsiteMenu = GUICtrlCreateMenu("Websites")
$WebsiteItemGoogle = GUICtrlCreateMenuItem("Google", $WebsiteMenu)
$WebsiteItemYahoo = GUICtrlCreateMenuItem("Yahoo!", $WebsiteMenu)
$WebsiteItemBing = GUICtrlCreateMenuItem("Bing", $WebsiteMenu)
$WebsiteItemYouTube = GUICtrlCreateMenuItem("YouTube", $WebsiteMenu)
$WebsiteItemLyrics = GUICtrlCreateMenuItem("Lyrics", $WebsiteMenu)
GUICtrlCreateLabel("You are current searching: YouTube", -1, 18, 200, 20)
$YouTubeSearchButton = GUICTRLCreateButton("Submit", 60, 46, 60, 20)
GUISetState(@SW_SHOW)
        EndIf
If $WebSite = "Lyrics" Then
            GUIDelete()
GUICreate("Quick Search", 200, 100)
$WebsiteMenu = GUICtrlCreateMenu("Websites")
$WebsiteItemGoogle = GUICtrlCreateMenuItem("Google", $WebsiteMenu)
$WebsiteItemYahoo = GUICtrlCreateMenuItem("Yahoo!", $WebsiteMenu)
$WebsiteItemBing = GUICtrlCreateMenuItem("Bing", $WebsiteMenu)
$WebsiteItemYouTube = GUICtrlCreateMenuItem("YouTube", $WebsiteMenu)
$WebsiteItemLyrics = GUICtrlCreateMenuItem("Lyrics", $WebsiteMenu)
GUICtrlCreateLabel("You are current searching: Lyrics", -1, 18, 200, 20)
$LyricsSearchButton = GUICTRLCreateButton("Submit", 60, 46, 60, 20)
GUISetState(@SW_SHOW)
        EndIf

While 1
        $msg = GUIGetMsg()
        Select
        Case $msg = $GoogleSearchButton
            MsgBox(0, "Test", "GOOGLE!")
        Case $msg = $YahooSearchButton
            MsgBox(0, "Test", "YAHOO!")
        Case $msg = $BingSearchButton
            MsgBox(0, "Test", "BING!")
        Case $msg = $YouTubeSearchButton
            MsgBox(0, "Test", "YOUTUBE!")
        Case $msg = $LyricsSearchButton
            MsgBox(0, "Test", "LYRICS!!")
        EndSelect
        WEnd

Func ShowGUI()
    if $state = 1 Then
    GUISetState(@SW_SHOW)
    $state = 0
Else
    GUISetState(@SW_HIDE)
    $state = 1
    EndIf
EndFunc

Not quite sure why it is.. I've been at it for a while now and can't figure it out.. :/

Thanks.


MCR.jpg?t=1286371579

Most recent sig. I made

Quick Launcher W/ Profiles Topic Movie Database Topic & Website | LiveStreamer Pro Website | YouTube Stand-Alone Playlist Manager: Topic | Weather Desktop Widget: Topic | Flash Memory Game: Topic | Volume Control With Mouse / iTunes Hotkeys: Topic | Weather program: Topic | Paws & Tales radio drama podcast mini-player: Topic | Quick Math Calculations: Topic

Share this post


Link to post
Share on other sites



Damein,

I have answered in the other topic. ;)

Next time, rather than double posting, just use the "Report" button at bottom left of your post to explain and ask to a Mod to move it. As long as you do not make a habit of it, no-one will mind! :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Thanks Melba, I send the report, didn't realize there was a button for it ;)


MCR.jpg?t=1286371579

Most recent sig. I made

Quick Launcher W/ Profiles Topic Movie Database Topic & Website | LiveStreamer Pro Website | YouTube Stand-Alone Playlist Manager: Topic | Weather Desktop Widget: Topic | Flash Memory Game: Topic | Volume Control With Mouse / iTunes Hotkeys: Topic | Weather program: Topic | Paws & Tales radio drama podcast mini-player: Topic | Quick Math Calculations: Topic

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  
Followers 0