James Posted June 4, 2007 Share Posted June 4, 2007 Hey,I am doing some window movements. Basically, I am making some physics to the window. Lets say you want to move a window, normally you would drag it to the desired location. But with this, you click the title, and flick the mouse, let go, and it moves. Then if it hits the desktops sides it will bound back.expandcollapse popup#cs Name: Window Physics Author: James Brooks aka Secure_ICT Description: Drag windows and let go to see them move! #ce HotKeySet("^!e", "_Exit") #include <Constants.au3> #include <Misc.au3> Local $WinTitle, $WinPos, $WinList, $Window ; Window Boundaries Global $Desktop[2] $Desktop[0] = @DesktopWidth ; The desktop width $Desktop[1] = @DesktopHeight ; The desktop height While WinActive($WinTitle) _WindowName() Wend While 1 _WinMoveCheck() Wend Func _WindowName() $WinTitle = WinGetTitle("") ConsoleWrite($WinTitle & @CRLF) EndFunc Func _WinMoveCheck() $Window = WinGetPos("") For $i = 1 to 40 WinMove($WinTitle, "", $Window[0] - 1, $Window[1]) Next EndFunc Func _BouncBack() If $WinTitle = $Desktop[0] or $Desktop[1] Then Do For $b = 1 to 5 WinMove($WinTitle, "", $Window[0] + 1, $Window[1]) Next Until WinGetPos($Window, "") = $Desktop[0] + 10 EndIf EndFunc Func _Exit() Exit EndFuncI'm not sure on how to, Get the window to bounce back if it hits the sides How to know if a window is movingAny help is much appreciated.Thanks,James Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
PsaltyDS Posted June 4, 2007 Share Posted June 4, 2007 Basically, I am making some physics to the window. Lets say you want to move a window, normally you would drag it to the desired location. But with this, you click the title, and flick the mouse, let go, and it moves. Then if it hits the desktops sides it will bound back.I'm not sure on how to, Get the window to bounce back if it hits the sides How to know if a window is movingWinGetPos() returns X, Y, width, height of the window:- If X <= 0 then you hit the left side- If X + width >= @DesktopWidth then you hit the right side- If Y <=0 then you hit the top- If Y + height >= @DesktopHeight then you hit the bottomIf X or Y change from loop to loop then it's moving. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
James Posted June 4, 2007 Author Share Posted June 4, 2007 Thanks.. Thats what I could figure out. Much appreciated. Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
James Posted June 4, 2007 Author Share Posted June 4, 2007 Hmm, I tried to check if it hit left or right sides, but it doesnt work. expandcollapse popup#cs Name: Window Flicker Author: James Brooks aka Secure_ICT Description: Drag windows and let go to see them move! #ce HotKeySet("^!e", "_Exit") Opt("WinTitleMatchMode", 2) #include <Misc.au3> If _Singleton("W1NFL1CK3R", 1) = 0 Then MsgBox(0x10, "Error", "An occurence of Window Flicker is already running.") EndIf Local $ProgramName, $Window, $WindowList Global $DesktopBound[2] $DesktopBound[0] = @DesktopHeight / @DesktopHeight + @DesktopHeight - 1 $DesktopBound[1] = @DesktopWidth / @DesktopWidth + @DesktopWidth - 1 $Window = WinGetTitle($Window) $Program = WinGetPos("") $x = $Program[0] $y = $Program[1] $Width = $Program[2] $Height = $Program[3] ; Sleep(1000) ; _ErrorBound() While 1 $ProgramName = WinGetTitle("", "") ;_DesktopBorder() WEnd #cs Func _Bounce() If $ProgramBound[0] or $ProgramBound[1] = 0 Then Do For $a = 1 To 10 WinMove($ProgramName, "", @DesktopWidth / 2, @DesktopHeight / 2) Next Until $Program = @DesktopWidth / 2 & @DesktopHeight / 2 EndIf EndFunc #ce Func _DesktopBorder() ; For $b = 1 To @DesktopHeight ; _BounceWindow() ; Next If $Program <= 0 Then MsgBox(0, "You hit:", "The left side!") If $WindowList + $Width >= @DesktopWidth Then MsgBox(0, "You hit:", "The right side!") EndFunc ;==>_DesktopBorder Func _WinList() $WindowList = WinList() For $c = 1 To $WindowList[0][0] ; Next EndFunc ;==>_WinList Func _ErrorBound() #cs Used for Checking errors #ce ; MsgBox(0, "Desktop Info", "Your Desktop Boundary is: Height: " & $DesktopBound[0] & " Width: " & $DesktopBound[1]) ; MsgBox(0, "Program Info", "Your Program Boundary is: Height: " & $ProgramBound[0] & " Width: " & $ProgramBound[1]) EndFunc ;==>_ErrorBound Func _Exit() Exit EndFunc ;==>_Exit Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
James Posted June 4, 2007 Author Share Posted June 4, 2007 Ok, I tried doing it all. But the window just keeps moving continuosly. I only want to make it move if it hits the border. expandcollapse popup#cs Name: Window Flicker Author: James Brooks aka Secure_ICT Description: Drag windows and let go to see them move! #ce HotKeySet("^!e", "_Exit") Opt("WinTitleMatchMode", 2) #include <Misc.au3> If _Singleton("W1NFL1CK3R", 1) = 0 Then MsgBox(0x10, "Error", "An occurence of Window Flicker is already running.") Exit EndIf Local $ProgramName, $Window, $WindowList Global $DesktopBound[2] $DesktopBound[0] = @DesktopHeight / @DesktopHeight + @DesktopHeight - 1 $DesktopBound[1] = @DesktopWidth / @DesktopWidth + @DesktopWidth - 1 $Window = WinGetTitle($Window) $Program = WinGetPos("") $x = $Program[0] $y = $Program[1] $Width = $Program[2] $Height = $Program[3] While 1 $ProgramName = WinGetTitle("", "") _DesktopBorder() WEnd Func _DesktopBorder() If $x <= 0 Then WinMove($Program, "", Random(100, 200, 1), $y) If $x + $Width >= @DesktopWidth Then WinMove($Program, "", Random(100, 200, 1), $y) If $y <= 0 Then WinMove($Program, "", Random(100, 200, 1), $y) If $y + $Height >= @DesktopHeight Then WinMove($Program, "", Random(1, $Width, 1), $y) EndFunc ;==>_DesktopBorder Func _Exit() Exit EndFunc ;==>_Exit Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
James Posted June 4, 2007 Author Share Posted June 4, 2007 Does anyone know hwo to see if the window is in a certain place? Thanks, James Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
James Posted June 5, 2007 Author Share Posted June 5, 2007 Anyone? I cant figure out when it hits the right places. Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
James Posted June 5, 2007 Author Share Posted June 5, 2007 OK, I got the places to work. But I dont know how to make sure that the program has hits the points? Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
James Posted June 10, 2007 Author Share Posted June 10, 2007 BUMP! I will explain again! When you select a Window and move it, you can just flick it, and it will move, when it hits the desktop sides it will bounce to a random position on the screen. -James Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
PsaltyDS Posted June 11, 2007 Share Posted June 11, 2007 (edited) What is the point of this math gyration? Global $DesktopBound[2] $DesktopBound[0] = @DesktopHeight / @DesktopHeight + @DesktopHeight - 1 $DesktopBound[1] = @DesktopWidth / @DesktopWidth + @DesktopWidth - 1oÝ÷ Ø8¯È¨©¥éìmçèæwû.nÚÚrÛ(¶Æ¥Á¬¬jëh×6Global $DesktopBound[2] $DesktopBound[0] = 1 + @DesktopHeight - 1 $DesktopBound[1] = 1 + @DesktopWidth - 1 Why bother with the array, though? Just use the macros @DesktopHeight and @DesktopWidth directly. And you don't call the array again in the rest of the script fragment you posted. P.S. You've got the cart before the horse. Nothing here detects a mouse "flick". Nothing here implements any "physics" (like a balistic arc for the window path, maybe). The window movement is random. Etc. Etc. What in this code has anything to do with your stated script's purpose? Edited June 11, 2007 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
James Posted June 11, 2007 Author Share Posted June 11, 2007 It doesn't matter. I quit this whole thing. It's too ho for me too work correctly in. Thanks though Psalty! Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ 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