Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

[tool] ShellHook Messages


  • Please log in to reply
9 replies to this topic
Serenity
  • Members
  • 1271 posts
  • Last active:
  • Joined: 07 Nov 2004
Posted Image
ShellHook Messages simply displays messages received by hooking onto the shell. I wrote this to see what windows couldn't be caught with this method whilst refining my popup script and thought I'd share it. I might have got carried away adding the message filter but it is there if you need it. :)

Hotkeys
C to clear list
P to pause
R to reload
X to exit

Release History
2008/09/10 v0.2 released
#SingleInstance Force
#NoTrayIcon
SetBatchLines, -1
; Process, Priority,, High
Title := "ShellHook Messages", Filters := "", Pause := 0
FilterMenu(), Gui()
Hwnd := WinExist(), WM_VSCROLL := 0x115, SB_BOTTOM := 7
DllCall( "RegisterShellHookWindow", UInt,Hwnd )
MsgNum := DllCall( "RegisterWindowMessage", Str,"SHELLHOOK" )
OnMessage( MsgNum, "ShellMessage" )
Return

DecToHex( ByRef lParam ) 
{
	SetFormat, Integer, Hex
	Return lParam += 0
}

FilterMenu()
{
	Global FilterList
	Menu, Filter, Add, Filter &All, FilterAll
	Menu, Filter, Add, Filter &None, FilterNone
	Menu, Filter, Add
	FilterList = WINDOWCREATED,WINDOWDESTROYED,ACTIVATESHELLWINDOW,WINDOWACTIVATED
	,GETMINRECT,REDRAW,TASKMAN,LANGUAGE,SYSMENU,ENDTASK,ACCESSIBILITYSTATE,APPCOMMAND
	,WINDOWREPLACED,WINDOWREPLACING,HIGHBIT,FLASH,RUDEAPPACTIVATED
	Loop, Parse, FilterList, `,
	{
		If A_Loopfield	
			Menu, Filter, Add, %A_Loopfield%, SetFilter
	}
	Menu, FilterMenu, Add, Message &Filter, :Filter
	Gui, Menu, FilterMenu
}

Gui()
{
	Global
	Gui, +LastFound +AlwaysOnTop +Resize ; +ToolWindow
	Gui, Margin, 0, 0
	Gui, Font, s8, Microsoft Sans Serif
	Gui, Color,, DEDEDE
	Gui, Add, ListView, w400 r10 vData +Grid +NoSort, lParam (hWnd)|Process|wParam|Message
	LV_ModifyCol( 1, 60 ), LV_ModifyCol( 2, 100 ), LV_ModifyCol( 3, 40 ), LV_ModifyCol( 4, 180 )
	Gui, Show,, %Title%
}

ShellMessage( wParam,lParam ) 
{
	Global Data,Hwnd,WM_VSCROLL,SB_BOTTOM,Filters,Pause
	WinGetTitle, title, ahk_id %lParam%
	WinGet, pname, ProcessName, ahk_id %lParam%
	WinGet, pid, PID, ahk_id %lParam%

	if wParam = 1
		msg = HSHELL_WINDOWCREATED
	if wParam = 2
		msg = HSHELL_WINDOWDESTROYED
	if wParam = 3
		msg = HSHELL_ACTIVATESHELLWINDOW
	if wParam = 4
		msg = HSHELL_WINDOWACTIVATED
	if wParam = 5
		msg = HSHELL_GETMINRECT
	if wParam = 6
		msg = HSHELL_REDRAW
	if wParam = 7
		msg = HSHELL_TASKMAN
	if wParam = 8
		msg = HSHELL_LANGUAGE
	if wParam = 9
		msg = HSHELL_SYSMENU
	if wParam = 10
		msg = HSHELL_ENDTASK
	if wParam = 11
		msg = HSHELL_ACCESSIBILITYSTATE
	if wParam = 12	
		msg = HSHELL_APPCOMMAND
	if wParam = 13
		msg = HSHELL_WINDOWREPLACED
	if wParam = 14
		msg = HSHELL_WINDOWREPLACING
	if wParam = 15
		msg = HSHELL_HIGHBIT
	if wParam = 16
		msg = HSHELL_FLASH
	if wParam = 17
		msg = HSHELL_RUDEAPPACTIVATED
	
	If wParam not in %Filters%
	{
		If ( Pause = 0 )
		{	
			DecToHex( lParam )
			LV_Add( "", lParam, pname, wParam, msg )
			SendMessage, WM_VSCROLL, SB_BOTTOM, 0, SysListView321, ahk_id %Hwnd%		
		}	
	}	
}

SetFilter:
Menu, Filter, ToggleCheck, %A_ThisMenuItem%
Loop, Parse, FilterList, `,
{
	If ( A_ThisMenuItem = A_Loopfield )
	{
		If A_Index in %Filters% ; remove from filter
		{		
			Filter := A_Index
			Loop, Parse, Filters, `,
			{
				If ( A_Loopfield != Filter )
					NewFilters .= A_Loopfield . ( A_Loopfield != "" ? "`," : "" ) 
			}
			Filters := NewFilters, NewFilters := ""
		}	
		Else ; add to filter
		{
			Filters .= A_Index . ","
		}	
	}	
}
Return

FilterAll:
Filters =
Loop, Parse, FilterList, `,
{	
	Menu, Filter, Check, %A_Loopfield%
	Filters .= A_Index . ( A_Index != 17 ? "," : "" ) 
}
Return

FilterNone:
Loop, Parse, FilterList, `,
{
	Menu, Filter, UnCheck, %A_Loopfield%
	Filters = 
}
Return

GuiContextMenu:
Menu, Filter, Show
Return

GuiSize:
GuiControl, Move, Data, w%A_GuiWidth% h%A_GuiHeight%
SendMessage, WM_VSCROLL, SB_BOTTOM, 0, SysListView321, ahk_id %Hwnd%
Return

GuiClose:
GuiEscape:
ExitApp
Return

#IfWinActive ShellHook Messages
	C::LV_Delete()
		
	P::
	Pause :=! Pause, WinTitle := ( Pause = 0 ? Title : Title . " (Paused)" )
	WinSetTitle %WinTitle%
	Return
	
	R::Reload
	X::ExitApp	
#IfWinActive


tank
  • Moderators
  • 4244 posts
  • Last active: Dec 15 2014 01:23 AM
  • Joined: 21 Dec 2007
I will be using this
just so im clear it captures all messages sans what is filtered?

Serenity
  • Members
  • 1271 posts
  • Last active:
  • Joined: 07 Nov 2004
Yes. If the menu item is checked, then it won't be displayed in the Listview.

  • Guests
  • Last active:
  • Joined: --
:shock: OMG


Your Briljant Thank You Very Very Much

Serenity for President

n-l-i-d
  • Guests
  • Last active:
  • Joined: --
Very nice! 8)
________________________________________________________
New here? Please, before you post...
1. Read the tutorial and try the examples. -> 2. Take a look at the command list to get an idea of what you could do. -> 3. Create your script. Consult the documentation and the FAQ if you get stuck. -> 4. Search the forum if you need help or examples, method 1 (forum), method 2 (site), method 3 (Google). -> 5. Post your code on the forum in the "Ask for Help" section if you still run into problems (but read this first). -> 6. There is more AHK on autohotkey.net and the Wiki and there is an AHK IRC chat.


maraskan_user
  • Members
  • 52 posts
  • Last active: Dec 08 2014 11:18 PM
  • Joined: 20 Jun 2008
Great tool, Serenity! Thank you!

Does anybody happen to know what message wParam 32772 and 32774 correlate to? I happened to be getting wParam 4 when activating a window, but lately, it's always been 32772 instead..

protophantom
  • Members
  • 1 posts
  • Last active: Jan 06 2009 10:25 PM
  • Joined: 06 Jan 2009
I am having a weird issue with this program. When I open a program, I get a HSHELL_WINDOWCREATED message as expected. When I close it, however, I get multiple HSHELL_WINDOWDESTROYED messages. Does anyone have any idea why this might happen, and what the extraneous HSHELL_WINDOWDESTROYED messages refer to? I have attached a screenshot of the ShellHook Messages Window and the behavior which produced it.

Thank you

Posted Image
This is the sequence of events which created the screenshot above:

Clicked Start (first 3 lines)
Clicked the Icon for paint (the next three lines, labled as mspaint.exe)
Closed paint (8 lines)

results in 7 HSHELL_WINDOWDESTROYED messages

three with a hWnd that matches the HSHELL_WINDOWCREATED message
three with a different hWnd
one more with a third hWnd
[/list]Clicked the ShellHook Messages window (to get the screenshot) (last line)
[/list]

messagenewbie
  • Guests
  • Last active:
  • Joined: --
Great tool! Is there a way to catch wm_command as well?

messagenewbie
  • Guests
  • Last active:
  • Joined: --
Was that a dumb question? :(

KooKsTeR
  • Members
  • 157 posts
  • Last active: Mar 21 2013 09:18 PM
  • Joined: 19 Feb 2010
Great script man! You might want to have something like this in it for credits sake:
Menu, FilterMenu, Add, About

About:
MsgBox, 262148,, Would you like to go to the Forum Topic?`n`n[tool] ShellHook Messages`nhttp://www.autohotkey.com/forum/viewtopic.php?t=35623
IfMsgBox Yes
	Run,http://www.autohotkey.com/forum/viewtopic.php?t=35623
return