Win d or show desktop script not focusing

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
joseph470
Posts: 2
Joined: 18 Jun 2021, 18:05

Win d or show desktop script not focusing

18 Jun 2021, 18:43

I'm having trouble getting a script working to show the desktop (same thing that Wind d does).
the code I'm trying to use is:

Code: Select all

^d::send #d
The code works to minimize and maximize all open windows, the problem is that about 50-80% of the time it retains focus inside the window that is now minimized.
In other words:
^d minimizes all the windows but when I type to select a folder on the desktop it continues typing in the program that was previously open.
I can cycle through ^d a couple times and it will eventually focus on the desktop, but most of the time it doesn't.

I've tried a couple things and found that the problem is in having (ctrl, alt, shift) as modifiers to the hotkey.

So scripts like these work to focus on the desktop like #d normally does.

Code: Select all

F1::send #d
 
g & h::send #d

#h::send #d
But these ones end up not focusing on desktop most of the time.

Code: Select all

^d::send #d
^d::send #m
^d::WinMinimizeAll
^d::send {Ctrl up}#d
!d::send #d
+d::send #d
I"m curious if anyone knows why this is happening, and if there's any way to get this to work while using ctrl.
User avatar
mikeyww
Posts: 26851
Joined: 09 Sep 2014, 18:38

Re: Win d or show desktop script not focusing

18 Jun 2021, 19:17

It might relate to how Win is managed. The following seemed to work.

Code: Select all

^d::
KeyWait, d
KeyWait, Ctrl
Send #d
SoundBeep, 1000
Return
joseph470
Posts: 2
Joined: 18 Jun 2021, 18:05

Re: Win d or show desktop script not focusing

18 Jun 2021, 19:55

That fixed it. Thanks for the help.
diego10_arg
Posts: 1
Joined: 15 Nov 2021, 14:29

Re: Win d or show desktop script not focusing

15 Nov 2021, 14:52

This is pretty much what I was looking for.

Is it possible to activate this script by clicking the (empty) taskbar instead of using a hotkey?

Thanks in advance!
User avatar
mikeyww
Posts: 26851
Joined: 09 Sep 2014, 18:38

Re: Win d or show desktop script not focusing

15 Nov 2021, 16:33

Code: Select all

#Include d:\utils\acc\Acc.ahk ; https://gist.github.com/tmplinshi/0fcb8655c1402a3662ac048d0d974915
~LButton::                    ; Click empty taskbar area -> Show the desktop
                              ; https://www.autohotkey.com/boards/viewtopic.php?p=429875#p429875
oAcc := Acc_ObjectFromPoint(vChildId)
If oAcc.accName(vChildId) = "Running applications" && oAcc.accRole(vChildId) = ROLE_SYSTEM_TOOLBAR := 22
 WinMinimizeAll
Return

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Draken, Google [Bot], haomingchen1998, LepG and 266 guests