Autohotkey, How to create drop-down list to select items
I have few short hotstrings/hotkeys. If I type "one", there's a corresponding actions, if I typed two, there another corresponding actions.
My question is, how can I make a single hotkey for all, that when I press a key, a drop-down list/msgbox will appear, then I can choose an item, and upon clicking it, it will perform the corresponding macro based on the list below?
::one::
{
do this
do that
}
return
::two::
{
do this
do that
}
return
::three::
{
do this
do that
}
return
::four::
{
do this
do that
}
return
::five::
{
do this
do that
}
return
Also, is Autohotkey a good one for learning scripts? Or AutoIT? Or I should learn major scripting language (like the ones I usually heard - Perl, PhP, etc.)
We're those programming language able to do simple steps, like recording just keyboard pressing and mouse movements?
. Thanks,
Faye
Solution 1:
AHK-example:
; create the gui:
Gui, +AlwaysOnTop
; DropDownList:
; Gui, Add, DDL, gAction vChoice Choose1 w200, one|two|three|four
; ListBox:
Gui, Add, ListBox, gAction vChoice w200 h60, one|two|three|four
return
; Press F1 to show the gui:
F1::
CoordMode, Mouse, Screen
MouseMove, 40, 50, 0
Gui, Show, x0 y0, Actions
return
Action:
Gui, Submit ; or
; Gui, Submit, NoHide ; if you don't want to hide the gui-window after an action
If (Choice = "one")
MsgBox, 1st action
If (Choice = "two")
MsgBox, 2nd action
If (Choice = "three")
MsgBox, 3rd action
If (Choice = "four")
MsgBox, 4th action
return
GuiClose:
ExitApp
EDIT
If you want to choose an action by using the Up/Down Arrows and Enter, you need to add a default Button to the gui
or this:
Gui, +AlwaysOnTop
Gui, Add, ListBox, gAction vChoice w200 h60, one|two|three|four
return
; Press F1 to show the gui:
F1:: Gui, Show, x0 y0, Actions
Action:
If ((A_GuiEvent = "DoubleClick") || (Trigger_Action))
{
Gui, Submit
If (Choice = "one")
MsgBox, 1st action
If (Choice = "two")
MsgBox, 2nd action
If (Choice = "three")
MsgBox, 3rd action
If (Choice = "four")
MsgBox, 4th action
}
return
#If WinActive("Actions ahk_class AutoHotkeyGUI")
Enter::
Trigger_Action := true
GoSub, Action
Trigger_Action := false
return
#If
GuiClose:
ExitApp