Jump to content

How to bring an application to bring on top (focus) and active


Recommended Posts


Could you provide more infomation about what you want.

Here is a Vbs Script that uses AppActivate and SendKeys Method

1:\ Open Notepad

2:\ Add Some Text

3:\ Save And Closes the new Text flle

AppActivate And Sending Keystrokes to a Program

Save As Demo_SendKey.vbs


Dim Act :Set Act = CreateObject("Wscript.Shell")
Act.Run("Notepad.exe"),1,False
Do Until Success = True
Success = Act.AppActivate("Notepad")
Wscript.Sleep 1000
Loop

Act.SendKeys "This is a test of AppActivate."
WScript.Sleep 1000
Act.SendKeys "{ENTER}"
Act.SendKeys "T" :WScript.Sleep 500
Act.SendKeys "e" :WScript.Sleep 500
Act.SendKeys "s" :WScript.Sleep 500
Act.SendKeys "t" :WScript.Sleep 500
Act.SendKeys "%F"
Act.SendKeys "{DOWN}" :WScript.Sleep 500
Act.SendKeys "{DOWN}" :WScript.Sleep 500
Act.SendKeys "{DOWN}" :WScript.Sleep 500
Act.SendKeys "{ENTER}" :WScript.Sleep 500
Act.SendKeys "Demo_Send_Key.txt"
Act.SendKeys "{ENTER}",500
Act.SendKeys "%F" :WScript.Sleep 1000
Act.SendKeys "{DOWN}" :WScript.Sleep 500
Act.SendKeys "{DOWN}" :WScript.Sleep 500
Act.SendKeys "{DOWN}" :WScript.Sleep 500
Act.SendKeys "{DOWN}" :WScript.Sleep 500
Act.SendKeys "{DOWN}" :WScript.Sleep 500
Act.SendKeys "{DOWN}" :WScript.Sleep 500
Act.SendKeys "{ENTER}" :WScript.Sleep 500

Rename Demo_SendKey.vbs.txt to Demo_SendKey.vbs to make active.

Demo_SendKey.vbs.txt

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...