Finding a HWND in Win8.1 without UIAccess

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
WAZAAAAA
Posts: 88
Joined: 13 Jan 2015, 19:48

Finding a HWND in Win8.1 without UIAccess

01 Nov 2017, 19:01

I've been trying to detect the HWND/window handle of a specific window without the need to use UI Access rights. Said window appears to the right in Windows 8.1 when you press either Win+Q, Win+W or Win+S and looks like this:
Image
(ahk_class:SearchPane Title:Search Pane ahk_exe:explorer.exe)

The problem is that the commands needed to find said HWND only seem to work with UIAccess enabled. These are the methods I have tested: WinGet ControlGet WinExist()... they all resulted in empty output variables.

Code: Select all

DetectHiddenWindows, On

$*Ins::
WinGet, method1, ID, ahk_class SearchPane
ControlGet, method2, Hwnd,,, ahk_class SearchPane
method3 := WinExist("ahk_class SearchPane")
MsgBox,%method1%`n`n%method2%`n`n%method3%
method1=
method2=
method3=
return
Strangely enough, MouseGetPos was the only method that let me find the correct HWND without UIAccess (see example code in the documentation https://autohotkey.com/docs/commands/Mo ... tm#Example), but I don't want to use the mouse, there needs to be no user interaction.

Once the HWND is known, I can easily hide the window by setting its WS_VISIBLE style without UIA like this:

Code: Select all

WinSet, Style, -0x10000000, ahk_id %method1%
Note that I'm running my scripts with admin and SeDebugPrivilege rights, but only UIA seems to work...

Is this simply impossible to achieve or is there some kind of workaround to get rid of the search bar? Alternatively, is there a reliable way to enable UIAccess automatically for compiled and uncompiled scripts?
YOU'RE NOT ALEXANDER
BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: Finding a HWND in Win8.1 without UIAccess

02 Nov 2017, 03:27

I'm getting the idea that it's a timing issue. The sample (mouse) code you're using, uses a (100ms) SetTimer routine what is probably the reason that it delivers a result, while your hotkey script is bearing the chance that right [before|after] the window pops up it's losing the focus. Well, I might be wrong :)
User avatar
WAZAAAAA
Posts: 88
Joined: 13 Jan 2015, 19:48

Re: Finding a HWND in Win8.1 without UIAccess

02 Nov 2017, 13:07

nah man, starting the same script I included in the thread with "Right Click -> Run with UI Access" will output the right HWND
YOU'RE NOT ALEXANDER

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 336 guests