In Case anyone is listening

Started by spl, July 07, 2026, 07:31:01 AM

Previous topic - Next topic

spl

Yeah, I know this could be done with pure WB, but couldn't resist a PS one-liner with multi pipeline. Uses my std_out function to display current port listeners.
;Get Port Listeners
;Stan Littlefield 7/8/2026
;========================================================================================================================
Gosub udfs
file = Dirscript():"listeners.txt"
If fileexist(file) Then filedelete(file)
args = "Get-NetTCPConnection -State Listen | Select-Object -Property LocalPort, State, @{name='ProcessID';expression={(Get-Process -Id $_.OwningProcess). ID}}, @{name='ProcessName';expression={(Get-Process -Id $_.OwningProcess). Path}} | Sort-Object LocalPort"
cmd="Powershell"
msg='Display Port Listeners'
BoxOpen("Running...",cmd:" ":args:@LF:"PLEASE WAIT...MAY TAKE SOME TIME")
TimeDelay(3)
vals = Get_stdout()
Fileput(file,vals)
If FileExist(file) Then Run("notepad.exe",file)
Exit
;======================================================================
:udfs
#DefineSubroutine Get_stdout()
ObjectClrOption("useany","System")
objInfo = ObjectClrNew("System.Diagnostics.ProcessStartInfo")
Output=""
timeOut = ObjectType("I2",5000)
objInfo.FileName = cmd
objInfo.RedirectStandardError = ObjectType("BOOL",@TRUE)
objInfo.RedirectStandardOutput = ObjectType("BOOL",@TRUE)
objInfo.UseShellExecute = ObjectType("BOOL",@FALSE)
objInfo.CreateNoWindow = ObjectType("BOOL",@TRUE)
objInfo.Arguments = args
oProcess = ObjectClrNew("System.Diagnostics.Process")
oProcess.StartInfo = objInfo
BoxShut()
oProcess.Start()
oProcess.WaitForExit(timeout)
STDOUT = oProcess.StandardOutput.ReadToEnd()
STDERR = oProcess.StandardError.ReadToEnd()
Output = Output:STDOUT:@CRLF
;If STDERR<>""
;   Output = Output:"STDERR:":STDERR:@CRLF
;Endif
oProcess = 0
objInfo = 0

Return (Output)
#EndSubroutine
Return
;==========================================================
Stan - formerly stanl [ex-Pundit]

td

"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

kdmoyers

This reminds me of a similar problem, only for the keyboard instead of port listeners.

Does anyone know of something that tells all the things that are trapping keys in the system? I've got so many hot keys defined, intentionally and unintentionally, that it's become a mess.
The mind is everything; What you think, you become.

td

Of course, finding all the hot keys on a system can be a challenge because it is not a stationary target. There are global hot keys, desktop shortcut hotkeys, and several flavors of application hotkeys that may or may not be active only when the application has the input focus.

As I am sure you already know, the ShortcutInfo function can give you the hotkey combination associated with a desktop shortcut. Several freeware programs purported to find all active hotkeys. ActiveHotkey is one but I have never tried it.  Another application I have never used can be found on GitHub:

https://github.com/wikimint/winshortcuts

I think there are also COM or .Net based objects you could use to write your own WIL script to get at the global system shortcuts. I haven't tried that either.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

SMF spam blocked by CleanTalk