lordicast Posted November 6, 2009 Share Posted November 6, 2009 (edited) Is it posible to to use WinMove to move multiple windows at the same time with no lag? Currently one slides but when the second one moves the first one pauses until the second one is set. I will make a example script if needed but this is a hypothetical question. Edit Spelling: Edited November 6, 2009 by lordicast [Cheeky]Comment[/Cheeky] Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 6, 2009 Moderators Share Posted November 6, 2009 lordicast, Do you mean like this? expandcollapse popup; Credit to MikeOsdx and GaryFrost for original code snippet #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> $hGUI1 = GUICreate ("Test1", 150, 100, -1, -1) $hButton1 = GUICtrlCreateButton("Move Me!", 10, 10, 80, 30) GUISetState() ; Get position of GUI1 and set GUI2 coords $aPos1 = WinGetPos($hGUI1) $iX1 = $aPos1[0] $iY1 = $aPos1[1] $iX2 = $iX1 + 156 $iY2 = $iY1 $hGUI2 = GUICreate ("Test2", 150, 100, $iX2, $iY2) $hButton2 = GUICtrlCreateButton("Move Me!", 10, 10, 80, 30) GUISetState() ;Register move event GUIRegisterMsg($WM_MOVE, "MY_WM_MOVE") ; Set dock flag $Dock = 2 While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $hButton1 $iX = Random(10, @DesktopWidth - 160, 1) $iY = Random(10, @DesktopHeight - 150, 1) WinMove($hGUI1, "", $iX, $iY, Default, Default, 10) Case $hButton2 $iX = Random(10, @DesktopWidth - 310, 1) $iY = Random(10, @DesktopHeight - 150, 1) WinMove($hGUI2, "", $iX, $iY, Default, Default, 10) EndSwitch WEnd Func MY_WM_MOVE($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam, $lParam If ($hWnd = $hGUI1) Or ($hWnd = $hGUI2) Then _SynchroGUIs($hGUI1, $hGUI2, $Dock, $iX1, $iX2, $iY1, $iY2) EndIf Return $GUI_RUNDEFMSG EndFunc ;==>MY_WM_MOVE Func _SynchroGUIs(ByRef $GUI1, ByRef $GUI2, ByRef $Dock, ByRef $iX1, ByRef $iX2, ByRef $iY1, ByRef $iY2) Local $aPos1 = WinGetPos($GUI1) Local $aPos2 = WinGetPos($GUI2) If (($aPos1[0] <> $iX1 Or $aPos1[1] <> $iY1) And BitAND(WinGetState($GUI1), 2) Or $Dock = 2) Then $iX1 = $aPos1[0] $iY1 = $aPos1[1] $iX2 = $aPos1[2] + $iX1 $iY2 = $iY1 WinMove($GUI2, "", $iX2, $iY2);, $aPos2[2], $aPos1[3]) $Dock = 1 ElseIf (($aPos2[0] <> $iX2 Or $aPos2[1] <> $iY2) And BitAND(WinGetState($GUI2), 2)) Then $iX2 = $aPos2[0] $iY2 = $aPos2[1] $iX1 = $aPos2[0] - $aPos1[2] $iY1 = $iY2 WinMove($GUI1, "", $iX1, $iY1);, $aPos1[2], $aPos2[3]) ElseIf ($aPos1[0] <> $iX1 Or $aPos1[1] <> $iY1) And BitAND(WinGetState($GUI1), 16) Then WinSetState($GUI2, "", @SW_MINIMIZE) ElseIf ($aPos2[0] <> $iX2 Or $aPos2[1] <> $iY2) And BitAND(WinGetState($GUI2), 16) Then WinSetState($GUI1, "", @SW_MINIMIZE) ElseIf ($aPos1[0] <> $iX1 Or $aPos1[1] <> $iY1) And BitAND(WinGetState($GUI1), 2) Then WinSetState($GUI2, "", @SW_RESTORE) ElseIf ($aPos2[0] <> $iX2 Or $aPos2[1] <> $iY2) And BitAND(WinGetState($GUI2), 2) Then WinSetState($GUI1, "", @SW_RESTORE) EndIf EndFunc ;==>_SynchroGUIs M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
lordicast Posted November 6, 2009 Author Share Posted November 6, 2009 (edited) Kind of here's the issue. I want window 2 constantly sliding left and right in the while loop but when i hit UP for window 1 the HotKey pauses the second window when it shouldnt. expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> HotKeySet('{Esc}', 'End') HotKeySet('{up}','SLideUP') $Win1 = GUICreate('Win1', 200, 200, @DesktopWidth / 2, @DesktopHeight / 2) GUISetState(@SW_SHOW) $Win2 = GUICreate('Win2', 200, 200, @DesktopWidth / 2, @DesktopHeight / 2) GUISetState(@SW_SHOW) While 1 SlideLEFT() $Mx = GUIGetMsg() Switch $Mx Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func SlideLEFT() $W2pos = WinGetPos($Win2) $x = $W2pos[0] $y = $W2pos[1] For $i = 0 To -300 Step -1 WinMove($Win2, '', $x + $i, $y) Sleep(10) Next For $i = -300 To 0 Step 1 WinMove($Win2, '', $x + $i, $y) Sleep(10) Next EndFunc ;==>SlideLEFT Func SlideUP() $Wpos = WinGetPos($Win1) $x = $Wpos[0] $y = $Wpos[1] For $i = 0 To -300 Step -1 WinMove($Win1, '', $x, $y + $i) Sleep(10) Next For $i = -300 To 0 Step 1 WinMove($Win1, '', $x, $y + $i) Sleep(10) Next EndFunc ;==>SlideUP Func End() Exit EndFunc ;==>End Edited November 6, 2009 by lordicast [Cheeky]Comment[/Cheeky] Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 6, 2009 Moderators Share Posted November 6, 2009 lordicast,That is not what you asked at first. But because the first example was easy, here is another which is more like you say you want now: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> HotKeySet('{Esc}', 'End') HotKeySet('{up}','StartUP') Global $iX_1 = @DesktopWidth / 2, $iY_1 = @DesktopHeight / 2, $sDir_1 = "up" Global $iX_2 = @DesktopWidth / 2, $iY_2 = @DesktopHeight / 2, $sDir_2 = "left" Global $fUp = False $Win1 = GUICreate('Win1', 200, 200, @DesktopWidth / 2, @DesktopHeight / 2) GUISetState(@SW_SHOW) $Win2 = GUICreate('Win2', 200, 200, @DesktopWidth / 2, @DesktopHeight / 2) GUISetState(@SW_SHOW) While 1 SlideLEFT() Sleep(10) If $fUp Then SlideUP() Sleep(10) Else Sleep(20) EndIf $Mx = GUIGetMsg() Switch $Mx Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func SlideLEFT() If $sDir_2 = "left" Then $iX_2 -= 1 If $iX_2 < 100 Then $sDir_2 = "right" Else $iX_2 += 1 If $iX_2 > @DesktopWidth - 300 Then $sDir_2 = "left" EndIf WinMove($Win2, "", $iX_2, $iY_2) EndFunc ;==>SlideLEFT Func SlideUP() If $sDir_1 = "up" Then $iY_1 -= 1 If $iY_1 < 100 Then $sDir_1 = "down" Else $iY_1 += 1 If $iY_1 > @DesktopHeight - 300 Then $sDir_1 = "up" EndIf WinMove($Win1, "", $iX_1, $iY_1) EndFunc ;==>SlideUP Func StartUP() $fUp = True EndFunc Func End() Exit EndFunc ;==>EndYou will need to play with the Sleep timings to get the movement you want - but remember that anything less than Sleep(10) is still Sleep(10)! There is a Monoceres script in Examples somewhere which lets you set smaller times - and explains why Sleep(10) is a low as you can go.Incidentally, this is a perfect example of where Static variables would be of use - the window coords could stay within the functions and be retained between each call. Just move these lines into the relevant functions and change the Global to Static - and then run with Beta 3.3.1.4 or 3.3.1.5. Global $iX_1 = @DesktopWidth / 2, $iY_1 = @DesktopHeight / 2, $sDir_1 = "up" ; Move to SlideUP() Global $iX_2 = @DesktopWidth / 2, $iY_2 = @DesktopHeight / 2, $sDir_2 = "left" ; Move to SlideLEFT()M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
AndyG Posted November 6, 2009 Share Posted November 6, 2009 Hi, ...2 moving windows, win1 moves only if UP-Arrow is pressed, win 2 moves all the time expandcollapse popup#include <Misc.au3> #include <GUIConstantsEx.au3> HotKeySet('{Esc}', 'End') HotKeySet('{up}', 'SLideUP') Global $moveright = 1, $moveup = 1 $dll = DllOpen("user32.dll") $Win1 = GUICreate('Win1', 200, 200, @DesktopWidth / 2, @DesktopHeight / 2) GUISetState(@SW_SHOW) $Win2 = GUICreate('Win2', 200, 200, @DesktopWidth / 2, @DesktopHeight / 2) GUISetState(@SW_SHOW) While 1 SlideLEFT() If _IsPressed("26", $dll) Then SlideUP() $Mx = GUIGetMsg() Switch $Mx Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func SlideLEFT() $W2pos = WinGetPos($Win2) $x = $W2pos[0] $y = $W2pos[1] If $moveright = 1 And $x > 600 Then $moveright = -1 If $moveright = -1 And $x < 300 Then $moveright = 1 WinMove($Win2, '', $x + $moveright, $y) Sleep(10) EndFunc ;==>SlideLEFT Func SlideUP() $Wpos = WinGetPos($Win1) $x = $Wpos[0] $y = $Wpos[1] If $moveup = 1 And $y > 600 Then $moveup = -1 If $moveup = -1 And $y < 300 Then $moveup = 1 WinMove($Win1, '', $x, $y + $moveup) Sleep(10) EndFunc ;==>SlideUP Func End() Exit EndFunc ;==>End Link to comment Share on other sites More sharing options...
Bert Posted November 6, 2009 Share Posted November 6, 2009 Do you need the windows to be docked together? The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
lordicast Posted November 6, 2009 Author Share Posted November 6, 2009 Thanks to all! @Volly no they need to be free moving @Melba Thanks never looked at it that way! @Andy thanks but Melba pretty much got it on the head. @ME whew headache gone! Ok so I multi task horriblly which explains why I explain things so horribly if that make since?!? What im going for and what im building is full action deskmate ninja warrior battle. they will have fights on my desktop while im working! they work fine together problem is when 1 character throws a ninja star at the other he can't jump over it! IE; Win1 = Character Win2 = Ninja star coming at him So the problem was that if he tried to jump over it it would pause and wait for him to come down and nail him! Thanks to all I hope to post it when done! [Cheeky]Comment[/Cheeky] 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