Can't unhide a hidden window

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Lem2001
Posts: 127
Joined: 27 Jun 2017, 17:59

Can't unhide a hidden window

Post by Lem2001 » 09 Mar 2024, 06:58

I'm trying to run an application hidden, send it some keystrokes while hidden, and then subsequently unhide it.

In the Help file it says to use a variable to store the newly launched program's unique Process ID. When I tried doing this the program did launch hidden (I can see it in Task Manager) but I can't get it to unhide no matter what I try.

I even tried taking the keystrokes out so that all it would do is launch hidden, sleep for 2 sec, and then unhide. But that didn't work either.

Code: Select all

Run, "C:\Windows\write.exe", , Hide, pid
WinWait, ahk_pid %pid%
Sleep 2000
WinShow, ahk_pid %pid%

The keystrokes that I want to send to the hidden window is: Send, !hPSA which has been tested on a normal window and works fine.

So I was trying to use the following with the script above:

Code: Select all

ControlSend, NetUIHWND1, {Alt down}h{Alt up}PSA, ahk_pid %pid%
I don't know whether it worked or not though, because I could never unhide the window to see the result (I just had to kill the process in Task Manager).

User avatar
mikeyww
Posts: 27366
Joined: 09 Sep 2014, 18:38

Re: Can't unhide a hidden window

Post by mikeyww » 09 Mar 2024, 09:34

I recommend using the HWND if you are targeting a window.

Code: Select all

#Requires AutoHotkey v1.1.33.11
app      := "notepad.exe"
winTitle := "ahk_class Notepad"
ctl      := "RichEditD2DPT1" ; Win 11
DetectHiddenWindows On
Run % app,, Hide
WinWait % winTitle
hWnd := WinExist()

#If WinExist("ahk_id" hWnd)
F4::WinShow
F3::
ControlSend % ctl, 123
SoundBeep 1500
Return
#If
The documentation is a good source of information.

ControlSend:
By default, hidden windows are not detected and hidden text elements are detected, unless changed with DetectHiddenWindows and DetectHiddenText.

Post Reply

Return to “Ask for Help (v1)”