Reputation: 1
I tried to create a Python script that goes through all my autohotkey scripts and runs them if they aren't running. This was simple enough for scripts converted into executables, but I haven't been able to find a way to see if .ahk scripts are running. I tried using python autohotkey libraries, but I haven't managed to find any with this functionality.
How would this be possible using Python?
Upvotes: 0
Views: 278
Reputation: 6499
The processes are all going to be named AutoHotkey.exe, but they were all started with different arguments. The first (and by default the only) argument is going to be a path to the script that's running.
You can check this for example with the task manager, just enable the commandline column in the processes tab. Alternatively, you can use e.g. ProcessExplorer to see it even easier.
And about getting the commandline in Python, I don't know Python, but you're likely going to want to use WMI/(C).
Easiest way is probably going to be using some Python WMI library. A Google search gives me this one, probably worth taking a look at.
Here's an example PowerShell command for using WMI to get the commandlines:
Get-WmiObject Win32_Process -Filter "name = 'AutoHotkey.exe'" | Format-List -Property CommandLine
Wouldn't be too hard to parse the desired info from that either, if doing it properly gets too complicated.
Upvotes: 2