Ahk script that can start or stop another Script Topic is solved

Ask gaming related questions (AHK v1.1 and older)
PatriceNicole
Posts: 6
Joined: 22 Sep 2022, 14:44

Ahk script that can start or stop another Script

Post by PatriceNicole » 22 Sep 2022, 14:50

Hi ! Anyone can tell me if is a way to make a simple ahk script that can start and stop another few others ahk scripts? For example if i press one mouse button the script will start other scripts that will stop after 10 seconds for example and sleep 10 seconds and after start again… and this repeat until i stop the main/master script!?

User avatar
mikeyww
Posts: 26945
Joined: 09 Sep 2014, 18:38

Re: Ahk script that can start or stop another Script  Topic is solved

Post by mikeyww » 23 Sep 2022, 06:16

Welcome to this AutoHotkey forum!

I would start with :arrow: Run, to see if you can start a script.

To close a script, you can use WinClose. See the links here. Use DetectHiddenWindows. The leading text of a script's window title is the full path to the script.

Code: Select all

script = %A_ScriptDir%\test.ahk
F3::Run, %script%
F4::
DetectHiddenWindows, On
WinClose, %script% ahk_class AutoHotkey
Return

PatriceNicole
Posts: 6
Joined: 22 Sep 2022, 14:44

Re: Ahk script that can start or stop another Script

Post by PatriceNicole » 23 Sep 2022, 13:17

well still not figure how to do it .... or not working for me ...


this is how 1 script look ... i have 5 of them !

Code: Select all

#NoEnv

~XButton2::

Toggle=0

{CoordMode, Pixel, Window
PixelSearch, FoundX, FoundY, 960, 723, 960, 723, 0xFFEE00, 0, Fast RGB
If (ErrorLevel = 0)
{
        Send {5}

}		
Return
Del::exitapp

and i want {~XButton1} to be nr 1 script that put "at work" those 5 pixelsearch scripts .... to work 5 seconds .... and sleep 5 seconds ! and repeat until i press the ~XButton1 again !

User avatar
mikeyww
Posts: 26945
Joined: 09 Sep 2014, 18:38

Re: Ahk script that can start or stop another Script

Post by mikeyww » 23 Sep 2022, 16:11

In thinking about how to simplify, my first question is whether you really need separate script files and, if so, why.

Instead of trying to make all of the steps work at once, it might help to see if you can get one action working. When you succeed, you can then build upon your script.

For me, "not working" is almost the same as saying nothing. As a description, it doesn't say what the script actually does, or what it should do.

A simple question: when you execute a PixelSearch, what is the ErrorLevel? Is it the ErrorLevel that you expected?

PatriceNicole
Posts: 6
Joined: 22 Sep 2022, 14:44

Re: Ahk script that can start or stop another Script

Post by PatriceNicole » 24 Sep 2022, 02:26

well its a game that get more points if i have separate ahk scripts than do all buttons in 1 script.... but with one conndition... to press start and stop from 5 to 5 seconds... overal in 5 minutes i get more points in game than i use 1 macro with all 5 comands in it... i know its sound strange but sending the colors that fast bring me more points... puting even a little "sleep" it get less points in game overal of 5 minute of testing non stop ... so i need a master who control this and i was think to create the script that start and stop this mess from 5 to 5 seconds ! XD

User avatar
mikeyww
Posts: 26945
Joined: 09 Sep 2014, 18:38

Re: Ahk script that can start or stop another Script

Post by mikeyww » 24 Sep 2022, 06:17

This script will show you whether your target color is found.

Code: Select all

#SingleInstance Force
duration  = 2000     ; Milliseconds
wait      = 2000     ; Wait between searches
target   := 0xFFEE00 ; Red-Green-Blue
x         = 960
y         = 723
log       = %A_ScriptDir%\1.log
FileRecycle, %log%
WinGetActiveTitle, title
MouseMove, x, y
MsgBox, 64, Active window, %title%
FileAppend, Time`,Color`,Missing`n, %log%
Loop, 2 {
 If (A_Index > 1) {
  ToolTip, Waiting
  Sleep, wait
 }
 end := A_TickCount + duration
 While (A_TickCount < end) {
  Sleep, 50
  PixelGetColor, rgb, x, y, RGB
  ToolTip, % missing := rgb != target
  FileAppend, %A_Now%`,%rgb%`,%missing%`n, %log%
 }
}
ToolTip
Run, %log%
MsgBox, 64, Done, Done!

Post Reply

Return to “Gaming Help (v1)”