Know when a window opens
Know when a window opens
Hallo.
I need to know when a window opens on the desktop, without testing it continuously... is it possible?
I think is possible to set or detect a windows message, by Dll call or similar... do you know how is possible?
It it possible to detect when an opened window is modified?
Thank you very much.
I need to know when a window opens on the desktop, without testing it continuously... is it possible?
I think is possible to set or detect a windows message, by Dll call or similar... do you know how is possible?
It it possible to detect when an opened window is modified?
Thank you very much.
Re: Know when a window opens
See WinWait.
Not without testing it continuously, and that testing would most likely entail capturing an image of it and then continuously checking to see if that image is still there — if not, it has changed.
Re: Know when a window opens
I'm sorry no explain well...
WinWait... stops the program until a window exists...
I need to detect any opening window while the program works...
Re: Know when a window opens
Check out this library. It might allow you to check for changes without continuously checking as well.
Re: Know when a window opens
Or:
Code: Select all
DllCall("RegisterShellHookWindow", "UInt", A_ScriptHwnd)
OnMessage(DllCall("RegisterWindowMessage", "Str", "SHELLHOOK"), "done")
SetKeyDelay, 100
Loop
Send x
F3::Run, notepad
done(wParam, lParam) {
If (wParam = WINDOWCREATED := 1) {
WinGet, pname, ProcessName, ahk_id %lParam%
If (pname = "notepad.exe") {
MsgBox, 64, Done, Done!
ExitApp
}
}
}
Re: Know when a window opens
Thank you very much.
Very interesting.
For you, about the speed, what is better:
- that libray solution
- another solution based on another independent program with WinWait.. (or similar) and PostMessage... to the working program with OnMessage... ?
The PostMessage solution is quick or not?
Very interesting.
For you, about the speed, what is better:
- that libray solution
- another solution based on another independent program with WinWait.. (or similar) and PostMessage... to the working program with OnMessage... ?
The PostMessage solution is quick or not?
Re: Know when a window opens
You can test your idea by computing the elapsed times via:
https://www.autohotkey.com/docs/Variables.htm#TickCount
https://www.autohotkey.com/docs/Variables.htm#TickCount
Re: Know when a window opens
I don't understand what is the syntax meaning of this:
(wParam = WINDOWCREATED := 1)
(wParam = WINDOWCREATED := 1)
Re: Know when a window opens
WINDOWCREATED is assigned to the value of 1. A comparison then occurs between this value and the value of wParam. The result is true (1) if the values are equal; the result is otherwise zero.
WINDOWCREATED is assigned only as an aid to the reader of the script. It helps the reader to understand that when a window is created, the value of wParam is 1. Otherwise, the value of wParam is not 1.
WINDOWCREATED is assigned only as an aid to the reader of the script. It helps the reader to understand that when a window is created, the value of wParam is 1. Otherwise, the value of wParam is not 1.
Re: Know when a window opens
It seem very interesting.
I am testing it.
Please can you explain the meaning of the 2 dll calls?
I am searching it on the Microsoft site, but that explanations are very poor...
Thank you very much.
I am testing it.
Please can you explain the meaning of the 2 dll calls?
I am searching it on the Microsoft site, but that explanations are very poor...
Thank you very much.
Re: Know when a window opens
This page has more details: https://autohotkey.com/board/topic/32628-tool-shellhook-messages/
My knowledge in this area is crude at best. I believe that the idea is that the Windows shell hook is registered to the script (window) itself. When the hook is triggered by a window action (e.g., window created, activated, redrawn, or destroyed), the script receives a message and then calls the "done" function. The page cited above shows other kinds of windowing codes that can be processed.
My knowledge in this area is crude at best. I believe that the idea is that the Windows shell hook is registered to the script (window) itself. When the hook is triggered by a window action (e.g., window created, activated, redrawn, or destroyed), the script receives a message and then calls the "done" function. The page cited above shows other kinds of windowing codes that can be processed.
Re: Know when a window opens
The WINDOWCREATED message is very useful.
Can you show me all other possible values?
I need to know when a window is moved or modified:is it possible?
Thank you very much.
Can you show me all other possible values?
I need to know when a window is moved or modified:is it possible?
Thank you very much.
Re: Know when a window opens
[Class] WinHook
viewtopic.php?t=59149#p249149
viewtopic.php?t=59149#p249149
Re: Know when a window opens
xtra:
Thanks, it seem very interesting but I am not able to make an object program.
Thanks, it seem very interesting but I am not able to make an object program.
Re: Know when a window opens
Code: Select all
#SingleInstance Force
wTitle = ahk_exe notepad.exe
Process, Priority,, B
Gui, +AlwaysOnTop
Gui, Font, s20
Gui, Color, FFFF9E
Gui, Add, Text, w300 Center vtext
Loop {
WinWait, %wTitle%
SetTimer, Check, 250
show("Open")
SoundBeep, 1500
WinWaitClose
SetTimer, Check, Off
show("Closed")
SoundBeep, 1000
last := current := ""
}
Check:
last := current
WinGetPos, x, y, w, h, %wTitle%
current = %x%,%y%,%w%,%h%
(last) && (current != last) && show("Moved")
Return
show(text) {
GuiControl,, text, %text%
Sleep, 150
Gui, Show, NoActivate, Status
SetTimer, Hide, -900
Return
Hide:
Gui, Hide
Return
}
Re: Know when a window opens
Sorry...
What is "boiler"?
Your idea is interesting, but is very similar to my idea...
I need to detect the resizing or moving of *any* window, and execute a code only in that cases...
I am searching a better idea to no load the computer ( the test every 250 mS ) when no necessary.
Is it possible to use this API call
GetGUIThreadInfo
It seem useful, but very complicated...
I found this info:
"There is no event for capturing the window move, so your option is to query the position frequently."
Is it right?
What is "boiler"?
Your idea is interesting, but is very similar to my idea...
I need to detect the resizing or moving of *any* window, and execute a code only in that cases...
I am searching a better idea to no load the computer ( the test every 250 mS ) when no necessary.
Is it possible to use this API call
GetGUIThreadInfo
It seem useful, but very complicated...
I found this info:
"There is no event for capturing the window move, so your option is to query the position frequently."
Is it right?
Re: Know when a window opens
I don't know a lot about the boiler, but it seems to be a thing that writes a lot of posts in this forum and answers people's questions, including yours! viewtopic.php?p=492204#p492204
Code: Select all
#Include D:\utils\WinEvents.ahk
Process, Priority,, B
Gui, +AlwaysOnTop
Gui, Font, s20
Gui, Color, FFFF9E
Gui, Add, Text, w300 Center vtext
HookEvent("adjusting", [EVENT_SYSTEM_MOVESIZESTART, EVENT_SYSTEM_MOVESIZEEND])
adjusting(hHook, event, hwnd, idObject, idChild, dwEventThread, dwmsEventTime) {
If (event = EVENT_SYSTEM_MOVESIZESTART) {
WinGet, pname, ProcessName, ahk_id %hwnd%
GuiControl,, text, % SubStr(pname, 1, -4)
Gui, Show, x100 y100 NoActivate, Adjusting window
} Else Gui, Hide
}
Re: Know when a window opens
One edit here that can (frequently) capture the maximize event.
Code: Select all
#Include D:\utils\WinEvents.ahk
Process, Priority,, B
Gui, +AlwaysOnTop
Gui, Font, s20
Gui, Color, FFFF9E
Gui, Add, Text, w300 Center vtext
HookEvent("adjusting", [EVENT_SYSTEM_MOVESIZESTART, EVENT_SYSTEM_MOVESIZEEND])
~LButton::
CoordMode, Mouse
MouseGetPos, x, y, hWnd
SendMessage, WM_NCHITTEST := 0x84,, (x & 0xFFFF) | (y & 0xFFFF) << 16,, ahk_id %hWnd%
If ErrorLevel in 8,9
WinGet, pname, ProcessName, ahk_id %hWnd%
Return
#If pname
~LButton Up::
MsgBox, 64, Changed, % SubStr(pname, 1, -4)
pname =
Return
#If
adjusting(hHook, event, hwnd, idObject, idChild, dwEventThread, dwmsEventTime) {
If (event = EVENT_SYSTEM_MOVESIZESTART) {
WinGet, pname, ProcessName, ahk_id %hwnd%
GuiControl,, text, % SubStr(pname, 1, -4)
Gui, Show, x100 y100 NoActivate, Adjusting window
} Else Gui, Hide
}
-
- Posts: 83
- Joined: 16 May 2020, 12:27
- Location: Italy
Re: Know when a window opens
@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?
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?
Courses on AutoHotkey