Ask AI on The Internet
Question: create an autohotkey script when i can drag and drop an app shortcut and constantly monitor if that shortcuts exe is running or not by displaying a green icon if the app is running or red icon if it is not. I should be able to add multiple apps and save the setup. allow me to right click an app in the list and remove it
Sure! Below is a basic AutoHotkey (AHK) script that sets up a GUI where you can drag and drop application shortcuts to add them to a monitoring list. The script will display a green or red icon depending on whether each application's `.exe` is currently running. You can also right-click an app in the list to remove it. ```ahk #Persistent #NoEnv SetWorkingDir %A_ScriptDir% SetBatchLines, -1 Gui, +Resize Gui, Add, ListView, x10 y10 w480 h400 +ReadOnly vAppList gAppList, Application|Status Gui, Add, Button, x10 y420 w70 gSaveSetup, Save Gui, Add, Button, x90 y420 w70 gLoadSetup, Load GuiContextMenu: LV_GetText(AppName, A_EventInfo, 1) Menu, RemoveAppMenu, Add, Remove '%AppName%', RemoveApp Menu, RemoveAppMenu, Show return RemoveApp: LV_Delete(A_EventInfo) return GuiDropFiles: Loop, Parse, A_GuiEvent, `n { IfExist %A_LoopField% { SplitPath, A_LoopField, OutFileName, OutDir, OutExt, OutName, OutDrive AddApp(OutName, OutDir) } } return AddApp(AppName, AppPath) { LV_Add("", AppName, "----") LV_ModifyCol() } SaveSetup: FileDelete, Apps.ini Loop, Parse, LV_GetCount() { LV_GetText(AppName, A_Index, 1) LV_GetText(Status, A_Index, 2) IniWrite, %LV_GetText(A_Index, 1)%, Apps.ini, Apps, %A_Index% } return LoadSetup: If FileExist("Apps.ini") { LV_Delete() Loop { IniRead, AppName, Apps.ini, Apps, %A_Index% if (AppName = "ERROR") break AddApp(AppName, "") } } return SetTimer, CheckAppStatus, 5000 return CheckAppStatus: Loop, Parse, LV_GetCount() { LV_GetText(AppName, A_Index, 1) if (ProcessRunning(AppName)) { LV_Modify(A_Index, "Col2", "Green") } else { LV_Modify(A_Index, "Col2", "Red") } } return ProcessRunning(Name) { Process, Exist, %Name%.exe return !!ErrorLevel } GuiClose: ExitApp return AppList: if (A_GuiEvent = "R") { LV_GetText(AppName, A_EventInfo) Menu, RemoveAppMenu, Show } return ``` ### Instructions: 1. **Add Applications:** - Drag and drop application shortcuts into the main GUI window. The applications will be added to the list. 2. **Monitor Applications:** - The script checks every 5 seconds if the applications are running or not. - A green icon indicates that the application is running, and a red icon indicates that it is not. 3. **Save/Load Setup:** - Click the "Save" button to save the current setup to an `Apps.ini` file. - Click the "Load" button to load the applications from the `Apps.ini` file. 4. **Remove Applications:** - Right-click on an application in the list and select "Remove" to remove it from the monitoring list. Make sure you have `autohotkey` installed to use this script. Save the content into a file with the `.ahk` extension and run it using AutoHotkey. This will provide you with a basic interface to monitor your applications.
Think your answer is better than the AI's? Post it below.
Other Most Relevant Posts:
Question Tags
If you want your question answered by an AI, click here.
Post your own comment: