AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

GUI Float Question [expert/wise-person help needed]
Goto page 1, 2, 3, 4, 5  Next
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
FireGirl



Joined: 04 May 2007
Posts: 88

PostPosted: Sun Jun 03, 2007 6:33 pm    Post subject: GUI Float Question [expert/wise-person help needed] Reply with quote

I am getting into developing GUI applications.... one technique I would absolutely love to achieve is the following: (I will do my best to eloborate with my words Smile....


Basically, if I 'pick up' a GUI and throw it around the screen in a wild jerky motion, so to speak, and let off the mouse button, I want the GUI to continue sliding in the general direction I inferred, but just for a moment as it should slow down and stop (not go totally crazy.... but not the usual pinpoint precision drop/and go typical with Windows GUI). Sort of a GUI that can react to slide GUI's around with less hand effort.... though I know it will not be as precise, it can work in certain situations to move a GUI window in a general direction..... can someone help me with pointers or a way to achieve this, that isn't too messy or too clunky?

I know AHK is great to design GUI's.... is there a way to give GUI's more screen elasticity and 'floating' sort of properties? I know this may be annoying to some users, but I have a special partially disabled user requesting this feature in a application which relies heavily on moving gui controls, who doesn't have precision hand-eye movement control.... so something like this would be perfect to give more flexibility and general capability to move windows using allot less effort/movements of the hand than a controlled pick up, move hand, drop gui, etc....

Best wishes, & thank you for any guidance.

Sincerely, Fire
Back to top
View user's profile Send private message
Titan



Joined: 11 Aug 2004
Posts: 5390
Location: /b/

PostPosted: Sun Jun 03, 2007 7:32 pm    Post subject: Re: GUI Float Question [expert/wise-person help needed] Reply with quote

FireGirl wrote:
is there a way to give GUI's more screen elasticity and 'floating' sort of properties?
You need a few mechanic equations here. Firstly you need to have your Gui pick up on WM_ENTERSIZEMOVE and WM_EXITSIZEMOVE notifications, storing window positions and tick count for the former event. You then need to calculate the distance between the two vectors using pythagoras theorem and find a bearing using trigonometry i.e. arc cosine, you can find an example on my gesture script. Once you have these it should be easy to find the rate of deceleration, and then loop on moving the window in the right direction with delays to sync with the current velocity (since WinMove is instantaneous). This is just for a single direction of motion; for an elastic effect you need to bound to screen edges. If you want to take it even further you can plot coords at specified intervals and move along a bezier curve.

If we had a games programmer on the forum he/she should be able to write you an example. There may also be an easier method using GDI or external DLLs.
_________________

Back to top
View user's profile Send private message Visit poster's website
FireGirl



Joined: 04 May 2007
Posts: 88

PostPosted: Sun Jun 03, 2007 7:58 pm    Post subject: Reply with quote

Wow thank you Titan!! You are the best. It is amazing you can think so easily like that. I must admit, this is turning out to be a bit over my head on technical implementation (bezier curves and whatnot) ... but Your tech psychics analysis thinking sounds achievable. If you can, or someone else catching this can decipher Titan's data and turn out a example that would be very very helpful to me.

Brilliant Titan! Thank you for advancing this one step. I feel like I am one step closer to making this dream become reality for a user Smile Have a very nice day.

Code:

Gui, 1: -caption
Gui, 1: -border
gui, 1: font, s7 bold, Arial
Gui, 1: Add, Text, cFFFFFF x0 y10,PLEASE MAKE THIS GUI SHELL MOVABLE, FLOAT, GROOVE
Gui, 1: Add, Text, cFFFFFF x0 y25,AND EVEN BOUNCE OF SCREEN SIDES WITH EASE IF YOU CAN...
Gui, 1: Add, Text, cFFFFFF x0 y40,THINK SEVERELY HAND-EYE COORDINATED DISABLED USER FOR
Gui, 1: Add, Text, cFFFFFF x0 y55,BEST USABILITY CAPABILITY/EFFECT/PURPOSE....
Gui, 1: Show, x100 y100 w400 h400
Gui, 1: Color, 008000

Back to top
View user's profile Send private message
ManaUser



Joined: 24 May 2007
Posts: 906

PostPosted: Sun Jun 03, 2007 11:45 pm    Post subject: Reply with quote

Here's my stab at it. It
Code:
; AutoHotkey Version: 1.0.45.04
; Language:       English
; Platform:       Win9x/NT
; Author:         ManaUser
;
; Script Function:
;   1. Press ALT+F9 to bind to the active window.
;       2. Drag the window and let go, Weeeeee! Watch that window slide.

#NoEnv

!F9::
SetTimer GlideCtrl, 20
WinGet TargetWindow, ID, A
WinGetPos CurX, CurY, , , ahk_id %TargetWindow%
LastX := CurX
LastY := CurY
Return

GlideCtrl:
If GetKeyState("LButton", "P")
{
   WinGetPos CurX, CurY, , , ahk_id %TargetWindow%
   SpeedX := CurX - LastX
   SpeedY := CurY - LastY
   LastX := CurX
   LastY := CurY
}
Else
{
   CurX += SpeedX
   CurY += SpeedY
   WinMove, ahk_id %TargetWindow%, , %CurX%, %CurY%
   LastX := CurX
   LastY := CurY
   SpeedX *= 0.93
   SpeedY*= 0.93
}
Return

I don't have much experience with the GUI command so this just latches on to an existing window. It's a little rough, kind of moves jerky. And I'm not really sure how to imporve that. But the basic effect is there. No handling of edges though. (Not that it would be hard to add.)
Back to top
View user's profile Send private message
FireGirl



Joined: 04 May 2007
Posts: 88

PostPosted: Mon Jun 04, 2007 4:53 am    Post subject: Reply with quote

That is so wonderful ManaUser ...., I am surprised you did that in relativity few lines of code. IF anyone at the sound of these words knows bezier curves or whatnot, and can implement it and a boundary so the GUI will not leave the screen --- this will be so perfect. Smile Smile Smile Smile

Thanks a million. Sincerest wishes, Firegirl
Back to top
View user's profile Send private message
ManaUser



Joined: 24 May 2007
Posts: 906

PostPosted: Mon Jun 04, 2007 7:35 am    Post subject: Reply with quote

I can do the edges part at least. Do you really want it to bounce?
Back to top
View user's profile Send private message
FireGirl



Joined: 04 May 2007
Posts: 88

PostPosted: Mon Jun 04, 2007 1:50 pm    Post subject: Reply with quote

I was envisioning it to bounce proportional to the force applied against it., but by default not to the extent that if a GUI was slung with amazing force, it shouldn't bounce like a ping-pong ball all over the place out of control.... that would be a problem. The best analogy I can use is, maybe envision it like bouncing up against a wall of mattresses, like a brake and it will bounce & decelerate down against a variable 1-100 that can be set Question So 100 would be like a ping pong ball maybe, 10 would barely bump away, and 1 would stick like a magnet, and I suppose 0 will turn off bouncing and the GUI can simply float off screen.... that may be most logical & helpful to have this adjustability in certain situations.....I am also real curious how to get the smooth factor down so it is pleasant to look at. Maybe someone else understands what Titan was suggesting with bezier curves or his other concepts to get the fluid motion in place, and we can cross-implement this.

I am so amazed how we can work together using the Internet. Thank you so much for helping and getting the ball rolling, and helping me put this together for a student. You are a great person and it is looking great.

If anyone else out there wants to help with the smooth part please jump in the mix!! We will thank you over-and-over immensely!

Have an awesome day!!!
Sincerely, Firegirl Very Happy
Back to top
View user's profile Send private message
PhiLho



Joined: 27 Dec 2005
Posts: 6721
Location: France (near Paris)

PostPosted: Mon Jun 04, 2007 2:48 pm    Post subject: Reply with quote

I was able to improve ManaUser's excellent starting point.
Now, the window stops if it hits the walls, er, the screen bounds, and if the speed becomes too low.
It is stopped completely, so you have to rebind again the window to move it again, it might be annoying or a good thing.
I added some informative tooltips to show what is going on.

Code:
; AutoHotkey Version: 1.0.46.16
; Language:       English
; Platform:       Win9x/NT
; Author:         ManaUser & PhiLho
;
; Script Function:
;   1. Press ALT+F9 to bind to the active window.
;       2. Drag the window and let go, Weeeeee! Watch that window slide.

!F9::
   SetTimer GlideCtrl, 33
   WinGet targetWindow, ID, A
   WinGetPos curX, curY, winW, winH, ahk_id %targetWindow%
   lastX := curX
   lastY := curY
   bMoved := false
   ToolTip Drag the window
Return

GlideCtrl:
;~    IfWinNotExist ahk_id %targetWindow%
;~       Goto StopGlide   ; Use closed the window
   If GetKeyState("LButton", "P")
   {
      ; Moving the window
      bMoved := true
      WinGetPos curX, curY, , , ahk_id %TargetWindow%
      speedX := curX - lastX
      speedY := curY - lastY
      ToolTip %speedX% %speedY%
      lastX := curX
      lastY := curY
   }
   Else If (bMoved)
   {
      curX += speedX
      curY += speedY
      If (curX < 0)
      {
         curX := 0
         Goto StopGlide
      }
      If (curY < 0)
      {
         curY := 0
         Goto StopGlide
      }
      If (curX + winW > A_ScreenWidth)
      {
         curX := A_ScreenWidth - winW
         Goto StopGlide
      }
      If (curY + winH > A_ScreenHeight)
      {
         curY := A_ScreenHeight - winH
         Goto StopGlide
      }
      WinMove, ahk_id %TargetWindow%, , %curX%, %curY%
      lastX := curX
      lastY := curY
      speedX *= 0.93
      speedY *= 0.93
      ToolTip % Floor(speedX) . " " . Floor(speedY)
      If (speedX < 1 and speedY < 1)
         Goto StopGlide
   }
Return

StopGlide:
   SetTimer GlideCtrl, Off
   ToolTip Glide stopped
   bMoved := false
Return

No advanced maths here (not sure if they are really needed) and still very jerky. On the last point, there is not much improvement to expect (playing with SetBatchLines, Process Priority and such) because we are not doing DirectX in C, but plain GDI (window drawing) in AutoHotkey (slow interpreted language with limited SetTimer).
_________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")
Back to top
View user's profile Send private message Visit poster's website
ManaUser



Joined: 24 May 2007
Posts: 906

PostPosted: Mon Jun 04, 2007 4:20 pm    Post subject: Reply with quote

I've been playing around with this some more, and noticed something awkward with the edge handling. Normally you can drag a window (partway) off the screen, but we don't want it to "glide" off the screen. The interaction between these two things is... odd.

So I was thinking, what if instead off dragging the title bar as normal, you could drag the window by pointing at any part and holding down the middle mouse button? This way the script would have full control over the dragging and could prevent it from going off the edge at any time. (I got this idea from the EasyWindowDrag sample script.)
Back to top
View user's profile Send private message
ManaUser



Joined: 24 May 2007
Posts: 906

PostPosted: Mon Jun 04, 2007 5:40 pm    Post subject: Reply with quote

Okay, give this a try. I really like how it came out. No more pressing F9, this version works on any window, and you don't even have to drag by the title bar. Just use the middle button. You can also fiddle with SPEEDMULT, INERTIA and BOUNCYNESS variables to tweak the effect.

Code:
; EasyGlide
; Based on Easy Window Dragging
;
; AutoHotkey Version: 1.0.45.04
;           Platform: XP/2k/NT
;             Author: Paul Pliska (ManaUser)
;
; Script Function:
; This will make the middle mouse button drag any window.
; Additionally, if you let go while dragging, the window will "glide"
; for short distance, and even bounce off the edges of the screen. The
; speed, distance and "bouncyness" can be adjusted by changing the
; SPEEDMULT, INERTIA and BOUNCYNESS variables below.

#NoEnv
#SingleInstance Force

 SPEEDMULT = 2.00 ;Multiplies the Speed ;)
   INERTIA = 0.90 ;1 means Glide forever, 0 means not at all.
BOUNCYNESS = 0.50 ;1 means no speed is lost, 0 don't bounce.

;Suggested Settings: SPEEDMULT=2 INERTIA=0.9 BOUNCYNESS=0.5

;Clicking any mouse button will stiop a glide.
~*LButton::
SetTimer, Glide, off
Return
~*RButton::
SetTimer, Glide, off
Return

MButton::
SetTimer, Glide, off
CoordMode, Mouse ;Switch to screen/absolute coordinates.
MouseGetPos, LastMouseX, LastMouseY, MouseWin
WinGetPos, OriginalPosX, OriginalPosY,,, ahk_id %MouseWin%
WinGet, WinState, MinMax, ahk_id %MouseWin%
if WinState = 0  ;Only if the window isn't maximized
{
   WinGetPos, LastX, LastX, , , ahk_id %MouseWin%
   SetTimer, WatchMouse, 10 ; Track the mouse as the user drags it.
}
return

WatchMouse:
GetKeyState, LButtonState, MButton, P
if LButtonState = U    ;Button has been released, so drag is complete.
{         ;Now it's time to glide.
   SpeedX *= SPEEDMULT
   SpeedY *= SPEEDMULT
   SetTimer, WatchMouse, off
   SetTimer, Glide, 10
   return
}

CoordMode, Mouse
MouseGetPos, MouseX, MouseY
WinGetPos, WinX, WinY, WinWidth, WinHeight, ahk_id %MouseWin%
SysGet, WorkArea, MonitorWorkArea
WinX := WinX + MouseX - LastMouseX
WinY := WinY + MouseY - LastMouseY

;Enforce Boundries
if (WinX < WorkAreaLeft)
   WinX := WorkAreaLeft
if (WinY < WorkAreaTop)
   WinY := WorkAreaTop
if (WinX + WinWidth > WorkAreaRight)
   WinX := WorkAreaRight - WinWidth
if (WinY + WinHeight > WorkAreaBottom)
   WinY := WorkAreaBottom - WinHeight

SetWinDelay, -1   ; Makes the below move faster/smoother.
WinMove, ahk_id %MouseWin%, , WinX, WinY
SpeedX := WinX - LastWinX
SpeedY := WinY - LastWinY
LastMouseX := MouseX  ; Update for the next timer-call to this subroutine.
LastMouseY := MouseY
LastWinX := WinX
LastWinY := WinY
return

Glide:
SpeedX *= INERTIA
SpeedY *= INERTIA
If (Abs(SpeedX) < 1 AND Abs(SpeedY) < 1)
{
   SetTimer, Glide, off ;It's barely moving, bring it to a complete stop.
   Return
}

WinGetPos, WinX, WinY, WinWidth, WinHeight, ahk_id %MouseWin%
SysGet, WorkArea, MonitorWorkArea

WinX += SpeedX
WinY += SpeedY

;Enforce Boundries, AND BOUNCE!
if (WinX < WorkAreaLeft)
{
   WinX := WorkAreaLeft
   SpeedX *= -BOUNCYNESS
}
if (WinY < WorkAreaTop)
{
   WinY := WorkAreaTop
   SpeedY *= -BOUNCYNESS
}
if (WinX + WinWidth > WorkAreaRight)
{
   WinX := WorkAreaRight - WinWidth
   SpeedX *= -BOUNCYNESS
}
if (WinY + WinHeight > WorkAreaBottom)
{
   WinY := WorkAreaBottom - WinHeight
   SpeedY *= -BOUNCYNESS
}

WinMove, ahk_id %MouseWin%, , %WinX%, %WinY%
LastWinX := WinX
LastWinY := WinY
return
Back to top
View user's profile Send private message
FireGirl



Joined: 04 May 2007
Posts: 88

PostPosted: Mon Jun 04, 2007 9:40 pm    Post subject: Reply with quote

Brilliant! Smile Wow this is so cool & great.....

Sincerely, Firegirl.
Back to top
View user's profile Send private message
SKAN



Joined: 26 Dec 2005
Posts: 6264

PostPosted: Mon Jun 04, 2007 10:36 pm    Post subject: Reply with quote

@Paul: Nice demo Very Happy
Back to top
View user's profile Send private message
Laszlo



Joined: 14 Feb 2005
Posts: 4078
Location: Pittsburgh

PostPosted: Tue Jun 05, 2007 12:52 am    Post subject: Reply with quote

Nice script, Paul! I fixed a couple of bugs and sped it up a little by moving those instructions out of the timer routines, which always give the same results. There are a few other changes:

1. Moving from the current window position is not only slow (needs to ask for the current coordinates), but also makes the end of glide often vertical or horizontal, when one of the speed components becomes less than 0.5 (it does not contribute to the move any more). Fractional position values are better, they keep on growing, and when they reach the next pixel value, the window moves in that direction, too. This way the glide remains in the correct direction.

2. We don't need the variables LastWinX/Y, the dragging speed can be determined from the mouse coordinates.

3. Sometimes, when you release the middle mouse button, the window dragging stops, or changes direction, preventing glide, or directing it in the wrong direction. I added geometric averaging of the last speed values to reduce the effects of this occasional glitches.
Code:
; EasyGlide
; Based on Easy Window Dragging
;
; AutoHotkey Version: 1.0.45.04+
;            Platform: XP/2k/NT
;            Author: Paul Pliska (ManaUser)
;
; Script Function:
; Make the middle mouse button drag any window, in any internal point.
; Additionally, if you let go while dragging, the window will "glide"
; for short distance, and even bounce off the edges of the screen.
; The distance and "bouncyness" can be adjusted by changing constants

#SingleInstance Force
#NoEnv
SetBatchLines -1        ; Run faster
SetWinDelay -1          ; Makes the window moves faster/smoother.
CoordMode Mouse, Screen ; Switch to screen/absolute coordinates.
SysGet WorkArea, MonitorWorkArea

SpeedA     = 0.90       ; Averaging factor (for slow button release)
SpeedB    := 1 - SpeedA ; Speed = A * previous_speed_value + B * new_speed_value
INERTIA    = 0.99       ; 1 means Glide forever, 0 means not at all.
BOUNCYNESS = 0.90       ; 1 means no speed is lost, 0 don't bounce.
SpeedX := SpeedY := 0

~*LButton::             ; Clicking a mouse button stops glide.
~*RButton::
   SetTimer Glide, Off
Return

MButton::
   SetTimer Glide, Off
   MouseGetPos LastMouseX, LastMouseY, MouseWin
   WinGet WinState, MinMax, ahk_id %MouseWin%
   IfNotEqual WinState,0, Return ; Only if the window isn't maximized
   WinGetPos WinX, WinY, WinWidth, WinHeight, ahk_id %MouseWin%
   SetTimer WatchMouse, 10       ; Track the mouse as the user drags it
Return

MButton Up::
   SetTimer WatchMouse, Off      ; MButton has been released, so drag is complete.
   SetTimer Glide, 10            ; Start gliding
Return

WatchMouse:                      ; Drag: Button is still pressed
   MouseGetPos MouseX, MouseY
   WinX += MouseX - LastMouseX
   WinX := WinX < WorkAreaLeft ? WorkAreaLeft : WinX+WinWidth > WorkAreaRight ? WorkAreaRight-WinWidth : WinX
   WinY += MouseY - LastMouseY
   WinY := WinY < WorkAreaTop ? WorkAreaTop : WinY+WinHeight > WorkAreaBottom ? WorkAreaBottom-WinHeight : WinY

   WinMove ahk_id %MouseWin%,, WinX, WinY
   SpeedX := SpeedX*SpeedA + (MouseX-LastMouseX)*SpeedB
   SpeedY := SpeedY*SpeedA + (MouseY-LastMouseY)*SpeedB
   LastMouseX := MouseX, LastMouseY := MouseY
Return

Glide:                           ; Let window glide on
   SpeedX *= INERTIA,  SpeedY *= INERTIA
   If (SpeedX*SpeedX + SpeedY*SpeedY < 0.02) {
      SetTimer Glide, Off        ; It's barely moving, bring it to a complete stop
      Return
   }
   WinX += SpeedX,   WinY += SpeedY
   If (WinX < WorkAreaLeft  OR  WinX + WinWidth > WorkAreaRight)
      SpeedX *= -BOUNCYNESS
   If (WinY < WorkAreaTop  OR  WinY + WinHeight > WorkAreaBottom)
      SpeedY *= -BOUNCYNESS
   WinX := WinX < WorkAreaLeft ? WorkAreaLeft : WinX+WinWidth > WorkAreaRight ? WorkAreaRight-WinWidth : WinX
   WinY := WinY < WorkAreaTop ? WorkAreaTop : WinY+WinHeight > WorkAreaBottom ? WorkAreaBottom-WinHeight : WinY
   WinMove ahk_id %MouseWin%,, WinX, WinY
Return
Back to top
View user's profile Send private message
ManaUser



Joined: 24 May 2007
Posts: 906

PostPosted: Tue Jun 05, 2007 3:29 am    Post subject: Reply with quote

Huh, I just realized I'd been using an outdated version. I had to upgrade to get "foo ? bar : baz" to work. Anyway...
Laszlo wrote:
Nice script, Paul! I fixed a couple of bugs and sped it up a little by moving those instructions out of the timer routines, which always give the same results. There are a few other changes:

1. Moving from the current window position is not only slow (needs to ask for the current coordinates), but also makes the end of glide often vertical or horizontal, when one of the speed components becomes less than 0.5 (it does not contribute to the move any more). Fractional position values are better, they keep on growing, and when they reach the next pixel value, the window moves in that direction, too. This way the glide remains in the correct direction.

Ah-ha! I was wondering how to avoid that. Some of your speed tweaks must have really helped too, because it's much smoother, very nice! I think I'll put GetWorkArea on a 10 second timer though, just in case they change resolution or resize the task bar.

Quote:
2. We don't need the variables LastWinX/Y, the dragging speed can be determined from the mouse coordinates.

My reason for using LastWin was that if the window bumps the edge of the screen, its true position can't be determined by the mouse position. On the other hand, it seems fine how you've got it, but it does change the functionality a little.

Quote:
3. Sometimes, when you release the middle mouse button, the window dragging stops, or changes direction, preventing glide, or directing it in the wrong direction. I added geometric averaging of the last speed values to reduce the effects of this occasional glitches.

I thought of doing this too, but couldn't get it working well. That does seem to help, but I turned it down a little because the high setting made it hard put down a window without having it glide. (I reorganized the "constants" some too.)

I also used made it do a normal middle click if the window is maximized, instead of nothing. So here's yet another version with those changes:

Code:
; EasyGlide
; Based on Easy Window Dragging
;
;      AutoHotkey Version: 1.0.46+ (uses ?: operator)
;                Platform: XP/2k/NT
;                  Author: Paul Pliska (ManaUser)
; Performance Enhancement: Laszlo
;
; Script Function:
; Make the middle mouse button drag any window, in any internal point.
; Additionally, if you let go while dragging, the window will "glide"
; for short distance, and even bounce off the edges of the screen.
; The distance and "bouncyness" can be adjusted by changing constants.

    INERTIA = 0.97 ; 1 means Glide forever, 0 means not at all.
 BOUNCYNESS = 0.50 ; 1 means no speed is lost, 0 means don't bounce.
SENSITIVITY = 0.33 ; Higher is more responsive, lower smooths out glitchs more.
                   ; Must be greater than 0 and no higher than 1.

#SingleInstance Force
#NoEnv
SetBatchLines -1        ; Run faster
SetWinDelay -1          ; Makes the window moves faster/smoother.
CoordMode Mouse, Screen ; Switch to screen/absolute coordinates.
SpeedA := 1 - SENSITIVITY
SetTimer WorkAreaCheck, 10000   ;Just in case they move the task bar.
GoSub WorkAreaCheck      ;or change resolution.

~*LButton::             ; Clicking a mouse button stops glide.
~*RButton::
   SetTimer Glide, Off
Return

MButton::
   SetTimer Glide, Off
   MouseGetPos LastMouseX, LastMouseY, MouseWin
   WinGet WinState, MinMax, ahk_id %MouseWin%
   IfNotEqual WinState, 0 ; If the window is maximized, just to normal Middle Click
   {
       Click Middle
       Return
   }
   WinGetPos WinX, WinY, WinWidth, WinHeight, ahk_id %MouseWin%
   SetTimer WatchMouse, 10       ; Track the mouse as the user drags it
Return

WatchMouse:
   If !GetKeyState("MButton","P") {
      SetTimer WatchMouse, Off   ; MButton has been released, so drag is complete.
      SetTimer Glide, 10         ; Start gliding
      Return
   }
                                 ; Drag: Button is still pressed
   MouseGetPos MouseX, MouseY
   WinX += MouseX - LastMouseX
   WinY += MouseY - LastMouseY

   ;Enforce Boundries
   WinX := WinX < WorkAreaLeft ? WorkAreaLeft : WinX+WinWidth > WorkAreaRight ? WorkAreaRight-WinWidth : WinX
   WinY := WinY < WorkAreaTop ? WorkAreaTop : WinY+WinHeight > WorkAreaBottom ? WorkAreaBottom-WinHeight : WinY

   WinMove ahk_id %MouseWin%,, WinX, WinY
   SpeedX := SpeedX*SpeedA + (MouseX-LastMouseX)*SENSITIVITY
   SpeedY := SpeedY*SpeedA + (MouseY-LastMouseY)*SENSITIVITY
   LastMouseX := MouseX,     LastMouseY := MouseY
Return

Glide:
   SpeedX *= INERTIA
   SpeedY *= INERTIA
   If (Abs(SpeedX) < 0.2 AND Abs(SpeedY) < 0.2) {
      SetTimer Glide, Off        ; It's barely moving, bring it to a complete stop
      Return
   }

   WinX += SpeedX,   WinY += SpeedY

   If (WinX < WorkAreaLeft  OR  WinX + WinWidth > WorkAreaRight)
      SpeedX *= -BOUNCYNESS
   If (WinY < WorkAreaTop  OR  WinY + WinHeight > WorkAreaBottom)
      SpeedY *= -BOUNCYNESS
   WinX := WinX < WorkAreaLeft ? WorkAreaLeft : WinX+WinWidth > WorkAreaRight ? WorkAreaRight-WinWidth : WinX
   WinY := WinY < WorkAreaTop ? WorkAreaTop : WinY+WinHeight > WorkAreaBottom ? WorkAreaBottom-WinHeight : WinY

   WinMove ahk_id %MouseWin%,, WinX, WinY
Return

WorkAreaCheck:
SysGet WorkArea, MonitorWorkArea
Return
Back to top
View user's profile Send private message
FireGirl



Joined: 04 May 2007
Posts: 88

PostPosted: Tue Jun 05, 2007 5:18 am    Post subject: Reply with quote

Synergy city! I can't believe how good this headed so amazingly quick and efficiently Shocked

Thank you all so so much....

Peace & Grace, Firegirl


Last edited by FireGirl on Tue Jun 05, 2007 5:28 am; edited 2 times in total
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Goto page 1, 2, 3, 4, 5  Next
Page 1 of 5

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group