eightban's memo

残しておきたい記事をまとめてみました。このブログに書いてあるドキュメントやブログで配布しているファイルの使用によって発生するいかなる損害に対してもこのブログの管理者は責任を負いません。使用する場合は自己責任のもとに使用してください。

AutoHotkey アクセシビリティ

scrollhover 画面の左右両端にマウスカーソルがあるとマウスホイールしてスクロール。画面下の部分にマウスカーソルがあると一定の時間ごとにページダウンをする autohotkey

更新日:

scrollhover

ぺんじろうさんの作成されたオートホットキースクリプトをバージョン2.0に対応させページダウンの機能を持たせたものになります。便利なものを公開していただきありがとうございます

GitHub - yasushiito/myahk

ダウンロード

スクリプト

システムトレイとスクリーンキーボードを対象外にしているので対象にしたい場合はコメントにしてください

scrollhover()

Persistent
; 2023/11/22
;マウスポインターをウィンドウの左右両端に一定期間停止させるとスクロールが始まる。
;マウスポインターがウィンドウの上半分にある時は上方向にスクロール、下半分にある時は下方向にスクロールする。
;ウィンドウの上下両端に近づくほどスクロール速度が早くなる。

;;マウスポインターをウィンドウの下部の端に一定期間停止させるとページアップページダウンが始まる。


scrollhover(){

    global scrollCnt := 0
    global scrollSpdCnt := 0
    global wtime := 500
    global dz := 8
    global kflg := 1
    SetTimer scrollWait, wtime
    Return
}
;マウスポインターが一定期間滞留したか判定するための処理。
scrollWait()
{

    global scrollCnt
    global scrollSpdCnt

    test := scrollTest()
    ;監視対象のウィンドウがある場合、そのアプリケーションが終了していたらスクロール処理も停止させる。
    if test < 0
    {
;        SetTimer scrollWait,Off
        SetTimer , 0
        SetTimer scroll,0
        ExitApp
    }
    if test > 0
    {
        scrollCnt += 1
        If scrollCnt > 2
        {
            SetTimer ,0
;            SetTimer scrollWait,Off
            scrollCnt := 0
            scrollSpdCnt := 0
            SetTimer scroll, 150
        }
        return
    }
    scrollCnt := 0
    return
}
scroll()
{

    global scrollCnt
    global scrollSpdCnt
    global wtime

    test := scrollTest()
    if test < 0
    {
        SetTimer scrollWait,0
        SetTimer ,0
;        SetTimer scroll,Off
        ExitApp
    }
    if test = 0
    {
;        SetTimer scroll,Off
        SetTimer ,0
        scrollCnt := 0
        SetTimer scrollWait, wtime
        return
    }
    if test <= 4
    {
        ; up
        spd := test -1
        direction := - 1
    }
    Else
    {
        ; scroll down
        spd := 8 - test
        direction := 1
    }
    if scrollSpdCnt >= spd
    {
        scrollSpdCnt := 0
        if direction < 0
            Send "{WheelUp}"
        Else
            Send "{WheelDown}"
    }
    Else
    {
        scrollSpdCnt += 1
    }
    return
}
scrollTest(){
    global kflg
    global dz

    CoordMode "Mouse","Screen"
    MouseGetPos &mx, &my, &ovid

    If ovid = 0
        return 0
    ret := _try.WinGetID( "ahk_class " "Shell_TrayWnd")
    If ovid = ret
        return 0
    ret := _try.WinGetID( "ahk_exe  " "osk.exe")
    If ovid = ret
        return 0

;    WinGetPos &wx, &wy, &ww, &wh, "ahk_id " ovid
;    ret := _try.WinGetPos( &wx, &wy, &ww, &wh, "ahk_id " ovid)
;
    ret := _try.WinGetPos( &wx, &wy, &ww, &wh, "ahk_id " ovid)
      ;  MsgBox ww , wh,"T5"
    If ret = 0
        return 0

    wxww := wx + ww
    If wx < 0
        wx := 0
    If wxww > A_ScreenWidth
        wxww := A_ScreenWidth

    wywh := wy + wh
    If wy < 0
        wy := 0
    If wywh > A_ScreenHeight
        wywh := A_ScreenHeight
    lbarl := wx + 2
    lbarr := wx + 20
    rbarl := wxww -20
    rbarr := wxww -2
    bbart := wywh -20-1-dz
    bbarb := wywh -1-dz
    bbar1 := wx + 20
    bbar2:= wx + Round(ww/3)
    bbar3:= wx + Round(2*ww/3)
    bbar4 := wxww - 20

;    if (my >= bbart and my <= bbarb and kflg = 1)
    if (my >= bbart and my <= bbarb )
    {
        if (mx >= bbar1 and mx <= bbar4)
        {
            sleep 3000
            MouseGetPos &mx2, &my2
            if (mx = mx2 and my = my2)
            {
                if (mx >= bbar1 and mx <= bbar2)
                    send "{PgUp}"
                if (mx > bbar2 and mx <= bbar4)
                    send "{PgDn}"
                if (mx > bbar3 and mx <= bbar4)
                    sleep 10000
                sleep 3000
            }
        }
    }
    f := 0
    ;;if mx Between lbarl and lbarr
    if (mx >= lbarl and mx <= lbarr)
        f += 1
;    if mx Between rbarl and rbarr
    if (mx >= rbarl and mx <= rbarr)
        f += 1
    if f > 0
    {
        rx := mx - wx
        ry := my - wy
        rng := Floor(wh / 8)
        If rng = 0
            stp := 1
        Else
            stp := Floor(ry / rng) + 1
        return stp
    }
    return 0
}
class _try {
	static __call(fn, p) {
		try return %fn%(p*)
		catch targeterror
			return 0
	}
}

バッチファイル

powershell -WindowStyle Hidden -Command ^
 "C:\app\AutoHotkey\AutoHotkey.exe /ErrorStdOut C:\app\AutoHotkey\scrollhover.ahk"    

-AutoHotkey, アクセシビリティ

Copyright© eightban's memo , 2024 All Rights Reserved Powered by STINGER.