Sign in to follow this  
Followers 0
OneSolution

GUI combobox with a submit button?

8 posts in this topic

Hello talented people,

I have a gui with multi combox that I use to link to my favorite websites and emails. Though its working like I wanted. I'm just carious if there's a way that I can have a submit button that will submit the website or email that I select from the combobox instead of it redirecting me when the selection is made from the dropdown menu. For example; if I select yahoo under my favorite menu it will redirect to yahoo.com. I'm trying to prevent this from happening because sometime the wrong website will be selected. So to simplify this I think by having a submit button to redirect it when press submit will solve that issue. Here is my code. I may need a little suggestions if there's something wrong with it. Thank you very much!Any help will be much appreciated!!

#include-once
#include <GUIConstantsEx.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>
#include <GuiButton.au3>
#include<EditConstants.au3>
#include <IE.au3>

$hGUI = GUICreate("Test", 1500, 900)

$oIE=_IECreateEmbedded()
GUICtrlCreateObj($oIE,4,1,1267,880)
_IENavigate($oIE, 'http://www.autoitscript.com')

$Label1 = GUICtrlCreateLabel("Favorite",1370,10, 80, 27)
$Label2 = GUICtrlCreateLabel("Email",1370,80, 80, 27)

$button = GUICtrlCreateButton("Submit", 1350, 150, 89, 40, $WS_GROUP)

$hCombo = GUICtrlCreateCombo("", 1290, 30, 200, 20)
GUICtrlSetData(-1, "Google|Yahoo|Ebay|MSN")
$hCombo1 = GUICtrlCreateCombo("", 1290, 100, 200, 20)
GUICtrlSetData(-1, "Yahoo|Hotmail|Gmail")

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $hCombo
            Switch GUICtrlRead($hCombo)
                Case "Google"
                    _IENavigate($oIE, 'https://google.com')
                Case "Yahoo"
                    _IENavigate($oIE, 'https://Yahoo.com')
                Case "Ebay"
                    _IENavigate($oIE, 'http://www.ebay.com/')
                Case "MSN"
                    _IENavigate($oIE, 'http://www.msn.com/')
            EndSwitch

        Case $hCombo1
            Switch GUICtrlRead($hCombo1)
                Case "GMail"
                    _IENavigate($oIE, 'https://mail.google.com')
                Case "Yahoo"
                    _IENavigate($oIE, 'https://login.yahoo.com/')
                Case "Hotmail"
                    _IENavigate($oIE, 'https://login.live.com')
            EndSwitch



EndSwitch
WEnd

Share this post


Link to post
Share on other sites



Create one? I must be misunderstanding what you are trying to achieve, because all you need to do is to actually create a button, and replace the $hCombo1 case with the button's case

Share this post


Link to post
Share on other sites

There is a simpler way to do this without a GUI. IE supports a favorites bar. A trick you can do with it is add folders to it as well as links. What I do is I add folders and put links in the folders. Then it is a simple matter of clicking the folder and a drop down of links appears. Select the one one you want and off you go. Easy to manage and it takes up only a small amount of space. The below picture show what it will look like:

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

If you do want a GUI, why not get rid of the dropdowns altogether and use buttons? I did something similar for the "Deal a Day Sites" script in my signature. You could do something like this, giving your GUI more real estate for the actual IE object:

#include-once
#include <GUIConstantsEx.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>
#include <GuiButton.au3>
#include<EditConstants.au3>
#include <IE.au3>

$hGUI = GUICreate("Test", 1500, 900)

$oIE=_IECreateEmbedded()
GUICtrlCreateObj($oIE,4,1,1267,880)
_IENavigate($oIE, 'http://www.autoitscript.com')

$Label1 = GUICtrlCreateLabel("Favorites",1370,10, 80, 27)
$Label2 = GUICtrlCreateLabel("Email",1370,170, 80, 27)


$Googlebtn = GUICtrlCreateButton("Google", 1350, 50, 89, 40)
$Yahoobtn = GUICtrlCreateButton("Yahoo", 1350, 100, 89, 40)
$Gmailbtn = GUICtrlCreateButton("GMail", 1350, 200, 89, 40)
$Hotmailbtn = GUICtrlCreateButton("Hotmail", 1350, 250, 89, 40)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Googlebtn
            _IENavigate($oIE, 'https://google.com')
         Case $Yahoobtn
            _IENavigate($oIE, 'https://Yahoo.com')
        Case $Gmailbtn
            _IENavigate($oIE, 'https://mail.google.com')
        Case $Hotmailbtn
            _IENavigate($oIE, 'https://login.live.com')
    EndSwitch
WEnd
Edited by JLogan3o13

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

Create one? I must be misunderstanding what you are trying to achieve, because all you need to do is to actually create a button, and replace the $hCombo1 case with the button's case

Yes I know how to do that. What if I have 100 or more favorite website. That would be alot of button to put on a Gui. Combobox just seem neater :sweating: . I'm more interested in learning how it can be done. Just got stuck. :  Thank you for advice.

Share this post


Link to post
Share on other sites

There is a simpler way to do this without a GUI. IE supports a favorites bar. A trick you can do with it is add folders to it as well as links. What I do is I add folders and put links in the folders. Then it is a simple matter of clicking the folder and a drop down of links appears. Select the one one you want and off you go. Easy to manage and it takes up only a small amount of space. The below picture show what it will look like:

attachicon.giffavoritebar.jpg

That's a very nice trick. Thank you. :thumbsup:  But like I told Palestinian. It's about learning how it can be done. Might need it for a project in the future. Thank you.

Share this post


Link to post
Share on other sites

 

If you do want a GUI, why not get rid of the dropdowns altogether and use buttons? I did something similar for the "Deal a Day Sites" script in my signature. You could do something like this, giving your GUI more real estate for the actual IE object:

#include-once
#include <GUIConstantsEx.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>
#include <GuiButton.au3>
#include<EditConstants.au3>
#include <IE.au3>

$hGUI = GUICreate("Test", 1500, 900)

$oIE=_IECreateEmbedded()
GUICtrlCreateObj($oIE,4,1,1267,880)
_IENavigate($oIE, 'http://www.autoitscript.com')

$Label1 = GUICtrlCreateLabel("Favorites",1370,10, 80, 27)
$Label2 = GUICtrlCreateLabel("Email",1370,170, 80, 27)


$Googlebtn = GUICtrlCreateButton("Google", 1350, 50, 89, 40)
$Yahoobtn = GUICtrlCreateButton("Yahoo", 1350, 100, 89, 40)
$Gmailbtn = GUICtrlCreateButton("GMail", 1350, 200, 89, 40)
$Hotmailbtn = GUICtrlCreateButton("Hotmail", 1350, 250, 89, 40)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Googlebtn
            _IENavigate($oIE, 'https://google.com')
         Case $Yahoobtn
            _IENavigate($oIE, 'https://Yahoo.com')
        Case $Gmailbtn
            _IENavigate($oIE, 'https://mail.google.com')
        Case $Hotmailbtn
            _IENavigate($oIE, 'https://login.live.com')
    EndSwitch
WEnd

Thank you for the suggestion. I do know how to create one like your example. Here's what I done so far put a large list in the combobox and have it redirect to my favorite website when I click the link from the dropdown menu. What I'm looking for is for it not to redirect to the website unless I click a submit button. Yes button can do that but there's only so much you can put in a Gui. Just trying to learn different ways to create a little program for quick access to emails and websites. In my case this is one feature that I'm stuck on. :

Share this post


Link to post
Share on other sites

Yes I know how to do that. What if I have 100 or more favorite website. That would be alot of button to put on a Gui. Combobox just seem neater :sweating: . I'm more interested in learning how it can be done. Just got stuck. :  Thank you for advice.

 

I didn't say you should get rid of the combobox, I said replace the combobox case with the button case.

$Website = GUICtrlRead($hCombo)
Case $hButton
     If $Website = "Google" Then
          _IENavigate($oIE, 'https://google.com')
     Endif

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