Hotkey to select a specific window that is already on top

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Avastgard
Posts: 133
Joined: 30 Sep 2016, 21:54

Hotkey to select a specific window that is already on top

27 Jan 2018, 16:51

I use the Pomello App and it already stays on top of other windows even if I click them. However, to use its built-in hotkeys, I have to click the window to select it so the hotkeys will take effect.

What I want is a way to make one hotkey to select this specific window (Pomello) and that's it. Like Alt + A to select the Pomello window so I can use its hotkeys without having to hover the mouse to the window and click it.

It would be nice to make it a toggle so that pressing it again would reselect the previously selected window.

I'm still an ahk noob, so any help with that would be much appreciated.
User avatar
boiler
Posts: 17163
Joined: 21 Dec 2014, 02:44

Re: Hotkey to select a specific window that is already on top

27 Jan 2018, 20:59

The first couple lines of any of your hotkey definitions for that window should be:

Code: Select all

WinActivate, Pomello
WinWaitActive, Pomello
...assuming Pomello is the title of the Pomello app's window.

Rather than pressing it again to return to the other window, wouldn't it be better to automatically activate the previous window after it does what it needs to with the Pomello window active?
Avastgard
Posts: 133
Joined: 30 Sep 2016, 21:54

Re: Hotkey to select a specific window that is already on top

28 Jan 2018, 00:24

boiler wrote:Rather than pressing it again to return to the other window, wouldn't it be better to automatically activate the previous window after it does what it needs to with the Pomello window active?
Thanks for the reply!

How would the script know when I am done with Pomello to automatically select the previous window?
User avatar
boiler
Posts: 17163
Joined: 21 Dec 2014, 02:44

Re: Hotkey to select a specific window that is already on top

28 Jan 2018, 02:01

This isn't meant to sound flippant, but you're done with it when you're done with it. You want to send certain keys to it, right? After you've sent them, then switch back to the other window. I guess I was thinking your hotkey to switch to that window would also send a certain key to it. But if your hotkey is only to switch windows, then your plan to switch it back by pressing the hotkey again after you're done manually pressing the keys meant for that window makes sense.
Avastgard
Posts: 133
Joined: 30 Sep 2016, 21:54

Re: Hotkey to select a specific window that is already on top

28 Jan 2018, 07:32

No, the hotkey would only serve to select the window, as Pomello has its own hotkey comands. Right now I don't plan on using ahk to also send these hotkey commands, I'd rather just use Pomello's commands.

I set the hotkey to Alt+A and just added the first line you provided and it works just as intended. Since Alt+Tab is just a button away, I think I'll just use that to switch back to the previous window. Just for curiosity's sake, would there be a way to make the command a toggle, so I could press Alt+A again to return to the previous window?
User avatar
boiler
Posts: 17163
Joined: 21 Dec 2014, 02:44

Re: Hotkey to select a specific window that is already on top

28 Jan 2018, 08:28

This would do it:

Code: Select all

!a::
	IfWinNotActive, Pomello
	{
		WinGet, ID, ID, A
		WinActivate, Pomello
	}
	else
		WinActivate, ahk_id%ID%
return

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Descolada, smith2 and 83 guests