Is this "DetectHiddenWindows" bug?

Get help for the alpha version of AutoHotkey v2 here. Please state the v2 version you are working with in the title when making a new topic.
jetdone
Posts: 5
Joined: 25 Jan 2021, 10:34

Is this "DetectHiddenWindows" bug?

25 Jan 2021, 10:44

[Moderator's note: Topic moved from Bug Reports.]

I have the code to trigger OBS Studio shortcut key, but with DetectHiddenWindows , PostMessage is not working, is it DetectHiddenWindows bug?
My Code:

Code: Select all

DetectHiddenWindows True
id := WinGetID("ahk_exe obs64.exe")

Result := PostMessage(0x102, 0x79,,,"ahk_id" . id)
Sleep 250
Result := PostMessage(0x102, 0x78,,,"ahk_id" . id)

DetectHiddenWindows False
The above code cannot trigger the OBS Studio shortcut key.

And

Code: Select all

;DetectHiddenWindows True  <-- Remark this code
id := WinGetID("ahk_exe " . obs_exe)

Result := PostMessage(0x102, 0x79,,,"ahk_id" . id)
Sleep 250
Result := PostMessage(0x102, 0x78,,,"ahk_id" . id)

;DetectHiddenWindows False <-- Remark this code
The above code can trigger the shortcut key but only in window status is not in hidden

[Mod edit: [quote] tags replaced with [code][/code] tags.]
just me
Posts: 7747
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Is this "DetectHiddenWindows" bug?

25 Jan 2021, 11:39

Most likely there's another hidden window of obs64.exe found prior to the main window.
User avatar
Xtra
Posts: 2062
Joined: 02 Oct 2015, 12:15

Re: Is this "DetectHiddenWindows" bug?

25 Jan 2021, 13:20

WinGetID() is not an AHK built in function. Try WinExist() ?
User avatar
boiler
Posts: 6876
Joined: 21 Dec 2014, 02:44

Re: Is this "DetectHiddenWindows" bug?

26 Jan 2021, 08:26

Xtra wrote: WinGetID() is not an AHK built in function. Try WinExist() ?
It’s v2 code. Note PostMessage is used as a function as well.
jetdone
Posts: 5
Joined: 25 Jan 2021, 10:34

Re: Is this "DetectHiddenWindows" bug?

26 Jan 2021, 10:02

How to get "Main Window" rather than "Child Window"?
just me
Posts: 7747
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Is this "DetectHiddenWindows" bug?

27 Jan 2021, 07:34

I might have misunderstood your post, do you want to post WM_CHAR messages to a hidden window?
User avatar
lmstearn
Posts: 392
Joined: 11 Aug 2016, 02:32
GitHub: lmstearn
Contact:

Re: Is this "DetectHiddenWindows" bug?

27 Jan 2021, 09:10

You mean:

Code: Select all

id := WinGetID("ahk_exe " . obs64_exe)
?
Sometimes Postmessage times out with hidden windows. SendMessage might be better.
:arrow: itros "ylbbub eht tuO kaerB" a ni kcuts m'I pleH
jetdone
Posts: 5
Joined: 25 Jan 2021, 10:34

Re: Is this "DetectHiddenWindows" bug?

27 Jan 2021, 10:23

lmstearn wrote:
27 Jan 2021, 09:10
You mean:

Code: Select all

id := WinGetID("ahk_exe " . obs64_exe)
?
Sometimes Postmessage times out with hidden windows. SendMessage might be better.
Status: When Target Window is hidden
if I don't use "DetectHiddenWindows true", then id is blank.
if I used "DetectHiddenWindows true",
- then if I used "Result := PostMessage(0x102, 0x79,,"Qt5152QWindowIcon1","ahk_id" . id)" will return "Target Control not found".
- then if I used "Result := PostMessage(0x102, 0x79,,,"ahk_id" . id", then It does not trigger to the obs Studio hotkey.

Status: When Target Window is not hidden
if I don't use "DetectHiddenWindows true",
- then if I used "Result := PostMessage(0x102, 0x79,,"Qt5152QWindowIcon1","ahk_id" . id)" then it will work.
- then if I used "Result := PostMessage(0x102, 0x79,,,"ahk_id" . id", then it will work.

So I think there has a bug on DetectHiddenWindows.
jetdone
Posts: 5
Joined: 25 Jan 2021, 10:34

Re: Is this "DetectHiddenWindows" bug?

27 Jan 2021, 10:38

just me wrote:
27 Jan 2021, 07:34
I might have misunderstood your post, do you want to post WM_CHAR messages to a hidden window?
Environment:
- obs studio (Freeware)
- obs studio setup hotkey "Ctrl+F1" to start record screen
- obs studio setup hotkey "Ctrl+F2" to stop record screen

My requirement as below:
1. make obs studio as a "background program", the AutoHotKey will submit "Ctrl+F1" and "Ctrl+F2" to stop recording and restart the recording in every hour.
2. the recording trigger key of the function of AutoHotkey script will not affect the normal operation of computer use.
3. The AutoHotkey script can keep to submit the hotkey either windows is hidden or not.
4. The AutoHotkey will detect obs studio is not running, and then will auto start the program.
User avatar
lmstearn
Posts: 392
Joined: 11 Aug 2016, 02:32
GitHub: lmstearn
Contact:

Re: Is this "DetectHiddenWindows" bug?

27 Jan 2021, 21:12

A hidden window isn't visible at all. DetectHiddenWindows doesn't make it so, it just detects whether the window exists, so in most cases the window has to be made visible for anything to work. You could try things like increasing the power plan, thread/app priority or CPU etc., however.
:arrow: itros "ylbbub eht tuO kaerB" a ni kcuts m'I pleH
jetdone
Posts: 5
Joined: 25 Jan 2021, 10:34

Re: Is this "DetectHiddenWindows" bug?

28 Jan 2021, 08:21

lmstearn wrote:
27 Jan 2021, 21:12
A hidden window isn't visible at all. DetectHiddenWindows doesn't make it so, it just detects whether the window exists, so in most cases the window has to be made visible for anything to work. You could try things like increasing the power plan, thread/app priority or CPU etc., however.
But I used WinSpy (A window detect tool) to post message, obs is also can react that submission. I think the window process is existed, although it is minimized to tray icon.

Return to “AutoHotkey v2 Help”

Who is online

Users browsing this forum: No registered users and 2 guests