I need a little help with a piece of code that I have a problem with.
I create a master script that runs all by itself. but I want it to open other scripts when certain processes are open, and close the same scripts when the certain process closes (or is not opened).
Code: Select all
#persistent ;just added this in because without it, the master script will terminate on its own. Don't understand why
notepadon = 0
Loop ;this will be my code to check whether or not a process is running or if a variable is a certain value. Not unlike Gamemaker Studio's "step" event which was my entrypoint into coding.
{
If ProcessExist("notepad.exe") && notepadon == 0
{
Run, open "C:\Users\Owner\Desktop\Delate Line of Text Behind the cursor.ahk" ;runs this ahk file when notepade opens.
notepadon = 1 ;stop creating more instances of the script but DO NOT terminate the loop.
}
If !ProcessExist("notepad.exe") && notepadon == 1
{
DetectHiddenWindows, On
WinClose, "C:\Users\Owner\Desktop\Delate Line of Text Behind the cursor.ahk" ;I am still working on getting this function to work.
notepadon = 0 ;reset the variable so that if I re-open notepad, this script will re-open the "Delate" ahk script.
}
}
ProcessExist(Name)
{
Process,Exist,%Name%
return Errorlevel
}
return
Ok. So WHen I view it in task manager, it is taking up about 10 percent of the cpu power! whereas way more advanced scripts such as those that allow you to scroll inactive windows uses up 0%.
Without this loop function, It only works when I first open the master script. is there a less processor intensive alternative to this code?