Jump to content

Problem with GUIGetMsg


 Share

Recommended Posts

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

Link to comment
Share on other sites

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
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

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...