Help with slightly modifying this script?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
Patrick_Dayna
Posts: 44
Joined: 01 Jun 2021, 15:48

Help with slightly modifying this script?

22 Jun 2021, 19:39

I found this script by the Wizard, SKAN. It detects any newly created window. It works really well. Thing is I need to detect when the Save As, Open file , Import dialogs are created.

The script does not detect them. Because, I think, they are classes belonging to the process that created them. Is there any way to modify it so it detects these dialog boxes too? Thank you.

Code: Select all

#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
User avatar
SKAN
Posts: 1551
Joined: 29 Sep 2013, 16:58

Re: Help with slightly modifying this script?

22 Jun 2021, 20:20

Need refining.. Doesn't detect FileOpen in PSPad :eh:
Let me know if it works for you.

Code: Select all

#NoEnv
#Warn
#SingleInstance, Force
#Persistent

CBA := RegisterCallBack("WinDetectDialog")
EVENT_SYSTEM_DIALOGSTART:=0x10
hHook := DllCall("SetWinEventHook","Int",EVENT_SYSTEM_DIALOGSTART, "Int",EVENT_SYSTEM_DIALOGSTART
               , "Ptr",0, "Ptr",CBA, "Int",0, "Int",0, "Int",0, "Ptr")
Return

WinDetectDialog() {
Critical
  SetTimer, MsgBox, -1
}

MsgBox:
 NewID := WinActive("A")
 WinGetTitle, Title, ahk_id %NewID%
 WinGetClass, Class, ahk_id %NewID%
 TrayTip, New Window Opened, Title:`t%Title%`nClass:`t%Class%
Return
User avatar
Patrick_Dayna
Posts: 44
Joined: 01 Jun 2021, 15:48

Re: Help with slightly modifying this script?

22 Jun 2021, 20:45

Hey SKAN!
Man thank you so much!
I tried your solution it works with some widows and not with others, I think your suspicions were right. Strangely enough, it also stops working a few minutes later on the same programs it was initially working on, such as notepad. I could be doing the same thing such as Open... but TrayTip does not show up.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: gongnl, Rohwedder and 263 guests