^+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
Russell's answer gets you a large chunk of the way there using RDP as an example. It's a little harder to detect that you're in vsphere/vmware console but can be done with the below. I've commented the changes/additions
#UseHook
#SingleInstance force
; A window's title can contain WinTitle anywhere inside it to be a match
SetTitleMatchMode, 2
setTimer, windowWatch, 500
windowWatch:
; if rdp OR (partial title matching vsphere AND you are in the console captured section)
if WinActive("ahk_class TscShellContainerClass") or (WinActive(" - vSphere Client") and Control("MKSEmbedded1")) {
if (!active) {
active := true
Sleep 50
suspend off
}
} else {
active := false
suspend on
}
return
; return ClassNN of mouse position
Control(ClassNN) {
MouseGetPos,,,,control
return (ClassNN = control)
}
I use this to allow play/pause media keys to work in both rdp/vsphere
Media_Play_Pause::
Sleep 50
Run "C:\Foobar2000\foobar2000.exe" /playpause
return
Best Answer
I found this:
Could that be what your looking for?