WideBoyDixon Posted May 5, 2009 Share Posted May 5, 2009 This arose from a topic in the help forum and I'm just cross-posting here at Sandin's suggestion. The problem was how to monitor messages going to another window not controlled by AutoIt. After much searching I found a suitable workaround. First of all you need to download this package: http://allapi.mentalis.org/vbexamples/vbex...xample=DSSUBCLSUnzip dssubcls.dll in to the same folder as your script. You can then use it to "subclass" any other window. My example in Notepad:expandcollapse popup#include <WindowsConstants.au3> #include <GuiListbox.au3> Global $hList _Main() Exit Func _Main() Local $hGUI = GUICreate("Subclass", 400, 400) Local $cList = GUICtrlCreateList("", 8, 8, 384, 384, BitOR($WS_BORDER, $WS_VSCROLL)) GUISetState() $hList = GUICtrlGetHandle($cList) Local $hDSSUBCLS = DllOpen("dssubcls.dll") Run("Notepad.exe") WinWait("[CLASS:Notepad]") Local $hNotepad = WinGetHandle("[CLASS:Notepad]") Local $hCallback = DllCallbackRegister("_MyCallback", "long", "long;long;long") Local $aRet = DllCall($hDSSUBCLS, "long", "SubClass", "hwnd", $hNotepad, "ptr", DllCallbackGetPtr($hCallback), "long", 0, "long", 0, "long", 0, "long", 1) $aRet = DllCall($hDSSUBCLS, "long", "UseSendMessage", "long", 1) While GUIGetMsg() <> -3 Sleep(100) WEnd DllClose($hDSSUBCLS) GUIDelete() EndFunc ;==>_Main Func _MyCallback($uiMsg, $wParam, $lParam) Switch $uiMsg Case $WM_COMMAND If $lParam = 0 Then _GUICtrlListBox_AddString($hList, "WM_COMMAND(" & $wParam & "," & $lParam & ")") EndIf EndSwitch Return 0 EndFunc ;==>_MyCallbackSelecting a menu item from Notepad puts a message in to the list box. Should work for other windows and applications too although I'm not sure what will happen under Vista/Windows7 and whether you're allowed to do this. Note that the "hooked" application does tend to run a little slower and I suspect that's because it's firing messages at _MyCallback() which is taking too long to respond. However, I'm not certain about this.More information about the "SubClass" function can be found in the TXT file that's also in the package.Hope this helps. Have fun.WBD qsek 1 [center]Wide by name, Wide by nature and Wide by girth[u]Scripts[/u]{Hot Folders} {Screen Calipers} {Screen Crosshairs} {Cross-Process Subclassing} {GDI+ Clock} {ASCII Art Signatures}{Another GDI+ Clock} {Desktop Goldfish} {Game of Life} {3D Pie Chart} {Stock Tracker}[u]UDFs[/u]{_FileReplaceText} {_ArrayCompare} {_ToBase}~ My Scripts On Google Code ~[/center] Link to comment Share on other sites More sharing options...
Zedna Posted May 5, 2009 Share Posted May 5, 2009 Looks really good Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Creator Posted May 5, 2009 Share Posted May 5, 2009 Running Vista here and it works fine! Nicely done. Link to comment Share on other sites More sharing options...
sandin Posted May 5, 2009 Share Posted May 5, 2009 tnx again for this tool, it's amazing! Some cool glass and image menu | WinLIRC remote controler | Happy Holidays to all... | Bounce the sun, a game in which you must save the sun from falling by bouncing it back into the sky | Hook Leadtek WinFast TV Card Remote Control Msges | GDI+ sliding toolbar | MIDI Keyboard (early alpha stage, with lots of bugs to fix) | Alt+Tab replacement | CPU Benchmark with pretty GUI | Ini Editor - Edit/Create your ini files with great ease | Window Manager (take total control of your windows) Pretty GUI! | Pop-Up window from a button | Box slider for toolbar | Display sound volume on desktop | Switch hotkeys with mouse scroll Link to comment Share on other sites More sharing options...
ziggery Posted September 14, 2012 Share Posted September 14, 2012 awesome tool Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now