Jump to content
Sign in to follow this  
Scottswan

Speed up mouse move

Recommended Posts

Scottswan

This little script is for game shortcuts (and to save my mouse clicker). It runs great on XP with a dual core cpu, but on a P4 3.06ghz single core with XP the mouse moves are painfully slow. I was wondering if there is a way to optimize the mouse move code to speed it up a bit.

Also I now need to double the number of moves, and the current code will probably get even slower. Maybe instead of calling each new position I could use an array? I'm not very advanced at coding.

; Some global keys.
HotKeySet("{ESC}", "Quit")
HotKeySet("`", "Triclick") ;tilde key
HotKeySet("!z", "HarvestDL") ;Alt + z
HotKeySet("!x", "HarvestDR") ;Alt + x
HotKeySet("!a", "HarvestUL") ;Alt + a
HotKeySet("!s", "HarvestUR") ;Alt + s

;Click the mouse 3 times.
Func Triclick()
  MouseClick("primary", default, default, 1, 100)
  Sleep(50)
  MouseClick("primary", default, default, 1, 100)
  Sleep(50)
  MouseClick("primary", default, default, 1, 100)
EndFunc

;Harvest down and to the left 5 times.
Func HarvestDL()
$xpos = MouseGetPos(0)
$ypos = MouseGetPos(1)
  MouseClick("primary", default, default, 1, 100)
$xpos = $xpos - 55
$ypos = $ypos + 30
MouseMove ($xpos, $ypos)  
  Sleep(50)
  MouseClick("primary", default, default, 1, 100)
$xpos = $xpos - 55
$ypos = $ypos + 30
MouseMove ($xpos, $ypos)  
  Sleep(50)
  MouseClick("primary", default, default, 1, 100)
$xpos = $xpos - 55
$ypos = $ypos + 30
MouseMove ($xpos, $ypos)  
  Sleep(50)
  MouseClick("primary", default, default, 1, 100)
$xpos = $xpos - 55
$ypos = $ypos + 30
MouseMove ($xpos, $ypos)  
  Sleep(50)
  MouseClick("primary", default, default, 1, 100)
EndFunc

;Harvest down and to the right 5 times.
Func HarvestDR()
$xpos = MouseGetPos(0)
$ypos = MouseGetPos(1)
  MouseClick("primary", default, default, 1, 100)
$xpos = $xpos + 55
$ypos = $ypos + 30
MouseMove ($xpos, $ypos)
  Sleep(50)
  MouseClick("primary", default, default, 1, 100)
$xpos = $xpos + 55
$ypos = $ypos + 30
MouseMove ($xpos, $ypos)
  Sleep(50)
  MouseClick("primary", default, default, 1, 100)
$xpos = $xpos + 55
$ypos = $ypos + 30
MouseMove ($xpos, $ypos)
  Sleep(50)
  MouseClick("primary", default, default, 1, 100)
$xpos = $xpos + 55
$ypos = $ypos + 30
MouseMove ($xpos, $ypos)
  Sleep(50)
  MouseClick("primary", default, default, 1, 100)  
EndFunc

;Harvest up and to the left 5 times.
Func HarvestUL()
$xpos = MouseGetPos(0)
$ypos = MouseGetPos(1)
  MouseClick("primary", default, default, 1, 100)
$xpos = $xpos - 55
$ypos = $ypos - 30
MouseMove ($xpos, $ypos)  
  Sleep(50)
  MouseClick("primary", default, default, 1, 100)
$xpos = $xpos - 55
$ypos = $ypos - 30
MouseMove ($xpos, $ypos)  
  Sleep(50)
  MouseClick("primary", default, default, 1, 100)
$xpos = $xpos - 55
$ypos = $ypos - 30
MouseMove ($xpos, $ypos)  
  Sleep(50)
  MouseClick("primary", default, default, 1, 100)
$xpos = $xpos - 55
$ypos = $ypos - 30
MouseMove ($xpos, $ypos)  
  Sleep(50)
  MouseClick("primary", default, default, 1, 100)
EndFunc

;Harvest up and to the right 5 times.
Func HarvestUR()
$xpos = MouseGetPos(0)
$ypos = MouseGetPos(1)
  MouseClick("primary", default, default, 1, 100)
$xpos = $xpos + 55
$ypos = $ypos - 30
MouseMove ($xpos, $ypos)
  Sleep(50)
  MouseClick("primary", default, default, 1, 100)
$xpos = $xpos + 55
$ypos = $ypos - 30
MouseMove ($xpos, $ypos)
  Sleep(50)
  MouseClick("primary", default, default, 1, 100)
$xpos = $xpos + 55
$ypos = $ypos - 30
MouseMove ($xpos, $ypos)
  Sleep(50)
  MouseClick("primary", default, default, 1, 100)
$xpos = $xpos + 55
$ypos = $ypos - 30
MouseMove ($xpos, $ypos)
  Sleep(50)
  MouseClick("primary", default, default, 1, 100)  
EndFunc

; Run endless loop to keep script alive.
While 1
  Sleep(10)
WEnd

Func Quit()
  Exit
EndFunc

Thanks!

-Scott

Share this post


Link to post
Share on other sites
water

Use

MouseMove(x,y,0)
This will move the mouse without delay.

BTW: The help file is your friend :idea:


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
Scottswan

Use

MouseMove(x,y,0)
This will move the mouse without delay.

BTW: The help file is your friend :idea:

Thanks, that made a big difference on the slow PC.

I can't even see the movement, but it still works. :)

-Scott

Share this post


Link to post
Share on other sites
K711

Use

MouseMove(x,y,0)
This will move the mouse without delay.

BTW: The help file is your friend :blink:

I have the same exact problem, however MouseClick("left",x,y,clicks,SPEED set to 0) still is Very slow. Even mouse moves are EXTREMELY slow. This same file runs lighning fast on my quad core Win XP machine. I am running it on a flash game. Whats strange is If I run it on the blank desktop it is super fast. It used to work fine, now its doing this. I have tried, different versions of flash, system resore all the way back to initial win xp install, windows updates in stages from Sp1/IE6 to SP3/IE8. Re-installed video drivers. I am at a wall! Please any ideas would help!

Thank you!

Share this post


Link to post
Share on other sites
tweaker

I have the same exact problem, however MouseClick("left",x,y,clicks,SPEED set to 0) still is Very slow. Even mouse moves are EXTREMELY slow. This same file runs lighning fast on my quad core Win XP machine. I am running it on a flash game. Whats strange is If I run it on the blank desktop it is super fast. It used to work fine, now its doing this. I have tried, different versions of flash, system resore all the way back to initial win xp install, windows updates in stages from Sp1/IE6 to SP3/IE8. Re-installed video drivers. I am at a wall! Please any ideas would help!

Thank you!

One thing to take into consideration is the actual speed of the mouse from the OS layer. Go into Control Panel, Mouse, Pointer Options and set your speed to Fast. See if that speeds things up for you.

Share this post


Link to post
Share on other sites
Ascend4nt

You can also modify the AutoIT 'Opt' settings for 'MouseClickDelay' and 'MouseClickDownDelay' (lookup 'Opt' in Help)

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  

×