Jump to content

Speed up mouse move


Recommended Posts

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

Link to comment
Share on other sites

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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

  • 1 month later...

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!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

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...