Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to get a name of the active application in vbs?

Status
Not open for further replies.

maysider

Technical User
Apr 5, 2006
15
CZ
How to get a name of the active application in vbscript? I've been founding this for a long time, but because of beeing beginner I haven't found a final solution. Could someone help me and could exactly write in vbs this?:
"if wmplayer is.active then
wscript.echo "wmplayer is active"
end if"
thanx
 
Is it possible to find out a name of the active app?
 
Code:
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colProcesses = objWMIService.ExecQuery _
    ("Select * from Win32_Process")
       'Seed the report
       NotepadStatus = "Notepad is not running"
For Each objProcess in colProcesses
    If objProcess.Name = "notepad.exe" Then
       NotepadStatus = "Notepad is running"
    End IF
Next

WScript.Echo NotepadStatus

I hope you find this post helpful.

Regards,

Mark
 
I think I've explained my problem a little confused. I don't need to know, if is application running - I want to know, if is my application in active mode (in the foreground). And would be better, if I knew exact name of active (in the foreground) application....not to know if is running.
thx
 
I don't think that is possible. It is possible to SET what you want to be in the foreground however.

I hope you find this post helpful.

Regards,

Mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top