Good mouse remaped on keyboard ahk script

Get help with using AutoHotkey and its commands and hotkeys
lluke
Posts: 29
Joined: 12 Feb 2018, 19:10

Good mouse remaped on keyboard ahk script

18 Oct 2018, 09:40

Is there a good script that can control mouse using keyboard?
I want to have control using 4 arrow keys even when two keys are pressed. For example I press Up and left so it goes diagonal up,left.
I stared to write some script but have problem with blocking if statements:

Code: Select all

z & i::
If GetKeyState("j")
    MouseMove, -20, -20, 0, R
  else if GetKeyState("l")
    MouseMove, 20, -20, 0, R
  else
    MouseMove, 0, -20, 0, R
Return
z & k::
If GetKeyState("j")
    MouseMove, -20, 20, 0, R
  else if GetKeyState("l")
    MouseMove, 20, 20, 0, R
  else
    MouseMove, 0, 20, 0, R
Return
unfortunately next conditions are blocked by z & j, and z & l if statements and you cannot go diagonal

Code: Select all

z & j:: MouseMove, -20, 0, 0, R  ; Win+UpArrow hotkey => Move cursor upward
 z & l::MouseMove, 20, 0, 0, R  ; Win+RightArrow => Move cursor to the right
User avatar
TheDewd
Posts: 1131
Joined: 19 Dec 2013, 11:16
Location: USA

Re: Good mouse remaped on keyboard ahk script

18 Oct 2018, 13:19

Try this:

Code: Select all

#SingleInstance, Force
#Persistent

; Z+J Left
; Z+L Right
; Z+I Up
; Z+K Down
; Z+I+J Diag-Top-Left
; Z+I+L Diag-Top-Right
; Z+K+J Diag-Bottom-Left
; Z+K+L Diag-Bottom-Right

z & j::
	If (GetKeyState("K", "P")) {
		MouseMove, -20, 20, 0, R
	} Else If (GetKeyState("I", "P")) {
		MouseMove, -20, -20, 0, R
	} Else {
		MouseMove, -20, 0, 0, R
	}
return

z & l::
	If (GetKeyState("K", "P")) {
		MouseMove, 20, 20, 0, R
	} Else If (GetKeyState("I", "P")) {
		MouseMove, 20, 20, 0, R
	} Else {
		MouseMove, 20, 0, 0, R
	}
return


z & i::
	If (GetKeyState("L", "P")) {
		MouseMove, 20, -20, 0, R
	} Else If (GetKeyState("J", "P")) {
		MouseMove, -20, -20, 0, R
	} Else {
		MouseMove, 0, -20, 0, R
	}
return

z & k::
	If (GetKeyState("L", "P")) {
		MouseMove, 20, 20, 0, R
	} Else If (GetKeyState("J", "P")) {
		MouseMove, -20, 20, 0, R
	} Else {
		MouseMove, 0, 20, 0, R
	}
return
Image Bulldozer - Sokoban inspired game from 1994 recreated in AutoHotkey.
lluke
Posts: 29
Joined: 12 Feb 2018, 19:10

Re: Good mouse remaped on keyboard ahk script

18 Oct 2018, 16:59

Thank you very much. Thats what i need :)
One more question. Is there a way to prevent of delay of first key pressed so the mouse move could be more smooth

Return to “Ask For Help”

Who is online

Users browsing this forum: Drugwash, Google [Bot], Mipha, scriptors and 68 guests