Jump to content

Slide Mouse from Point 1 to Point 2


asym
 Share

Recommended Posts

.

I did a simple graphic in paint of what I intend to do for easier understanding

Posted Image

I tried to do it myself, this is what I came to

Obviously it doesn't work as I intended thats why I am asking for your help

I couldn't come with a way to do it starting from where it stopped being pressed and that stuff as explained in the image

While $script = True
        If _IsPressed("20", $dll) Then
            MouseMove(622, 439)
            MouseDown("left")
            MouseMove(850, 440)
            MouseMove(622, 439)
            MouseUp("left")

        EndIf
    WEnd

A million thanks to who can help me with this :unsure:

Link to comment
Share on other sites

  • Moderators

kaneco,

I think this should do what you want: :>

; Set HotKeys
HotKeySet("q", "_Left")
HotKeySet("w", "_Right")
HotKeySet("{ESC}", "On_Exit")

; Set initial conditions
$iDelta = 0
$iX = 200
$iY = 200

While 1
    ; Change the x coord
    $iX += $iDelta
    ; Keep mouse in within limits
    If $iX < 200 Then $iX = 200
    If $iX > 500 Then $iX = 500
    ; Move the mouse
    MouseMove($iX, $iY, 100)
    ; Wait a moment
    Sleep(20)
WEnd

Func _Right()
    ; Move mouse to right
    $iDelta = 1
EndFunc

Func _Left()
    ; Move mouse to left
    $iDelta = -1
EndFunc

Func On_Exit()
    Exit
EndFunc

Press Q to move to the left and W to move to the right - ESC exits the script. :unsure:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

This is one strange request topic xD

#Include <Misc.au3>
HotKeySet("{SPACE}","somefunc")
HotKeySet("{ESC}","Exiting")
$direction = True
$zero_pos = 300
$count_pos = 0
While 1
    If _IsPressed("20") Then
        If $direction = True Then
            MouseMove($zero_pos+$count_pos,@DesktopHeight/2,0)
            $count_pos += 1
            If $count_pos+1 > 300 Then $direction = False
        Else
            MouseMove($zero_pos+$count_pos,@DesktopHeight/2,0)
            $count_pos -= 1
            If $count_pos -1 < 0 Then $direction = True
        EndIf
    Else
        $direction = True
        Select
            Case $count_pos > 150 And $count_pos < 300
                $count_pos += 1
                MouseMove($zero_pos+$count_pos,@DesktopHeight/2,0)
            Case $count_pos < 150 And $count_pos > 0
                MouseMove($zero_pos+$count_pos,@DesktopHeight/2,0)
                $count_pos -= 1
        EndSelect
    EndIf
    Sleep(10)
WEnd

Func somefunc()
EndFunc
Func Exiting()
    Exit
EndFunc

Edit:

added one more $direction = True

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
Share on other sites

Perhaps not the most cleanest script, but it might be usefull:

Edit: nevermind my script, I didn't notice that you wanted the cursor to remain moving while the key is pressed

#include <Misc.au3>

$script = True
$dll = DllOpen("user32.dll")
$spot = StringSplit("622,439,850,440", ",")
Dim $lastposition[2]

While $script = True
        $status = 0
        If _IsPressed("20", $dll) Then ;startbutton = spacebar
        HotKeySet("{Esc}", "Stop") ;stopbutton = esc
        HotKeySet("{ENTER}", "Terminate") ;button to exit script
        Move()
        EndIf
    WEnd
DllClose($dll)

Func Move()
While 1
    If $status = 1 Then
    MouseMove($lastposition[0], $lastposition[1])
    MouseMove($spot[3], $spot[4])
    $status = 0
    EndIf
    MouseMove($spot[1], $spot[2])
    MouseDown("left")
    MouseMove($spot[3], $spot[4])
    MouseMove($spot[1], $spot[2])
    MouseUp("left")
WEnd
EndFunc

Func Stop()
While 1
    $status = 1
    If _IsPressed("20", $dll) Then ;startbutton = spacebar
    $lastposition = MouseGetPos()
    ExitLoop
    EndIf
    MouseMove($spot[1], $spot[2])
WEnd
EndFunc

Func Terminate()
Exit
EndFunc
Edited by Michiel78
Link to comment
Share on other sites

kaneco,I think this should do what you want: :>

; Set HotKeysHotKeySet("q", "_Left")HotKeySet("w", "_Right")HotKeySet("{ESC}", "On_Exit"); Set initial conditions$iDelta = 0$iX = 200$iY = 200While 1   ; Change the x coord    $iX += $iDelta  ; Keep mouse in within limits   If $iX < 200 Then $iX = 200 If $iX > 500 Then $iX = 500 ; Move the mouse    MouseMove($iX, $iY, 100)    ; Wait a moment Sleep(20)WEndFunc _Right()  ; Move mouse to right   $iDelta = 1EndFuncFunc _Left()  ; Move mouse to left    $iDelta = -1EndFuncFunc On_Exit()   ExitEndFunc
Press Q to move to the left and W to move to the right - ESC exits the script. :)M23

This one worked well but I needed the same key for the mouse to move towards the point 2 or towards the point 1

This is one strange request topic xD

#Include <Misc.au3>HotKeySet("{SPACE}","somefunc")HotKeySet("{ESC}","Exiting")$direction = True$zero_pos = 300$count_pos = 0While 1 If _IsPressed("20") Then        If $direction = True Then           MouseMove($zero_pos+$count_pos,@DesktopHeight/2,0)          $count_pos += 1         If $count_pos+1 > 300 Then $direction = False       Else            MouseMove($zero_pos+$count_pos,@DesktopHeight/2,0)          $count_pos -= 1         If $count_pos -1 < 0 Then $direction = True     EndIf   Else        $direction = True       Select          Case $count_pos > 150 And $count_pos < 300              $count_pos += 1             MouseMove($zero_pos+$count_pos,@DesktopHeight/2,0)          Case $count_pos < 150 And $count_pos > 0                MouseMove($zero_pos+$count_pos,@DesktopHeight/2,0)              $count_pos -= 1     EndSelect   EndIf   Sleep(10)WEndFunc somefunc()EndFuncFunc Exiting()   ExitEndFunc
Edit:added one more $direction = True

Sure it is strange :unsure: at least makes us think a bit... it's one of those things that could really make my day If I could accomplish it ;)

Well your script worked wonders at least on a blank window, but Im having trouble changing the "origin" point, I messed around with the $zero_pos but still can't get the y coordinate

Perhaps not the most cleanest script, but it might be usefull:Edit: nevermind my script, I didn't notice that you wanted the cursor to remain moving while the key is pressed

#include <Misc.au3>$script = True$dll = DllOpen("user32.dll")$spot = StringSplit("622,439,850,440", ",")Dim $lastposition[2]While $script = True        $status = 0        If _IsPressed("20", $dll) Then ;startbutton = spacebar       HotKeySet("{Esc}", "Stop") ;stopbutton = esc        HotKeySet("{ENTER}", "Terminate") ;button to exit script        Move()      EndIf    WEndDllClose($dll)Func Move()While 1   If $status = 1 Then MouseMove($lastposition[0], $lastposition[1])   MouseMove($spot[3], $spot[4])   $status = 0 EndIf   MouseMove($spot[1], $spot[2])   MouseDown("left")   MouseMove($spot[3], $spot[4])   MouseMove($spot[1], $spot[2])   MouseUp("left")WEndEndFuncFunc Stop()While 1    $status = 1 If _IsPressed("20", $dll) Then ;startbutton = spacebar  $lastposition = MouseGetPos()   ExitLoop    EndIf   MouseMove($spot[1], $spot[2])WEndEndFuncFunc Terminate()ExitEndFunc

This one repeatedly moved to point 2, It's not really what I wanted

Thanks all 3 of you... Im still trying to figure it out, the 2nd script seems to do the job, now Im just trying to make it do the job "where" I want it :D, if you could throw a little help bogQ I would appreciate

Again, thanks for your time... I haven't worked with autoit for months now and I couldn't really find a way to do it...

Link to comment
Share on other sites

$zero_pos is your desktop Width starting point (origin from your picture),

Change @DesktopHeight/2 to the Height post that you need

300 is the end point (point 2 from your picture that is equal to origin + 300)

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
Share on other sites

$zero_pos is your desktop Width starting point (origin from your picture),

Change @DesktopHeight/2 to the Height post that you need

300 is the end point (point 2 from your picture that is equal to origin + 300)

Thank you, Neverming I was being lazy lol, I read the code and actually understood it in 1 min

But I am having issues with the clicking part, I need it to always hold the "left mouse key"

I tried with the MouseDown, but while going to Point 2 it's moving really irregular, well the mouse in the screen seems to be moving OK, but what I am actually trying to move seems like it's having seizures from right to left... So it's pressing down but actually really in a really irregular way...

Can you help me with this?

RIght now it's like this

#Include <Misc.au3>
Opt("WinWaitDelay", 100)
Opt("WinDetectHiddenText", 1)
Opt("MouseCoordMode", 0)
Opt("PixelCoordMode", 0)
HotKeySet("{SPACE}","somefunc")
HotKeySet("{ESC}","Exiting")
$direction = True
$zero_pos = 622
$count_pos = 0
$yy = 440
While 1
    If _IsPressed("20") Then
        If $direction = True Then
            MouseMove($zero_pos+$count_pos,$yy,0)
            MouseDown("left")
            $count_pos += 1
            If $count_pos+1 > 300 Then $direction = False
        Else
            MouseMove($zero_pos+$count_pos,$yy,0)
            $count_pos -= 1
            If $count_pos -1 < 0 Then $direction = True
        EndIf
    Else
        $direction = True
        Select
            Case $count_pos > 150 And $count_pos < 300
                $count_pos += 1
                MouseMove($zero_pos+$count_pos,$yy,0)
            Case $count_pos < 150 And $count_pos > 0
                MouseMove($zero_pos+$count_pos,$yy,0)
                $count_pos -= 1
                MouseUp("left")
        EndSelect
    EndIf
    Sleep(10)
WEnd

Func somefunc()
EndFunc
Func Exiting()
    Exit
EndFunc
Edited by kaneco
Link to comment
Share on other sites

but what I am actually trying to move seems like it's having seizures from right to left...

So what are you trying to move?

Note that in main post you did not tell anyone about clicking part.

And try not to bump topic if 24h perion isnt over.

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
Share on other sites

So what are you trying to move?

Note that in main post you did not tell anyone about clicking part.

And try not to bump topic if 24h perion isnt over.

Sorry for the bump...

And I was almost sure I did say it in the first post, now that I checked again I see I didnt :/ my bad...

Can you help me with it?

I was around it like 1 hour yesterday messing with the MouseDown thingy and couldn't figure how to make it work properly :unsure:

Link to comment
Share on other sites

So what are you trying to move?

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
Share on other sites

It may seem pretty strange or whatever you wanna call it lol

I have guitar rig 4 for PC and I have my guitar pluged to the PC, I want to simulate a wha pedal, guitar rig as a thing that does it but I have to click with the mouse and I think you agree with me that it's not very "handy" to play the guitar and move you mouse at the same time

So I am trying to simulate it using the Space bar and use the keyboard as a wha pedal for my guitar lol...

I recorded a video with camtasia

http://tinypic.com/player.php?v=30jmxhw&s=7

It seems to be a bit laggy but I think you get the point

Edited by kaneco
Link to comment
Share on other sites

I cant test anything because i don`t have guitar, so i rely cant see where the problem is, i did try to see can i move that button (program on trial version) from memory (memory, in that moment in my head looked like correct solution to try to play with for something like this, and it would probably offer more reliable effect ) instead using the mouse and it did work, only problem is that memory address change after every restart of program so at the moment i don`t have solution for your problem.

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
Share on other sites

I cant test anything because i don`t have guitar, so i rely cant see where the problem is, i did try to see can i move that button (program on trial version) from memory (memory, in that moment in my head looked like correct solution to try to play with for something like this, and it would probably offer more reliable effect ) instead using the mouse and it did work, only problem is that memory address change after every restart of program so at the moment i don`t have solution for your problem.

You dont need a guitar to do it :unsure:

Wow you even went through the trouble of installing the trial version, wow, I am deeply thankful for what you have done so far... I wish this forum had a reputation system so I could give you positive reputation

What you did first is exactly what I need, I already tested it, it moves exactly how I want and in the area I want I just need it to do exactly the same thing but while pressing the left mouse button as I need to have it pressed to drag the Wah pedal bar in Guitar rig... I tried using the MouseDown("left") thing in your code but it doesn't work well maybe Im placing the code in the wrong place.

Its a really "rudimentary" way of doing it but it works as a wah pedal and It would be really useful for me because it would enable me to record stuff with the wah pedal in my computer instead of going through the trouble of having to buy one of those 500$+ guitar to computer interfaces

Link to comment
Share on other sites

I think you may have been close, but I think you need both MouseDown and MouseUp in all the If/Else conditions.

010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Link to comment
Share on other sites

something to test on, mouse coordinates are for windows classic style

I do think that you should try to use _Timer_Diff to have the calculated movement on mouse on needed interval of time from one point to another, if you need something like that ofc.

#include <Misc.au3>
#include <GUIConstantsEx.au3>
HotKeySet("{SPACE}", "somefunc")
HotKeySet("{ESC}", "Exiting")
$direction = True
$mouse = False
$zero_pos = 124
$count_pos = 0
$yy = 243
$bar_size = 300
GUICreate("slider", 400, 100, 100, 200)
$slider1 = GUICtrlCreateSlider(10, 10, 322, 20)
GUICtrlSetLimit(-1, 300, 0)
GUISetState()
While 1
    $msg = GUIGetMsg()
    If _IsPressed("20") Then
        If $direction = True Then
            MouseMove($zero_pos + $count_pos, $yy, 0)
            $count_pos += 1
            If $count_pos + 1 > $bar_size Then $direction = False
        Else
            MouseMove($zero_pos + $count_pos, $yy, 0)
            $count_pos -= 1
            If $count_pos - 1 < 0 Then $direction = True
        EndIf
        If Not $mouse Then
            MouseDown("left")
            $mouse = True
        EndIf
    Else
        $direction = True
        Select
            Case $count_pos > $bar_size/2 And $count_pos < $bar_size
                $count_pos += 1
                MouseMove($zero_pos + $count_pos, $yy, 0)
            Case $count_pos < $bar_size/2 And $count_pos > 0
                MouseMove($zero_pos + $count_pos, $yy, 0)
                $count_pos -= 1
            Case Else
                If $mouse Then
                    MouseUp("left")
                    $mouse = False
                EndIf
        EndSelect
    EndIf
    Sleep(10)
    If $msg = $GUI_EVENT_CLOSE Then Exit
WEnd

Func somefunc()
EndFunc   ;==>somefunc
Func Exiting()
    Exit
EndFunc   ;==>Exiting
Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...