Sign in to follow this  
Followers 0
Vindicator

winmove with delay (as if dragged?)

8 posts in this topic

How do I make WinMove move a window slowly instead of instantly, as if someone is dragging the window?

My script so far:

#include <GuiConstants.au3>
#include <misc.au3>
GuiCreate("MyGUI", 115, 165,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_BORDER))

$Pic_1 = GuiCtrlCreatePic("template.gif", 0, 0, 120, 170)

GuiSetState()
Func _ClickWait()
    While (_IsPressed('01') == 0)
        sleep(10)
    WEnd
        $y=MouseGetPos(1)
$x=MouseGetPos(0)
WinMove("MyGUI","",$x,$y);<===   This Part
WinSetOnTop("MyGUI","",1)
EndFunc
While 1
_ClickWait()
WEnd

I wanted the appearance that the window folows the mouse click...


If I hadn't said thank you yet, and you deserve it, than thank you...

Share this post


Link to post
Share on other sites



It does... you have to hold down the mouse..

Did you want the clicking of the mouse to toggle the following?

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

yeas

so like if I click one place, it would move there as if some invisibly mouse dragged it to that point

because whit that code, it instantly reappears that the clicked location... I was thinking maybe it would slowly move to that point... I was thinking of a while loop that moves it one pixel at a time but uhhh... Im sure there must be a simpler way?

Edited by P a R a D o X

If I hadn't said thank you yet, and you deserve it, than thank you...

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

yeas

so like if I click one place, it would move there as if some invisibly mouse dragged it to that point

because whit that code, it instantly reappears that the clicked location... I was thinking maybe it would slowly move to that point... I was thinking of a while loop that moves it one pixel at a time but uhhh... Im sure there must be a simpler way?

Look at For...Next Loops in the helpfile. Edited by Paulie

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

is this what you wanted??

This is a little glitchy, and slow... but you could try something like this

#include <GuiConstants.au3>
#include <misc.au3>
$hWnd = GuiCreate("MyGUI", 115, 165,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_BORDER))

$Pic_1 = GuiCtrlCreatePic("template.gif", 0, 0, 120, 170)

GuiSetState()
Func _ClickWait()
    While (_IsPressed('01') == 0)
        sleep(10)
    WEnd
EndFunc
While 1
_ClickWait()
$ss = WInGetPos($hWnd)
$sp = MouseGetPos()
_WinMoveTo($hWnd, $ss[0], $ss[1], $sp[0], $sp[1])
WEnd

Func _WinMoveTo($hWnd, $a, $b, $c, $d)
    Local $u, $s, $v, $d1x, $d1y, $d2x, $d2y, $m, $n
    Local $i
    $u = $c-$a
    $v = $d-$b
    $d1x =  sgn($u)
    $d1y =  sgn($v)
    $d2x =  sgn($u)
    $d2y = 0
    $m = abs($u)
    $n = abs($v)
    if ($m <= $n) Then
        $d2x = sgn($v)
        $d2y = abs($v)
        $n = abs($u)
    EndIf
    $s = $m/2
    Local $x = $a, $y = $b
    for $i = 0 to round($m)
        
        WinMove($hWnd, "", $x, $y)
        $s += $n
        if ($s >= $m) Then
            $s -= $m
            $x += $d1x
            $y += $d1y
        Else
            $x += $d2x
            $y += $d2y
        EndIf
    Next
EndFunc

Func SGN($a)
    if ($a>0) then return 1
    if ($a<0) then return -1
    return 0
EndFunc
Edited by CHRIS95219

Share this post


Link to post
Share on other sites

Wow, with a little add in of WinSetOnTop, that works like a charm, but I'm still trying to understand what you did, but hey, thanks, I would imagine that took you some time... thanks again


If I hadn't said thank you yet, and you deserve it, than thank you...

Share this post


Link to post
Share on other sites

Wow, with a little add in of WinSetOnTop, that works like a charm, but I'm still trying to understand what you did, but hey, thanks, I would imagine that took you some time... thanks again

lol, np... Just a little research for line algorithms...

anyways, i added a function that gets the coordinates to draw a straight line to the mouse coordinates :whistle: _WinMoveTo($window_handel, $x_start, $y_start, $x_end, $y_end)

Share this post


Link to post
Share on other sites

interesting...


If I hadn't said thank you yet, and you deserve it, than thank you...

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0