^+i::
if WinExist("ahk_class Chrome_WindowImpl_0")
{
WinActivate
ControlFocus, Chrome_AutocompleteEditView1
}
else
Run "C:\Users\vleeshue\AppData\Local\Google\Chrome\Application\chrome.exe"
return
Should do the trick
("Chrome_AutocompleteEditView1" is the name of the omnibar control, so you could add Send ^a
to select all)
Note: To get the ahk_class
for your version of Chrome, e.g., ahk_class Chrome_WindowImp1-0
, use the AU3_Spy.exe
inside the autohotkey directory. This will allow you to find the correct ahk class for your chrome browser if the example one doesn't work.
Update: I can't reproduce, maybe it will be better with another control...
To have a list of a window controls I use this code:
#Persistent
SetTimer, WatchCursor, 100
return
WatchCursor:
MouseGetPos, , , id, control
WinGetTitle, title, ahk_id %id%
WinGetClass, class, ahk_id %id%
WinGet, ControlList, ControlList, A
ToolTip, Under Cursor:`nahk_id: %id%`nahk_class: %class%`nTitle:%title%`nControl: %control%`n`nWindow Control List:`n%ControlList%
return
So the controls of my google chrome 4.0.249.78 beta (36714) are:
- ViewsTextfieldEdit1
- Chrome_RenderWidgetHostWND1
- Chrome_AutocompleteEditView1
- Chrome_WindowImpl_01
- Chrome_WindowImpl_02
In AutoHotkey you can easily remap Ctrl+W per application. For instance in EditPlus Ctrl+F4 closes an MDI window.
#IfWinActive EditPlus -
^w::Send ^{F4}
If say a menu's Close
doesn't have a hotkey, you can use AltFC to open the File
menu and use the accelerator.
If that fails you can use ControlClick (e.g. on a toolbar icon).
If that fails you can use PostMessage/SendMessage.
A more advanced script could certainly close the application after its children, if it doesn't already do so.
Best Answer