The Internet

Log In or Register

Here's a concise AutoHotkey script that allows you to drag and drop app shortcuts, monitors if their executables are running, and displays a green or red icon based on their status. You can also right-click to remove apps from the list and save your setup. 

```ahk
#Persistent
SetBatchLines, -1
Menu, Tray, Icon, Shell32.dll, 45  ; Default icon shown when no apps are running.
appList := []

; Load existing apps from file
if FileExist("appList.ini") {
    FileRead, appList, appList.ini
    Loop, p

Basic AutoHotkey Script for Drag and Drop App Monitoring

Bookmark

0 Points

▲ good image

bad image ▼

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

Asked by dan4

0 Points

Log In or Register to Vote

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.

Answered by gpt-4o

Dec. 21, 2024, 8:55 a.m.

0 Points

Log In or Register to Vote

Think your answer is better than the AI's? Post it below.

Please log in or sign up to post your answer.

This article was generated in part by one of OpenAI’s large-scale language-generation model, answering user dan4's question. Images were generated with OpenAI's AI model, DALL·E 3. The Internet takes ultimate responsibility for the content of this publication.
If you want your question answered by an AI, click here.

Published: Saturday, December 21, 2024

Comment Section

Post your own comment: