hi im a noob need some help here :)

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Joo Se Hyuk
Posts: 69
Joined: 05 Sep 2016, 12:52

hi im a noob need some help here :)

23 Aug 2017, 22:42

hi

im pretty new in ahk need some help guys :)

so this is my script everything works fine except one thing, i want send l every time when i push the w button, so there is my script:

w::

send l
send t
send f
send eer

start := A_TickCount
loop

{
now := A_TickCount-start
if now > 700

send 5

{
if now > 6000

send 3

{
if now > 7000
break


}
}
}

return
Joo Se Hyuk
Posts: 69
Joined: 05 Sep 2016, 12:52

Re: hi im a noob need some help here :)

24 Aug 2017, 01:05

ye but if i do this my A_TickCount loop do nothing
User avatar
DyaTactic
Posts: 221
Joined: 04 Apr 2017, 05:52

Re: hi im a noob need some help here :)

24 Aug 2017, 07:24

There seems to be a lot more you want then just w::l. The loop you wrote, does it need to run indefinedly, when should it stop?
Joo Se Hyuk
Posts: 69
Joined: 05 Sep 2016, 12:52

Re: hi im a noob need some help here :)

24 Aug 2017, 13:23

so i think no one understand me, my script working exelent and i want to keep that way BUT i also want send l button every time once when i push w button.
it there any solution for that?
newbquest2
Posts: 10
Joined: 21 Aug 2017, 05:57

Re: hi im a noob need some help here :)

24 Aug 2017, 20:33

When you say it's working "excellent", what does it do now? What do you expect it to do?

You describe it as doing this "everything works fine except one thing". Describe what it does now. I think it might not be doing what you think! Like, maybe you think that it loops, but it really only loops when you press the w button. So say what you think it does...
obeeb
Posts: 140
Joined: 20 Feb 2014, 19:15

Re: hi im a noob need some help here :)

24 Aug 2017, 23:10

I think there is a chance I understood you, you should really try to be more clear, the following will do what I think you might want:

Code: Select all

#MaxThreadsPerHotkey 2

w::
	if (running) {
		send l
		return
	}
	running := true
	
	send l
	send t
	send f
	send eer

	start := A_TickCount 
	loop 
	{
		now := A_TickCount-start
		if now > 700
			send 5

		if now > 6000
			send 3

		if now > 7000
			break
	}
	running := false
return
I also formatted your code and removed the unneeded blocks.
newbquest2
Posts: 10
Joined: 21 Aug 2017, 05:57

Re: hi im a noob need some help here :)

25 Aug 2017, 07:33

@obeeb , I'm curious what the code does. what are these thread things - could you explain your version of the code, and original OP's version -- what's happening?
obeeb
Posts: 140
Joined: 20 Feb 2014, 19:15

Re: hi im a noob need some help here :)

25 Aug 2017, 13:14

newbquest2 wrote:@obeeb , I'm curious what the code does. what are these thread things - could you explain your version of the code, and original OP's version -- what's happening?
Threads in Autohotkey are exlained in the documentation Threads. I can copy paste it here or you can just go read it, if something is not clear ask.
If you are asking about what is a Thread in general, a thread of execution simply means code that your process(program) currently executes if a process has 2 threads(not relevant to Autohotkey it only simulates threads) it means that it simultaneously executes more then one piece of code(or the same code 2 times) i.e. it does 2 things at the same time.

I will explain what the code does assuming you read the documentation.
The original code sends ltfeer and then starts a loop which does nothing for the first 700 milliseconds then sends 5 until 6 seconds have passed and then sends 3 for another second and exits the loop.
If I managed to guess OP's needs correctly he wants to press w, start the loop and while it runs press w again and send l when he does that.
Autohotkey by default allows only one thread to run for each hotkey so in order to do what he wants I needed to increase it to 2 with #MaxThreadsPerHotkey.
With the current code when you press w the first time running is set to true and the loop starts if you press w the second time while the loop runs it will send l and return.
newbquest2
Posts: 10
Joined: 21 Aug 2017, 05:57

Re: hi im a noob need some help here :)

26 Aug 2017, 21:56

obeeb wrote:...
Got it - this was very clear. I wasn't getting what OP wants, whereas you made a good guess of it.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: mstrauss2021, Spawnova, zephyrus2706 and 355 guests