ABOUT ME

Contact.
Email:yj.anthonyjo@gmail.com
Introduce : CS Student.

Today
-
Yesterday
-
Total
-
  • Trackpoint(트랙포인트, PointingStick)스크롤(with autohotkey)
    기타/꿀팁 2020. 12. 14. 23:31
    반응형

    얼마전 7년을 써오던 노트북을 보내주고 Hp elitebook 845 g7을 구매하여 사용하고 있다.

    디자인적으로나, 활용도의 측면에서나 고민되던 것이 있는데 바로 트랙포인트(레노버의 빨콩)이다. 색에 따라서 국내에서는 빨콩, 파콩, 검콩.. 등으로 다양하게 불린다.

     

    그냥 썩히기 아까워서 한번 사용해보려고 마음을 먹었다. 전반적으로 나쁘지 않고 익숙해지면 상당히 유용하게 쓸 수 있을 것 같다.

    하지만, 여기서 문제가 발생했다. 레노버의 Thinkpad의 경우, Middle Button이라고 해서 누르고 트랙포인트를 사용하면 스크롤이 되는 버튼이 있다. 하지만, 이 노트북의 경우 존재하지 않았다. 

    다시말해, 트랙포인트로는 스크롤을 할 수 없다는 것이다.

    이말은 즉, 웹서핑 등을 할때 스크롤이 필요하다면 어쩔 수 없이 손이 밑으로 내려와야한다는 것이다.

     

    얼마나 불편한가? 굳이 트랙포인트로 잘 사용하고 있다가 스크롤 해야되서 밑으로 내려와야한다니..

    이 트랙포인트의 활용도를 매우 떨어트리는 단점이었다.

     

    '이를 어떻게 해결할 수 있을까?' 하고 많은 커뮤니티들을 찾아보았고, 마침내 HP의 포럼에서 해답을 찾을 수 있었다.

    바로, autohotkey를 이용하는 것이었다. 지금까지 autohotkey에 대해서는 말로만 많이 들어보았고 실제로 사용해본적은 없었다. 이번기회에 설치해보고 스크립트를 만들고 실행해보았다.

    autohotkey설치는 autohotkey.com에 들어가 다운로드 후 설치하면 된다.

    스크립트는 다음과 같다.

    ScrollLock::Suspend
    
    RButton::
    CoordMode, Mouse, Screen
    MouseGetPos, posx, posy
    moved = 0
    timer = 0
    Loop
    {
     GetKeyState, state, RButton, P
     IF state = U
     {
     IF (moved != 1)
     MouseClick, Right
     Break
     }
    
     MouseMove, posx, posy, 0
    
     Sleep, 1
     timer := timer + 1
     IF (timer < 5)
     Continue
    
     timer = 0
    
     MouseGetPos, newx, newy
     diffy := Abs(newy - posy)
     diffx := Abs(newx - posx)
    
     IF (newy < posy)
     {
     moved = 1
     IF (diffy < 2)
     Click WheelUp
     ELSE IF (diffy < 15)
     Click WheelUp 2
     ELSE IF (diffy < 30)
     Click WheelUp 3
     ELSE IF (diffy < 45)
     Click WheelUp 4
     ELSE
     Click WheelUp 5
     }
     IF (newy > posy)
     {
     moved = 1
     IF (diffy < 2)
     Click WheelDown
     ELSE IF (diffy < 15)
     Click WheelDown 2
     ELSE IF (diffy < 30)
     Click WheelDown 3
     ELSE IF (diffy < 45)
     Click WheelDown 4
     ELSE
     Click WheelDown 5
     }
     IF (newx > posx)
     {
     moved = 1
     IF (diffx > 30)
     {
     Send, !{Right}
     Sleep, 100
     }
     }
     IF (newx < posx)
     {
     moved = 1
     IF (diffx > 30)
     {
     Send, !{Left}
     Sleep, 100
     }
     }
    }
    Return

    이것을 시작프로그램(Win+R -> shell:startup시 나오는 폴더)으로 지정해주었고, 정상적으로 작동하는 것을 알 수 있었다.

    https://h30434.www3.hp.com/t5/Notebooks-Archive-Read-Only/Trackpoint-scroll-on-ZBook-14/td-p/4711174

     

    Trackpoint scroll on ZBook 14

    Hey!   I love the trackpoint on my HP ZBook 14. Though I can't figure out how to scroll while using it.   Scrolling through webpages is so-so using space. It works, but it's not a great experience. This does not work when coding. I would love a way of lo

    h30434.www3.hp.com

    실행하게 되면, 마우스 우클릭 상태로 마우스를 움직이면 스크롤이 된다.

    하지만, 에러가 간혹 발생하고, Whale브라우저 같은 경우에는 오른쪽 버튼을 클릭한 채로 움직이는 것이 하나의 제스처로 사용할 수 있다.

    이점을 고려하여, 필자는 파일 이름변경외 거의 아무 역할도 없는 f2키로 대체하였다.

    #NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
    ; #Warn  ; Enable warnings to assist with detecting common errors.
    SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
    SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
    ScrollLock::Suspend
    
    $f2::
    CoordMode, Mouse, Screen
    MouseGetPos, posx, posy
    moved = 0
    timer = 0
    Loop
    {
     GetKeyState, state, f2, P
     IF state = U
     {
     IF (moved != 1)
     Send, {f2}
     Break
     }
    
     MouseMove, posx, posy, 0
    
     Sleep, 1
     timer := timer + 1
     IF (timer < 5)
     Continue
    
     timer = 0
    
     MouseGetPos, newx, newy
     diffy := Abs(newy - posy)
     diffx := Abs(newx - posx)
    
     IF (newy < posy)
     {
     moved = 1
     IF (diffy < 2)
     Click WheelUp
     ELSE IF (diffy < 15)
     Click WheelUp 2
     ELSE IF (diffy < 30)
     Click WheelUp 3
     ELSE IF (diffy < 45)
     Click WheelUp 4
     ELSE
     Click WheelUp 5
     }
     IF (newy > posy)
     {
     moved = 1
     IF (diffy < 2)
     Click WheelDown
     ELSE IF (diffy < 15)
     Click WheelDown 2
     ELSE IF (diffy < 30)
     Click WheelDown 3
     ELSE IF (diffy < 45)
     Click WheelDown 4
     ELSE
     Click WheelDown 5
     }
     IF (newx > posx)
     {
     moved = 1
     IF (diffx > 30)
     {
     Send, !{Right}
     Sleep, 100
     }
     }
     IF (newx < posx)
     {
     moved = 1
     IF (diffx > 30)
     {
     Send, !{Left}
     Sleep, 100
     }
     }
    }
    Return
    

    실행하면, f2를 누른상태로 마우스를 움직이면 스크롤이 된다.

    혹시 간단히 사용하고싶은 사람이 있을까하여, exe파일을 올려둔다.

    trackpoint_scroll.exe
    1.06MB

     

    https://autohotkey.com/board/topic/69412-send-f1-not-working/

     

    Send >+{F1} Not working - Ask for Help

    Send >+{F1} Not working - posted in Ask for Help: I need to send, in one of my scripts, multiple comands that use RShift+RCtrl+Key. But when i use the send command to send RShift or RCtrl it sends regular Ctrl or Shift.I made a test script trying to figure

    autohotkey.com

    Arceles의 답변이 도움되었다.

    더보기

    Returning the help that I obtained here I'm gonna help you:

    I had a similar problem when I wanted to map the same key... into it's same inverted functions, like this:

    '::send {?} ;same key

    ?::send {'} ;same key

    And of course it didn't worked, it send weird commands (and this is just because the ' and ? are the same key in my keyboard, the ? is gotten by using '+Shift)

    So what I did here is:

    $'::send {?} ;same key

    $?::send {'} ;same key

    And worked wonders.

     

    12/25 추가

    모니터를 한대 더 연결하고 사용하고자 하였다. 하지만, '주 모니터'로 설정된 모니터가 아닌 다른 모니터에서 해당 스크립트는 오류를 발생시켰다. 기능을 실행하고자 하면 마우스를 움직이지도 않았는데 다른 곳으로 움직인다.

    해당 오류는 MoveMouse 에서 발생하는 에러였고, 구글링 결과

    DllCall("SetThreadDpiAwarenessContext", "ptr", -3, "ptr") 을 추가하여 해결할 수 있음을 알게되었다.

     

    문제의 원인은, 두 디스플레이의 배율 설정(전체 확대)의 다름이었다. 실제로 필자의 노트북은 125%, 보조모니터는 100%의 배율로서 사용하고있다. 

    참고 : https://www.autohotkey.com/boards/viewtopic.php?t=73780

     

    MouseMove using wrong coordinates (Monitor dependent) - AutoHotkey Community

    Home Board index AutoHotkey Bug Reports Search It is currently 25 Dec 2020, 06:14 All times are UTC-05:00 Report problems with documented functionality JohnCritton Posts: 3 Joined: 23 Mar 2020, 05:23 @ Quote 23 Mar 2020, 05:45 Hi, I’m using version 1.1.3

    www.autohotkey.com

    수정된 스크립트 (+vi editor처럼 사용하면 좋겠다 싶어서 ctfl + hjkl을 각각 좌하상우 방향키역할을 할 수 있게 해두었다. (필요하지 않으신분들은, 7~10번째 줄을 없애고 사용하시면 됩니다.))

    #NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
    ; #Warn  ; Enable warnings to assist with detecting common errors.
    SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
    SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
    ScrollLock::Suspend
    
    ^h::send {left}
    ^j::send {down}
    ^k::send {up}
    ^l::send {right}
    $f2::
    CoordMode, Mouse, Screen
    DllCall("SetThreadDpiAwarenessContext", "ptr", -3, "ptr")
    MouseGetPos, posx, posy
    moved = 0
    timer = 0
    Loop
    {
     GetKeyState, state, f2, P
     IF state = U
     {
     IF (moved != 1)
     Send, {f2}
     Break
     }
    
     MouseMove, posx, posy, 0
    
     Sleep, 1
     timer := timer + 1
     IF (timer < 5)
     Continue
    
     timer = 0
    
     MouseGetPos, newx, newy
     diffy := abs(newy - posy)
     diffx := abs(newx - posx)
    
     ;ToolTip, Screen :`tx %posx% y %posy%`ndiff: x %diffx% y %diffy%
    
     IF (newy < posy)
     {
     moved = 1
     IF (diffy < 12)
     Click WheelUp
     ELSE IF (diffy < 25)
     Click WheelUp 2
     ELSE IF (diffy < 40)
     Click WheelUp 3
     ELSE IF (diffy < 55)
     Click WheelUp 4
     ELSE
     Click WheelUp 5
     }
     IF (newy > posy)
     {
     moved = 1
     IF (diffy < 12)
     Click WheelDown
     ELSE IF (diffy < 25)
     Click WheelDown 2
     ELSE IF (diffy < 40)
     Click WheelDown 3
     ELSE IF (diffy < 55)
     Click WheelDown 4
     ELSE
     Click WheelDown 5
     }
     IF (newx > posx)
     {
     moved = 1
     IF (diffx > 30)
     {
     Send, !{Right}
     Sleep, 100
     }
     }
     IF (newx < posx)
     {
     moved = 1
     IF (diffx > 30)
     {
     Send, !{Left}
     Sleep, 100
     }
     }
    }
    Return
    반응형

    댓글

Designed by Tistory.