Know when a window opens

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
mikeyww
Posts: 26940
Joined: 09 Sep 2014, 18:38

Re: Know when a window opens

Post by mikeyww » 26 Nov 2022, 07:57

I doubt it.

You might be able to use a loop that waits for a window title-- boiler's response to your initial post. There could be other approaches as well, using UI Automation to count the number of tabs, etc.

A browser tab is not (always) a window, but a WinWait might still be able to detect a tab title, depending on the browser and how it manages window titles.

Archimede
Posts: 503
Joined: 25 Nov 2021, 09:49
Location: Switzerland / Italy

Re: Know when a window opens

Post by Archimede » 26 Nov 2022, 10:46

mikeyww:
your example is clear and useful, I am studying it.
What is the meaning of this:
[EVENT_SYSTEM_MOVESIZESTART, EVENT_SYSTEM_MOVESIZEEND]
into the function call
HookEvent("WinEventProc", [EVENT_OBJECT_HIDE,EVENT_OBJECT_SHOW])
What is the meaning of [...]?

Another query:
HookEvent(...) allows 4 arguments; the third argument is the PID ( Process IDenfier ): is it possible to obtain it by an AutoHotKey function?
If no, how is possible to obtain it?

mikeyww: are you an AutoHotKey developer?

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

Re: Know when a window opens

Post by mikeyww » 26 Nov 2022, 11:19

You can read these things in the documentation.

https://www.autohotkey.com/docs/misc/Arrays.htm

https://www.autohotkey.com/docs/commands/WinGet.htm#PID

I do not develop AutoHotkey!

Archimede
Posts: 503
Joined: 25 Nov 2021, 09:49
Location: Switzerland / Italy

Re: Know when a window opens

Post by Archimede » 26 Nov 2022, 11:35

Then the PID is the same like returned by WinGet, var, PID

I am documeting well all ( all functions and all constants ): at the end do you think it can be interesting to send it here?

Please can you explain the meaning of the 7 arguments of the UDF function that must be declared in the first argument of HookEvent( ... )?
What is the handle to an event hook function?
What is the handle to the window gerates event? How I can search it by AutoHotKey function?
What is the thread id?
Thank you very much.

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

Re: Know when a window opens

Post by mikeyww » 26 Nov 2022, 11:53

I did not test the script with PID, but that is my guess. You can always try it.

You may want to ask the script's author some of your questions. I would also do some basic reading.

viewtopic.php?t=42657

https://learn.microsoft.com/en-us/windows/win32/winauto/event-constants

Archimede
Posts: 503
Joined: 25 Nov 2021, 09:49
Location: Switzerland / Italy

Re: Know when a window opens

Post by Archimede » 26 Nov 2022, 12:18

I sent questions to author, but I think it will no answer me because the last communication is on the 2018...
I searched the CHILDID_SELF value: is was very difficult and I found 0: is it true?

I red all informations about all constants, thank you very much.

Thank you very much.
Last edited by Archimede on 26 Nov 2022, 12:20, edited 1 time in total.

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

Re: Know when a window opens

Post by mikeyww » 26 Nov 2022, 12:19

Sorry, but I don't know much beyond the two pages that I have cited above!

GameNtt
Posts: 154
Joined: 19 Aug 2022, 03:36

Re: Know when a window opens

Post by GameNtt » 12 Dec 2022, 12:15

MancioDellaVega wrote:
26 Nov 2022, 07:51
@mikeyww
Is it possible use that technique to intercept the opening of a new tab in the chrome browser
and know what is the title of that tab?
Perhaps this might help? Although this helps only in knowing the title of the tab.
viewtopic.php?f=74&t=107438

MancioDellaVega
Posts: 83
Joined: 16 May 2020, 12:27
Location: Italy

Re: Know when a window opens

Post by MancioDellaVega » 13 Dec 2022, 07:05

GameNtt wrote:
12 Dec 2022, 12:15
MancioDellaVega wrote:
26 Nov 2022, 07:51
@mikeyww
Is it possible use that technique to intercept the opening of a new tab in the chrome browser
and know what is the title of that tab?
Perhaps this might help? Although this helps only in knowing the title of the tab.
viewtopic.php?f=74&t=107438
Yep..very good alternative...thanks.
Courses on AutoHotkey

Archimede
Posts: 503
Joined: 25 Nov 2021, 09:49
Location: Switzerland / Italy

Re: Know when a window opens

Post by Archimede » 11 Apr 2023, 13:21

Hallo.
I am testing the use of the HookEvent(...) function.
I call it only for a single process, specifyng the Process ID.
I need to know a thing: if the process automatically closes by itself, must I use the UnHook(...) function?
If I use the HookEvent(...) function for 10 processes, and only one closes by itself, how I can use UnHook(...) for close the waiting only for that process?
I hope to be clear, it is difficult to understand all...
:-)

Post Reply

Return to “Ask for Help (v1)”