Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Move Mouse in a Single Axis
#1
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.
An old blog on QM coding and automation.

The Macro Hook
#2
Macro Macro3111
Code:
Copy      Help
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
#3
works great.  thanks!
An old blog on QM coding and automation.

The Macro Hook
#4
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     Help - how to add the trigger to the macro
Code:
Copy      Help
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
#5
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.
An old blog on QM coding and automation.

The Macro Hook


Forum Jump:


Users browsing this thread: 1 Guest(s)