Hello im so new on ahk scripts and i am from Turkey so if i write something wrong please ignore.
I don't know how I can explain but to put it simply im trying write a step by step script.
I write something like this
1::
SendInput cvcv{enter}
Sleep 200
SendInput bitis{enter}
Sleep 1200
SendInput t/animdur{enter}
Sleep 500
SendInput t/l cc{space}{!}{space}vvv{enter}
return
I want to make this script step by step. So if I press 1 it will say "cvcv" and wait for another 1.When I press 1 again at any time I want it will say bitis. I want it to wait until I tell it to write the next line.
I hope I was able to explain my problem. I did research with my poor English, but when I could not make a conclusion I decided to open a topic. Thanks in advance
Trying to create a gradual script (I think)
-
- Posts: 4
- Joined: 12 May 2020, 04:11
Re: Trying to create a gradual script (I think)
Hallo,
try:
try:
Code: Select all
1::
SendInput cvcv{enter}
KeyWait, 1
KeyWait, 1, d
SendInput bitis{enter}
KeyWait, 1
KeyWait, 1, d
SendInput t/animdur{enter}
KeyWait, 1
KeyWait, 1, d
SendInput t/l cc{space}{!}{space}vvv{enter}
return
Re: Trying to create a gradual script (I think)
Code: Select all
1::Send()
Send() {
array := ["cvcv{enter}","bitis{enter}","t/animdur{enter}","t/l cc{space}{!}{space}vvv{enter}"]
i++
if (i > array.Length()) ? i := 1 : i := i
SendInput % array[i]
}
Remember to use [code]CODE[/code]-tags for your multi-line scripts. Stay safe, stay inside, and remember washing your hands for 20 sec !
Re: Trying to create a gradual script (I think)
The ternary statement would be like this (it’s generally used in place of if, not in conjunction with it):BNOLI wrote: ↑12 May 2020, 05:18Concept. Not tested.Code: Select all
1::Send() Send() { array := ["cvcv{enter}","bitis{enter}","t/animdur{enter}","t/l cc{space}{!}{space}vvv{enter}"] i++ if (i > array.Length()) ? i := 1 : i := i SendInput % array[i] }
Code: Select all
i := (i > array.Length()) ? 1 : i
Re: Trying to create a gradual script (I think)
Welcome dombiskerem. Your English is good enough, I think!
Rohwedder has given a good answer.
You can also make it just run once if you put ExitApp instead of Return (or there are other ways to control when and how a script runs - you might only want it happening on one window type, etc.).
Sorry, BNOLI, I tested your script and it doesn't move past cvcv. I tried moving the array initialization to auto-execute position and return, and then it didn't do anything.
Rohwedder has given a good answer.
You can also make it just run once if you put ExitApp instead of Return (or there are other ways to control when and how a script runs - you might only want it happening on one window type, etc.).
Sorry, BNOLI, I tested your script and it doesn't move past cvcv. I tried moving the array initialization to auto-execute position and return, and then it didn't do anything.
Re: Trying to create a gradual script (I think)
You might try it with the change I showed. And as I mentioned, the increment of i could be incorporated into the one line like this:
Code: Select all
i := 1
1::Send()
Send() {
static array := ["cvcv{enter}","bitis{enter}","t/animdur{enter}","t/l cc{space}{!}{space}vvv{enter}"]
SendInput % array[i]
i := (i = array.Length()) ? 1 : i + 1
}
-
- Posts: 4
- Joined: 12 May 2020, 04:11
Re: Trying to create a gradual script (I think)
Thank u so much but i have a question. It works when I press 1 as you wrote, but my another line it like this : "3:: SendInput t/abindir{enter}". When i Press 2 times its working really fine.But in the third press of 1, it writes my abindir, which is my 3rd line, How can I solve this problem ?Rohwedder wrote: ↑12 May 2020, 05:10Hallo,
try:Code: Select all
1:: SendInput cvcv{enter} KeyWait, 1 KeyWait, 1, d SendInput bitis{enter} KeyWait, 1 KeyWait, 1, d SendInput t/animdur{enter} KeyWait, 1 KeyWait, 1, d SendInput t/l cc{space}{!}{space}vvv{enter} return
I have another problem too, I wonder if I can reset this command line in the middle.
Re: Trying to create a gradual script (I think)
another idea:
Code: Select all
1::
No++
Loop, Parse,% "
(
cvcv
bitis
t/animdur
t/l cc{space}{!}{space}vvv
)",`n
IF (No = Max:=A_Index)
SendInput,%A_LoopField%{Enter}
No := Mod(No,Max)
Return
Re: Trying to create a gradual script (I think)
@boiler Nup, afraid not. Just doesn't seem to do anything. I'm not sure why.
Re: Trying to create a gradual script (I think)
I suppose this might be better than your first because it's not sitting inside the hotkey block waiting for key-ups and key-downs? It's neat anyway.Rohwedder wrote: ↑12 May 2020, 05:49another idea:Code: Select all
1:: No++ Loop, Parse,% " ( cvcv bitis t/animdur t/l cc{space}{!}{space}vvv )",`n IF (No = Max:=A_Index) SendInput,%A_LoopField%{Enter} No := Mod(No,Max) Return
Re: Trying to create a gradual script (I think)
You could also incorporate the increment of the variable into it to get rid of the separate i++ line.
That's great! Wasn't aware of that.
Sorry, BNOLI, I tested your script and it doesn't move past cvcv. I tried moving the array initialization to auto-execute position and return, and then it didn't do anything
Yep, the reason why I've labeled it as a concept, bc as I wasn't sure where to position the array (was initially set at the AutoExecute section as well), and if its content will work if used to handle keys. Thx for testing
That's great! Wasn't aware of that.
Sorry, BNOLI, I tested your script and it doesn't move past cvcv. I tried moving the array initialization to auto-execute position and return, and then it didn't do anything
Yep, the reason why I've labeled it as a concept, bc as I wasn't sure where to position the array (was initially set at the AutoExecute section as well), and if its content will work if used to handle keys. Thx for testing
Remember to use [code]CODE[/code]-tags for your multi-line scripts. Stay safe, stay inside, and remember washing your hands for 20 sec !
-
- Posts: 4
- Joined: 12 May 2020, 04:11
Re: Trying to create a gradual script (I think)
guys sorry but I don't think I can understand the language you speak Can someone say the working code pleaseahketype wrote: ↑12 May 2020, 05:59I suppose this might be better than your first because it's not sitting inside the hotkey block waiting for key-ups and key-downs? It's neat anyway.Rohwedder wrote: ↑12 May 2020, 05:49another idea:Code: Select all
1:: No++ Loop, Parse,% " ( cvcv bitis t/animdur t/l cc{space}{!}{space}vvv )",`n IF (No = Max:=A_Index) SendInput,%A_LoopField%{Enter} No := Mod(No,Max) Return
-
- Posts: 4
- Joined: 12 May 2020, 04:11
Re: Trying to create a gradual script (I think)
Guys thanks for cods its workin fine but im trying to write 31 {3}{1} like this but its write just 3 how can i fix that
Re: Trying to create a gradual script (I think)
@Rohwedder Waaaaaa?
I just realised I had no idea what Max:=A_Index was doing in there. I've found the maths function, Max(), but it doesn't mention that syntax. It looks like an ordinary variable, but can't be or it wouldn't loop, presumably, via the Mod() parameter No := Mod(No,Max).
I just realised I had no idea what Max:=A_Index was doing in there. I've found the maths function, Max(), but it doesn't mention that syntax. It looks like an ordinary variable, but can't be or it wouldn't loop, presumably, via the Mod() parameter No := Mod(No,Max).
Re: Trying to create a gradual script (I think)
Oh I think I see now - it is a normal variable, and it's assigned inside the conditional. I didn't realise you could do that.
At first I was reading it as IF (No = (Max=A_Index)), like that was testing the end of the array.
At first I was reading it as IF (No = (Max=A_Index)), like that was testing the end of the array.
Re: Trying to create a gradual script (I think)
Max stores the number of lines so that No can be reset after the loop
with No := Mod(No,Max) if necessary.
with No := Mod(No,Max) if necessary.
Re: Trying to create a gradual script (I think)
Sorry, was writing from a mobile device. Just need to make i static. This does it:
Code: Select all
1::Send()
Send() {
static i := 1
static array := ["cvcv{enter}","bitis{enter}","t/animdur{enter}","t/l cc{space}{!}{space}vvv{enter}"]
SendInput % array[i]
i := (i = array.Length()) ? 1 : i + 1
}