JAFN Posted April 22, 2011 Share Posted April 22, 2011 I so wanted to go a day without asking a question here. Now it is barely noon and I have one I can not find the answer to in the help or here in the forums. How can I tell if a window has been moved other than brute forcing it? An equivalent to 'onmoveEvent' in many C based languages. [size="2"]The second mouse gets the cheese[/size] Link to comment Share on other sites More sharing options...
kaotkbliss Posted April 22, 2011 Share Posted April 22, 2011 WinGetPos() Perhaps something like $hWin=WinGetPos("My Gui") While 1 Sleep(10) $movegui=WinGetPos("My Gui") If $movegui[0]<>$hWin[0] Then MsgBox(0,"Title","Gui Moved!") EndIf Wend 010101000110100001101001011100110010000001101001011100110010000 001101101011110010010000001110011011010010110011100100001 My Android cat and mouse gamehttps://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek We're gonna need another Timmy! Link to comment Share on other sites More sharing options...
JohnOne Posted April 22, 2011 Share Posted April 22, 2011 If you want to detect a user moving your gui, then you could try $GUI_EVENT_PRIMARYDOWN constant or $GUI_EVENT_PRIMARYUP. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
JAFN Posted April 22, 2011 Author Share Posted April 22, 2011 WinGetPos() Perhaps something like $hWin=WinGetPos("My Gui") While 1 Sleep(10) $movegui=WinGetPos("My Gui") If $movegui[0]<>$hWin[0] Then MsgBox(0,"Title","Gui Moved!") EndIf Wend That was pretty much what I had in mind as brute forcing it. My code is not really suited for this. I was hoping there was an object oriented method I was too blind to see or was underdocumented. [size="2"]The second mouse gets the cheese[/size] Link to comment Share on other sites More sharing options...
martin Posted April 22, 2011 Share Posted April 22, 2011 (edited) I so wanted to go a day without asking a question here. Now it is barely noon and I have one I can not find the answer to in the help or here in the forums.How can I tell if a window has been moved other than brute forcing it? An equivalent to 'onmoveEvent' in many C based languages....or did you mean a window which you created in your AutoIt script? If so then you need GuiRegister($WM_MOVE,"somefunc") which is possibly what you're thinking of for an on-move event.Otherwise as kaotkbliss says because afaik even shell hooking doesn't tell you when a window is moved. Edited April 22, 2011 by martin Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
JAFN Posted April 22, 2011 Author Share Posted April 22, 2011 If you want to detect a user moving your gui, then you could try $GUI_EVENT_PRIMARYDOWN constant or $GUI_EVENT_PRIMARYUP.I've got to think on this, perhaps combined with a Window has focus command something workable might be crafted.Thanks. [size="2"]The second mouse gets the cheese[/size] Link to comment Share on other sites More sharing options...
JAFN Posted April 22, 2011 Author Share Posted April 22, 2011 ...or did you mean a window which you cretaed in your AutoIt script? If so then you need GuiRegister($WM_MOVE,"somefunc") which is possibly what you're thinking of for an on-move event.Bingo.Got to go out but I will try this as soon as I get back.Thank you. [size="2"]The second mouse gets the cheese[/size] Link to comment Share on other sites More sharing options...
JohnOne Posted April 22, 2011 Share Posted April 22, 2011 I've got to think on this, perhaps combined with a Window has focus command something workable might be crafted.Thanks.What I was thinking was upon a mousedown or up, whichever you choose, a function is called to determine if the window has moved since its last position, which of course you would need to do on script start or something. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
JAFN Posted April 22, 2011 Author Share Posted April 22, 2011 ...or did you mean a window which you created in your AutoIt script? If so then you need GuiRegister($WM_MOVE,"somefunc") which is possibly what you're thinking of for an on-move event.Otherwise as kaotkbliss says because afaik even shell hooking doesn't tell you when a window is moved.I'd really like to understand this but my eyes went cross-eyed reading the help example.If you are willing could you show my the bare minimum needed to make this work? [size="2"]The second mouse gets the cheese[/size] Link to comment Share on other sites More sharing options...
martin Posted April 23, 2011 Share Posted April 23, 2011 I'd really like to understand this but my eyes went cross-eyed reading the help example. If you are willing could you show my the bare minimum needed to make this work? Sure. expandcollapse popup; *** Start added by AutoIt3Wrapper *** #include <WindowsConstants.au3> ; *** End added by AutoIt3Wrapper *** #AutoIt3Wrapper_Add_Constants=n Global Const $WM_ENTERSIZEMOVE = 0x231, $WM_EXITSIZEMOVE = 0x232 ConsoleWrite(wingethandle("Tabbed Windows?") & @CRLF) $gp = GUICreate("main gui", 300, 300, 200, 200);,-1,$WS_EX_MDICHILD,wingethandle("Tabbed Windows?")) GUISetState() $gs = GUICreate("dragged gui", 200, 150, 400, 400) GUISetState() Global $RelPos[2] GUIRegisterMsg($WM_ENTERSIZEMOVE, "setrelpos") GUIRegisterMsg($WM_MOVE, "followme") While 1 If GUIGetMsg() = -3 Then Exit WEnd Func followme($hW, $iM, $wp, $lp) If $hW <> $gp Then Return Local $xpos = BitAND($lp, 0xffff) Local $ypos = BitShift($lp, 16) Local $xypos = WinGetPos($gp) WinMove($gs, "", $xypos[0] - $RelPos[0], $xypos[1] - $RelPos[1]) EndFunc ;==>followme Func SetRelPos($hW, $iM, $wp, $lp) If $hW <> $gp Then Return Local $gpp = WinGetPos($gp) Local $gsp = WinGetPos($gs) $RelPos[0] = $gpp[0] - $gsp[0] $RelPos[1] = $gpp[1] - $gsp[1] EndFunc ;==>SetRelPos Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
JAFN Posted April 23, 2011 Author Share Posted April 23, 2011 Sure. expandcollapse popup; *** Start added by AutoIt3Wrapper *** #include <WindowsConstants.au3> ; *** End added by AutoIt3Wrapper *** #AutoIt3Wrapper_Add_Constants=n Global Const $WM_ENTERSIZEMOVE = 0x231, $WM_EXITSIZEMOVE = 0x232 ConsoleWrite(wingethandle("Tabbed Windows?") & @CRLF) $gp = GUICreate("main gui", 300, 300, 200, 200);,-1,$WS_EX_MDICHILD,wingethandle("Tabbed Windows?")) GUISetState() $gs = GUICreate("dragged gui", 200, 150, 400, 400) GUISetState() Global $RelPos[2] GUIRegisterMsg($WM_ENTERSIZEMOVE, "setrelpos") GUIRegisterMsg($WM_MOVE, "followme") While 1 If GUIGetMsg() = -3 Then Exit WEnd Func followme($hW, $iM, $wp, $lp) If $hW <> $gp Then Return Local $xpos = BitAND($lp, 0xffff) Local $ypos = BitShift($lp, 16) Local $xypos = WinGetPos($gp) WinMove($gs, "", $xypos[0] - $RelPos[0], $xypos[1] - $RelPos[1]) EndFunc ;==>followme Func SetRelPos($hW, $iM, $wp, $lp) If $hW <> $gp Then Return Local $gpp = WinGetPos($gp) Local $gsp = WinGetPos($gs) $RelPos[0] = $gpp[0] - $gsp[0] $RelPos[1] = $gpp[1] - $gsp[1] EndFunc ;==>SetRelPos Thank you very much. It might take a day to wrap my head around it. But then it opens up lots of possibilities. [size="2"]The second mouse gets the cheese[/size] 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