多个MouseGetPos坐标

时间:2019-06-11 09:10:52

标签: autohotkey

我试图弄清楚如何使AutoHotKey脚本通过MouseGetPos同时在不同的热键上保存不同的坐标,而又不覆盖另一个。

我想循环执行一些事件序列。假设在某个点上,我希望它执行在循环之前或之中(但在操作之前)保存的第一个坐标,然后让脚本在循环中的下一个点执行另一个坐标。

我希望可以预先设置坐标(而不是在执行hotkey1之前先按Hotkey1,然后在hotkey1之后再按hotkey2,以确保不会被覆盖)。

一个例子是:

如果一个热键保存一个坐标:

hotkey1::
MouseGetPos, posx, posy,

// If inserted into a loop, it would be:
MouseMove, %posx%, %posy%,

一个热键保存另一个坐标:

hotkey2::
MouseGetPos, posx1, posy1,

// In loop:
MouseMove, %posx1%, %posy1%,

如果输入到随机循环中

#SingleInstance Force
SendMode Input
#MaxThreadsPerHotkey, 2
#NoEnv
#Persistent
SetWorkingDir %A_ScriptDir%
SetTitleMatchMode, 3
SetMouseDelay, -1

Process, Priority, , H
SetKeyDelay, -1, -1
SetDefaultMouseSpeed, 0

SetKeyDelay, 0, 10, Play 
SetMouseDelay, 10, Play

CoordMode, Mouse, Screen

hotkey1::
MouseGetPos, posx, posy,
return

hotkey2::
MouseGetPos, posx1, posy1,
return

Toggle=0
f::
Toggle := !Toggle
Loop
{
 If Toggle
   {
    Send {a}
    sleep 100
    MouseMove, %posx%, %posy%, // Say I want it to move to bottom left corner
    Send {LButton}
    sleep 100

            If !Toggle
                Break

    MouseMove, %posx1%, %posy1%, // Say this coordinate would be top-right corner
    Send {LButton}
    sleep 100
    Send {c}
   }
}
return

q::ExitApp

如果我按此顺序触发hotkey1和hotkey2,则将保存hotkey1,然后将其覆盖hotkey2,使hotkey1与hotkey2相同。我想要2个单独保存的坐标。

我是通过让一个脚本触发另一个脚本来做到这一点还是可以在一个脚本中完成?

0 个答案:

没有答案