fisofo Posted January 31, 2007 Share Posted January 31, 2007 lod3n suggested at one point making an autoit script to allow windows to snap together, similar to this: http://www.cs.utoronto.ca/~iheckman/allsnap/Additionally, being able to catch the "maximize window" event and reinterpret it would be sweet... I'd like to try to get both implemented into splitmon script I'm working on (sig).so basically... is this possible, and if so, how do you do it? Or even better, has someone already done it?Searching around did not yield much... Link to comment Share on other sites More sharing options...
fisofo Posted January 31, 2007 Author Share Posted January 31, 2007 Thanks, I'll do that. Link to comment Share on other sites More sharing options...
fisofo Posted February 2, 2007 Author Share Posted February 2, 2007 I'm making progress Larry, thanks for the suggestions. One question though: where do you get these values? 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 They don't seem to match up with the winuser header... and more to the point, what would $HCBT_MOVESIZE be? Link to comment Share on other sites More sharing options...
fisofo Posted February 2, 2007 Author Share Posted February 2, 2007 1) They are porprietary values defined in my hook.dll and 2) I dunno?Lar.gotcha, no prob $HCBT_MINMAX should work fine for my purposes... Link to comment Share on other sites More sharing options...
fisofo Posted February 3, 2007 Author Share Posted February 3, 2007 (edited) Hello again! Man, I hope it's warmer than 10 below wherever you guys live. With windchill it hit -40 this morning!Anyway, question for you Larry: The CBT is indeed returning info that I want (specifically, Maximize Window events), however, it's also returning a bunch of stuff I don't want. Is there some way to tell whether a window is about to be minimized, restored, or maximized... because I can't seem to do that using your CBT hook.I've posted your code modified below to only return CBT MINMAX info. run it and you'll see that it returns the same message whether being minimzed, restored, or maximized.One thought I had was to check the mouse position in relation to the window to determine which button was clicked... but that just seems clunky and prone to error.Any ideas on how to get this to work?expandcollapse popupConst $WH_CBT = 5 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_MINMAX,"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, 0, 0) EndFunc Func GoAway() Exit EndFunc Func OnAutoItExit() DLLCall("user32.dll","int","UnhookWindowsHookEx","hwnd",$hhCBT[0]) DLLCall("kernel32.dll","int","FreeLibrary","hwnd",$DLLinst[0]) EndFuncEdit: it would appear that I probably won't be able to block whatever operation the CBT is reporting (correct me if I'm wrong). That being the case, perhaps I'll just check window position info after a CBT message to determine what happened and then reinterpret it as I see fit.Messy though, I would still appreciate any other ideas someone might have. Edited February 3, 2007 by fisofo Link to comment Share on other sites More sharing options...
fisofo Posted February 4, 2007 Author Share Posted February 4, 2007 Sounds good... yep, it looks like lParam always returns 0, so that's probably the missing link. Thanks for continuing to look at this with me, have a great superbowl Sunday! Link to comment Share on other sites More sharing options...
fisofo Posted February 6, 2007 Author Share Posted February 6, 2007 (edited) Sweetness, that's perfect Larry. For those interested, here's the CBT LParam returns: ; LParam = 3 = maximize ; LParam = 6 = minimize ; LParam = 9 = restore which, of course, are equivalent to our good friends @SW_MAXIMIZE, etc... Edited February 6, 2007 by fisofo Link to comment Share on other sites More sharing options...
kwlayman Posted July 11, 2007 Share Posted July 11, 2007 I need to intercept creation of a window so I can move and resize it before it appears. Using the code in this thread and in mousehook allows me to receive notification of the window opening, but I can't find a way to block it opening or change it's parameters. All I can do is resize/move it afterwards causing an annoying flash as the window opens in it's original position and then gets moved. According to the info I've read cbt hooks allow you to block and change the hooked action but I can't figure out how to do it with hook.dll, it just seems to pass the messages on. Could someone please help me on this? 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