Ahk script that can start or stop another Script Topic is solved
-
- Posts: 6
- Joined: 22 Sep 2022, 14:44
Ahk script that can start or stop another Script
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!?
Re: Ahk script that can start or stop another Script Topic is solved
Welcome to this AutoHotkey forum!
I would start with 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.
I would start with 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
-
- Posts: 6
- Joined: 22 Sep 2022, 14:44
Re: Ahk script that can start or stop another Script
well still not figure how to do it .... or not working for me ...
this is how 1 script look ... i have 5 of them !
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 !
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 !
Re: Ahk script that can start or stop another Script
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?
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?
-
- Posts: 6
- Joined: 22 Sep 2022, 14:44
Re: Ahk script that can start or stop another Script
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
Re: Ahk script that can start or stop another Script
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!