用于滚动的自动热键脚本

问题描述 投票:0回答:2

所以我对自动热键不太熟悉,但我希望有人帮助我编写一个脚本,每秒向上滚动鼠标滚轮并通过按住特定键来触发。

提前致谢!

autohotkey
2个回答
2
投票
F1::
    while GetKeyState("F1", "P") ; while holding down F1
    {
        SendInput, {WheelDown}   ; send this command to the active window
        Sleep, 1000              ; every second (1000 ms)
    }
return

https://www.autohotkey.com/docs/commands/While.htm


0
投票

根据我自己的需要调整 Relax 的 answer -

在 AutoHotKey v1 中

; Autoexecute
; Add below code to the top of your script
; Add more apps with GroupAdd to enable auto-scroll

GroupAdd, AutoScroll, ahk_class SUMATRA_PDF_FRAME       ; Sumatra
GroupAdd, AutoScroll, ahk_class Chrome_WidgetWin_1      ; hakuneko.exe

; Add below code anywhere in your script after Autoexecute

#If WinActive("ahk_group AutoScroll")

^+s::   ; CTRL + SHIFT + s keys
Progress, b w200 x1650 y985 ctWhite cwBlack zh0 fs9 ws1000 fm9,• Scrolling •,,,Arial
loop {      ; can release Shift and S keys once loop starts
    send {down 3}
    sleep 100
    KeyWait, Shift, d t0    ; press Shift to scroll faster
    if (ErrorLevel = 1) {
        sleep 200
    }
    KeyWait, CTRL, d t0     ; release CTRL key to break out of the loop
    if (ErrorLevel = 1) {
        Progress, Off
        break
        }
}
return

#If

在 AutoHotKey v2 中

; Autoexecute
; Add below code to the top of your script
; Add more apps with GroupAdd to enable auto-scroll

GroupAdd "AutoScroll", "ahk_class SUMATRA_PDF_FRAME"       ; Sumatra
GroupAdd "AutoScroll", "ahk_class Chrome_WidgetWin_1"      ; hakuneko.exe

; Add below code anywhere in your script after Autoexecute

#HotIf WinActive("ahk_group AutoScroll")

^+s:: {   ; CTRL + SHIFT + s
MyNotification("• Scrolling •", "200", "1650", "985")
loop {      ; can release Shift and S keys once loop starts
    send "{down}"
    sleep 30
    if !(KeyWait("Shift", "d t0") = 1) { ; press Shift to scroll faster
        MyNotification("• Scrolling •", "200", "1650", "985")
        ; increase parameter 200 (milliseconds) to slow down
        ; if notification is annoying, replace with "sleep 200" (without quotes)
    } 
    if !(KeyWait("CTRL", "d t0") = 1) { ; release CTRL key to break out of the loop
        break
        }
    }
}

#HotIf

; replace Progress command from AHK v1 with GUI in AHK v2
MyNotification(mytext, myduration, xAxis, yAxis) {
MyNotification := Gui()
MyNotification.Opt("+AlwaysOnTop -Caption +ToolWindow")  ; +ToolWindow avoids a taskbar button and an alt-tab menu item.
MyNotification.BackColor := "EEEEEE"  ; Can be any RGB color (it will be made transparent below).
MyNotification.SetFont("s9 w1000", "Arial")  ; Set font size (32-point)
MyNotification.Add("Text", "cBlack Center", mytext)  ; show progress text
MyNotification.Show("x1650 y985 NoActivate")  ; NoActivate avoids deactivating the currently active window
WinMove xAxis, yAxis,,, MyNotification
Sleep myduration
MyNotification.Destroy
}

© www.soinside.com 2019 - 2024. All rights reserved.