Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

Fire event on window creation/resize/move/close


  • Please log in to reply
6 replies to this topic

#1 Mechaflash

Mechaflash

    Sons of Anarchy

  • Active Members
  • PipPipPipPipPipPip
  • 1,377 posts

Posted 11 July 2012 - 02:08 PM

How would I go about waiting for interaction of a window on the desktop and targeting that window?

I'm making a window-organizing app (which I'll share after it's complete) and want to watch for when a window is resized/moved on the desktop.

Edited by mechaflash213, 11 July 2012 - 07:54 PM.

  • Jardz likes this
“Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.”







#2 BrewManNH

BrewManNH

    באָבקעס מיט קודוצ׳ה

  • MVPs
  • 10,154 posts

Posted 11 July 2012 - 02:14 PM

I would use the GUIRegisterMsg function and look for the $WM_SYSCOMMAND actions. In my signature is a link to a demo script that I created that shows you the different messages sent by the GUI when you interact with it. The move action isn't listed, but the parameter to look for is WParam = 0xF012 for clicking on the title bar of a gui.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to an XP machine, and I'm not going to.

 

Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude

 

How to ask questions the smart way!

 

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.
Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.
_FileGetProperty - Retrieve the properties of a file SciTE Toolbar - A toolbar demo for use with the SciTE editorGUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.
GUIToolTip UDF Demo - Demo script to show how to use the GUIToolTip UDF to create and use customized tooltips. Latin Square password generator

 

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.


#3 PhoenixXL

PhoenixXL

    be what you are, its always the BEST..

  • MVPs
  • 1,561 posts

Posted 11 July 2012 - 02:25 PM

WM_MOVE and WM_RESIZE may help with GUIRegisterMsg

PredictText: Predict Text of an Edit Control Like Scite. | Remote Gmail: Execute your Scripts through Gmail. | StringRegExp: Share and learn RegExp. |

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). | Database: An easier approach for _SQ_LITE beginners. |

MathsEx: A UDF for Fractions and LCM, GCF/HCF. | FloatingText: An UDF for make your text floating. | Clipboard Extendor: A clipboard monitoring tool. |

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression. |


#4 Mechaflash

Mechaflash

    Sons of Anarchy

  • Active Members
  • PipPipPipPipPipPip
  • 1,377 posts

Posted 11 July 2012 - 02:26 PM

Thanks Brew. This will work out nicely.

EDIT: I'll look into it Phoenix thx.

Edited by mechaflash213, 11 July 2012 - 02:26 PM.

“Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.”

#5 Mechaflash

Mechaflash

    Sons of Anarchy

  • Active Members
  • PipPipPipPipPipPip
  • 1,377 posts

Posted 11 July 2012 - 04:08 PM

Did a miniscule test on when a new window is created. The initial _ArrayDisplay() fires the event, however opening up application windows/system windows (New firefox instance and new My Documents instance) doesn't fire it.

I'm thinking GUIRegisterMsg() is only for the actual GUI created by AutoIt and not any window?

EDIT: Removed $iWinCount and added it to the 0 index on $ahWinList
EDIT2: Added _WinOrg_UnRegisterWindow() function to show it fires when you close the _ArrayDisplay()

AutoIt         
#include <Array.au3> ;~ HotKeySet("^!e", "_IncludeExclude") GUIRegisterMsg(0x0001, "_WinOrg_RegisterWindow") ; If Window is Created GUIRegisterMsg(0x0002, "_WinOrg_UnRegisterWindow") ; If Window is Destroyed ;~ GUIRegisterMsg(0x0003, "_WinOrg_WindowCheck") ; If Window Moves ;~ GUIRegisterMsg(0x0005, "_WinOrg_WindowCheck") ; If Window is Resized ;~ GUIRegisterMsg(0x0047, "_WinOrg_WindowCheck") ; If Window Position Changes ; Global $ahWinList Defined in _WinOrg_Initialize() _WinOrg_Initialize() _ArrayDisplay($ahWinList) _ArrayDisplay($ahWinList) While 1     Sleep(100) WEnd Func _WinOrg_Initialize()     $avWinListTemp = WinList()     Global $ahWinList[$avWinListTemp[0][0]]     $x = 0     For $i = 1 To $avWinListTemp[0][0]         If $avWinListTemp[$i][0] <> "" And _WinOrg_IsVisible($avWinListTemp[$i][1]) Then             $x+=1             $ahWinList[$x] = $avWinListTemp[$i][1]         EndIf     Next     $ahWinList[0] = $x     ReDim $ahWinList[$x + 1] EndFunc     Func _WinOrg_IsVisible($handle)         If BitAND(WinGetState($handle), 2) Then             Return 1         Else             Return 0         EndIf     EndFunc Func _WinOrg_RegisterWindow($hWndGUI, $MsgID)     msgbox(0,"","REGISTERED WINDOW WITH HANDLE: " & $hWndGUI) EndFunc Func _WinOrg_UnRegisterWindow($hWndGUI, $MsgID)     msgbox(0,"","UNREGISTERED WINDOW WITH HANDLE: " & $hWndGUI) EndFunc

Edited by mechaflash213, 11 July 2012 - 05:08 PM.

“Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.”

#6 Mechaflash

Mechaflash

    Sons of Anarchy

  • Active Members
  • PipPipPipPipPipPip
  • 1,377 posts

Posted 11 July 2012 - 07:49 PM

Was doing some research... I believe the only way to accomplish this is to hook in WH_GETMESSAGE. However, hooks, dlls and the like are still above and beyond my knowledge of use. So at this time, I'll just use a loop gathering window handles and running checks against it. It may or may not be slower than the hook method, as hooking WH_GETMESSAGE does increase processing time, but the code would be a bit cleaner and easier to adjust/expand upon via the hook method.

If I get around to implementing it via the hook method, I'll update the OP.

Edited by mechaflash213, 11 July 2012 - 07:55 PM.

“Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.”

#7 rover

rover

    unmutual

  • Active Members
  • PipPipPipPipPipPip
  • 825 posts

Posted 11 July 2012 - 08:43 PM

How would I go about waiting for interaction of a window on the desktop and targeting that window?

I'm making a window-organizing app (which I'll share after it's complete) and want to watch for when a window is resized/moved on the desktop.


_WinAPI_SetWinEventHook($EVENT_SYSTEM_MOVESIZESTART, $EVENT_SYSTEM_MOVESIZEEND, $pEventProc)
I see fascists...




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users