Saving a mouse location, to be used later in script adding 20 pixels to the y of that once per loop

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
mikeybea2
Posts: 5
Joined: 11 Dec 2017, 15:41

Saving a mouse location, to be used later in script adding 20 pixels to the y of that once per loop

13 Dec 2017, 22:55

is it possible to effectively Save a mouse location, to be used later in script, adding 20 pixels to the y of that once per loop (ending up at around 80 time per run.

Hi i have this script running at the moment, over time the mouse seems to drift off usually around the 11th loop meaning halting the process completely. I realize i could pretty easily just work out the Y value for each file, but that a lot of work.

Code: Select all

#NoEnv
SetWorkingDir %A_ScriptDir%
CoordMode, Mouse, Screen
SendMode Input
#SingleInstance Force
SetTitleMatchMode 2
#WinActivateForce
SetControlDelay 1
SetWinDelay 0
SetKeyDelay -1
SetMouseDelay -1
SetBatchLines -1


F3::
COPYINATOR:
MousePosX := 345
MousePosY := 116
TheRest:
WinActivate, ahk_exe kubioshrv.exe
Sleep, 333
/*
Press Open 
*/
Click, 9, 61 Left, 1
Gosub, MoveLocation
Sleep, 213599
SoundPlay, C:\Users\mbea204\Downloads\Homer - Woohoo! (1).wav
/*
PRESS  SAVE
*/
Click, 31, 59 Left, 1
Sleep, 500
Sleep, 19000
/*
SELECT SAVE LOCATION 
*/
Click, 913, 1843 Left, 1
Sleep, 500
Sleep, 40000
/*
EXIT 
*/
SoundPlay, C:\Users\mbea204\Downloads\front-desk-bells-daniel_simon.wav
Click, 247, 59 Left, 1
Sleep, 500
Goto, TheRest

[b]MoveLocation:
Click, %MousePosX%, %MousePosY%, 0
Sleep, 500
Click, Rel 0, 20 Left, 2
Sleep, 300
CoordMode, %MousePosX%`, %MousePosY%, Screen
MouseGetPos, 345, MousePosY
Return[/b]
its the part in bald that is really important and seems to drift. I would like it to move downby 20 pixels, save that new location carrry on with the rest of the script, and then the next loop reload those previous position and again add 20 effectivlely moving down list. Is this possible?

Thanks in advance!
User avatar
Exaskryz
Posts: 2882
Joined: 17 Oct 2015, 20:28

Re: Saving a mouse location, to be used later in script adding 20 pixels to the y of that once per loop

13 Dec 2017, 23:21

Your MouseGetPos is weird because you are putting a value into the variable 345, I do not recommend this.

But generally, see this which might help:

Code: Select all

Loop, 5
{
MouseGetPos, X, Y
MouseMove, X, Y+20
Sleep 1000
}
return
Hopefully this will give you an idea on how to handle things.

See Expressions for me using that lone percent sign. (Forced-expressions.) Edit: Boiler points out below it's not necessary, so I removed it from the code above. But leaving a link to it in case you try to use this on other commands.
Last edited by Exaskryz on 14 Dec 2017, 09:57, edited 1 time in total.
User avatar
boiler
Posts: 16931
Joined: 21 Dec 2014, 02:44

Re: Saving a mouse location, to be used later in script adding 20 pixels to the y of that once per loop

14 Dec 2017, 05:01

Your CoordMode statement towards the end of the script is also messed up.
User avatar
boiler
Posts: 16931
Joined: 21 Dec 2014, 02:44

Re: Saving a mouse location, to be used later in script adding 20 pixels to the y of that once per loop

14 Dec 2017, 05:04

Exaskryz wrote:See Expressions for me using that lone percent sign. (Forced-expressions.)
Although the percent sign isn't needed to force expressions for MouseMove. Those parameters are already accepted as expressions without it.
mikeybea2
Posts: 5
Joined: 11 Dec 2017, 15:41

Re: Saving a mouse location, to be used later in script adding 20 pixels to the y of that once per loop

14 Dec 2017, 19:07

Hi boiler and Exaskryz ! thanks for your help! I've implemented the new code and tried fixed up.

However, the issue still remains that after the usually around 20-23 loops it looses it placement and seem to open the same file which In turn stops the process ( because the program asks if you want to overwrite this output if its there twice).

it seems that its not properly saving the mouse location at that point, and the other mouse movements in the script are eventually put it off place since it still depends on the mouse position :? ? is there anyway around this?

heres the new code

Code: Select all


#NoEnv
SetWorkingDir %A_ScriptDir%
CoordMode, Mouse, Screen
SendMode Input
#SingleInstance Force
SetTitleMatchMode 2
#WinActivateForce
SetControlDelay 1
SetWinDelay 0
SetKeyDelay -1
SetMouseDelay -1
SetBatchLines -1


F3::
COPYINATOR:
X := 345
Y := 116

TheRest:
WinActivate, ahk_exe kubioshrv.exe
Sleep, 333
/*
Press Open 
*/
Click, 9, 61 Left, 1
Gosub, MoveLocation
Sleep, 213599
SoundPlay, C:\Users\mbea204\Downloads\Homer - Woohoo! (1).wav
/*
PRESS  SAVE
*/
Click, 31, 59 Left, 1
Sleep, 1200
Sleep, 19000
/*
SELECT SAVE LOCATION 
*/
Click, 913, 1843 Left, 1
Sleep, 1200
Sleep, 40000
/*
EXIT 
*/
SoundPlay, C:\Users\mbea204\Downloads\front-desk-bells-daniel_simon.wav
Click, 247, 59 Left, 1
Sleep, 500
Goto, TheRest


MoveLocation:
MouseMove, % X,% Y+20
Sleep 300
MouseClick, left, 0 , 0  , 2, 50 , ,R
Sleep 1000
MouseGetPos, X, Y
Return

User avatar
boiler
Posts: 16931
Joined: 21 Dec 2014, 02:44

Re: Saving a mouse location, to be used later in script adding 20 pixels to the y of that once per loop

14 Dec 2017, 20:27

You realize you're moving the mouse 2 pixels to the right and 50 down each time before you get the new X and Y for next time through the loop, so it slowly drifts off to the right and moves quickly down the list. I thought you wanted it to just go down 20 pixels in Y each time.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 317 guests