« 4月 2012 5月 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

2月 17 2011

PhotoshopのスクロールをG13のスティックで移動するスクリプト

PhotoshopのスクロールをG13のスティックで移動するスクリプト
G13のスティックにマウスのホイール回転とCtrlキーの組み合わせを割り当てます。
オリジナルのソースはこちらのフォーラムから。

SAIではキー割り当てでスクロールできるのですけれども、
Photoshopは「Ctrl+PageDown」とかでも10pixづつしか動ず、
通常ホイール回転をスティックに割り当てられないのでなめらかなスクロールも難しいのですが
スクリプトで何かないかと探して自分用にアレンジしました。

*注意*
・斜め方向には動かせません∈(・ω・)∋ダムー・・・

・動作の方向が気に入らない場合は一番下の
「MoveMouseWheel(-1)」
の数値を+-逆にすれば方向かわります。
数値を大きくするとスクロールのスピードも速くなります。

function OnEvent(event, arg)
    OutputLogMessage("event = %s, arg = %s\n", event, arg)
end

function OnEvent(event, arg, family)
    --OutputLogMessage("event = %s, arg = %s\n", event, arg);
    if event=="PROFILE_ACTIVATED" then
        ClearLog(); OutputLogMessage("Script Started!\n")
        toggle = 0
    end

    if event=="M_PRESSED" and toggle~=0 then
        StartFunction(current)
    end

    if event=="G_PRESSED" then
        if arg==26 then                                     -- G26= Scroll Up (Thumbstick UP)
            if toggle == 0 then
                toggle = arg
                current = "ScrollUp"
                StartFunction(current)
            end
        elseif arg==28 then                                     -- G28= Scroll Down (Thumbstick DOWN)
            if toggle == 0 then
                toggle = arg
                current = "ScrollDown"
                StartFunction(current)
            end
        elseif arg==29 then                                     -- G29= Scroll Down (Thumbstick LEFT)
            if toggle == 0 then
PressKey("lctrl")
                toggle = arg
                current = "ScrollLeft"
                StartFunction(current)
            end
        elseif arg==27 then                                     -- G27= Scroll Down (Thumbstick RIGHT)
            if toggle == 0 then
PressKey("lctrl")
                toggle = arg
                current = "ScrollRight"
                StartFunction(current)
            end
        end

    elseif event=="G_RELEASED" then
        if arg==26 then                                     -- G26= Scroll Up (Thumbstick UP)
            if toggle == arg then
                toggle = 0
            end
        elseif arg==28 then                                     -- G28= Scroll Down (Thumbstick DOWN)
            if toggle == arg then
                toggle = 0
            end
        elseif arg==29 then                                     -- G29= Scroll Down (Thumbstick LEFT)
            if toggle == arg then
ReleaseKey("lctrl")
                toggle = 0
            end
        elseif arg==27 then                                     -- G27= Scroll Down (Thumbstick RIGHT)
            if toggle == arg then
ReleaseKey("lctrl")
                toggle = 0
            end
        end
    end

end

function StartFunction(name)                                -- Handler Function
    str=name.."()"
    return assert(loadstring(str))()
end

function RepeatFunction(delay, family)                      -- Handler Function
    if delay==nil then delay=0 end
    Sleep(delay)
    if family==nil then SetMKeyState(GetMKeyState())
    else SetMKeyState(GetMKeyState(family),family)
    end
end

function ScrollUp()
    MoveMouseWheel(-1)
    RepeatFunction(10,family)
end

function ScrollDown()
    MoveMouseWheel(1)
    RepeatFunction(10,family)
end

function ScrollRight()
    MoveMouseWheel(1)
    RepeatFunction(10,family)
end

function ScrollLeft()
    MoveMouseWheel(-1)
    RepeatFunction(10,family)
end