sandin Posted July 2, 2008 Posted July 2, 2008 Hi everybody.My 1st question is: What's the best way to hook a window on desktop (something like task manager - applications section does)?I tried Siao's script: http://www.autoitscript.com/forum/index.ph...536&hl=hookit's amazing, though it's not hooking all windows, like winlist() displays them (it doesn't hook RUN, or BROWSE windows, etc...)the script Siao made is very cool, cause it can hook a window without using many CPU resources, but cause of a situation of not being able to hook all windows, I tried setting winlist() function in a loop, and comparing it constantly with the old list, but this method is taking too much CPU resources so, what's the best way to hook all windows?My 2nd question is: Is it possible and how to hook a window's icon? (if Task manager can, I suppose AutoIt can do it as well)tnx for help 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
sandin Posted July 2, 2008 Author Posted July 2, 2008 sry to bring this post up, but better to up it than to make new/same topic ;/ 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
sandin Posted September 22, 2008 Author Posted September 22, 2008 sry to bring this post back up, but I'm going back to my script after a while, and I still have this issue. Is there a way to hook all windows? And hook their icons as well? 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
Nahuel Posted September 22, 2008 Posted September 22, 2008 Excuse my ignorance, but I don't know what you mean by "hook". Anyway, about the icon, check out this example: expandcollapse popup#include <Process.au3> #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> $A_Allwins=WinList() For $i=0 To $A_Allwins[0][0] If _IsVisible($A_Allwins[$i][1]) Then $s_proc=_ProcessGetName(WinGetProcess($A_Allwins[$i][1])) $s_tit=$A_Allwins[$i][0] _WindowInfo($s_tit,$s_proc) EndIf Next Func _IsVisible($hwnd) Return BitAND(WinGetState($hwnd),2) EndFunc Func _WindowInfo($s_tit,$s_proc) $Form1 = GUICreate("Window info", 448, 218, 281, 221) $Label1 = GUICtrlCreateLabel($s_tit, 44, 20, 366,50, $SS_CENTER) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") $Icon1 = GUICtrlCreateIcon(Processpath($s_proc), -1, 211, 60, 32, 32, BitOR($SS_NOTIFY,$WS_GROUP)) $Button1 = GUICtrlCreateButton("OK", 131, 136, 193, 41, $BS_DEFPUSHBUTTON) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE,$Button1 GUIDelete() Return EndSwitch WEnd EndFunc Func Processpath($Name) $strComputer = "." $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_Process WHERE Caption = '"&$Name&"'", "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) For $objItem In $colItems If $objItem.ExecutablePath Then Return $objItem.ExecutablePath Next EndFunc Is that what you wanted?
sandin Posted September 22, 2008 Author Posted September 22, 2008 lol! Respect! that's amazing! thank you! =) I still have this one issue, is there a way to hook all windows like Siao did but with question windows, run window, etc (siao's script doesn't hook them) (look 1st post) (and if I set WinGetProcess or winlist in an infinite loop, and compare it to the old one to see if I have new window, it'll take lots of CPU resources) 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
LarryDalooza Posted September 22, 2008 Posted September 22, 2008 http://www.autoitscript.com/forum/index.ph...st&p=545125 AutoIt has helped make me wealthy
sandin Posted September 22, 2008 Author Posted September 22, 2008 thanks for the link =) , but it still can't hook BROWSE, RUN, "question type" windows =( 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
LarryDalooza Posted September 22, 2008 Posted September 22, 2008 Well... my hook.dll will get whatever...http://www.autoitscript.com/forum/index.ph...st&p=458286expandcollapse popupConst $WH_CBT = 5 Const $HCBT_SETFOCUS = 0x1400 + 0x1A30 Const $HCBT_ACTIVATE = 0x1400 + 0x1A31 Const $HCBT_CREATEWND = 0x1400 + 0x1A32 Const $HCBT_DESTROYWND = 0x1400 + 0x1A33 Const $HCBT_MINMAX = 0x1400 + 0x1A34 Global $n,$msg,$buffer = "" HotKeySet("{ESC}","GoAway") $gui = GUICreate("test") Global $DLLinst = DLLCall("kernel32.dll","hwnd","LoadLibrary","str",".\hook.dll") Global $cbtHOOKproc = DLLCall("kernel32.dll","hwnd","GetProcAddress","hwnd",$DLLInst[0],"str","CBTProc") Global $hhCBT = DLLCall("user32.dll","hwnd","SetWindowsHookEx","int",$WH_CBT, _ "hwnd",$cbtHOOKproc[0],"hwnd",$DLLinst[0],"int",0) DLLCall(".\hook.dll","int","SetValuesCBT","hwnd",$gui,"hwnd",$hhCBT[0]) GUIRegisterMsg($HCBT_ACTIVATE,"myCBTfunc") ;GUIRegisterMsg($HCBT_CREATEWND,"myCBTfunc") While 1 $msg = GUIGetMsg() If $msg = -3 Then ExitLoop WEnd Func MyCBTFunc($hWndGUI, $MsgID, $WParam, $LParam) $n += 1 If $n > 25 Then $n = 25 $buffer = StringTrimLeft($buffer,StringInStr($buffer,@LF)) EndIf $buffer &= "CBT: " & $MsgID & "," & $WParam & "," & $LParam & @LF ToolTip($buffer) EndFunc Func GoAway() Exit EndFunc Func OnAutoItExit() DLLCall("user32.dll","int","UnhookWindowsHookEx","hwnd",$hhCBT[0]) DLLCall("kernel32.dll","int","FreeLibrary","hwnd",$DLLinst[0]) EndFunc AutoIt has helped make me wealthy
sandin Posted September 23, 2008 Author Posted September 23, 2008 (edited) I've done it =) thank you Larry Edited September 23, 2008 by sandin 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
sandin Posted September 23, 2008 Author Posted September 23, 2008 one more question, $HCBT_ACTIVATE works great for detecting creation of wins, but what should I use for detecting win's closing? $HCBT_DESTROYWND detects everything destroyed, but what I need is just detecting window destroying. Can this be done? 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
LarryDalooza Posted September 23, 2008 Posted September 23, 2008 Would it be OK to cycle through your window handles and check that they WinExist() on some interval... or do you absolutely need an event driven solution? Lar. AutoIt has helped make me wealthy
sandin Posted September 23, 2008 Author Posted September 23, 2008 Would it be OK to cycle through your window handles and check that they WinExist() on some interval... or do you absolutely need an event driven solution?Lar.tnx for the tip, it could work, and I'll do it this way unless, there is a way to set like you said event driven solution (which is not absolutely necessary ) 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
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