Run a program while another program is active (Autohotkey) - autohotkey

I was wondering if i could get AHK-script to automatically launch a program in the background when i start another.
Example:
Execute C:\any.exe.
AHK launches: C:\monitor.exe
When any.exe is closed, ahk should kill monitor.exe
Awsome if you guys could help me.
Edit: Note that i am a complete newcomer to programming or scripting in every way you can think of

Check out timer in the autohotkey docs.
You could set a timer that checks every 5 seconds to run winexist to test for the existence of c:\any.exe - and when it returns true then your code could run c:\monitor.exe
Now that your code knows that c:\any.exe is running, your code could launch a second timer that checks for when its process is closed (check out process in the ahk docs). When it is closed, then use winkill to close the c:\monitor.exe process.
So, look up these commands:
winexist
timer
process

Related

Launch on event with python

here I write my first question as programming beginner starting with python.
I have a small script that executes a loop, which function is to download a list from the server, compare it with other lists and see if something has happened. Usually the answer is NO, but sometimes something happens. When the answer becomes YES, I would like this script at this point to be able to "launch the second program", a similar script that from here takes care of the instructions to handle the specific event signaled while the " main program "continues to interrogate the server and compare the answers (that's the only thing he has to do).
considering that you can run it with two clicks from the desktop specifying only one variable (that comes from the first script), I thought it was easy to "trigger" the execution of a python file in a new window or something like that ...can anybody tell me how I can make it start at the request of the first script avoiding that the first script remains blocked waiting for answers and continues to execute its cycle?

Bluestacks - Start & Exit application using Macro

I have recorded a Bluestacks macro to perform menial tasks in the ZDay : Hearts for heros game. However, because there are so many unpredictable popups in the application I would like the macro to start the app, run the menial activity I recorded and then exit the application.
The application doesn't have a specific way to exit (file/exit doesn't exist) except on the phone is to force it closed using the OS. Is there a command I can put at the beginning of the macro to start the application and another to close the application at the end of the macro?
Bluestacks has controls that allow perform a generic exit command. So, I didn't need to know how to exit the program from inside the application. I just used the built in functionality to accomplish what I need.

Launching a background process in current Powershell session

I'm trying to find a method to launch a background process in Powershell. At first I tried using Start-Job and then realized that that launches the job in a new session. My end goal is to create a while loop that runs every hour (already have that code worked out) but I can't find a way to launch it in a background process that once the session closes the process with stop as well. Any help will be greatly appreciated.

Run a program automatically on script start-up

I am trying to make an AHK script open another program everytime it is started. The problem is, I don't want this to happen if that other program is already opened.
Here's what seems to be supposed to be working, but isn't : (this section is placed at the very top of my script)
SetTitleMatchMode, 2
#IfWinNotExist, Microsoft Excel - myExcelFile.xls
Run C:\myExcelFile.xls
#IfWinExist
;REST OF MY SCRIPT GOES HERE
What should be happening :
If the window "Microsoft Excel - myExcelFile.xls" is not opened, run it. If not, do not.
What is happening :
Whether it is opened or not, it will try to run it again.
So yeah, even though I had read the documentation, I had understood that the difference between #IfWin and IfWin was whether they were used inside or out of a specific hotkey. To my understanding, "creates context-sensitive hotkeys and hotstrings" also included "context-sensitive auto-execution" (when code is not inside a hotkey)
Indeed I was wrong and the solution is to remove the #.

Applescript to wait for AppleMail to download messages.

Prior to 10.7.x this AppleScript used to work with AppleMail:
tell application "Mail"
activate
check for new mail
repeat until (background activity count) = 0
do shell script "sleep 1"
end repeat
end tell
However, since 10.7.x+ this does not seem to work anymore. It doesn't even go in to the repeat loop. My guess is that AppleMail has changed the way it downloads emails and doesn't use "background activity" anymore.
Anyone know how to wait for all emails to download in AppleMail 5+ with AppleScript?
I checked on 10.8.2 and it worked. Maybe the check is really fast on your system and it's already finished when the repeat until condition is evaluated. But I can't understand what's the objective of the script. Also, it would be better if you replace the do shell script "sleep 1" with a simpler delay 1.