鼠标在特定位置时,让AutoHotKey键盘快捷键

时间:2017-02-19 02:55:47

标签: autohotkey

当我的鼠标位于屏幕上的某个位置(在这种情况下,低于1070像素)时,我是一个完整的新手白痴试图编写一个AutoHotKey脚本来执行键盘快捷键(在本例中为windows button + t) 。这就是我所写的内容,我认为它实际上没有做任何事情。

CoordMode, Mouse, Screen
Check:
MouseGetPos, yy
if (yy < 1070) {
    Send {LWin down}t{LWin up}
Return
}

语法可能与AutoHotKey实际上看起来的样子有所不同,但在阅读了一些论坛帖子后,我仍然无法分辨出我做错了什么。谢谢!

2 个答案:

答案 0 :(得分:1)

此代码字面上您要求的

Loop {
    MouseGetPos, x, y
    if (y < 1070){
        Send {LWin down}t{LWin up}
    }
    Sleep 10 ; Avoid excessive CPU usage
}

然而,虽然y <&lt; 1070,它将不断发送密钥组合。 我猜你只想在鼠标首次“进入”区域时发送密钥组合。

last_pos := 999999  ; Set initial value really high
Loop {
    MouseGetPos, x, y
    if (y < 1070 && last_pos >= 1070){
        Send {LWin down}t{LWin up}
    }
    last_pos := y
    Sleep 10 ; Avoid excessive CPU usage
}

答案 1 :(得分:0)

#t:: ;This will assign the window + t key to do something

{

Click 701,480      ;This clicks to a certain position on the screen. Autoit software can find the coordinates on the screen for you.

Send Hello         ;This will write something in an area like if its on a webpage or something.

Send {Return} 
     {Space}
     {ESC}
     {up}     ;The {} Hold different keystrokes to use- https://autohotkey.com/docs/commands/Send.htm

Sleep 300     ;This allows you to pause the program, you may need something to finish loading in.



}

这只是您将来使用的一些背景信息,使用Clive Galway所说的适合您,如果您想要做某事的位置设置使用Click ....,....如果它可能在不同的点使用上述答案。

相关问题