Jump to content

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

Simulate MButton with AHK+StrokeIt


  • Please log in to reply
3 replies to this topic
teuf
  • Members
  • 5 posts
  • Last active: Apr 26 2013 06:33 AM
  • Joined: 23 Apr 2013

Hello,

 

I often use gesture recognition engine to draw on sketchup/autocad software with a pen tablet.

Sensiva work fine with Win XP but is not up to date for Win.7 or Win.8

So I try to replace Sensiva with StrokeIt.

 

Problem : Sensiva for pen tablet use both left button and right button at a time to draw gesture, StrokeIt use only one button (Left or Riht or Middle)

And if I use Left or Right button with a pen tablet, Little movements are misunderstanding so I need to use middle button setup and simulate it on the open tablet.

 

 

I would wish simulate Middle Button pressing Right Button holding Left Button,

I already try to setup Middle button on Stroke it and remap a key to middle button with AutoHotkey (²::MButton) but it's not handy to draw longtime ang quickly.

 

I'm trying to set up AutoHotkey to simulate MButton with RButton+LButton but it doesn'w work

I already tried this :

 

RButton & LButton::MButton

RButton & LButton::mouseclick, middle

~RButton & LButton::Send, {MButton}

...

 

It doesn't work.

 

Thanks for your help

Stephane



teuf
  • Members
  • 5 posts
  • Last active: Apr 26 2013 06:33 AM
  • Joined: 23 Apr 2013

A few minute ago someone replies to me on StrokeIt Forum :

 

Leo Wrote :

(...)

Try this and play with sleep in Miliseconds

 

 ~LButton & RButton::
send {MButton down}
Sleep 300
send {MButton up}

(...)

 

So

It's seems to work but it make latency.

With long gesture 300 ms are sometime too short
but with simple gesture 300 ms are too long (I use 40 different gestures)

 

Is there any way to do thid without latency, without to play with "sleep" and milliseconds ?

 

Best regards.

Stephane



Screeling
  • Members
  • 5 posts
  • Last active: Apr 24 2013 08:44 PM
  • Joined: 24 Dec 2012

http://www.autohotke...-mouse-control/

 

In regards to the dllcall, it sends a message to the windows api saying "this is a physical mouse press." Bad things CAN happen if you use dll calls, but not that they will. Also, in general you won't see a human press a key faster than 50ms and some applications have issues with immediate keydown, keyup calls.

 

With that in mind I use keybd_event calls regularly in my scripts, such as below is pressing the number 1 up and down.

 

 

DllCall("keybd_event", UChar, 0x30, int, 002, int, 0, int, 0)
Sleep 100
DllCall("keybd_event", UChar, 0x30, int, 002, int, 2, int, 0)
Sleep 100


teuf
  • Members
  • 5 posts
  • Last active: Apr 26 2013 06:33 AM
  • Joined: 23 Apr 2013

Hello Screeling,

 

Thanks to you reply (even if I don't understand the script)

 

Leo, from StrokeIt forum, give me an interesting way which work perfectly with AutoCAD (With my own AutoCAD settings of course...) :

I use a pen tablet to draw gestures and simulate the MButton to drawing gestures with LButton hording RButton.

With my pen tablet "LButton" is the pen tip and "RButton" is the side button. So I press the side button in the first time (and hold it) and draw gesture with the pen tip holding the side button.

 

 

 

 

~RButton & LButton::
send {MButton down}
Loop
{
Sleep, 10
GetKeyState, state, RButton, P
if state = U ; The key has been released, so break out of the loop.
break
}
send {MButton up}
return

 

 

 

With AutoCAD It works without any latency and without kind of problems :-)

But with Sketchup (and probably other programs) it understand only RightButton released (even if I don't release it) and show me contextual menus... (because I press RButton in first time before drawing with the LButton)

 

In my case Autocad is very most important than Sketchup and I'm very happy with this scrip but it would be interesting to find a way that work with any programs.

 

Best regards and thanks you very much.

Stephane