FFIXV: Upgrade for my script. Help please! Topic is solved

Ask gaming related questions (AHK v1.1 and older)
overlord132
Posts: 14
Joined: 09 Nov 2015, 18:31

FFIXV: Upgrade for my script. Help please!

Post by overlord132 » 29 Jun 2022, 21:52

Hello!
I'm a begginer to make scripts and i took a script for diablo immortal for skill cycle. Now, i need to upgrade this script to play FFIXV.
I can send the code that i use to a start.

Well, first I need to expand the option of keybinds
1- add the numbers 5, 6, 7, 8 ,9 and 0
2- add too the F keys function like F1-F12;
3- if possible add too Q, W, E, R... until the P)

In second, I need to change the universal delay for each key, ex.: key "1" i can set 500 ms of delay and key "2" i can put 1 sec of delay. In resume, i need to set the delay for each key!

I really need it to play the game, cause i have a disable in my arms and i use only the right hand in my pc.

Code: Select all

Gui, Add, CheckBox, x2 y0 w30 h20 vum, 1
Gui, Add, CheckBox, x2 y20 w30 h20 vdois, 2 
Gui, Add, CheckBox, x2 y40 w30 h20 vtres, 3 
Gui, Add, CheckBox, x2 y60 w30 h20 vquatro, 4 
Gui, Add, Edit, x2 y80 w50 h20 vpausa, 500 
Gui, Add, Button, x60 y0 gsome, Hide 
Gui, Show, w100 h105, Untitled GUI 
return 
z:: 
gui, submit, nohide 
ativo:=1 
loop{ 
if(ativo=0){
 break 
}
 if(um=1){
 send, 1 
} 
if(dois=1){
 send, 2 
} if(tres=1){
 send, 3 
} 
if(quatro=1){
 send, 4 
} sleep, pausa 
} return 
some: 
Gui, Hide 
return 
F5::
Gui, Show 
return 
x:: 
ativo:=0 
return 
GuiClose: 
ExitApp 
return
Image

Rohwedder
Posts: 7549
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: FFIXV: Upgrade for my script. Help please!

Post by Rohwedder » 30 Jun 2022, 01:56

Hallo,
Try this.
First the input of all the keys and the individual delays. After confirmation with OK the output of the keys can be switched on/off with arrow key Down. Of course, the InputBox can be replaced by a gui:

Code: Select all

InputBox, SendTimers, Send Keys
	, Notation:`n{Key1} (Sleep1/ms)`,{Key2} (Sleep2/ms)`
	, ... `ne.g.:`t{q} 500`,{Space} 300`,{w} 100`n`nThen`
	,`tStart/Stop with Key: Down,,,200,,,,,{q} 500,{Space} 300,{w} 100

Down:: ;Start/Stop
StartStop := !StartStop
Loop, Parse, SendTimers, CSV
{
	StringSplit, KeySleep, A_LoopField, %A_Tab%%A_Space%, %A_Space%%A_Tab%
	IF StartStop
		SendTimer(A_Index, KeySleep1, KeySleep2)
	Else
		SendTimer(-A_Index)
}
Return

SendTimer(N, Output:="", Delay:=-100, AddRandom:=0)
{ 	Local D, C ;global Pseudo-Arrays: Ο%%, Τ%%, Δ%%, Ρ%%
	If (N>0 And Ο%N%>"") ;Update lock
		Return ;with Ο:Omikron, Τ:Tau, Δ:Delta, P:Rho
	Critical,% (C:=A_IsCritical)?:"Off"
	N:=Abs(N), Ο%N%:=Τ%N%:=Output, D:=Abs(Δ%N%:=Delay)
	Random, D, D, D+Ρ%N%:=AddRandom, N:=Func("T").Bind(N)
	SetTimer,% N,% (""<Output)?D:"Off"
	Critical,% C?:"Off" ;restore original criticality
	Return
}
T(N) ; called by SendTimer(), Timer function
{	Static Needle:="\{([0-9\-]{2,}|%.+%)\}|\{[^\}]*\}|."
	, BlindText:="{Blind}{Text}", Label:="SendTimerOff-"
	Critical
    Random, D, D:=Abs(Δ%N%),D+Ρ%N%,RegExMatch(Τ%N%,Needle,K)
	Random, K1, !(R:=StrSplit(K1,"-")) R.1, Max(0 R.1, 0 R.2)
	SendInput,% (StrLen(K)=1)?BlindText K:(K1?:D(K))
    SetTimer,,% D:=("0"<K1 Τ%N%:=StrReplace(Τ%N%, K,,, 1))
	?Max(D, K1?D(K1):0):(Δ%N%>0)?(D, Τ%N%:=Ο%N%):"Off"
	IF !++D And (!Ο%N%:="") And IsLabel(D:=Label N)
		SetTimer,% D, -10 ;jump to Label SendTimerOff-N
	Exit
}
D(K) ; called by T(), Deref function expands variable references
{	Static Needle := "%(.*?)%", Pos:=1
	While, Pos:=RegExMatch(K, Needle, M, Old:=Pos+StrLen(M))
		Out .= SubStr(K, Old, Pos-Old) %M1%
	Return, Out SubStr(K, Old), Pos:=1
}

overlord132
Posts: 14
Joined: 09 Nov 2015, 18:31

Re: FFIXV: Upgrade for my script. Help please!

Post by overlord132 » 30 Jun 2022, 18:22

@Rohwedder
Oh my god dude, it works very well! The script works perfectly and you help me a lot!
THANK YOU SOO MUCH!
Now, how I can make a GUI for it? Similar with the image above?

Rohwedder
Posts: 7549
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: FFIXV: Upgrade for my script. Help please!  Topic is solved

Post by Rohwedder » 01 Jul 2022, 02:36

Then, the 1st edit field is the delay, the 2nd the additional random delay:

Code: Select all

Keys = q,w,e,r,t,y,u,i,o,p,0,1,2,3,4,5,6,7,8,9
,F1,F2,F3,F4,F5,F6,F7,F8,F9,F10,F11,F12
Loop, Parse,% Keys, CSV
{
	y := 6+(A_Index-1)*20, VK := GetKeyVK(A_LoopField)
	StringUpper, Key, A_LoopField
	Gui, Add, CheckBox, x10 y%y% w35 h20 vC%VK%,% Key
	Gui, Add, Edit, xp+50 yp+2 w40 h15 vK%VK% Number, 500
	Gui, Add, Edit, xp+50 w40 h15 vR%VK% Number, 0
}
Gui, Add, Button, x55 yp+20 gsome, Hide
Gui, Show,, Untitled GUI
return
z:: ;ativo
gui, submit, nohide
Loop, Parse,% Keys, CSV
{
	VK := GetKeyVK(A_LoopField)
	IF (C%VK%) ;CheckBox
		SendTimer(A_Index, "{" A_LoopField "}", K%VK%, R%VK%)
}
return
some:
Gui, Hide
return
F5::
Gui, Show
return
x:: ;inativo
Loop, Parse,% Keys, CSV
	SendTimer(-A_Index)
return
GuiClose:
ExitApp
return
SendTimer(N, Output:="", Delay:=-100, AddRandom:=0)
{ 	Local D, C ;global Pseudo-Arrays: Ο%%, Τ%%, Δ%%, Ρ%%
	If (N>0 And Ο%N%>"") ;Update lock
		Return ;with Ο:Omikron, Τ:Tau, Δ:Delta, P:Rho
	Critical,% (C:=A_IsCritical)?:"Off"
	N:=Abs(N), Ο%N%:=Τ%N%:=Output, D:=Abs(Δ%N%:=Delay)
	Random, D, D, D+Ρ%N%:=AddRandom, N:=Func("T").Bind(N)
	SetTimer,% N,% (""<Output)?D:"Off"
	Critical,% C?:"Off" ;restore original criticality
	Return
}
T(N) ; called by SendTimer(), Timer function
{	Static Needle:="\{([0-9\-]{2,}|%.+%)\}|\{[^\}]*\}|."
	, BlindText:="{Blind}{Text}", Label:="SendTimerOff-"
	Critical
    Random, D, D:=Abs(Δ%N%),D+Ρ%N%,RegExMatch(Τ%N%,Needle,K)
	Random, K1, !(R:=StrSplit(K1,"-")) R.1, Max(0 R.1, 0 R.2)
	SendInput,% (StrLen(K)=1)?BlindText K:(K1?:D(K))
    SetTimer,,% D:=("0"<K1 Τ%N%:=StrReplace(Τ%N%, K,,, 1))
	?Max(D, K1?D(K1):0):(Δ%N%>0)?(D, Τ%N%:=Ο%N%):"Off"
	IF !++D And (!Ο%N%:="") And IsLabel(D:=Label N)
		SetTimer,% D, -10 ;jump to Label SendTimerOff-N
	Exit
}
D(K) ; called by T(), Deref function expands variable references
{	Static Needle := "%(.*?)%", Pos:=1
	While, Pos:=RegExMatch(K, Needle, M, Old:=Pos+StrLen(M))
		Out .= SubStr(K, Old, Pos-Old) %M1%
	Return, Out SubStr(K, Old), Pos:=1
}

overlord132
Posts: 14
Joined: 09 Nov 2015, 18:31

Re: FFIXV: Upgrade for my script. Help please!

Post by overlord132 » 01 Jul 2022, 16:07

@Rohwedder
It's perfect to me, thank you so much!
One last thing...

How can I implement this:

Code: Select all

Down:: ;Start/Stop
StartStop := !StartStop
in this last code?

Start/Stop function works better than Z/X for active/desactive to me.

Queue function is importan too...
e.g.: first it press the key "1" with 2 ms of delay, then come "2" with 3 seg of delay etc. then, the first key wait the order of others keys end to repeat the sequence again.

Other example, in the past, I used this to play:

Code: Select all

*1::
   SendInput, {1}
   Sleep, 2400

   SendInput, {2}
   Sleep, 2400

   SendInput, {3}
   Sleep, 2400
return

*2::
   SendInput, {1}
   Sleep, 2400

   SendInput, {4}
   Sleep, 2400

   SendInput, {5}
   Sleep, 2400
return

*3::
   SendInput, {1}
   Sleep, 2400

   SendInput, {6}
   Sleep, 2400
return

*4::
   SendInput, {=}
   Sleep, 1000

   SendInput, {3}
   Sleep, 2400

   SendInput, {5}
   Sleep, 2400

   SendInput, {6}
   Sleep, 2400
return

*'::
   SendInput, {7}
   Sleep, 2400

   SendInput, {8}
   Sleep, 2400

   SendInput, {7}
   Sleep, 2400

   SendInput, {9}
   Sleep, 2400
return
But sometimes it broke during the game, stop to work.

Rohwedder
Posts: 7549
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: FFIXV: Upgrade for my script. Help please!

Post by Rohwedder » 02 Jul 2022, 01:34

Now: Down:: ;Start/Stop. I have installed the 1-2-3 sequence twice.
Once as Sq1 constantly repeating like the other keys (give Sq1 the Delay: 2400) and once only once without initial delay by Hotkey *1::

Code: Select all

Sq1 = {1}{2}{3} ;Sequence1
Keys = q,w,e,r,t,y,u,i,o,p,0,1,2,3,4,5,6,7,8,9
,F1,F2,F3,F4,F5,F6,F7,F8,F9,F10,F11,F12
While, Sq%A_Index%
	Keys .= ",Sq" A_Index
Loop, Parse,% Keys, CSV
{
	y := 6+(-1+NK:=A_Index)*20
	StringUpper, Key, A_LoopField, T
	Gui, Add, CheckBox, x10 y%y% w35 h20 vC%A_Index%,% Key
	Gui, Add, Edit, xp+50 yp+2 w40 h15 vK%A_Index% Number, 500
	Gui, Add, Edit, xp+50 w40 h15 vR%A_Index% Number, 0
}
Gui, Add, Button, x55 yp+20 gsome, Hide
Gui, Show,, Untitled GUI
return
*1::SendTimer(99,"{1}{2}{3}", -2400)
Down:: ;Start/Stop
gui, submit, nohide
StartStop := !StartStop
Loop, Parse,% Keys Seqs, CSV
{
	IF (StartStop And C%A_Index%)
		SendTimer(A_Index, GetKeyVK(A_LoopField)?"{" A_LoopField "}"
		:%A_LoopField%, K%A_Index%, R%A_Index%)
	Else
		SendTimer(-A_Index)
}
return
some:
Gui, Hide
return
F5::
Gui, Show
return
GuiClose:
ExitApp
return
SendTimer(N, Output:="", Delay:=-100, AddRandom:=0)
{   Local D, C ;global Pseudo-Arrays: Ο%%, Τ%%, Δ%%, Ρ%%
    If (N>0 And Ο%N%>"") ;Update lock
        Return ;with Ο:Omikron, Τ:Tau, Δ:Delta, P:Rho
    Critical,% (C:=A_IsCritical)?:"Off"
    N:=Abs(N), Ο%N%:=Τ%N%:=Output, D:=Abs(Δ%N%:=Delay)
    Random, D, D, D+Ρ%N%:=AddRandom, N:=Func("T").Bind(N)
	SetTimer,% N,% (""<Output)?D*(Delay>0):"Off"
    Critical,% C?:"Off" ;restore original criticality
    Return
}
T(N) ; called by SendTimer(), Timer function
{   Static Needle:="\{([0-9\-]{2,}|%.+%)\}|\{[^\}]*\}|."
    , BlindText:="{Blind}{Text}", Label:="SendTimerOff-"
    Critical
    Random, D, D:=Abs(Δ%N%),D+Ρ%N%,RegExMatch(Τ%N%,Needle,K)
    Random, K1, !(R:=StrSplit(K1,"-")) R.1, Max(0 R.1, 0 R.2)
    SendInput,% (StrLen(K)=1)?BlindText K:(K1?:D(K))
    SetTimer,,% D:=("0"<K1 Τ%N%:=StrReplace(Τ%N%, K,,, 1))
    ?Max(D, K1?D(K1):0):(Δ%N%>0)?(D, Τ%N%:=Ο%N%):"Off"
    IF !++D And (!Ο%N%:="") And IsLabel(D:=Label N)
        SetTimer,% D, -10 ;jump to Label SendTimerOff-N
    Exit
}
D(K) ; called by T(), Deref function expands variable references
{   Static Needle := "%(.*?)%", Pos:=1
    While, Pos:=RegExMatch(K, Needle, M, Old:=Pos+StrLen(M))
        Out .= SubStr(K, Old, Pos-Old) %M1%
    Return, Out SubStr(K, Old), Pos:=1
}

Post Reply

Return to “Gaming Help (v1)”