problem with AHK-CvJoyInterface

Ask gaming related questions (AHK v1.1 and older)
TheFatal
Posts: 34
Joined: 30 Jan 2016, 06:58

Re: problem with AHK-CvJoyInterface

02 Feb 2016, 15:32

tnx for help again

all works fine but for some reason

Code: Select all

; X Axis Forward
			this.OutputAxes.OutputAxis1.SetState(StickOps.AHKToVjoy(100))	
			Sleep 10
			; X Axis centre
			this.OutputAxes.OutputAxis1.SetState(StickOps.AHKToVjoy(50))
			Sleep 20
			; X Axis Forward
			this.OutputAxes.OutputAxis1.SetState(StickOps.AHKToVjoy(100))
X Axis centre did not separate the Axis Forward actions, so it goes like 1 hold Axis Forward i see it in game and in vjoy monitor, dont know why :( code looks correct

here is my script

Code: Select all

class TheFatalsCustomPlugin extends _Plugin {
	Type := "TheFatal's Custom Plugin"
	Description := "Your description here"
	; The Init() method of a plugin is called when one is added. Use it to create your Gui etc
	Init(){
		; Create the GUI
		; Add a hotkey, and give it the name "MyHk1". All hotkey objects can be accessed via this.InputButtons[name]
		; Have it call MyHkChangedState when it changes state.
		this.AddInputButton("IB1", 0, this.MyHkChangedState.Bind(this), "xm ym w200")
		; Add an Output, and give it the name "MyOp1". All output objects can be accessed via this.OutputButtons[name]
		this.AddOutputButton("OB1", 0, "xm yp+25 w200")
		this.AddOutputButton("OB2", 0, "xm yp+25 w200")
		this.AddOutputAxis("OutputAxis1", 0, "xm yp+25 w125")
		this.AddOutputAxis("OutputAxis2", 0, "xm yp+25 w125")
	}
 
	; Called when the hotkey changes state (key is pressed or released)
	MyHkChangedState(e){
		if (e){	; Only do this on press of the Input Button (e=1), do nothing on release (e=0)
			static StickOps := UCR.Libraries.StickOps
			; The input button was pressed, send the sequence of actions
			; Y Axis Down
			this.OutputAxes.OutputAxis2.SetState(StickOps.AHKToVjoy(100))
			Sleep 50
			; Y Axis Centre
			this.OutputAxes.OutputAxis2.SetState(StickOps.AHKToVjoy(50))
			Sleep 50
			; X Axis Back
			this.OutputAxes.OutputAxis1.SetState(StickOps.AHKToVjoy(0))
			; Hold button 1
			this.OutputButtons.OB1.SetState(1)
			Sleep 50
			; X Axis Centre
			this.OutputAxes.OutputAxis1.SetState(StickOps.AHKToVjoy(50))
			Sleep 100
			; X Axis Forward
			this.OutputAxes.OutputAxis1.SetState(StickOps.AHKToVjoy(100))	
			Sleep 100
			; X Axis centre
			this.OutputAxes.OutputAxis1.SetState(StickOps.AHKToVjoy(50))
			Sleep 100
			; X Axis Forward
			this.OutputAxes.OutputAxis1.SetState(StickOps.AHKToVjoy(100))	
			; Hold Button 2
			this.OutputButtons.OB2.SetState(1)
			; Release Button 1
			this.OutputButtons.OB1.SetState(0)
			; X Axis centre
			this.OutputAxes.OutputAxis1.SetState(StickOps.AHKToVjoy(50))
		} else {
			; Input Button was released
			; Release Button 2
			this.OutputButtons.OB2.SetState(0)
		}
	}
}
 
User avatar
evilC
Posts: 4823
Joined: 27 Feb 2014, 12:30

Re: problem with AHK-CvJoyInterface

02 Feb 2016, 16:42

X Axis centre did not separate the Axis Forward actions, so it goes like 1 hold Axis Forward i see it in game and in vjoy monitor, dont know why :( code looks correct
It's quite hard to understand what you mean here. Do you mean that you do not see it go to centre?

We are talking tiny amounts of time here. 100ms is one tenth of a second. You may not see it go to the centre. If you are unsure if it is actually going to centre, increase the length of the sleep.
TheFatal
Posts: 34
Joined: 30 Jan 2016, 06:58

Re: problem with AHK-CvJoyInterface

02 Feb 2016, 17:22

evilC wrote: Do you mean that you do not see it go to centre?
exactly i tried to increase interval by set Sleep 2000 (2 seconds) and on vjoy monitor it does not go to centre

Code: Select all

; Hold button 1
			this.OutputButtons.OB1.SetState(1)
			Sleep 50
			; X Axis Centre
			this.OutputAxes.OutputAxis1.SetState(StickOps.AHKToVjoy(50))
			Sleep 100
			; X Axis Forward
			this.OutputAxes.OutputAxis1.SetState(StickOps.AHKToVjoy(100))	
			Sleep 2000
			; X Axis Centre
			this.OutputAxes.OutputAxis1.SetState(StickOps.AHKToVjoy(50))
			Sleep 2000
			; X Axis Forward
			this.OutputAxes.OutputAxis1.SetState(StickOps.AHKToVjoy(100))	
TheFatal
Posts: 34
Joined: 30 Jan 2016, 06:58

Re: problem with AHK-CvJoyInterface

03 Feb 2016, 04:17

can u please post your vjoy configuration ?
TheFatal
Posts: 34
Joined: 30 Jan 2016, 06:58

Re: problem with AHK-CvJoyInterface

04 Feb 2016, 06:40

finnaly i fixed it to work ;)

the problem was in missing sleep, after

Code: Select all

; Release Button 1
			this.OutputButtons.OB1.SetState(0)
			
correct code is

Code: Select all

class TheFatalsCustomPlugin extends _Plugin {
	Type := "TheFatal's Custom Plugin"
	Description := "Your description here"
	; The Init() method of a plugin is called when one is added. Use it to create your Gui etc
	Init(){
		; Create the GUI
		; Add a hotkey, and give it the name "MyHk1". All hotkey objects can be accessed via this.InputButtons[name]
		; Have it call MyHkChangedState when it changes state.
		this.AddInputButton("IB1", 0, this.MyHkChangedState.Bind(this), "xm ym w200")
		; Add an Output, and give it the name "MyOp1". All output objects can be accessed via this.OutputButtons[name]
		this.AddOutputButton("OB1", 0, "xm yp+25 w200")
		this.AddOutputButton("OB2", 0, "xm yp+25 w200")
		this.AddOutputAxis("OutputAxis1", 0, "xm yp+25 w125")
		this.AddOutputAxis("OutputAxis2", 0, "xm yp+25 w125")
	}
 
	; Called when the hotkey changes state (key is pressed or released)
	MyHkChangedState(e){
		if (e){	; Only do this on press of the Input Button (e=1), do nothing on release (e=0)
			static StickOps := UCR.Libraries.StickOps
			; The input button was pressed, send the sequence of actions
			; Y Axis Down
			this.OutputAxes.OutputAxis2.SetState(StickOps.AHKToVjoy(100))
			Sleep 50
			; Y Axis Centre
			this.OutputAxes.OutputAxis2.SetState(StickOps.AHKToVjoy(50))
			Sleep 50
			; X Axis Back
			this.OutputAxes.OutputAxis1.SetState(StickOps.AHKToVjoy(0))
			; Hold button 1
			this.OutputButtons.OB1.SetState(1)
			Sleep 50
			; X Axis Centre
			this.OutputAxes.OutputAxis1.SetState(StickOps.AHKToVjoy(50))
			Sleep 150
			; X Axis Forward
			this.OutputAxes.OutputAxis1.SetState(StickOps.AHKToVjoy(100))	
			Sleep 50
			; X Axis Centre
			this.OutputAxes.OutputAxis1.SetState(StickOps.AHKToVjoy(50))
			Sleep 50
			; X Axis Forward
			this.OutputAxes.OutputAxis1.SetState(StickOps.AHKToVjoy(100))	
			Sleep 25
			; Hold Button 2
			this.OutputButtons.OB2.SetState(1)
			; Release Button 1
			this.OutputButtons.OB1.SetState(0)
			Sleep 50
			; X Axis centre
			this.OutputAxes.OutputAxis1.SetState(StickOps.AHKToVjoy(50))
		} else {
			; Input Button was released
			; Release Button 2
			this.OutputButtons.OB2.SetState(0)
		}
	}
}
 
 
tnx a lot for help dude !!!
TheFatal
Posts: 34
Joined: 30 Jan 2016, 06:58

Re: problem with AHK-CvJoyInterface

04 Feb 2016, 08:52

one more question, how can i bind a simple sequence like press button1, then button2, then button3 ?

Code: Select all

; Hold button 1
			this.OutputButtons.OB1.SetState(1)
			; Release Button 1
			this.OutputButtons.OB1.SetState(0)
			Sleep 50
			; Hold button 2
			this.OutputButtons.OB2.SetState(1)
			; Release Button 2
			this.OutputButtons.OB2.SetState(0)
			Sleep 50
			; Hold button 3
			this.OutputButtons.OB3.SetState(1)
			; Release Button 3
			this.OutputButtons.OB3.SetState(0)	
this did not work :(

full code

Code: Select all

class string1 extends _Plugin {
	Type := "string1"
	Description := "Your description here"
	; The Init() method of a plugin is called when one is added. Use it to create your Gui etc
	Init(){
		; Create the GUI
		; Add a hotkey, and give it the name "MyHk1". All hotkey objects can be accessed via this.InputButtons[name]
		; Have it call MyHkChangedState when it changes state.
		this.AddInputButton("IB1", 0, this.MyHkChangedState.Bind(this), "xm ym w200")
		; Add an Output, and give it the name "MyOp1". All output objects can be accessed via this.OutputButtons[name]
		this.AddOutputButton("OB1", 0, "xm yp+25 w200")
		this.AddOutputButton("OB2", 0, "xm yp+25 w200")
		this.AddOutputButton("OB3", 0, "xm yp+25 w200")
	}
 
	; Called when the hotkey changes state (key is pressed or released)
	MyHkChangedState(e){
		if (e){	; Only do this on press of the Input Button (e=1), do nothing on release (e=0)
			static StickOps := UCR.Libraries.StickOps
			; The input button was pressed, send the sequence of actions
			; Hold button 1
			this.OutputButtons.OB1.SetState(1)
			; Release Button 1
			this.OutputButtons.OB1.SetState(0)
			Sleep 50
			; Hold button 2
			this.OutputButtons.OB2.SetState(1)
			; Release Button 2
			this.OutputButtons.OB2.SetState(0)
			Sleep 50
			; Hold button 3
			this.OutputButtons.OB3.SetState(1)
			; Release Button 3
			this.OutputButtons.OB3.SetState(0)	
	}
}
}
 
User avatar
evilC
Posts: 4823
Joined: 27 Feb 2014, 12:30

Re: problem with AHK-CvJoyInterface

04 Feb 2016, 13:48

There's no delay between the press and the release of the buttons.
Games will quite possibly not recognize the button as having been pressed.
You probably need 20-50ms between the down (1) and up (0) event.
TheFatal
Posts: 34
Joined: 30 Jan 2016, 06:58

Re: problem with AHK-CvJoyInterface

06 Feb 2016, 03:28

ok, i got it, now i have macro on 1 input button and on 2 input button, is there any way to execute macro 1 then macro 2 with sleep times by pressing the sequence of input buttons ?
feuercau
Posts: 1
Joined: 29 Oct 2019, 17:09

Re: problem with AHK-CvJoyInterface

29 Oct 2019, 17:23

Hello evilC,
I have tried to map the POV like you posted, but there is a problem. When the script is activated the first time and I press any button of WASD, the POV "up" stays pressed until I press other buttons. Can you fix this please? One more question: I set WASD as the direction buttons. Example: I press and hold D for going to the right, now I press F at the same time and I want that something in a game jumps. When I press only F it does nothing. The jumping is activated only when I press and hold D first, then press F. How can I do that? Thank you very much for your help.

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: No registered users and 83 guests