make me an ahk scrip i want a countdown loop from 1-3
- User
make me an ahk scrip i want a countdown loop from 1-3
- Assistant
Sure! Here's a simple AutoHotkey (AHK) script that counts from 1 to 3 with a 1-second delay between each number, and loops indefinitely:
#Persistent ; Keeps the script running Loop { Loop, 3 { Msg := A_Index ; 1, 2, 3 Tooltip, %Msg% ; Display the current count Sleep, 1000 ; Wait 1 second } }If you want to display the countdown in the console or output window instead of a tooltip pop-up, AutoHotkey doesn't have an in-built console, but you can use
TrayTiporTooltipas above. Let me know if you want the count to be sent as keyboard input or shown differently! - User
ok, but i dont want it to follow my mouse
- Assistant
Got it! The previous script uses
Tooltip, which by default follows the mouse cursor. To display the countdown numbers without following your mouse, you can specify a fixed position for the tooltip.Here's an updated version of the script where the tooltip stays fixed at the top-left corner of your screen:
#Persistent ; Keeps the script running Loop { Loop, 3 { Tooltip, %A_Index%, 10, 10 ; Display the count at coordinates (x=10, y=10) Sleep, 1000 ; Wait 1 second } Tooltip ; Clears the tooltip after each full cycle }Explanation:
Tooltip, %A_Index%, 10, 10shows the count at screen coordinates (10,10) instead of near the mouse cursor.Tooltipwithout parameters clears the tooltip.
Let me know if you'd like it displayed elsewhere or in another way!
- User
ok, can u change the color of the numbers, 1 is blue, 2 is green, 3 is bold red
- Assistant
AutoHotkey's built-in
Tooltipcommand doesn't support changing text color or font styles like bold directly.To achieve colored and styled text, you can use a GUI window instead of a tooltip. Here's a script that creates a small GUI fixed on the screen and updates the number with the colors and bold style you want:
#Persistent #NoTrayIcon ; Create the GUI window for the countdown Gui, +AlwaysOnTop -Caption +ToolWindow ; Always on top, no title bar or taskbar icon Gui, Color, 000000 ; Optional: set background black (or change as needed) Gui, Font, s48 ; Set font size to 48 (you can adjust) Gui, Add, Text, vCountText hwndCountHWND Center x0 y0 w100 h60, ; Placeholder for numbers Gui, Show, x10 y10 NoActivate, Countdown Loop { ; 1 in blue GuiControl,, CountText, 1 GuiControlGet, hwnd, hwnd, CountText Gui, Font, s48 c0000FF ; Blue color, size 48 GuiControl,, CountText, 1 Gui, Show, NoActivate, Countdown Sleep, 1000 ; 2 in green Gui, Font, s48 c008000 ; Green color (darker green) GuiControl,, CountText, 2 Gui, Show, NoActivate, Countdown Sleep, 1000 ; 3 in bold red Gui, Font, s48 cFF0000 Bold ; Red color, bold, size 48 GuiControl,, CountText, 3 Gui, Show, NoActivate, Countdown Sleep, 1000 } return GuiClose: GuiEscape: ExitApp - User
i want the tooltip can u style it in anyway?
- Assistant
AutoHotkey's built-in
Tooltipcommand is very limited and does not support any text styling like color, font size, or bold directly.The tooltip is a very simple OS-level feature that only displays plain text, and unfortunately, you cannot change its color or make text bold.
What can you do with Tooltip?
- You can change position (x, y).
- You can set the text.
- You can show or hide it.
What can't you do with Tooltip?
- Change text color.
- Change font size or style.
- Add bold or other rich text effects.
Alternative: Using a GUI
If you want styled text (colored, bold, different fonts), your best bet is to create a tiny GUI window as in the example I gave before. It behaves like a tooltip (appears near the screen corner, on top, no border) but gives full control over font, color, boldness, etc.
Summary
- User
gui blocks other commands
- Assistant
- User
can i use 2 tooltips for the same thing? but in different coordinates
- Assistant
AutoHotkey's built-in
Tooltipcommand supports displaying only one tooltip window at a time per script. If you callTooltipagain, it will update or replace the existing tooltip—you cannot show two active tooltips simultaneously using the standardTooltipcommand.
Summary:
- User
my tooltip is stopping when i press a numpad number, i dont want it to be interrupted
- Assistant
- User
this is myu unumpad script
Numpad3:: ; 3 runa ataque aoe While GetKeyState("Numpad3","P") && !AutoPanickActive { Random, offsetX, -5, 5 Random, offsetY, -5, 5
Send, {Alt down}{Numpad3}{Alt up} MouseClick, Left, 3134 + offsetX, 215 + offsetY ; sqm primeiro monstro battle Random, sleepDuration, 1010, 1020 Sleep, %sleepDuration% Send, {2} Sleep, %sleepDuration%} Return
- Assistant
- User
i dont wanna change how my num3 is working, its as its supposed to be, while im pressing the key it does my combo randomizing its seconds to not get caught
- Assistant
- User
i cant change the randomizing and sleep factor , it needs to run every 1 and change seconds while im pressing the key i also dont want it to block my other scripts
- Assistant
- User
i will send u my whole script and then u break it for me into different scripts as u see fit so nothing gets blocked my needs: autopanick should be running at all times and not get interrupted , auto heal is the same, but i can do someworkarounds with it, the tooltip should not get interrupted, the rest are simple combos that could either get interrupted or happens only when i press a key so it doesnt really matter
- Assistant
Sure! Please send me your full script and I'll help break it down into separate scripts/modules so that the key features like AutoPanick, AutoHeal, and the Tooltip run uninterrupted, while other combo scripts run as hotkeys without blocking the core functionality.
- User
- Assistant
- User
In script A, autoheal wont block auto panick?
- Assistant
Great question!
In Script A (Core.ahk), both AutoPanick and AutoHeal run via separate
SetTimers with different intervals:AutoPanicktimer runs every 50 msAutoHealtimer runs every 1100 ms (1.1 sec)
Because they’re timer-based and very lightweight,
AutoHealwill NOT blockAutoPanickas long as each timer subroutine finishes quickly.
Important points:
- User
in script A , why did u do this :
UpdateTooltip: Tooltip, %count%, 1889, 938 Tooltip, %count%, 1889, 651 count++ if (count > 3) count := 1 return
and to keep it like this :
Loop { Loop, 3 { Tooltip, %A_Index%, 1889, 938 ; Display the count at coordinates (x=10, y=10) Tooltip, %A_Index%, 1889, 651 ; Display the count at coordinates (x=10, y=10) Sleep, 1000 ; Wait 1 second
} Tooltip ; Clears the tooltip after each full cycle}
- Assistant
- User
ok, its cool, so the tooltip would never break my autopanick right?
- Assistant
Exactly! Since the tooltip update runs via
SetTimer(which executes its subroutine briefly and asynchronously), it does not block or interfere with your AutoPanick routine.To summarize:
- Tooltip updates are lightweight and quick.
- They run every 1 second via timer, then immediately return.
- Meanwhile, your AutoPanick timer (running every 50 ms) and other subroutines continue to run freely.
- No blocking loops or sleeps in the tooltip code = no interrupts.
So your AutoPanick will run smoothly without interruptions from the tooltip, and the tooltip will keep updating as intended.
Let me know if you want me to help with anything else!
- User
nice, ill trust you, now im gonna analyze script b
- Assistant
Sounds great! Take your time reviewing Script B. If you find anything you'd like optimized or if you want suggestions on how to handle those blocking loops more efficiently (while keeping your random sleeps and combo logic intact), just let me know.
I'm here to help make sure everything runs smoothly and as you want it!
Good luck analyzing, and don’t hesitate to ask!
- User
in script B and C, do i need to have this line ? global AutoPanickActive
because autopanick is from another script, so how can it be active?
- Assistant
- User
i dont understand, will it work or not because of the flag?
- Assistant
Thanks for asking for clarity — this is an important point!
- User
so , if i run script B and press num3, its gonna run or not? i know its gonna check for the flag but tthere s no flag because its in another script
- Assistant
Exactly — if you run Script B alone (or alongside Script A, but without any inter-script communication), and press
Numpad3:- Script B will check its own local
AutoPanickActivevariable. - Since Script B has no knowledge of Script A’s
AutoPanickActive, this variable will befalse(or undefined) by default. - So the condition
!AutoPanickActivewill be true. - Therefore, your
Numpad3loop will run regardless of whether Script A’s AutoPanick is active or not.
So, to answer your question plainly:
If you do not implement any sharing or synchronization, pressing Numpad3 in Script B will run the loop no matter what Script A is doing, because Script B doesn’t actually know if panic is active.
What you need to do to prevent that:
- Implement a shared flag (e.g., a small file) indicating panic state.
- Script B will check its own local
- User
so i dont need to change anything for it to work right?
- Assistant
You do need to make changes if you want Script B (and others) to respect the
AutoPanickActivestatus from Script A.
Here's why:
- Variables like
AutoPanickActiveare not shared automatically between separate scripts. - Without some way to share that state (like via a file, WM_COPYDATA message, or other IPC), each script's
AutoPanickActiveis independent. - So if Script B checks
if AutoPanickActive, it only sees its own variable, which by default is false. - This means Script B has no idea if Script A set panic mode.
Therefore:
- If you want Script B to pause combos during AutoPanick in Script A, you must implement inter-script communication, e.g. sharing the panic flag via a file or other method.
- If you don't do this, Script B will NOT pause and will run combos regardless of AutoPanick.
TL;DR:
- To keep the behavior you want,
- Variables like
- User
i dont want it to check the flag, i dont need it to check the flag anymore, the only reason it was there it was to not interfere with autopanick but since its in another script now i just need it to run when i press the keys and not care if it will interrupt other macros because it wont
- Assistant
Got it! Thanks for clarifying.
So your goal now is:
- Scripts are separated.
- Script B’s combos just run when you press the keys, without any check for
AutoPanickActiveat all. - You don't care if combos interrupt anything, because the critical stuff (AutoPanick/AutoHeal/Tooltip) is in another script and won't be blocked.
- You just want your combos to work independently and freely.
In that case:
You do NOT need to keep any
AutoPanickActivechecks in Script B or C anymore.Simply remove all these conditions like:
while GetKeyState("Numpad3","P") && !AutoPanickActiveand replace with:
while GetKeyState("Numpad3","P")
This will make combos run whenever you press the keys, without caring about panick or other scripts.
Summary:
- No shared flags needed.
- User
but does it need to ? or it wont make any difference? explain to me and please, the the adjustments for script b and c so its cleaner
- Assistant
- User
- Assistant
- User
whbat about these bits
lastAutoPanickTime := 0
FullRotationsemUtitoIndex := 0
autoRopeAndShovelIndex := 0 autoCaniVetesIndex := 0 autoFoodCombinationIndex := 0 toggle := false ; Initialize the toggle variable at the start
AfkKillCompletoIndex := 1
- Assistant
Great question!
These lines are variable initializations, important for your script to start with well-defined values.
Where to place them and how to handle them now that your script is split?
1.
- User
dont want examples, assign them for the right scripts for me , A, B and C, although i think u already did that for script A
- Assistant
Certainly! Here is the assignment of those variables to each script (A, B, and C) based on your original usage and our split:
Script A (Core.ahk)
lastAutoPanickTime := 0 autoFoodCombinationIndex := 0 toggle := false FullRotationsemUtitoIndex := 0 AfkKillCompletoIndex := 1
Script B (Combos.ahk)
(No variables from your listed set are used in combos script, so no initializations needed here.)
Script C (QoL.ahk)
autoRopeAndShovelIndex := 0 autoCaniVetesIndex := 0
Summary:
- All timer/state variables and toggles related to core automation, panic, food, and full rotations go to Script A.
- Your combo hotkeys (script B) don’t use these variables directly—no init needed.
- Your QoL cycling indexes (
autoRopeAndShovelIndex,autoCaniVetesIndex) belong in Script C.
If you want, I can help integrate these into your scripts for you!
- User
u did not adjust these
AutoFood: ;comidas de buffs if AutoPanickActive return If WinActive("ahk_class Qt5158QWindowOwnDCIcon") { autoFoodCombinationIndex := (autoFoodCombinationIndex + 1) ; Increment the index if (autoFoodCombinationIndex > 4) ; Reset the index if it exceeds 4 autoFoodCombinationIndex := 1
; Send the appropriate key based on the combination index switch (autoFoodCombinationIndex) { case 1: Send, {F9} Sleep 10 case 2: Send, {F10} Sleep 10 case 3: Send, {F11} Sleep 10 case 4: Send, {F12} Sleep 10 } }return
AutoRefill: ;comida, deposit all e refill if AutoPanickActive return If WinActive("ahk_class Qt5158QWindowOwnDCIcon") { Send, {=} ;mushroom Sleep 10 Send, {i} ;deposit all Sleep 10 Send, {u} ;refill Sleep 10 } return
- Assistant
Thanks for the reminder! Since you clarified you don't want the
AutoPanickActiveflag checked anymore (because the scripts are separated), I'll remove theif AutoPanickActivechecks in your AutoFood and AutoRefill labels and clean up accordingly.
Adjusted code for Script A (Core.ahk):
AutoFood: ; comidas de buffs If WinActive("ahk_class Qt5158QWindowOwnDCIcon") { autoFoodCombinationIndex := (autoFoodCombinationIndex + 1) ; Increment the index if (autoFoodCombinationIndex > 4) ; Reset the index if it exceeds 4 autoFoodCombinationIndex := 1 ; Send the appropriate key based on the combination index switch (autoFoodCombinationIndex) { case 1: Send, {F9} Sleep 10 case 2: Send, {F10} Sleep 10 case 3: Send, {F11} Sleep 10 case 4: Send, {F12} Sleep 10 } } return AutoRefill: ; comida, deposit all e refill If WinActive("ahk_class Qt5158QWindowOwnDCIcon") { Send, {=} ; mushroom Sleep 10 Send, {i} ; deposit all Sleep 10 Send, {u} ; refill Sleep 10 } return - User
auytoheal not working, it should press f4 every 1 second no?
- Assistant
Let's troubleshoot your AutoHeal timer in Script A (Core.ahk) to make sure it presses F4 every ~1 second.
1. Check your timer setup
You should have near the top (after your variable inicializations):
SetTimer, AutoHeal, 1100 - User
it was the name of the screen
- Assistant
Ah, that makes sense!
The
WinActive("ahk_class Qt5158QWindowOwnDCIcon")condition depends on the exact window class name of the application you want AutoHeal to work on. If the window class doesn't match exactly, the condition never passes, andSend, {F4}is skipped.
How to fix / verify window class:
-
Use AutoHotkey Window Spy (comes with AHK) to get the correct window class or title of your game window.
-
Replace the
ahk_classvalue in:
If WinActive("ahk_class YOUR_WINDOW_CLASS_HERE")with the one that matches your game's active window.
Alternatively, if you just want it to run regardless of active window:
AutoHeal: Send, {F4} return
Good practice:
- Use the correct window condition to avoid sending keys to wrong windows.
- If your game can change windows or multiple windows exist, consider more robust checks like window titles or process names.
Glad you found it! If you want help setting a flexible window check or anything else, just let me know.
-
- User
- Assistant
- User
what about all these lines? i see u removed some of them
#Persistent #NoEnv #Warn #MaxHotkeysPerInterval 99000000 #HotkeyInterval 99000000 #KeyHistory 0 #SingleInstance Force ListLines Off SendMode Input SetDefaultMouseSpeed, 0 SetMouseDelay, -1 SetKeyDelay, -1, -1 CoordMode, Pixel, Screen CoordMode, Mouse, Screen
- Assistant
- User
the order doesnt matter ?
- Assistant
Good question!
Does the order of these directives and commands matter?
Generally, the order of most directives and one-time setup commands at the top of your AutoHotkey script does NOT matter too much, but there are a few recommendations and things to keep in mind:
What you can keep in any order (mostly):
#NoEnv#Warn
- User
its ok for 3 the of them?
- Assistant
Yes! It’s perfectly fine—and common practice—to use a very similar or even the same header (directives and initial settings) in all three scripts. This ensures consistent behavior and avoids unexpected issues caused by different settings.
So for all three scripts (Core, Combos, QoL), you can safely have headers like this at the top:
#SingleInstance Force #NoEnv #Warn ListLines Off #Persistent SendMode Input SetDefaultMouseSpeed, 0 SetMouseDelay, -1 SetKeyDelay, -1, -1 CoordMode, Pixel, Screen CoordMode, Mouse, Screen
Why this is good:
- Consistency: Keeps mouse, pixel, send modes the same across all scripts.
- Safety: Prevents accidental multiple instances.
- Debugging: Enables warnings in all 3 scripts while turning off line listing.
- Persistence: Ensures scripts stay running if needed (timers or background processes).
- User
shouild persistend be above liost lines
- Assistant
Yes, it's best practice to place
#PersistentaboveListLines Off(and generally above most other directives/commands) because:#Persistentis a directive that tells AutoHotkey to keep the script running indefinitely.- It should appear early in the script, before anything that might rely on it.
ListLines Offis mainly for debugging and doesn’t affect script execution, so it can go after#Persistent.
Recommended order of these two lines:
#Persistent ListLines Off
Full common header example (recommended order):
#SingleInstance Force #NoEnv #Warn #Persistent ListLines Off SendMode Input SetDefaultMouseSpeed, 0 SetMouseDelay, -1 SetKeyDelay, -1, -1 CoordMode, Pixel, Screen CoordMode, Mouse, Screen
Summary
- Place
#Persistentnear the top, beforeListLines Off. - Keep all directives together at the top of the script.
- This order prevents unexpected behavior and maintains clarity.
- User
#SingleInstance Force #NoEnv #Warn #Persistent ListLines Off
SendMode Input SetDefaultMouseSpeed, 0 SetMouseDelay, -1 SetKeyDelay, -1, -1
CoordMode, Pixel, Screen CoordMode, Mouse, Screen
this order then?
- Assistant
Exactly! This order is perfect and follows best practices for AutoHotkey script headers:
#SingleInstance Force #NoEnv #Warn #Persistent ListLines Off SendMode Input SetDefaultMouseSpeed, 0 SetMouseDelay, -1 SetKeyDelay, -1, -1 CoordMode, Pixel, Screen CoordMode, Mouse, Screen- All directives are grouped at the top.
#Persistentcomes beforeListLines Off.- Input and timing settings come next.
- Coordinate modes come last in the header.
Use this header at the top of all your scripts (Core, Combos, QoL) for consistency and reliability.
If you need help integrating this header into your scripts or with anything else, just ask!