Hey guys!
I have on my computer several text editors and Internet browsers. I want to make a single or a couple of hotkeys to bring up some sort of popup menu or sth like windows context menu to choose one specific program among available ones. For instance, I program alt + ctrl + B to show a menu of installed internet browsers (currently I have Opera, Vivaldi, Edge, Brave and Firefox) and each time select the desired app and popup menu closes afterwards. Is there a way to this task?
A popup menu for Hotkey? Topic is solved
Re: A popup menu for Hotkey?
For this example
have your icons in a subfolder named 'Icons'
with the same filename as the editor with extension '.png'
dimensions 16x16
If spaces are used in the Editor's name, use quotes
have your icons in a subfolder named 'Icons'
with the same filename as the editor with extension '.png'
dimensions 16x16
If spaces are used in the Editor's name, use quotes
Code: Select all
#Requires AutoHotkey v1.1.36+
; the Hotkey
Hotkey, F5, Show, On
; create the menu
Menu:
Editors := { Notepad: "C:\Windows\System32\notepad.exe"
, TextPad: A_ProgramFiles . "\TextPad 8\TextPad.exe"
, "Other 1": A_ProgramFiles . "\Other 1\Other 1.exe"
, "Other 2": A_ProgramFiles . "\Other 2\Other 2.exe" }
For Editor, Path in Editors
{ Menu, List, Add , %Editor% , Run
Menu, List, Icon , %Editor% , % A_ScriptDir . "\Icons\" . Editor . ".png"
}
Return
; show the menu
Show:
Menu, List, Show
Return
; open the selected editor
Run:
Run, % Editors[A_ThisMenuItem]
Return
Re: A popup menu for Hotkey?
Hey there! Sorry for late response, sadly I was out of town. Can I change the background color of individual items in menu? like first one red, next blue and so on..gmoises wrote: ↑09 Feb 2023, 12:06For this example
have your icons in a subfolder named 'Icons'
with the same filename as the editor with extension '.png'
dimensions 16x16
If spaces are used in the Editor's name, use quotes
Code: Select all
#Requires AutoHotkey v1.1.36+ ; the Hotkey Hotkey, F5, Show, On ; create the menu Menu: Editors := { Notepad: "C:\Windows\System32\notepad.exe" , TextPad: A_ProgramFiles . "\TextPad 8\TextPad.exe" , "Other 1": A_ProgramFiles . "\Other 1\Other 1.exe" , "Other 2": A_ProgramFiles . "\Other 2\Other 2.exe" } For Editor, Path in Editors { Menu, List, Add , %Editor% , Run Menu, List, Icon , %Editor% , % A_ScriptDir . "\Icons\" . Editor . ".png" } Return ; show the menu Show: Menu, List, Show Return ; open the selected editor Run: Run, % Editors[A_ThisMenuItem] Return
Re: A popup menu for Hotkey? Topic is solved
Here is a very simple way to get a colorful context menu.
. .
It is also possible to create more complex designs.
.
. .
Code: Select all
#SingleInstance, Force
MenuItems := []
MenuItems[ 1 ] := { Text: "Calculator" , RunPath: "Calc.exe" , TextColor: "White" , BackgroundColor: "Red" }
MenuItems[ 2 ] := { Text: "Item 2" , RunPath: "Calc.exe" , TextColor: "White" , BackgroundColor: "Green" }
MenuItems[ 3 ] := { Text: "Item 3" , RunPath: "Calc.exe" , TextColor: "000000" , BackgroundColor: "FFFFFF" }
MenuItems[ 4 ] := { Text: "Item 4" , RunPath: "Calc.exe" , TextColor: "ffff00" , BackgroundColor: "ff00ff" }
MenuItems[ 5 ] := { Text: "Item 5" , RunPath: "Calc.exe" , TextColor: "ffffff" , BackgroundColor: "0000ff" }
ControlHandles := []
Gui, 1:New, +AlwaysOnTop -Caption +Border +ToolWindow
Gui, 1:Color, 22262a
Gui, 1:Font, s16 Bold, Segoe UI
Gui, 1:Margin, 5, 5
Loop, % MenuItems.Length() {
cc := MenuItems[ A_Index ]
Gui, 1:Add, Progress, % "w300 h30 +Disabled +Background" cc.BackgroundColor
Gui, 1:Add, Text, % "c" cc.TextColor " xp yp w300 h30 +BackgroundTrans +Center +0x200 hwndhwnd gRunIt" , % cc.Text
cc.Hwnd := hwnd
ControlHandles[ hwnd ] := cc
}
;~ gui, 1:Show
return
*ESC::ExitApp
F1::
CoordMode, Mouse, Screen
MouseGetPos, x , y
Gui, 1:Show, % "x" x - 100 " y" y - 20
return
RunIt:
MouseGetPos,,,, ctrl, 2
try{
Run, % ControlHandles[ ctrl ].RunPath
}catch{
MsgBox, ERROR
}
Gui, 1:Hide
return
.