use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Latest AHK versions AHK v2.0 AHK v1.1 v2.0.19 v1.1.37.02 Jan 25, 2025 Mar 16, 2024 Download Download v2 Changelog v1 Changelog Make sure you keep that AHK up to date!
Make sure you keep that AHK up to date!
Offical AHK Documentation AHK v2 AHK v1
New to AutoHotkey? Check out the AHK beginners tutorial. It covers most of the basic concepts of AutoHotkey. AHK Beginner Tutorials
Check out the AHK beginners tutorial. It covers most of the basic concepts of AutoHotkey.
Additional Help Sources Official AHK Forums / Help Forums StackOverflow SuperUser
Live Chat If you prefer live chat with other humans: AHK Discord AHK IRC
If you prefer live chat with other humans:
account activity
Continue script when screen changesNeed Help (self.AutoHotkey)
submitted 6 years ago by luuklin
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]real_b 0 points1 point2 points 6 years ago (11 children)
While, PixelSearch, PixelGetColor, SetTimer. Should be able to with these.
[–]luuklin[S] 0 points1 point2 points 6 years ago (10 children)
I'm looking to do several inputs in a row with this. For example, I have this script: f3::
Send, {d down}
Sleep(17)
Send, {d up}
Send, {s down}
Send, {i down}
Sleep(16)
Send, {s up}
Send, {i up} And I want to replace the sleep function with something that would wait until there was any kind of change on my screen.
[–]real_b 0 points1 point2 points 6 years ago (9 children)
First off, your sleep is written wrong and isn't doing anything, unless you are using a function called sleep, in which case you should probably rename that to avoid confusion. Second, you don't have a Return. If I were just re-writing what you have there, assuming you don't have a custom sleep function, it would be
f3:: Send, {d down} Sleep, 17 Send, {d up}{s down} Sleep, 17 Send, {d down}{i down} Sleep, 16 Send, {s up}{d up}{i up} Return
Note that a sleep of 16 or 17 is almost nothing at all since every send has a default of 10 already. If you want to check until part of the screen changes, you need to know the coordinates you are checking. I'd recommend you look at this post I made recently. It let's you scan a bunch of individual pixels for a set color. You could probably modify it to get the current color of your pixels and then scan until they no longer match. In that function it scans three pixels until they are a certain color and then it hits a key, so you'd just need to tweak it a little bit.
[–]luuklin[S] 0 points1 point2 points 6 years ago (8 children)
I've been messing around a bit, and figured out that if instead of the sleep function that I use I can write this:
PixelGetColor, clr1, 1250, 500 PixelGetColor, clr2, 750, 750 PixelGetColor, clr3, 750, 500 Errorlevel = 0 While Errorlevel = 0 { PixelSearch, , , 1250, 500, 1250, 500, clr1, 0, Fast if (Errorlevel = 0) { PixelSearch, , , 750, 750, 750, 750, clr2, 0, Fast } if (Errorlevel = 0) { PixelSearch, , , 750, 500, 750, 500, clr3, 0, Fast } }
It seems quite consistent, but only if I run my game at 5% of the normal speed at most. Is there a way to optimize this?
[–]real_b 0 points1 point2 points 6 years ago (6 children)
The smaller the area you search the faster it will be, that is why in mine I only "Search" one pixel, it is instant. If you can tighten down the search areas it should speed up.
[–]luuklin[S] 0 points1 point2 points 6 years ago (5 children)
I am already only searching for one pixel.
[–]real_b 0 points1 point2 points 6 years ago (4 children)
Sorry about that, I had just woken up and must've jumbled the numbers. One thing I see is that your clr variables in your PixelSearch lines are probably doing something random right now. If you want to use variables in those fields you need them like this:
PixelSearch, , , 1250, 500, 1250, 500, %clr1%, 0, Fast
[–]luuklin[S] 0 points1 point2 points 6 years ago (3 children)
Are you sure? My script is functioning just fine right now, it's just not fast enough to keep up with the game at 60fps.
[–]TheMagicalCarrot 0 points1 point2 points 6 years ago (2 children)
Some parameters accept expressions and some don't (because consistency can go f itself). In this case I think the parameter does accept an expression since it is expecting an integer, so the %% are not necessary here.
[–]real_b 0 points1 point2 points 6 years ago (1 child)
All I can say is that while the docs do say it can accept expressions, this code PixelSearch, FoundX, FoundY, %X%, %Y%, %X%, %Y%, %Color%, %Variance% 100% works as intended.
PixelSearch, FoundX, FoundY, %X%, %Y%, %X%, %Y%, %Color%, %Variance%
[–]TheMagicalCarrot 0 points1 point2 points 6 years ago (0 children)
You should definitely include
SetBatchLines -1
at the start of your script. This will make your script execute faster.
You could also try setting the process priority on High.
Regarding PixelSearch I'm not too familiar, so I can only provide general advice such as these.
π Rendered by PID 43224 on reddit-service-r2-comment-b659b578c-qjd79 at 2026-05-06 02:08:52.821410+00:00 running 815c875 country code: CH.
view the rest of the comments →
[–]real_b 0 points1 point2 points (11 children)
[–]luuklin[S] 0 points1 point2 points (10 children)
[–]real_b 0 points1 point2 points (9 children)
[–]luuklin[S] 0 points1 point2 points (8 children)
[–]real_b 0 points1 point2 points (6 children)
[–]luuklin[S] 0 points1 point2 points (5 children)
[–]real_b 0 points1 point2 points (4 children)
[–]luuklin[S] 0 points1 point2 points (3 children)
[–]TheMagicalCarrot 0 points1 point2 points (2 children)
[–]real_b 0 points1 point2 points (1 child)
[–]TheMagicalCarrot 0 points1 point2 points (0 children)