Activate taskbar / Force re-focus of current application

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
Scr1pter
Posts: 1272
Joined: 06 Aug 2017, 08:21
Location: Germany

Activate taskbar / Force re-focus of current application

16 Nov 2018, 06:22

Hello,

I would like to be able to activate the taskbar with a keyboard shortcut.
What I've tried was this:

Code: Select all

F1::
WinActivate, ahk_class Shell_TrayWnd
return
It did not work - the currently active program was still active.

The reason I need it:
I use a program named Logitech Gaming Software, which loads profiles automatically once I start an application.
(Excel, Notepad++, Default profile, Game profile etc.)

Everytime I change the application, the color of my mouse gets changed too.
(This indicates the profile change was sucessful.)

Sometimes it doesn't work, though.
(I run for example Excel, but I'm still in my default profile, which means all my macros will not work.)
When this happens, I always click on the taskbar (to force the load of the default profile),
and after that I click again on my target application.
99% it works then.

For this reason I'm searching for a way to remove the focus of the program and to set it again.
I thought clicking on the task bar would be the best way.

Any ideas?

Regards
Please use [code][/code] when posting code!
Keyboard: Logitech G PRO - Mouse: Logitech G502 LS - OS: Windows 10 Pro 64 Bit - AHK version: 1.1.33.09
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Activate taskbar / Force re-focus of current application

16 Nov 2018, 08:02

I don't know if it would work, but you could try a variant of the script here on the active control or window:
Notepad2: set Find Text dialog text - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=5&t=58872

Code: Select all

q::
WinGet, hWnd, ID, A
ControlGet, hCtl, Hwnd,, Edit1, % "ahk_id " hWnd
PostMessage, 0x8,,,, % "ahk_id " hCtl ;WM_KILLFOCUS := 0x8
PostMessage, 0x7,,,, % "ahk_id " hCtl ;WM_SETFOCUS := 0x7
return
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
jackdunning
Posts: 126
Joined: 01 Aug 2016, 18:17
Contact:

Re: Activate taskbar / Force re-focus of current application

21 Nov 2018, 15:05

What if you use the Click command to activate the Taskbar? Then, use SendInput, !{Esc} to return to the last window. I discuss the second part toward the end of this blog, "Activating the Last Window from the System Tray Icon Menu"

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Anput, Google [Bot], Nerafius and 118 guests