3

I have two monitors one of them is a touchscreen. do somebody now a simple code in autohotkey. that you received a value, between a mouse click and a touchscreen click

I use for example Photoshop application on my main monitor 1

And I have a virtual keyboard with my (favorite keystroke combos) on my touchscreen monitor 2

I want if I do with my left hand a touchscreen click on my virtual keyboard monitor 2.

That the mouse pointer stays on my main monitor 1

So that I can proceed with PhotoShop without interrupting to move my mouse pointer back to my main monitor 1.

This is the script so far a alternative idea.

::^d ;push ctrl + d to disable the mouse pointer movement
BlockInput MouseMove 
return

::^e ;push ctrl + e to enable the mouse pointer movement
BlockInput MouseMoveOff 
return

keystarter and autohotkey with two monitors

Mike
  • 2,051
  • 4
  • 28
  • 46
arnoldburg
  • 57
  • 8
  • Hello! Let me see if I understand what you need: so you want to use the mouse on the monitor without the touchscreen and when you type something on the touchscreen monitor you dont want the mouse to move over there? (You want to have the mouse still in the monitor that does not have the touchscreen) Am I right? – RCaetano Aug 08 '16 at 14:44
  • yep, i want to use, all my favorite shortcuts (macros) on the virtual keyboard that i did maked. push it with my left hand in one click, and then proceed without interrupting that the mouse pointer goes back to touch screen monitor. [look to picture](http://www.shortcut-s.eu/wpimages/wp587236ca_05_06.jpg) – arnoldburg Aug 08 '16 at 20:40

2 Answers2

1

Distinguishing between input devices is not a trivial task with AHK. It can be done, but it's quite complicated.
If you'd be okay with interpreting every click on the touchscreen as a touch click then you could do something like this:

When the mouse moves on the normal screen  
    store it's position in a variable.

When a left click is executed on the touch screen do the click  
    move the mouse back to the last know position on the normal monitor.

You'll need:

SysGet
RegisterCallback or SetTimer+MouseGetPos
Hotkeys

Forivin
  • 14,780
  • 27
  • 106
  • 199
  • i did think in the same way like you, to move it back to the last know mouse pointer position on the normal monitor. and i now that the differency between a **touch click**-**(goes to click coordinate direct)** and **mouse click**-**(goes to click coordinate step by step)** - but i want a simple code like this - **freeze the mouse pointer if you do a touch click** - and **unfreeze the mouse pointer when i move the mouse pointer with the mouse.** – arnoldburg Aug 09 '16 at 16:54
  • Sure with some math you could sort of do it like that. But you'd have to completely override the normal left-click action and replace it with controlclick actions, otherwise you cannot "freeze" the cursor. But some applications have issues receiving `ControlClick`s properly. – Forivin Aug 09 '16 at 18:06
  • I am thinkng about this 1 - if you move the mouse pointer with your mouse then unfreeze the mouse pointer 2 - if you do stand still (not moving) and do any kind of (left)click then freeze the mouse pointer (with this you do not need to override the normal left click and replace it with control click action) – arnoldburg Aug 09 '16 at 18:24
  • You don't understand. You cannot freeze the cursor. You could block user's generated mouse mouse events, but then you have no way of finding out if he tries to move the mouse, do a left click or even a touch click. – Forivin Aug 10 '16 at 06:52
  • Ok, thanks that you did try to help me - it is not possible to make a timer with MouseGetPos and if the **mouse pointer Coordinate position is not changing and you do a left click,** you than can not freeze the mouse pointer, and unfreeze it if the **mouse pointer Coordinate is changing without doing a click.** – arnoldburg Aug 10 '16 at 08:21
  • 1
    You don't understand how touch input works. A touch click will internally move the mouse first and then do a left click. This is how Windows works internally. If you block mouse input, then you also block touch input and you won't have a way to find out if the user is trying to touch-click, click or move the mouse. – Forivin Aug 10 '16 at 08:35
  • I do understand, its difficult, but it can be done, i did tested out on my touchscreen, if you do freeze the mouse pointer, then you can do a touchscreen click without that the mouse moving to the touchscreen monitor. it blocked the internally. unfreeze it and it stays. i need only a smart code. you can test it out manually with my old alternative idea code. – arnoldburg Aug 11 '16 at 09:31
  • What do you mean by "freeze". – Forivin Aug 11 '16 at 10:11
  • disable/freeze the mouse pointer movement - BlockInput MouseMove – arnoldburg Aug 11 '16 at 13:47
1

I do not have a second monitor to fully test this code but I have tested on my main monitor which is a touchscreen. This code should do the trick :)

; Screen pixel split between monitors
; You should change this values according to the desired region of interest
screen_split_min := 0
screen_split_max := 200
; To get absolute monitor coordinates
CoordMode, Mouse, Screen

MouseGetPos, pre_mx, pre_my
While 1
{
  MouseGetPos, tmp_mx, tmp_my
  If tmp_mx > %screen_split_max%
  {
    pre_mx := tmp_mx
    pre_my := tmp_my
  }
}

~LButton::
  MouseGetPos, mx, my
  If mx <= %screen_split_max% and mx >= %screen_split_min%
  {
    MouseMove, pre_mx, pre_my, 0
  }
return

HTH ;)

RCaetano
  • 642
  • 1
  • 8
  • 23
  • this code if a good alternative for me, and it works, i did change the code a little bit. only i am thinking about a code to **(freeze the mouse pointer if you stand still and do a click)** and **(unfreeze the mouse pointer if you are moving the mouse pointer with the mouse.)** – arnoldburg Aug 09 '16 at 17:10
  • To freeze the mouse pointer after a certain time you can have a timer mechanism which would check if X seconds has passed and the mouse position did not change, then perform a click. However, to unfreeze is more complicated: I do not know how to distinguish if it was from touch screen or from mouse... Unless you assume that a certain position on the screen (e.g. monitor 1) are only available to the mouse and other (monitor 2) to the touch screen. If is this what you want tell me so I can help you with the code ;) – RCaetano Aug 09 '16 at 18:07
  • Your example code works for me , i have - main monitor 1 (x0 to x1920) (y0 to y1080) and touch monitor 2 (x1921 to x3840) (y0 to y1080) - but the pros of to freeze the mouse pointer are: 1 - you do not have to go back 2 - if you do have only one touch monitor,with this idea you can use it everwear without to choose a area. – arnoldburg Aug 09 '16 at 19:19
  • So, if the code is working this answer is correct, or not? I am saying this so if people look for a similar problem could find a solution easly. Or you want another solution? As @Forivin said, internally the mouse will always move when performing a touch click so the approach you are talking about will not work properly. – RCaetano Aug 11 '16 at 08:25
  • i can confirm to you, that code works and that the answer is correct. (on two monitors) and about what @Forivin did said - i am not agree over that. if you freeze the mouse pointer, then it will block the internally, you can self test it out only manually with your own touch screen and my old alternative idea code. you can do a touchscreen click without that the mouse pointer moving to the touchscreen monitor. – arnoldburg Aug 11 '16 at 09:49