Created
March 20, 2022 20:41
-
-
Save vayn/a0bb5513bf2ac9aadb4bb2695575ded2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
strCmd = "%COMSPEC% /c ping 192.0.2.1 -n 1 -w 1000 >nul" | |
Set shell = CreateObject("WScript.Shell") | |
shell.Run strCmd, 0, 1 | |
WScript.Echo("Foreground window title: " & vbCrLf & GetForeWindowCaption()) | |
Function GetForeWindowCaption() | |
Const WM_GETTEXT = &HD | |
Set DX = CreateObject("DynamicWrapperX") | |
DX.Register "user32", "GetForegroundWindow", "f=s", "r=l" | |
DX.Register "user32", "SendMessage", "i=huuS", "f=s", "r=l" | |
Title = Space(100) | |
res = DX.SendMessage(DX.GetForegroundWindow(), WM_GETTEXT, 100, Title) | |
GetForeWindowCaption = Title | |
End Function |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment