specific port
GetComPortInfo(port) {
; Run PowerShell command to get device name associated with the port
RunWait, %ComSpec% /c powershell.exe -Command "(Get-WmiObject Win32_PnPEntity | Where-Object { $_.Name -match 'COM' + port }).Name", , UseErrorLevel, Output
if !ErrorLevel {
return "Device connected to COM" port ": " Output
} else {
return "No device found on COM" port
}
}
; Function to display text on OSD
ShowOnScreenDisplay(text) {
; Here you should call the appropriate function or method
; to display text on the OSD.
; Replace the following line with the actual function call
MsgBox, % text
}
; Function to retrieve list of connected COM ports
GetConnectedComPorts() {
ports := []
; Run 'mode' command to get a list of active COM ports
RunWait, %ComSpec% /c mode, , UseErrorLevel, Output
if !ErrorLevel {
Loop, Parse, Output, `n
{
; Extract port name from each line of output
if (RegExMatch(A_LoopField, "COM\d+", port))
ports.push(port)
}
}
return ports
}
; Example usage
connectedPorts := GetConnectedComPorts()
if (connectedPorts.length() > 0) {
for each, port in connectedPorts {
comPortInfo := GetComPortInfo(port)
ShowOnScreenDisplay(comPortInfo)
}
} else {
MsgBox, No COM ports found.
}
can anyone help me to improve the script to show tooltip only when com port device connected with its proper full name?
Стикер
maybe you didn't read the full sentences
Обсуждают сегодня