Sign in to follow this  
Followers 0
usera

help for create a Bar look select menu

15 posts in this topic

Greeting,

I am looking for the code to create a BAR look select menu.

for example:

1. APP1 (word)

2. App2 (Excel)

3. APP3 ...

9. Exit

there is a cursor bar can move up and down to pickup the application, once click enter then launch the applications (on 2 then launch Excel)

Thank you very very much!

Online waiting...

Share this post


Link to post
Share on other sites



I'm not sure if this is what you mean because I've never heard of a "bar look select menu"... But I'm guessing that you mean a combo box. Look at this from the helpfile:

#include <GUIConstants.au3>

GUICreate("My GUI combo") ; will create a dialog box that when displayed is centered

GUICtrlCreateCombo ("item1", 10,10); create first item
GUICtrlSetData(-1,"item2|item3","item3"); add other item snd set a new default

GUISetState ()

; Run the GUI until the dialog is closed
While 1
    $msg = GUIGetMsg()
    
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend

My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]

Share this post


Link to post
Share on other sites

I'm not sure if this is what you mean because I've never heard of a "bar look select menu"... But I'm guessing that you mean a combo box. Look at this from the helpfile:

#include <GUIConstants.au3>

GUICreate("My GUI combo"); will create a dialog box that when displayed is centered

GUICtrlCreateCombo ("item1", 10,10); create first item
GUICtrlSetData(-1,"item2|item3","item3"); add other item snd set a new default

GUISetState ()

; Run the GUI until the dialog is closed
While 1
    $msg = GUIGetMsg()
    
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend

Thanks, it is not exactly what I am looking for but good enough, but the question is how to pickup item1 then start run word.exe, pickup item2 to start run excel....

Thanks you are GURU

Share this post


Link to post
Share on other sites

Thanks, it is not exactly what I am looking for but good enough, but the question is how to pickup item1 then start run word.exe, pickup item2 to start run excel....

Thanks you are GURU

The solution I would suggest would be to have a button right next to it that says "Run" or similar...

I'm not really sure how much you know about AutoIt but if you haven't heard of GuiRegisterMsg() then don't bother trying to use it, it's really confusing at first. However, with GuiRegisterMsg() you could be notified when the selection of the combobox is changed and have it do a function...

I think the first solution is much easier.


My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]

Share this post


Link to post
Share on other sites

To the second half of your question... You will want to use GuiCtrlRead() to get information from the combobox. This will get you the text that is currently being seen. Then I would use a switch command to run the appropriate command. Something like this:

Switch GuiCtrlRead($comboBox)
Case 'Excel'
Run(@ProgramfilesDir & '\Microsoft Office\Exel.exe')
Case '....

There are other ways of doing this but this is probably the easiest.


My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]

Share this post


Link to post
Share on other sites

To the second half of your question... You will want to use GuiCtrlRead() to get information from the combobox. This will get you the text that is currently being seen. Then I would use a switch command to run the appropriate command. Something like this:

Switch GuiCtrlRead($comboBox)
Case 'Excel'
Run(@ProgramfilesDir & '\Microsoft Office\Exel.exe')
Case '....

There are other ways of doing this but this is probably the easiest.

Thanks for your help.

BUT BUT, I am Newbie in Autoit, could you please give show me how to do that? I meaning just put the code together?

thanks :)

Share this post


Link to post
Share on other sites

#include <GUIConstants.au3>

GUICreate("My GUI combo", 300, 40) ; will create a dialog box that when displayed is centered

$combo = GUICtrlCreateCombo ("", 10,10, 200, 20, $CBS_DROPDOWNLIST) 
GUICtrlSetData(-1,"Excel|Notepad","Excel"); add other item snd set a new default

$button = GuiCtrlCreatebutton('Run', 215, 10, 80, 22)

GUISetState ()

; Run the GUI until the dialog is closed
While 1
    Switch GuiGetMsg()
        Case $button
            Switch GuiCtrlRead($combo)
                Case "Excel"
                    Run(@ProgramFilesDir & '\Microsoft Office\Office11\Excel.exe')
                Case 'Notepad'
                    Run('notepad.exe')
            EndSwitch 
        
        Case $GUI_EVENT_CLOSE 
            Exit

    EndSwitch
            
Wend
Most people won't write code for you generally, but I find it helpful, and this is easy for me. Examine it and make sure you understand anything, ask if you don't...


My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]

Share this post


Link to post
Share on other sites

#include <GUIConstants.au3>

GUICreate("My GUI combo", 300, 40); will create a dialog box that when displayed is centered

$combo = GUICtrlCreateCombo ("", 10,10, 200, 20, $CBS_DROPDOWNLIST) 
GUICtrlSetData(-1,"Excel|Notepad","Excel"); add other item snd set a new default

$button = GuiCtrlCreatebutton('Run', 215, 10, 80, 22)

GUISetState ()

; Run the GUI until the dialog is closed
While 1
    Switch GuiGetMsg()
        Case $button
            Switch GuiCtrlRead($combo)
                Case "Excel"
                    Run(@ProgramFilesDir & '\Microsoft Office\Office11\Excel.exe')
                Case 'Notepad'
                    Run('notepad.exe')
            EndSwitch 
        
        Case $GUI_EVENT_CLOSE 
            Exit

    EndSwitch
            
Wend
Most people won't write code for you generally, but I find it helpful, and this is easy for me. Examine it and make sure you understand anything, ask if you don't...

Perfect Code, thank you very very very much! GURU

Share this post


Link to post
Share on other sites

Piano_Man is not a guru, he is just a nice member. This is easy code and doesn't really merit a term like guru.

No offense Piano_Man, of course.

Share this post


Link to post
Share on other sites

Piano_Man is not a guru, he is just a nice member. This is easy code and doesn't really merit a term like guru.

No offense Piano_Man, of course.

Bother.. I'm not a guru :) Maybe tomorrow... you never know... :)

My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]

Share this post


Link to post
Share on other sites

Perfect Code, thank you very very very much! GURU

Sorry Piano_Man,

one more question, I did use that code, the issue is if I pickup to run excel, excel opened, but the black (DOS) windows open as well, how can I prevent that black window open, I just want to see Excel open. after excel quit, the program close as well, how let me back to the selection allow me to select and launch notepad. like a loop. until I want to quit

Thanks

Share this post


Link to post
Share on other sites

You get a black DOS window? Weird, what version of Windows?

Try this:

#include <GUIConstants.au3>

GUICreate("My GUI combo", 300, 40); will create a dialog box that when displayed is centered

$combo = GUICtrlCreateCombo ("", 10,10, 200, 20, $CBS_DROPDOWNLIST)
GUICtrlSetData(-1,"Excel|Notepad","Excel"); add other item snd set a new default

$button = GuiCtrlCreatebutton('Run', 215, 10, 80, 22)

GUISetState ()

; Run the GUI until the dialog is closed
While 1
    Switch GuiGetMsg()
        Case $button
            Switch GuiCtrlRead($combo)
                Case "Excel"
                    Run(@ProgramFilesDir & '\Microsoft Office\Office11\Excel.exe')
                    WinSetState("C:\Windows\System32\cmd.exe", @SW_HIDE)
                Case 'Notepad'
                    Run('notepad.exe')
            EndSwitch
        
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
            
Wend

I forgot the name of the CMD title when it opens, just change it if it is wrong.

Share this post


Link to post
Share on other sites

You get a black DOS window? Weird, what version of Windows?

Try this:

#include <GUIConstants.au3>

GUICreate("My GUI combo", 300, 40); will create a dialog box that when displayed is centered

$combo = GUICtrlCreateCombo ("", 10,10, 200, 20, $CBS_DROPDOWNLIST)
GUICtrlSetData(-1,"Excel|Notepad","Excel"); add other item snd set a new default

$button = GuiCtrlCreatebutton('Run', 215, 10, 80, 22)

GUISetState ()

; Run the GUI until the dialog is closed
While 1
    Switch GuiGetMsg()
        Case $button
            Switch GuiCtrlRead($combo)
                Case "Excel"
                    Run(@ProgramFilesDir & '\Microsoft Office\Office11\Excel.exe')
                    WinSetState("C:\Windows\System32\cmd.exe", @SW_HIDE)
                Case 'Notepad'
                    Run('notepad.exe')
            EndSwitch
        
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
            
Wend

I forgot the name of the CMD title when it opens, just change it if it is wrong.

did add line WinSetState("C:\Windows\System32\cmd.exe", @SW_HIDE)

for some reason the black window still there.

test machine is windows 2003 sp1

Share this post


Link to post
Share on other sites

did add line WinSetState("C:\Windows\System32\cmd.exe", @SW_HIDE)

for some reason the black window still there.

test machine is windows 2003 sp1

Sorry,

for the black windows:

the run command will launch another Batch file.

like run ("c:\temp\test.bat")

Share this post


Link to post
Share on other sites

This worked for me - no cmd.exe window:

ShellExecute('Excel.exe')

And you wont' need the WinSetState function.

Windows 2K+ knows the path of Excel and that path you were using, didn't work on my particular machine.


Das Häschen benutzt Radar

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