Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate

Detect when a new window is opened.


  • Please log in to reply
2 replies to this topic
DetectWins?
  • Guests
  • Last active:
  • Joined: --
Title sums it up.. I need to detect whenever a new window is opened, and perhaps have a little message box that pops up whenever a new window opens containing the new windows title..

I looked through help file and found some interesting stuff on wingettitle, and I also tried search but I couldn't find any solutions or pushes in the right direction..

Thanks in advance for any help!

SKAN
  • Administrators
  • 9115 posts
  • Last active:
  • Joined: 26 Dec 2005

I need to detect whenever a new window is opened, and perhaps have a little message box that pops up whenever a new window opens containing the new windows title..


I would not recommend MsgBox which itself is a window and would trigger recursive events. I have used a TrayTip instead:

#Persistent
Gui +LastFound
hWnd := WinExist()

DllCall( "RegisterShellHookWindow", UInt,hWnd )
MsgNum := DllCall( "RegisterWindowMessage", Str,"SHELLHOOK" )
OnMessage( MsgNum, "ShellMessage" )
Return

ShellMessage( wParam,lParam ) {
  Local k
  If ( wParam = 1 ) ;  HSHELL_WINDOWCREATED := 1
     {
       NewID := lParam
       SetTimer, MsgBox, -1
     }
}

MsgBox:
 WinGetTitle, Title, ahk_id %NewID%
 WinGetClass, Class, ahk_id %NewID%
 TrayTip, New Window Opened, Title:`t%Title%`nClass:`t%Class%
Return

See: <!-- m -->http://www.autohotke... ... 323#123323<!-- m -->

:)

DetectWins?
  • Guests
  • Last active:
  • Joined: --
Wow thanks lots :D