Panning With Tablet's Pen Using Trackpad Gestures Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Jeff7171
Posts: 6
Joined: 13 Mar 2021, 11:38

Panning With Tablet's Pen Using Trackpad Gestures

Post by Jeff7171 » 13 Mar 2021, 11:54

So here's what I'm trying to do. I tried to write it myself, but it was too complicated, so I gave up lol

So I'm using OneNote, and I bought a pen tablet (CTL-472) for online teaching. I want to use my pen to pan freely/ in any direction (without using the scroll wheel because it only lets you scroll up, down, left, and right), but my pen doesn't have that feature. So my idea is... you know how when you put two fingers on your laptop's trackpad you can pan around the canvas/page by moving them any direction you want? I want to do that, but with my pen. So is there any way I can somehow remap those trackpad gestures to my pen, and activate it by pressing LShift?

Thanks, everyone.

User avatar
mikeyww
Posts: 26859
Joined: 09 Sep 2014, 18:38

Re: Panning With Tablet's Pen Using Trackpad Gestures

Post by mikeyww » 13 Mar 2021, 12:36

Does the two-finger gesture usually work in OneNote? If not, what is the usual method for panning in OneNote? When the panning happens, is it actually moving an entire window?

Below is a way to move a window with LShift.

Code: Select all

LShift::                                 ; Move the active window
WinRestore, % "ahk_id " WinActive("A")
CoordMode, Mouse
MouseGetPos, mxOrig, myOrig              ; Get initial mouse position
WinGetPos, wxOrig, wyOrig, width, height ; Get active window's position
While GetKeyState(A_ThisHotkey, "P") {
 Sleep, 10
 MouseGetPos, mxNew, myNew
 newX := wxOrig + mxNew - mxOrig, newY := wyOrig + myNew - myOrig
 WinMove, newX, newY                     ; Adjust position according to mouse distance moved
}
WinMove,,,,, Min(width, A_ScreenWidth - newX), Min(height, A_ScreenHeight - newY)
Return

Jeff7171
Posts: 6
Joined: 13 Mar 2021, 11:38

Re: Panning With Tablet's Pen Using Trackpad Gestures

Post by Jeff7171 » 13 Mar 2021, 13:32

Yes, it works anywhere. And what I mean by pan is panning the canvas or the screen inside that window.

I can't explain it well here, so here's a video to clarify it more. I'm sorry for the bg noise.
https://streamable.com/afjxhu

User avatar
mikeyww
Posts: 26859
Joined: 09 Sep 2014, 18:38

Re: Panning With Tablet's Pen Using Trackpad Gestures  Topic is solved

Post by mikeyww » 13 Mar 2021, 14:04

The following worked for me.

I added Panning Hand and Select Objects to Quick Access Toolbar. This gives you keyboard shortcuts. For me, I had Alt+7 for panning hand, and Alt+8 for selecting objects. I was then able to use my LShift and mouse to pan a drawing. You might need some adjustments for your device.

Code: Select all

#IfWinActive ahk_exe ONENOTE.EXE
LShift::
SoundBeep, 1500, 30
Send {Alt}7
Click, D
KeyWait, LShift
Click, U
Send {Alt}8
SoundBeep, 1000, 30
Return
#IfWinActive

Jeff7171
Posts: 6
Joined: 13 Mar 2021, 11:38

Re: Panning With Tablet's Pen Using Trackpad Gestures

Post by Jeff7171 » 13 Mar 2021, 15:10

The panning hand tool disables as soon as it detects my pen. It only works with my mouse.

User avatar
mikeyww
Posts: 26859
Joined: 09 Sep 2014, 18:38

Re: Panning With Tablet's Pen Using Trackpad Gestures

Post by mikeyww » 13 Mar 2021, 15:24

OK. Maybe there is a way to re-enable it. I do not have a way to test it. Others here may know more.

Jeff7171
Posts: 6
Joined: 13 Mar 2021, 11:38

Re: Panning With Tablet's Pen Using Trackpad Gestures

Post by Jeff7171 » 13 Mar 2021, 15:41

mikeyww wrote:
13 Mar 2021, 15:24
OK. Maybe there is a way to re-enable it. I do not have a way to test it. Others here may know more.
Yep, I can't use the pen and panning tool at the same time. Thanks!

Jeff7171
Posts: 6
Joined: 13 Mar 2021, 11:38

Re: Panning With Tablet's Pen Using Trackpad Gestures

Post by Jeff7171 » 13 Mar 2021, 15:46

mikeyww wrote:
13 Mar 2021, 14:04
The following worked for me.

I added Panning Hand and Select Objects to Quick Access Toolbar. This gives you keyboard shortcuts. For me, I had Alt+7 for panning hand, and Alt+8 for selecting objects. I was then able to use my LShift and mouse to pan a drawing. You might need some adjustments for your device.

Code: Select all

#IfWinActive ahk_exe ONENOTE.EXE
LShift::
SoundBeep, 1500, 30
Send {Alt}7
Click, D
KeyWait, LShift
Click, U
Send {Alt}8
SoundBeep, 1000, 30
Return
#IfWinActive
It worked! I just have to disable and re-enable the windows ink option on the settings of my pen tablet. Thank you!

Jeff7171
Posts: 6
Joined: 13 Mar 2021, 11:38

Re: Panning With Tablet's Pen Using Trackpad Gestures

Post by Jeff7171 » 13 Mar 2021, 15:52

Oh, it worked, but the pen pressure's gone. :(

User avatar
mikeyww
Posts: 26859
Joined: 09 Sep 2014, 18:38

Re: Panning With Tablet's Pen Using Trackpad Gestures

Post by mikeyww » 13 Mar 2021, 18:26

Good to hear the updates. I'm not sure whether there's something that can be done about the pressure issue (I have not tried to do that). Best of luck!

Le Hoang Nhat Minh
Posts: 1
Joined: 28 Nov 2021, 10:50

Re: Panning With Tablet's Pen Using Trackpad Gestures

Post by Le Hoang Nhat Minh » 28 Nov 2021, 10:59

I'm really appreciated your work. This post has a similar concept to mine, but I don't have the background of technology to code by myself. My idea is to use the button on my stylus pen to pan horizontally in OneNote, which can't be done due to the restriction of the program. Can you help me with this?

User avatar
mikeyww
Posts: 26859
Joined: 09 Sep 2014, 18:38

Re: Panning With Tablet's Pen Using Trackpad Gestures

Post by mikeyww » 28 Nov 2021, 12:26

I have a new version of OneNote that no longer works with this approach. Others may be able to help.

Post Reply

Return to “Ask for Help (v1)”