VBScript outputs ESC according to the title of the IE window

Time:2021-11-30

It’s been a long time. A printer driver will always pop up a window and tell you what’s wrong. Because my program comes out automatically and belongs to a machine that has not been supervised for a long time, when this information jumps out, it will stop the program. At this time, you should think that you can continue by pressing the ESC key. In the future to solve this problem, I useVBScriptI wrote a few lines of file instead of pressing this ESC.

Core code

?
1
2
3
4
5
6
7
8
9
10
11
'test function
PressESC"Windows Internet Explorer", "{ESCAPE}"
 
'the function we want to handle
Function PressESC(WindowTitle, KeyCommand)
  Set objShell = CreateObject("WScript.Shell")'define a WHS object
  If objShell.AppActivate(WindowTitle) Then 'check if there are windows we want to check
    Objshell. Appactivate windowtitle 'focus the window
    objShell.SendKeys KeyCommand 'Send an ESC key
  End If
End Function

Save the above code as a VBS file, and then set this VBS as the windows scheduler to automatically press ESC.

Recommended Today

Game case | application evolution and practice of service mesh in happy games

author Chen Zhiwei, Tencent level 12 background expert engineer, is now responsible for the public background technology research and development and team management of happy game studio. Rich experience in micro service distributed architecture and game background operation and maintenance research and development. preface The background of happy game studio is a distributed micro service […]