Posts: 1,769
Threads: 410
Joined: Feb 2003
03-24-2021, 01:34 PM
(This post was last modified: 03-24-2021, 01:37 PM by ken gray.)
is there a way to move the mouse in only a single direction (horizontal/vertical)?
For example, hit/hold a key and the first direction a mouse moves (h/v), it only moves in that axis. So, if I wanted to draw a straight horizontal line, I would hit/hold the key trigger, and move mouse left or right and I wouldn't have to worry about it moving slightly up or down since it is only allowed to move left or right.
Posts: 12,086
Threads: 142
Joined: Dec 2002
Macro
Macro3111
int vertical=1 ;;0 horizontal, 1 vertical
POINT p; xm p
int sx sy sw sh; GetVirtualScreen sx sy sw sh
RECT r
if vertical
,r.top=sy
,r.bottom=sy+sh
,r.left=p.x
,r.right=p.x
else
,r.left=sx
,r.right=sx+sw
,r.top=p.y
,r.bottom=p.y
ClipCursor &r
5
ClipCursor 0
Posts: 1,769
Threads: 410
Joined: Feb 2003
Posts: 1,006
Threads: 330
Joined: Mar 2007
I gave a shot at the rest of your question. Hope it helps.
Note:
- I keyboard-triggered it to the letter a. I tried to trigger it from Ctrl key up/down but couldn't do it easily through the menu's. Maybe you or Gintaras knows how.
- I had to use rep loop with ifk- break instead of 'wait K' (wait for for key up) because wait for key up doesn't seem to work if initial trigger is set to be eaten. Maybe there is another better way to manage it. But seems to work!
S
Macro
VerticalOrHorizontalCursorMovement
Trigger
a
int vertical;;;;0 horizontal, 1 vertical
POINT P0; xm P0 ;;save mouse position in P
int sx sy sw sh; GetVirtualScreen sx sy sw sh
double dHeight = sh
double dWidth = sw
double scaleCorrection = dWidth/dHeight
out scaleCorrection
WaitForMouseAction(1);err ret
0.01
POINT P1; xm P1
int xdiff = P1.x-P0.x
if xdiff < 0; xdiff =xdiff*-1
int ydiff = P1.y-P0.y
if ydiff < 0; ydiff =ydiff*-1
if xdiff > (ydiff*scaleCorrection);
,vertical = 0
,OnScreenDisplay "horizontal" 1 0 0 "" 0 0 32
else
,vertical=1
,OnScreenDisplay "vertical" 1 0 0 "" 0 0 32
RECT r
if vertical
,r.top=sy
,r.bottom=sy+sh
,r.left=P0.x
,r.right=P0.x
else
,r.left=sx
,r.right=sx+sw
,r.top=P0.y
,r.bottom=P0.y
ClipCursor &r
rep 10
,0.5
,ifk-(a)
,,break
ClipCursor 0
Posts: 1,769
Threads: 410
Joined: Feb 2003
oooooo.....this works great! I tied it to the backtic (cause I almost never use it).
My keyboard keeps me from tying it to scroll lock which I've never used.