Here is a way to do it with WMI.  Got this by quickly editing a scriptomatic generated script:


On Error Resume Next

Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20

arrComputers = Array("<COMPUTERNAME>")
For Each strComputer In arrComputers
   WScript.Echo
   WScript.Echo "=========================================="
   WScript.Echo "Computer: " & strComputer
   WScript.Echo "=========================================="

   Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
   Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_SoftwareFeature where vendor like '%Microsoft%'", "WQL", _
                                          wbemFlagReturnImmediately + wbemFlagForwardOnly)

   For Each objItem In colItems
      WScript.Echo "Accesses: " & objItem.Accesses
      WScript.Echo "Attributes: " & objItem.Attributes
      WScript.Echo "Caption: " & objItem.Caption
      WScript.Echo "Description: " & objItem.Description
      WScript.Echo "IdentifyingNumber: " & objItem.IdentifyingNumber
      WScript.Echo "InstallDate: " & WMIDateStringToDate(objItem.InstallDate)
      WScript.Echo "InstallState: " & objItem.InstallState
      WScript.Echo "LastUse: " & WMIDateStringToDate(objItem.LastUse)
      WScript.Echo "Name: " & objItem.Name
      WScript.Echo "ProductName: " & objItem.ProductName
      WScript.Echo "Status: " & objItem.Status
      WScript.Echo "Vendor: " & objItem.Vendor
      WScript.Echo "Version: " & objItem.Version
      WScript.Echo
   Next
Next


Function WMIDateStringToDate(dtmDate)
WScript.Echo dtm:
        WMIDateStringToDate = CDate(Mid(dtmDate, 5, 2) & "/" & _
        Mid(dtmDate, 7, 2) & "/" & Left(dtmDate, 4) _
        & " " & Mid (dtmDate, 9, 2) & ":" & Mid(dtmDate, 11, 2) & ":" & Mid(dtmDate,13, 2))
End Function



JK



Howard Tanner <[EMAIL PROTECTED]>
Sent by: [EMAIL PROTECTED]

01/26/2006 02:24 PM

To
Foo Ji-Haw <[EMAIL PROTECTED]>
cc
[email protected]
Subject
Re: Retrieving Windows applications on desktop





>>Is there a way in Perl to get a list of all the Windows applications
>>that are running? Basically applications that show in the
>>Alt-Tab list.
>>I am just wondering if I can get the desktop coordinates of the
>>respective windows applications.
>>
>>Any hint is appreciated.
>>
>
> WMI is a good start, but I don't think it exposes the application screen
> coordinates.
>
>

I could not find a way to get this info from WMI either.

However, what I think you're really looking for are the coordinates
for the top level windows, so there's no need for the processes. To do
this, you need to use the following Windows API's:

EnumWindows (uses a callback to identify each top-level window)
GetWindowText (to get the title of the window)
GetWindowInfo (returns a WINDOWINFO struct, which contains RECT
rcWindow, which is what you're looking for)

These API's are documented at Microsoft's MSDN library:
http://msdn.microsoft.com/library. Basically, the EnumWindows callback
is passed a window handle (hwnd) for each top-level window. The hwnd
can then be passed to GetWindowText and GetWindowInfo to get the
information you need about that window.

This is easy enough in a language that can call Windows API's but this
is beyond my current Perl skills. There's a Win32::API module that
might do the trick, but I can't see how to do the callback with it.
Perhaps an XS is the way to go, but that's beyond me right now, and
perhaps way more complicated than simply using a language that can
call Windows API's...

Perhaps someone else on this list can use this info to craft the Perl
you need...

Good luck,
HT

_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



*******************************************************************

This email and any files transmitted with it are confidential
and intended solely for the use of the individual or entity
to whom they are addressed. If you have received this
email in error please notify the sender by replying to this
email and then delete it from your system.

No reliance may be placed upon this email without written
confirmation of its contents and any liability arising from
such reliance without written confirmation is hereby
excluded.

JRI America

*******************************************************************
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to