Simulated clicks on virtual Nox game d-pad

Ask gaming related questions (AHK v1.1 and older)
shardzard
Posts: 5
Joined: 17 Jan 2018, 21:31

Simulated clicks on virtual Nox game d-pad

17 Jan 2018, 22:29

i want to make this with simulated clicks instead, is it possible? https://thepasteb.in/p/Q1hBP2kk5WxC8


here the full code:

Code: Select all

a::
Click, down, 100, 800
KeyWait, b, U
return

a Up::
Click Up
return

w::
Click, down, 250, 700
KeyWait, b, U
return

w Up::
Click Up
return

d::
Click, down, 400, 800
KeyWait, b, U
return

d Up::
Click Up
return

s::
Click, down, 250, 900
KeyWait, b, U
return

s Up::
Click Up
return
User avatar
evilC
Posts: 4823
Joined: 27 Feb 2014, 12:30

Re: Simulated clicks on virtual Nox game d-pad

18 Jan 2018, 06:43

What is KeyWait, b, U for?? Why are you waiting for release of key b after every keypress?
I take it fundamentally that you are trying to convert WSAD into clicks on a virtual d-pad, but bear in mind that the technique you are using will not support diagonals.
The way I solve this problem is to break it down so that the code has a concept of "axis" (x/y) and "vector" (-1, 0, or +1) - ie any of the 8 directions can be described in this way - eg:
up+left is x= -1, y = -1
right is x= +1, y= 0
etc...

Then we build a lookup array with the coordinate for each of these axes.

Code: Select all

ClickCoords := {x: {-1: 100, 0: 250, 1: 400} , y: {-1: 700, 0: 800, 1: 900}}
So let's say you want to click on the left arrow, that's x = -1 and y = 0
looking those values up in the array, we get x=100, y=800

So then, we just need a variable to hold the current position of each "axis" - eg it starts at {x:0, y:0} and when you hold A, it changes it to {x:-1, y:0}
Then the user holds W and it changes the variable to {x: -1, y: -1}

So as you can see, you can use these "vectors" to calculate where the mouse needs to be for any combination of x/y

Code: Select all

#SingleInstance force

; --- User Configurable variables ---
; The coordinates to click at for each axis
; -1 is top or left. +1 is bottom or right
ClickCoords := {x: {-1: 100, 0: 250, 1: 400}
				, y: {-1: 700, 0: 800, 1: 900}}

; --- NON User Configurable variables ---
CurrentPos := {x: 0, y: 0}
ClickState := 0
return

w::
	HandleMouse("y", -1)
	return

s::
	HandleMouse("y", 1)
	return

s up::
w up::
	HandleMouse("y", 0)
	return

a:: 
	HandleMouse("x", -1)
	return

d::
	HandleMouse("x", 1)
	return

a up::
d up::
	HandleMouse("x", 0)
	return

HandleMouse(axis, vector){
	global ClickCoords, CurrentPos, ClickState
	if (CurrentPos[axis] == vector){
		; Key repeat tried to set axis to position it is already in - ignore
		return
	}
	CurrentPos[axis] := vector
	if (ClickState){
		; If mouse held, release it before moving it
		Send {LButton Up}
		ClickState := 0
	}
	x := ClickCoords.x[CurrentPos.x]
	y := ClickCoords.y[CurrentPos.y]
	MouseMove, x, y, 0
	Send {LButton Down}
	ClickState := 1
}
shardzard
Posts: 5
Joined: 17 Jan 2018, 21:31

Re: Simulated clicks on virtual Nox game d-pad

18 Jan 2018, 14:26

Ty for the reply @!evilC, the game itself doesnt support diagonals, i did test your code and it works just fine but it still drags my mouse to the place and i need those clicks to be a simulated mouse instead because i need mine to do other interactions while pressing the WASD buttons, also, when i use your script after pressing any of the WASD keys it nevers let go of the mouse unless i click away, it goes back to the starting point but still pressing the pad, i need it to release the mouse, idk about the keywait, i've built that code using parts of other codes for similar usage so i guess i forgot to delete that.
But, yea, basically i just need my initial code not to use my actual mouse and a simulated/virtual one instead, i've looked around and found this ControlClick thing but it doesnt seem to be compatible with the "down" command to hold the key down.
shardzard
Posts: 5
Joined: 17 Jan 2018, 21:31

Re: Simulated clicks on virtual Nox game d-pad

18 Jan 2018, 16:29

No, i just need it to no use my mouse, it is the active window however it drags my mouse to the d-pad to perform the action and i need to control the mouse while pressing wasd because i can target a character in game while walking, so basically like if the WASD was a second mouse while i still use the first one.
User avatar
evilC
Posts: 4823
Joined: 27 Feb 2014, 12:30

Re: Simulated clicks on virtual Nox game d-pad

18 Jan 2018, 17:25

ahh I see.
OK, well you have two options.

1) ControlSend *might* work, and would allow you to click the buttons without making that window active or moving the mouse.

2) Recode the script such that it flicks to the dpad window, clicks, then moves back to where it was.

So, (1) is obviously more preferable.
Fire up window spy (Start-> type "active window info")
Click on the dpad window to make it active
move the mouse over one of the dpad directions
Hit Win+A to freeze the window spy
Take a screenshot including the dpad window and the window spy window
shardzard
Posts: 5
Joined: 17 Jan 2018, 21:31

Re: Simulated clicks on virtual Nox game d-pad

18 Jan 2018, 19:29

Tried the ControlSend as in "ControlSend Click, down, 250, 900" but it did not work, not sure if im doing it correctly, i dont understand whats the purpose of window spy, is it to record exactly the position of each of my d-pad directions?
User avatar
evilC
Posts: 4823
Joined: 27 Feb 2014, 12:30

Re: Simulated clicks on virtual Nox game d-pad

18 Jan 2018, 20:42

It tells us loads of stuff about the window (and if hovered over the dpad, the control we need to interact with), the screenshot I requested should help me whip up some code to test whether it will work
shardzard
Posts: 5
Joined: 17 Jan 2018, 21:31

Re: Simulated clicks on virtual Nox game d-pad

18 Jan 2018, 21:44

Here you go https://imgur.com/a/B1n2u , first one just a click at left d-pad button and second one after the Windows+A

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: No registered users and 65 guests