Run scripts or programs when a specific device is connected/disconnected

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
XMCQCX
Posts: 225
Joined: 14 Oct 2020, 23:44

Run scripts or programs when a specific device is connected/disconnected

Post by XMCQCX » 24 Sep 2022, 11:14

Hi,
That was requested a lot on the forum. I didn't find any script that was noob friendly to achieve this. I made one, but I don't have a programmer background. Just want to make sure that it's not too buggy before releasing it. I'm asking for help if any users are interested and want to take a look at it and test their devices. Any help for fixes or tips would be greatly appreciated !

UPDATE:
The script was officially released on this page, go there if you want to download the latest version:
viewtopic.php?f=6&t=108930

Keep in mind, this script is not finished yet. Bookmark this page if you want to keep up to date.

DeviceIDFinder
Find your device unique ID.

How to use:
- Run the programs and follow the instructions.

Code: Select all

/*
Script:    DeviceIDFinder.ahk
Author:    XMCQCX
Date:      2022-09-24
Version:   1.0.0
*/

#NoEnv
#SingleInstance, Force
SendMode Input
SetWorkingDir, %A_ScriptDir%

MsgBox, 64, Find deviceID, Plug your device and press OK

For Device in ComObjGet("winmgmts:").ExecQuery("Select * from Win32_PnPEntity")
    ListConnectedDeviceIDs .= device.name ":" A_Tab Device.DeviceID "`n"

;=============================================================================================

; Remove duplicates from ListConnectedDeviceIDs
Loop, Parse, ListConnectedDeviceIDs, "`n"
{
    ListConnectedDeviceIDs := (A_Index=1 ? A_LoopField : ListConnectedDeviceIDs . (InStr("`n" ListConnectedDeviceIDs
    . "`n", "`n" A_LoopField "`n") ? "" : "`n" A_LoopField ) )
}

;=============================================================================================

oConnectedDeviceIDs := {}
Loop, Parse, ListConnectedDeviceIDs, "`n"
    oConnectedDeviceIDs.Push({"DeviceID":A_Loopfield})

;=============================================================================================

MsgBox, 64, Find deviceID, Unplug your device and press OK

;=============================================================================================

For Device in ComObjGet("winmgmts:").ExecQuery("Select * from Win32_PnPEntity")
    strListConnectedDeviceIDs .= device.name ":" A_Tab Device.DeviceID "`n"

;=============================================================================================

; Remove duplicates from strListConnectedDeviceIDs
Loop, Parse, strListConnectedDeviceIDs, "`n"
{
    strListConnectedDeviceIDs := (A_Index=1 ? A_LoopField : strListConnectedDeviceIDs . (InStr("`n" strListConnectedDeviceIDs
    . "`n", "`n" A_LoopField "`n") ? "" : "`n" A_LoopField ) )
}

;=============================================================================================

Loop, Parse, strListConnectedDeviceIDs, "`n"
{
    For Index, Element in oConnectedDeviceIDs  
    {
        If InStr(strListConnectedDeviceIDs, Element.DeviceID)
            oConnectedDeviceIDs.RemoveAt(Index)
    }
}

;=============================================================================================

For Index, Element in oConnectedDeviceIDs
    DeviceIDFound .= Element.DeviceID "`n"

;=============================================================================================

strDeviceIDFound := ""
For each, line in StrSplit(DeviceIDFound, "`n")
{
    RegExMatch(line, "`nm)^(.*?)" A_TAB "(.*)$", OutputVar)
        strDeviceIDFound .= OutputVar1 "`n" OutputVar2 "`n`n"
}
strDeviceIDFound := RTrim(strDeviceIDFound, "`n`n")

If !strDeviceIDFound
    strDeviceIDFound := "No device found !"

;=============================================================================================

Gui, New
Gui, Add, Text,, DeviceID:
Gui, Add, Edit, vTextDeviceID ReadOnly, %strDeviceIDFound%
Gui, Add, Button, w175 vCopyToClipboard gCopyToClipboard, Copy to Clipboard
Gui, Add, Button, x+10 w175 gFindAnotherDeviceID, Find ID of another device
Gui, Add, Button, x+10 w175 gExit, Exit
GuiControl, Focus, CopyToClipboard
Gui, Show
return

;=============================================================================================

CopyToClipboard:
Clipboard := strDeviceIDFound
MsgBox, 64, Success, Device ID copied to Clipboard !
return

FindAnotherDeviceID:
Reload

Exit:
GuiClose:
Exitapp
DeviceIDPnP
Run scripts or programs when a specific device is connected/disconnected.
Works with devices connected to PC via USB, Bluetooth, HDMI, Headphone Jack etc... I'm not sure about what is working and what is not working, needs more testing.

How to use:
- Run "DeviceIDFinder.ahk" to identify your device.
- Add your devices IDs and devices names at the top of the script. (DeviceIDPnP.ahk)
The device's name doesn't have to exactly match the name found with "DeviceIDFinder.ahk". You can name it whatever you want.
- Add the devices names and the scripts or programs that you want to run/close when the devices are connected/disconnected at the bottom of the script.

Code: Select all

/*
Script:    DeviceIDPnP.ahk
Author:    XMCQCX
Date:      2022-09-27
Version:   1.1.1

Change log:
2022-09-27
1.1.1 - Fixed an issue with some devices status not properly updating when connecting/disconnecting.

2022-09-24
1.1.0 - Run or close scripts/programs if the devices are connected/disconnected when the script start.

Known issue:
- All scripts/programs not launching/closing when connecting multiple devices in "oMyDevices" at the same time or in quick succession.
  Not an issue when the script is launch.
*/

#NoEnv
#SingleInstance, Force
SendMode Input
SetWorkingDir, %A_ScriptDir%

oMyDevices := {}
oMyDevices.Push({"DeviceName":"USB Kingston DataTraveler 3.0","DeviceID":"USB\VID_0951&PID_1666\E0D55EA573DCF450E97C104C", "Status":""})
oMyDevices.Push({"DeviceName":"BLUETOOTH PLAYSTATION(R)3 Controller","DeviceID":"BTHPS3BUS\{53F88889-1AAF-4353-A047-556B69EC6DA6}&DEV&VID_054C&PID_0268&04766E9094F3\9&320AC31D&0&0", "Status":""})
oMyDevices.Push({"DeviceName":"HDMI Samsung TV","DeviceID":"SWD\MMDEVAPI\{0.0.0.00000000}.{ED3C7A62-B05B-44C6-ACD8-BCAA1E894265}", "Status":""})

;=============================================================================================

; List all devices connected
For Device in ComObjGet("winmgmts:").ExecQuery("Select * from Win32_PnPEntity")
    ListDevicesConnected .=  Device.Name A_Tab Device.DeviceID A_Tab Device.PNPClass A_Tab Device.Status "`n"

;=============================================================================================

; Establish the status of the devices in oMyDevices
For Index, Element in oMyDevices
{
    If InStr(ListDevicesConnected, Element.DeviceID)
    {
        EscapeStrElementDeviceID := RegExReplace(Element.DeviceID, "[\Q\.*?+[{|()^$\E]", "\$0")
        RegExMatch(ListDevicesConnected, "`nm)^(.*?)" A_TAB EscapeStrElementDeviceID A_TAB "(.*?)" A_TAB "(.*)$", ElementsDevice)

        If (ElementsDevice3 = "OK")
            oMyDevices[Index].Status := "Connected"
        
        If (ElementDevice3 = "Unknown")
            oMyDevices[Index].Status := "Disconnected"
    } 
    Else
        oMyDevices[Index].Status := "Disconnected"
}

;=============================================================================================

; Run or close scripts/programs if the devices are connected/disconnected when the script start.
Loop % oMyDevices.Count()
{
    ThisDeviceStatusAtStartup := oMyDevices[A_Index].DeviceName A_Space oMyDevices[A_Index].Status
    DeviceActions(ThisDeviceStatusAtStartup, ShowToolTip := "No")
}

;=============================================================================================

OnMessage(0x219, "WM_DEVICECHANGE") 
WM_DEVICECHANGE(wParam, lParam, msg, hwnd)
{
    SetTimer, CheckDevicesStatus , -1000
}
Return

;=============================================================================================

CheckDevicesStatus:

    ; Prevent the script to continue if it already previously ran during the last 1500ms.
    ElapsedTime := A_TickCount - StartTime
    if ElapsedTime between 1 and 1500
    {
        StartTime := A_TickCount
        return
    }

    ;=============================================================================================
    
    ; List all devices connected
    ListDevicesConnected := ""
    For Device in ComObjGet("winmgmts:").ExecQuery("Select * from Win32_PnPEntity")
        ListDevicesConnected .=   Device.Name A_Tab Device.DeviceID A_Tab Device.PNPClass A_Tab Device.Status "`n"

    ;=============================================================================================

    ; Find which device status has changed in oMyDevices
    ThisDeviceStatusHasChanged := ""
    For Index, Element in oMyDevices
    {
        If InStr(ListDevicesConnected, Element.DeviceID)
        {
            EscapeStrElementDeviceID := RegExReplace(Element.DeviceID, "[\Q\.*?+[{|()^$\E]", "\$0")
            RegExMatch(ListDevicesConnected, "`nm)^(.*?)" A_TAB EscapeStrElementDeviceID A_TAB "(.*?)" A_TAB "(.*)$", ElementDevice)

            If (ElementDevice3 = "OK")
                If (oMyDevices[Index].Status = "Disconnected"), oMyDevices[Index].Status := "Connected"
                    ThisDeviceStatusHasChanged := Element.DeviceName " Connected"
            
            If (ElementDevice3 = "Unknown")
                If (oMyDevices[Index].Status = "Connected"), oMyDevices[Index].Status := "Disconnected"
                    ThisDeviceStatusHasChanged := Element.DeviceName " Disconnected"
        }
        
        If !InStr(ListDevicesConnected, Element.DeviceID)
            If (oMyDevices[Index].Status = "Connected"), oMyDevices[Index].Status := "Disconnected"
                ThisDeviceStatusHasChanged := Element.DeviceName " Disconnected"
    }

    ;=============================================================================================

    ; If a device in oMyDevices status has changed go to DeviceActions()
    If ThisDeviceStatusHasChanged
        DeviceActions(ThisDeviceStatusHasChanged, ShowToolTip := "Yes")
    
    StartTime := A_TickCount

return

;=============================================================================================

DeviceActions(ThisDeviceStatusHasChanged, ShowToolTip := "") {

    If (ShowToolTip = "Yes") {
        CoordMode, ToolTip, Screen
        Tooltip, % ThisDeviceStatusHasChanged, 0, 0
        SetTimer, RemoveToolTipDeviceStatus, -5000
    }

    ;=============================================================================================

    If (ThisDeviceStatusHasChanged = "USB Kingston DataTraveler 3.0 Connected")
        If !WinExist("ahk_exe Notepad.exe")
            Run, Notepad.exe

    If (ThisDeviceStatusHasChanged = "USB Kingston DataTraveler 3.0 Disconnected")
        If WinExist("ahk_exe Notepad.exe")
            Winclose, % "ahk_exe Notepad.exe"

    ;=============================================================================================

    If (ThisDeviceStatusHasChanged = "BLUETOOTH PLAYSTATION(R)3 Controller Connected")
        If !WinExist("ahk_exe wordpad.exe")
            Run, wordpad.exe

    If (ThisDeviceStatusHasChanged = "BLUETOOTH PLAYSTATION(R)3 Controller Disconnected")
        If WinExist("ahk_exe wordpad.exe")
            Winclose, % "ahk_exe wordpad.exe"

    ;=============================================================================================

    If (ThisDeviceStatusHasChanged = "HDMI Samsung TV Connected")
        If !WinExist("ahk_exe mspaint.exe")
            Run, mspaint.exe
    
    If (ThisDeviceStatusHasChanged = "HDMI Samsung TV Disconnected")
        If WinExist("ahk_exe mspaint.exe")
            Winclose, % "ahk_exe mspaint.exe"

    ;=============================================================================================
}

RemoveToolTipDeviceStatus:
ToolTip
return
Last edited by XMCQCX on 28 Sep 2022, 20:33, edited 7 times in total.

Lepes
Posts: 141
Joined: 06 May 2021, 07:32
Location: Spain

Re: Run scripts or programs when a specific device is connected/disconnected

Post by Lepes » 24 Sep 2022, 13:32

Good Job!! It works here.

I got this:

Code: Select all

Dispositivo compuesto USB:
USB\VID_444D&PID_3436\5&1719F840&0&12

Dispositivo de entrada USB:
USB\VID_444D&PID_3436&MI_01\6&7D168FE&1&0001

Dispositivo de entrada USB:
USB\VID_444D&PID_3436&MI_00\6&7D168FE&1&0000

Dispositivo de control del consumidor compatible con HID:
HID\VID_444D&PID_3436&MI_01&COL03\7&AE1683C&0&0002

Controlador del sistema compatible con HID:
HID\VID_444D&PID_3436&MI_01&COL02\7&AE1683C&0&0001

Mouse compatible con HID:
HID\VID_444D&PID_3436&MI_01&COL01\7&AE1683C&0&0000

Dispositivo de teclado HID:
HID\VID_444D&PID_3436&MI_00\7&1E11847A&0&0000
I used the last one because I was identifying a keyboard (dactyl manuform with an Arduino Pro Micro).
I get tooltip updated when I dis/connect the keyboard :bravo: :bravo:

XMCQCX
Posts: 225
Joined: 14 Oct 2020, 23:44

Re: Run scripts or programs when a specific device is connected/disconnected

Post by XMCQCX » 24 Sep 2022, 16:38

Lepes wrote:
24 Sep 2022, 13:32
Good Job!! It works here.
Thanks for testing. I'm glad it's working for you ! I updated DeviceIDPnP to 1.1.0. Keep in mind, this script is not finished yet. Bookmark this page if you want to keep up to date.

Lepes
Posts: 141
Joined: 06 May 2021, 07:32
Location: Spain

Re: Run scripts or programs when a specific device is connected/disconnected

Post by Lepes » 25 Sep 2022, 03:50

What about to integrate both scripts into a single one with Gui?

I know this is a mess, I tried to not modify your scripts too much.
"FindUSB" label is your DeviceIDFinder.ahk
and "TestSelected" label is your DeviceIDPnP.ahk 1.1.0

I'm a noob, I'm sure it could be better done!

Code: Select all

; Generated by Auto-GUI 3.0.1
#SingleInstance Force
#NoEnv
SetWorkingDir %A_ScriptDir%
SetBatchLines -1

Gui Font, s9, Segoe UI
Gui Add, Tab3, x10 y10 w721 h680, Find|Configure
Gui Tab, 1
Gui Font
Gui Font, s17 Bold cBlack
Gui Add, Text, x180 y48 w360 h53 +0x200, USB Finder by XMCQCX 
Gui Font
Gui Font, s9, Segoe UI
Gui Add, Text, x20 y130, 1 - Press "Find USB" button and follow screen instructions
Gui Add, Button, gFindUSB x340 y118 w149 h38, &Find USB now!
Gui Add, Text, x20 y150, 2 - Listview will be full filled, select a line
Gui Add, ListView, x20 y180 w570 h285 +Report +Grid -Multi +LV0x4000, Name | ID

Gui Add, Button, gTestSelected x280 y490 w95 h28, Test Selected
Gui Add, Text, x20 y500, 3 - Press "Test Selected" button.
Gui Add, Text, x20 y525, 4 - Disconnect and connect your USB device, "Status device" text `n should change from Disconnected to Connected whenever you fisically disconnect and connect `n your Device.
Gui Add, Text, x20 y570, If you don't get both messages, test another item from the Listview.
Gui Font, s14, Segoe UI
Gui Add, Text, x20 y620, Device Status: 
Gui Tab


Gui Show, w744 h700, Window

Return

GuiEscape:
GuiClose:
    ExitApp




FindUSB:

/*
Script:    DeviceIDFinder.ahk
Author:    XMCQCX
Date:      2022-09-24
Version:   1.0.0
*/
MsgBox, 64, Find deviceID, Plug your device and press OK

For Device in ComObjGet("winmgmts:").ExecQuery("Select * from Win32_PnPEntity")
    ListConnectedDeviceIDs .= device.name ":" A_Tab Device.DeviceID "`n"

;=============================================================================================

; Remove duplicates from ListConnectedDeviceIDs
Loop, Parse, ListConnectedDeviceIDs, "`n"
{
    ListConnectedDeviceIDs := (A_Index=1 ? A_LoopField : ListConnectedDeviceIDs . (InStr("`n" ListConnectedDeviceIDs
    . "`n", "`n" A_LoopField "`n") ? "" : "`n" A_LoopField ) )
}

;=============================================================================================

oConnectedDeviceIDs := {}
Loop, Parse, ListConnectedDeviceIDs, "`n"
    oConnectedDeviceIDs.Push({"DeviceID":A_Loopfield})

;=============================================================================================

MsgBox, 64, Find deviceID, Unplug your device and press OK

;=============================================================================================

For Device in ComObjGet("winmgmts:").ExecQuery("Select * from Win32_PnPEntity")
    strListConnectedDeviceIDs .= device.name ":" A_Tab Device.DeviceID "`n"

;=============================================================================================

; Remove duplicates from ListConnectedDeviceIDs
Loop, Parse, strListConnectedDeviceIDs, "`n"
{
    strListConnectedDeviceIDs := (A_Index=1 ? A_LoopField : strListConnectedDeviceIDs . (InStr("`n" strListConnectedDeviceIDs
    . "`n", "`n" A_LoopField "`n") ? "" : "`n" A_LoopField ) )
}

;=============================================================================================

Loop, Parse, strListConnectedDeviceIDs, "`n"
{
    For Index, Element in oConnectedDeviceIDs  
    {
        If InStr(strListConnectedDeviceIDs, Element.DeviceID)
            oConnectedDeviceIDs.RemoveAt(Index)
    }
}

;=============================================================================================

For Index, Element in oConnectedDeviceIDs
    DeviceIDFound .= Element.DeviceID "`n"

;=============================================================================================

strDeviceIDFound := ""
For each, line in StrSplit(DeviceIDFound, "`n")
{
    RegExMatch(line, "`nm)^(.*?)" A_TAB "(.*)$", OutputVar)
    strDeviceIDFound .= OutputVar1 "`n" OutputVar2 "`n`n"

    if (OutputVar1 != "") && (OutputVar2 !=""){  ; Lepes
      LV_Add( , OutputVar1 , OutputVar2)
     
    }
}
LV_ModifyCol() ; Lepes
strDeviceIDFound := RTrim(strDeviceIDFound, "`n`n")

If !strDeviceIDFound
    strDeviceIDFound := "No device found !"
Return
; Lepes comment out this Gui
;=============================================================================================

;Gui, New
;Gui, Add, Text,, DeviceID:
;Gui, Add, Edit, vTextDeviceID ReadOnly, %strDeviceIDFound%
;Gui, Add, Button, w175 vCopyToClipboard gCopyToClipboard, Copy to Clipboard
;Gui, Add, Button, x+10 w175 gFindAnotherDeviceID, Find ID of another device
;Gui, Add, Button, x+10 w175 gExit, Exit
;GuiControl, Focus, CopyToClipboard
;Gui, Show
;return

;=============================================================================================

CopyToClipboard:
Clipboard := strDeviceIDFound
MsgBox, 64, Success, Device ID copied to Clipboard !
return


TestSelected:
/*
Script:    DeviceIDPnP.ahk
Author:    XMCQCX
Date:      2022-09-24
Version:   1.1.0

Changelog:
1.1.0 - Run or close scripts/programs if the device is connected/disconnected when the script start.
*/

;#NoEnv
;#SingleInstance, Force
;SendMode Input
;SetWorkingDir, %A_ScriptDir%

oMyDevices := {}
;Lepes
RowNumber := LV_GetNext(0,"Focused")
LV_GetText(DeviceName, RowNumber, 1)
LV_GetText(dID, RowNumber, 2)
oMyDevices.Push({"DeviceName": DeviceName, "DeviceID": dID})
tooltip, % DeviceName " - " dID
;oMyDevices.Push({"DeviceName":"USB Kingston DataTraveler 3.0","DeviceID":"USBSTOR\DISK&VEN_KINGSTON&PROD_DATATRAVELER_3.0&REV_\E0D55EA573DCF450E97C104C&0", "Status":""})
;oMyDevices.Push({"DeviceName":"PLAYSTATION(R)3 Controller","DeviceID":"BTHPS3BUS\{53F88889-1AAF-4353-A047-556B69EC6DA6}&DEV&VID_054C&PID_0268&04766E9094F3\9&320AC31D&0&0", "Status":""})
;oMyDevices.Push({"DeviceName":"HDMI Samsung TV","DeviceID":"SWD\MMDEVAPI\{0.0.0.00000000}.{ED3C7A62-B05B-44C6-ACD8-BCAA1E894265}", "Status":""})

;=============================================================================================

; List all devices connected
For Device in ComObjGet("winmgmts:").ExecQuery("Select * from Win32_PnPEntity")
    ListDevicesConnected .= Device.DeviceID "`n"

;=============================================================================================

; Establish the status of the devices in oMyDevices
For Index, Element in oMyDevices
{
    If InStr(ListDevicesConnected, Element.DeviceID)
        oMyDevices[Index].Status := "Connected"
    Else
        oMyDevices[Index].Status := "Disconnected"
}

;=============================================================================================

; Run or close scripts/programs if the device is connected/disconnected when the script start.
oMyDevicesCount := oMyDevices.Count()
Loop % oMyDevicesCount
{
    ThisDeviceStatusAtStartup := oMyDevices[A_Index].DeviceName A_Space oMyDevices[A_Index].Status
    DeviceActions(ThisDeviceStatusAtStartup, DontShowToolTip := "true")
}

;=============================================================================================

OnMessage(0x219, "notify_change") 
notify_change(wParam, lParam, msg, hwnd)
{
    SetTimer, CheckDevicesStatus , -25
}
Return

;=============================================================================================

CheckDevicesStatus:

    ; Prevent the script to continue if it already previously run during the last 1250ms.
    ElapsedTime := A_TickCount - StartTime
    if ElapsedTime between 1 and 1250
    {
        StartTime := A_TickCount
        return
    }

    ;=============================================================================================
    
    ; List all devices connected
    ListDevicesConnected := ""
    For Device in ComObjGet("winmgmts:").ExecQuery("Select * from Win32_PnPEntity")
        ListDevicesConnected .= Device.DeviceID "`n"

    ;=============================================================================================

    ; Find which device status has changed in oMyDevices
    ThisDeviceStatusHasChanged := ""
    For Index, Element in oMyDevices
    {
        If InStr(ListDevicesConnected, Element.DeviceID)
            If (oMyDevices[Index].Status = "Disconnected"), oMyDevices[Index].Status := "Connected"
                ThisDeviceStatusHasChanged := Element.DeviceName " Connected"

        If !InStr(ListDevicesConnected, Element.DeviceID)
            If (oMyDevices[Index].Status = "Connected"), oMyDevices[Index].Status := "Disconnected"
                ThisDeviceStatusHasChanged := Element.DeviceName " Disconnected"
    }

    ;=============================================================================================

    ; If a device in oMyDevices status has changed go to DeviceActions()
    If ThisDeviceStatusHasChanged
        DeviceActions(ThisDeviceStatusHasChanged, DontShowToolTip := "")
    
    StartTime := A_TickCount

return

;=============================================================================================

DeviceActions(ThisDeviceStatusHasChanged, DontShowToolTip := "") {

    If (!DontShowToolTip) {
        CoordMode, ToolTip, Window
        Tooltip, % ThisDeviceStatusHasChanged, 150, 640
        SetTimer, RemoveToolTip, -5000
        
    }

    ;=============================================================================================

    If (ThisDeviceStatusHasChanged = "USB Kingston DataTraveler 3.0 Connected")
        If !WinExist("ahk_exe Notepad.exe")
            Run, Notepad.exe

    If (ThisDeviceStatusHasChanged = "USB Kingston DataTraveler 3.0 Disconnected")
        If WinExist("ahk_exe Notepad.exe")
            Winclose, % "ahk_exe Notepad.exe"

    ;=============================================================================================

    If (ThisDeviceStatusHasChanged = "PLAYSTATION(R)3 Controller Connected")
        If !WinExist("ahk_exe wordpad.exe")
            Run, wordpad.exe

    If (ThisDeviceStatusHasChanged = "PLAYSTATION(R)3 Controller Disconnected")
        If WinExist("ahk_exe wordpad.exe")
            Winclose, % "ahk_exe wordpad.exe"

    ;=============================================================================================

    If (ThisDeviceStatusHasChanged = "HDMI Samsung TV Connected")
        If !WinExist("ahk_exe mspaint.exe")
            Run, mspaint.exe
    
    If (ThisDeviceStatusHasChanged = "HDMI Samsung TV Disconnected")
        If WinExist("ahk_exe mspaint.exe")
            Winclose, % "ahk_exe mspaint.exe"

    ;=============================================================================================

    ThisDeviceStatusHasChanged := ""
}

RemoveToolTip:
ToolTip
return
Attachments
22_09_25__10_44_19.PNG
22_09_25__10_44_19.PNG (44.86 KiB) Viewed 1520 times

XMCQCX
Posts: 225
Joined: 14 Oct 2020, 23:44

Re: Run scripts or programs when a specific device is connected/disconnected

Post by XMCQCX » 25 Sep 2022, 09:43

Lepes wrote:
25 Sep 2022, 03:50
What about to integrate both scripts into a single one with Gui?
Nice script, Lepes. I will think about it. About the GUI, It's a good idea. I might include one when it's officially release. If you keep working on yours, update it here if you want. I might take pieces of it and give you credits if I include it.

XMCQCX
Posts: 225
Joined: 14 Oct 2020, 23:44

Re: Run scripts or programs when a specific device is connected/disconnected

Post by XMCQCX » 28 Sep 2022, 20:33

Lepes wrote: I'm a noob, I'm sure it could be better done!
Hi Lepes, Finally, I will not include a GUI. The script was officially released on this page, go there if you want to download the latest version:
viewtopic.php?f=6&t=108930

Lepes
Posts: 141
Joined: 06 May 2021, 07:32
Location: Spain

Re: Run scripts or programs when a specific device is connected/disconnected

Post by Lepes » 29 Sep 2022, 07:44

Perfect! It is your script and maybe better on this way, everyone can adapt to any other script they have!

Post Reply

Return to “Ask for Help (v1)”