Here is a small test program that exhibits the problem. While the script is running, the WinOpened() function will be invoked anytime a window is created. If the created window is a file's "Properties" window (left click on a file in the File Explorer program and select "Properties"), the WinOpened() function will change the window's title to "<%Title%>" to indicate the script detected the window and then issue the WinMove command to move the window to screen location (100,100).
Only checked with AHK version 1.1.29.01
Code: Select all
#Persistent
;Register shell hook
DetectHiddenWindows, On ;Access this processes' hidden window
Process, Exist ;Get its process ID
hwnd := WinExist( "ahk_pid " . ErrorLevel ) ;Get its hwnd
;Get message when a window created
DllCall("RegisterShellHookWindow", "UInt", hwnd )
msgNum := DllCall( "RegisterWindowMessage", Str,"SHELLHOOK" )
;Call function when message received
OnMessage( msgNum, "winOpened" ) ;Register function to invoke
;Perform actions on just created window
winOpened( wParam, lParam )
{
If( wParam = 1 ) ; 1 = HSHELL_WINDOWCREATED
{
WinGet, hwnd, ID, A ;hwnd of just created window
;Act only on a File Explorer's file properties window
WinGetTitle, winTitle, ahk_id %hwnd%
if( InStr( winTitle, "Properties" ) )
{
;Change the title of the window (always works)
WinSetTitle, ahk_id %hwnd%, , <%winTitle%>
;Move the window (Only works if a compiled script)
WinMove, ahk_id %hwnd%, , 100, 100
}
}
}