I sometimes accidentally run two copies of notepad. Sometimes, I don't spot them both in my taskbar. I wondered if there was a way to alert me that I'm attempting to run the same .exe, if I already have it open?
For example, on my desktop I have a notepad file. I'll run that, but sometime later, I'll double click on it again, forgetting that I've already got the same file open in notepad for editing, because it's been minimised, and I don't check the taskbar to see if it's there. Thanks for any comments.
Hi, you could, if you wished, write a small script that launches Notepad from a shortcut
The sequence would be
If Notepad.exe already exists
Ask if you wish to continue
If yes, open Notepad
else exit
Quite easy in Autohotkey for example (free).
I just did a quick Google search and this is what I found:
How to check if a process is running via a batch script
windows - How to check if a process is running via a batch script - Stack Overflow
And here's the code that's posted that looks interesting and it's set up for Notepad. So there might not be much adjustments required to it.
Note: It's the second answer in the thread.. I'll check it out ASAP.
Code:PHP Code:
tasklist /FI "IMAGENAME eq notepad.exe" /FO CSV > search.log
FOR /F %%A IN (search.log) DO IF %%~zA EQU 0 GOTO end
start notepad.exe
:end
del search.log
Oh well.. that may not cut it.. I'll do some coding and see what I can come up with. I might have found a solution but it's going to take a bit of testing. With luck I'll have some solid results today.
Hi, here you are.. just install Autohotkey, and run the ahk script.
Notepad.zip
or simply run the exe file.
As you have the AHK file you can edit that as you wish. Install Autohotkey and you can compile it with 1 click.
Nice.. that's better than the code I was playing with for certain.
Jeff
Thank you, that's much appreciated. I have marked this thread as solved.