I need help with script :(

Ask gaming related questions (AHK v1.1 and older)
chemia123456
Posts: 4
Joined: 12 Apr 2018, 18:54

I need help with script :(

12 Apr 2018, 19:10

Hello,

I'm trying to make a script that presses 2345 in a random order with a random delay.

Right now I've got this it presses the Keys 2345 when I'm pressing 2

#InstallKeybdHook
#UseHook
f11::Suspend

;pause the script by pressing f11.


*2::
SendInput, 2
Random, sleepTime, 10, 25
Sleep, %sleepTime%
SendInput, 3
Random, sleepTime, 10, 25
Sleep, %sleepTime%
SendInput, 4
Random, sleepTime, 10, 25
Sleep, %sleepTime%
SendInput, 5
return

I need script that wil write random 2-5 numbers for example: i will press number 2 then script will write 2345 or 3452 or 4325 or 5234,
it's important to make the program display four numbers after touch a button and numbers cant be "repeated"
chemia123456
Posts: 4
Joined: 12 Apr 2018, 18:54

Re: I need help with script :(

12 Apr 2018, 19:57

oh i did it xD, that was easy xD
User avatar
Cuadrix
Posts: 236
Joined: 07 May 2017, 08:26

Re: I need help with script :(

12 Apr 2018, 20:02

Congrats!
chemia123456
Posts: 4
Joined: 12 Apr 2018, 18:54

Re: I need help with script :(

13 Apr 2018, 03:51

Eh new problem, I'm so weak in this, probably a few people will laugh a little, but I did it that way, and now when i try use 24 possibilities sequence of 2-5 number - I get strange delays in the operation of the script

when i press number 2 i will get:
2345 or 2354 or 2435 or 2453 or 2534 or 2543

#InstallKeybdHook
#UseHook
f11::Suspend

;pause the script by pressing f11.


*2::
Random, variable, 1, 6
If(variable=1)
SendInput, 2
Random, sleepTime, 10, 18
Sleep, %sleepTime%
If(variable=1)
SendInput, 3
Random, sleepTime, 10, 18
Sleep, %sleepTime%
If(variable=1)
SendInput, 4
Random, sleepTime, 10, 18
Sleep, %sleepTime%
If(variable=1)
SendInput, 5
If(variable=2)
SendInput, 2
Random, sleepTime, 10, 18
Sleep, %sleepTime%
If(variable=2)
SendInput, 3
Random, sleepTime, 10, 18
Sleep, %sleepTime%
If(variable=2)
SendInput, 5
Random, sleepTime, 10, 18
Sleep, %sleepTime%
If(variable=2)
SendInput, 4
If(variable=3)
SendInput, 2
Random, sleepTime, 10, 18
Sleep, %sleepTime%
If(variable=3)
SendInput, 4
Random, sleepTime, 10, 18
Sleep, %sleepTime%
If(variable=3)
SendInput, 3
Random, sleepTime, 10, 18
Sleep, %sleepTime%
If(variable=3)
SendInput, 5
If(variable=4)
SendInput, 2
Random, sleepTime, 10, 18
Sleep, %sleepTime%
If(variable=4)
SendInput, 4
Random, sleepTime, 10, 18
Sleep, %sleepTime%
If(variable=4)
SendInput, 5
Random, sleepTime, 10, 18
Sleep, %sleepTime%
If(variable=4)
SendInput, 3
If(variable=5)
SendInput, 2
Random, sleepTime, 10, 18
Sleep, %sleepTime%
If(variable=5)
SendInput, 5
Random, sleepTime, 10, 18
Sleep, %sleepTime%
If(variable=5)
SendInput, 3
Random, sleepTime, 10, 18
Sleep, %sleepTime%
If(variable=5)
SendInput, 4
If(variable=6)
SendInput, 2
Random, sleepTime, 10, 18
Sleep, %sleepTime%
If(variable=6)
SendInput, 5
Random, sleepTime, 10, 18
Sleep, %sleepTime%
If(variable=6)
SendInput, 4
Random, sleepTime, 10, 18
Sleep, %sleepTime%
If(variable=6)
SendInput, 3
return


you can see that is only for 6 possibilities but 1 time i did that for 24 and i make it again because there was so big deley
neverlevel
Posts: 60
Joined: 13 Apr 2016, 22:02

Re: I need help with script :(

15 Apr 2018, 18:24

the big delay is probably a random number being repeated over and over.. i was working on something for you but... it will stall a while until it finds every possibility and/or gives up..what i had so far..

Code: Select all

1::
{
random, r, 2, 5
send, %r%
sleep, 200
random, r2, 2, 5
send, %r2%
sleep, 200
random, r3, 2, 5
send, %r3%
sleep, 200
random, r4, 2, 5
send, %r4%
sleep, 200
msgbox, %r%%r2%%r3%%r4%
Out = %r%%r2%%r3%%r4%
msgbox, %Out%
}

f1::pause

i was about to save the Out var to a text file or INI file and run a check to see if it has been "seen" before when i realized every repeat will cause a stuttering problem..it might spit out the first 20 possibilities or more pretty fast..then struggle to find a random unused number..until eventually the last number has a 1 in...however many chance of showing up and takes 3 minutes to spit out.. so....Untested and not working but maybe a step in the right direction for you...or completely wrong and somebody will show up to correct me.......If there is one thing people like more than helping others...it is correcting them..

well.. this is what i ended up with..for repeat usage.. you may want to delete the ini file on exit. otherwise you will have to manually delete it each time before you run it.. i know you could save the numbers internally but i suck at lists or arrays or whatever that is.

Code: Select all


#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory
found = 0           ;count the number of new 4 digit numbers with all digits between 1 and 6..excluding 1 and 6 obviously?
loopcount = 0     ;Set loop counter to 0 so it doesnt loop forever
checkagain:        ;probably not needed but its how i did it....i can goto here when i want to restart the loop from mid loop
Loop
{
If found < 255                          ; when i found out there were 256 possibilities...this check could be made instead of the loopcount.
Msgbox, all numbers possible found?  


if Loopcount > 50000
{
msgbox, i have tried 50k times to find a number
Loopcount = 0                         ; reset loop count after you OK the msgbox and keep going.. you could add the filedelete myfile.ini here
}

Loopcount+=1
random, r, 2, 5

random, r2, 2, 5

random, r3, 2, 5

random, r4, 2, 5

Out = %r%%r2%%r3%%r4%
OutputVar = 0         
IniRead, OutputVar, myfile.ini, section2, %Out%
If Outputvar !=1
{
found+=1
IniWrite, 1, myfile.ini, section2, %Out%
;send, %out%
;msgbox, %out%
;send, %r%
;sleep, 200
;send, %r2%
;sleep, 200
;send, %r3%
;sleep, 200
;send, %r4%
;sleep, 200
}
;else
;goto, checkagain
}

f1::pause
Last edited by neverlevel on 15 Apr 2018, 19:05, edited 3 times in total.
wolf_II
Posts: 2688
Joined: 08 Feb 2015, 20:55

Re: I need help with script :(

15 Apr 2018, 18:44

I suggest to make a list of all 24 possible accepted answers. Then choose a random number 1..24. Use it to get the combo of 4 digits, delete it from the list, choose random number 1..23 (one less than previous) ...
neverlevel
Posts: 60
Joined: 13 Apr 2016, 22:02

Re: I need help with script :(

15 Apr 2018, 18:56

i got 256 possibilities..
wolf_II
Posts: 2688
Joined: 08 Feb 2015, 20:55

Re: I need help with script :(

15 Apr 2018, 19:04

see example
change For each, Perm in Permutations("abcd")
to this For each, Perm in Permutations("2345")
I see 24 possible permutations, what I am doing wrong?
neverlevel
Posts: 60
Joined: 13 Apr 2016, 22:02

Re: I need help with script :(

15 Apr 2018, 19:12

nothing. i am probably misinterpreting his request and overstressing the random request and counting his cannot repeat as the 4 digit number cant repeat..not each digit .
chemia123456
Posts: 4
Joined: 12 Apr 2018, 18:54

Re: I need help with script :(

17 Apr 2018, 13:25

Now I can handle it, thanks for the help.

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: No registered users and 46 guests