Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Stylus middle-mouse button emulation


  • Please log in to reply
7 replies to this topic
haxor
  • Members
  • 28 posts
  • Last active: Dec 25 2014 04:57 AM
  • Joined: 22 Jun 2008

I want to emulate a middle mouse button on my Surface Pro stylus; for instance, when I tap and press the stylus button without lifting the pen. The stylus is  Wacom tech with a single button (and an eraser). The link below has exactly what I want, but I can't get it to work. I don't know it I'm doing something wrong or it's a problem specific to the Surface.

 

http://www.autohotke...tton-emulation/

 

Any ideas?



Leef_me
  • Moderators
  • 8510 posts
  • Last active: Sep 10 2015 05:50 AM
  • Joined: 08 Apr 2009

Here is a script I use when I want to know what key was pressed.

Read through the script and then run it and follows the instructions.

Try the script with you normal keyboard to see how it works and detects keypresses.

 

Then try the script with your stylus to see if the script detects the "keys" that the stylus sends.

Perhaps you can then simulate these keypresses with AHk.

#singleinstance force
#persistent
#InstallKeybdHook
#InstallMouseHook
message=
(
The window behind this message is the Key History Window
type a few keys '123'
               and then hit F5
Do you see them in the key history?
press the mouse button
               then hit F5 again
do you see what button was pushed?
The hotkey F1 will copy the text from the KeyHistory Window to the clipboard
)
KeyHistory ; Display the history info in a window.
msgbox %message%
#KeyHistory 100
;KeyHistory ; Display the history info in a window.

esc::exitapp   ; press escape key to exit script
 
f1::
WinGetText, clipboard, ahk_class AutoHotkey
return
 


haxor
  • Members
  • 28 posts
  • Last active: Dec 25 2014 04:57 AM
  • Joined: 22 Jun 2008

I've tried using Key History before, but unfortunately it doesn't show the stylus button presses directly. First of all, the stylus button is not shown at all; clicking it while not touching the screen shows a little circle icon appearing by the pointer, but it is not shown in the key history. Second, the left and right clicks shown are not always "true" clicks; for instance, if you touch the screen, drag, and release, it is visible as distinct press and release events, but if you tap the screen, wait, and then release without moving the pointer, it is seen by AHK as a press and immediate release (no delay) at the time that you let go.

 

I need a way to directly track the events of the stylus button and the true press/release events when I tap the screen. How do I get those low-level events? (Also, it would be nice to be able to track eraser-button clicks as well, which register in the key history as identical to normal taps.



lblb
  • Members
  • 120 posts
  • Last active: Dec 02 2015 08:05 AM
  • Joined: 22 May 2012

Hi haxor,

 

I don't own a Surface Pro but I have an EP121 and have been involved in the design of toolbars for art programs using AHK. That has involved a lot of playing around trying to remap Wacom pen buttons and has been successful on pretty much any Wacom-based tablet PC. I've found that the best way is to just do a simple remap.  Has wacom come up yet with a driver that allows you to assign different functions to the pen buttons (that's possible in Win 7 but I don't think it's yet available in Win 8, which I'm assuming your SP has)?

 

If not, is your pen button set to right-click? If that's the case, you can maybe just do a simple remapping like

 

rbutton::

do something

return

 

If your pen button is indeed set to right-click, then you could also explore the use of something like "Keywait" or "GetKeyState" to "do something" as long as the pen button is pressed.

 

 

Remapping the eraser on Wacom pen seems to be pretty difficult as I've found that it's usually not detected by AHK or when looking at HID devices. Maybe there is a better way around, but the only way that I have found to remap the eraser is to modify the Wacom pen settings manually (and that is probably only available with a correct Wacom driver, which you may not have). If you are interested, you can find a description of what I've found here:

http://forum.tabletp...tablet-pen.html

 

Note that in this Tablet PC forum, there are a lot of Autohotkey based solutions to make your use of your tablet easier. I would suggest you explore the following:

http://forum.tabletp....com/microsoft/

http://forum.tabletp...w.com/software/



haxor
  • Members
  • 28 posts
  • Last active: Dec 25 2014 04:57 AM
  • Joined: 22 Jun 2008

Unfortunately, there aren't any available Wacom drivers to remap the pen button or any other way of changing pen behavior. As for remapping RMB, that won't help. As I said above, the pen button doesn't actually send a right-click; a right-click is only sent if you tap while holding the button. I'd ideally like to add functionality for, say, pressing the button while pressing on the screen with the pen.



Stenemo
  • Members
  • 10 posts
  • Last active: Jun 26 2017 07:52 AM
  • Joined: 21 May 2013

This is terrible - could someone who has a tablet confirm that this is still the case? There really should be a wrka workaround for their faulty system of sending key events.

 

This sounds like the same problem AutoHotkey users have with the function key - it is also not registered correctly, and to my knowledge there is no workaround for that... I feel like I am left only with the option of using something like strokeIt, which isn't as eligant, nor has the same functionality (it rather complements AutoHotkey than substitutes it).



Stenemo
  • Members
  • 10 posts
  • Last active: Jun 26 2017 07:52 AM
  • Joined: 21 May 2013

double post



scriptor
  • Members
  • 668 posts
  • Last active: Feb 15 2016 01:02 AM
  • Joined: 20 Jun 2013

what exactly are you trying to do - are you trying to find a way to incorporate a middle click into your stylus?