Jump to content

Analyzing COM objects


water
 Share

Recommended Posts

Just for the records:
 
MS provides an easy method to retrieve the methods, properties, events of COM objects by using PowerShell.

  • Open powershell.
  • Create the object. The syntax is:
    $variable = New-object -ComObject "ProgID"
  • Type the variable name to retrieve the properties of the object
  • Use "Get-Member" to retrieve all properties, methods, collections and events of the object

Example: 

$IE = New-object -ComObject "InternetExplorer.Application"
$IE
$IE|Get-Member
PS> $object = New-Object -COMObject "InternetExplorer.Application"
PS> $object

Application          : System.__ComObject
Parent               : System.__ComObject
Container            :
Document             :
TopLevelContainer    : True
Type                 :
Left                 : 309
Top                  : 92
Width                : 1383
Height               : 870
LocationName         :
LocationURL          :
Busy                 : False
Name                 : Windows Internet Explorer
HWND                 : 2361028
FullName             : C:\Program Files\Internet Explorer\iexplore.exe
Path                 : C:\Program Files\Internet Explorer\
Visible              : False
StatusBar            : True
StatusText           :
ToolBar              : 1
MenuBar              : True
FullScreen           : False
ReadyState           : 0
Offline              : False
Silent               : False
RegisterAsBrowser    : False
RegisterAsDropTarget : True
TheaterMode          : False
AddressBar           : True
Resizable            : True

PS> $object|Get-Member

   TypeName: System.__ComObject#{d30c1661-cdaf-11d0-8a3e-00c04fc9e26e}

Name                 MemberType Definition
----                 ---------- ----------
ClientToWindow       Method     void ClientToWindow (int, int)
ExecWB               Method     void ExecWB (OLECMDID, OLECMDEXECOPT, Variant, Variant)
GetProperty          Method     Variant GetProperty (string)
GoBack               Method     void GoBack ()
GoForward            Method     void GoForward ()
GoHome               Method     void GoHome ()
GoSearch             Method     void GoSearch ()
Navigate             Method     void Navigate (string, Variant, Variant, Variant, Variant
Navigate2            Method     void Navigate2 (Variant, Variant, Variant, Variant, Varia
PutProperty          Method     void PutProperty (string, Variant)
QueryStatusWB        Method     OLECMDF QueryStatusWB (OLECMDID)
Quit                 Method     void Quit ()
Refresh              Method     void Refresh ()
Refresh2             Method     void Refresh2 (Variant)
ShowBrowserBar       Method     void ShowBrowserBar (Variant, Variant, Variant)
Stop                 Method     void Stop ()
AddressBar           Property   bool AddressBar () {get} {set}
Application          Property   IDispatch Application () {get}
Busy                 Property   bool Busy () {get}
Container            Property   IDispatch Container () {get}
Document             Property   IDispatch Document () {get}
FullName             Property   string FullName () {get}
FullScreen           Property   bool FullScreen () {get} {set}
Height               Property   int Height () {get} {set}
HWND                 Property   int64 HWND () {get}
Left                 Property   int Left () {get} {set}
LocationName         Property   string LocationName () {get}
LocationURL          Property   string LocationURL () {get}
MenuBar              Property   bool MenuBar () {get} {set}
Name                 Property   string Name () {get}
Offline              Property   bool Offline () {get} {set}
Parent               Property   IDispatch Parent () {get}
Path                 Property   string Path () {get}
ReadyState           Property   tagREADYSTATE ReadyState () {get}
RegisterAsBrowser    Property   bool RegisterAsBrowser () {get} {set}
RegisterAsDropTarget Property   bool RegisterAsDropTarget () {get} {set}
Resizable            Property   bool Resizable () {get} {set}
Silent               Property   bool Silent () {get} {set}
StatusBar            Property   bool StatusBar () {get} {set}
StatusText           Property   string StatusText () {get} {set}
TheaterMode          Property   bool TheaterMode () {get} {set}
ToolBar              Property   int ToolBar () {get} {set}
Top                  Property   int Top () {get} {set}
TopLevelContainer    Property   bool TopLevelContainer () {get}
Type                 Property   string Type () {get}
Visible              Property   bool Visible () {get} {set}
Width                Property   int Width () {get} {set}
Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

That is pretty ace.

Windows PowerShell
Copyright © 2009 Microsoft Corporation. All rights reserved.
 
PS C:UsersJOHN> $SW = New-object -ComObject "ShockwaveFlash.ShockwaveFlash.11"
PS C:UsersJOHN> $SW
 
 
ReadyState                 : 0
TotalFrames                :
Playing                    : True
Quality                    : 1
ScaleMode                  : 0
AlignMode                  : 0
BackgroundColor            : -1
Loop                       : True
Movie                      :
FrameNum                   : -1
WMode                      : Window
SAlign                     :
Menu                       : True
Base                       :
Scale                      : ShowAll
DeviceFont                 : False
EmbedMovie                 : False
BGColor                    :
Quality2                   : High
SWRemote                   :
FlashVars                  :
AllowScriptAccess          :
MovieData                  :
InlineData                 :
SeamlessTabbing            : True
Profile                    : False
ProfileAddress             :
ProfilePort                : 0
AllowNetworking            : all
AllowFullScreen            : false
AllowFullScreenInteractive : false
IsDependent                : False
 
 
 
PS C:UsersJOHN> $SW|Get-Member
 
 
   TypeName: System.__ComObject#{d27cdb6c-ae6d-11cf-96b8-444553540000}
 
Name                       MemberType Definition
----                       ---------- ----------
Back                       Method     void Back ()
CallFunction               Method     string CallFunction (string)
CurrentFrame               Method     int CurrentFrame ()
DisableLocalSecurity       Method     void DisableLocalSecurity ()
EnforceLocalSecurity       Method     void EnforceLocalSecurity ()
FlashVersion               Method     int FlashVersion ()
Forward                    Method     void Forward ()
FrameLoaded                Method     bool FrameLoaded (int)
GetVariable                Method     string GetVariable (string)
GotoFrame                  Method     void GotoFrame (int)
IsPlaying                  Method     bool IsPlaying ()
LoadMovie                  Method     void LoadMovie (int, string)
Pan                        Method     void Pan (int, int, int)
PercentLoaded              Method     int PercentLoaded ()
Play                       Method     void Play ()
Rewind                     Method     void Rewind ()
SetReturnValue             Method     void SetReturnValue (string)
SetVariable                Method     void SetVariable (string, string)
SetZoomRect                Method     void SetZoomRect (int, int, int, int)
Stop                       Method     void Stop ()
StopPlay                   Method     void StopPlay ()
TCallFrame                 Method     void TCallFrame (string, int)
TCallLabel                 Method     void TCallLabel (string, string)
TCurrentFrame              Method     int TCurrentFrame (string)
TCurrentLabel              Method     string TCurrentLabel (string)
TGetProperty               Method     string TGetProperty (string, int)
TGetPropertyAsNumber       Method     double TGetPropertyAsNumber (string, int)
TGetPropertyNum            Method     double TGetPropertyNum (string, int)
TGotoFrame                 Method     void TGotoFrame (string, int)
TGotoLabel                 Method     void TGotoLabel (string, string)
TPlay                      Method     void TPlay (string)
TSetProperty               Method     void TSetProperty (string, int, string)
TSetPropertyNum            Method     void TSetPropertyNum (string, int, double)
TStopPlay                  Method     void TStopPlay (string)
Zoom                       Method     void Zoom (int)
AlignMode                  Property   int AlignMode () {get} {set}
AllowFullScreen            Property   string AllowFullScreen () {get} {set}
AllowFullScreenInteractive Property   string AllowFullScreenInteractive () {get} {set}
AllowNetworking            Property   string AllowNetworking () {get} {set}
AllowScriptAccess          Property   string AllowScriptAccess () {get} {set}
BackgroundColor            Property   int BackgroundColor () {get} {set}
Base                       Property   string Base () {get} {set}
BGColor                    Property   string BGColor () {get} {set}
DeviceFont                 Property   bool DeviceFont () {get} {set}
EmbedMovie                 Property   bool EmbedMovie () {get} {set}
FlashVars                  Property   string FlashVars () {get} {set}
FrameNum                   Property   int FrameNum () {get} {set}
InlineData                 Property   IUnknown InlineData () {get} {set}
IsDependent                Property   bool IsDependent () {get} {set}
Loop                       Property   bool Loop () {get} {set}
Menu                       Property   bool Menu () {get} {set}
Movie                      Property   string Movie () {get} {set}
MovieData                  Property   string MovieData () {get} {set}
Playing                    Property   bool Playing () {get} {set}
Profile                    Property   bool Profile () {get} {set}
ProfileAddress             Property   string ProfileAddress () {get} {set}
ProfilePort                Property   int ProfilePort () {get} {set}
Quality                    Property   int Quality () {get} {set}
Quality2                   Property   string Quality2 () {get} {set}
ReadyState                 Property   int ReadyState () {get}
SAlign                     Property   string SAlign () {get} {set}
Scale                      Property   string Scale () {get} {set}
ScaleMode                  Property   int ScaleMode () {get} {set}
SeamlessTabbing            Property   bool SeamlessTabbing () {get} {set}
SWRemote                   Property   string SWRemote () {get} {set}
TotalFrames                Property   int TotalFrames () {get}
WMode                      Property   string WMode () {get} {set}
 
 
PS C:UsersJOHN>

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

To be honest, it is something I found on the AHK forum ^_^

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Is it possible to use powershell via command line?

I tried doing it adding $IE = New-object -ComObject "InternetExplorer.Application" as an argument but get ..

"Invalid assignment expression. The left hand side of an assignment operator nee

ds to be something that can be assigned to like a variable or a property."

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

It is possible AFAIK. From the top of my head: Use '-command $IE = New-object -ComObject "InternetExplorer.Application"*

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

powershell -command "$IE = New-object -ComObject InternetExplorer.Application; $IE|Get-Member"

or

powershell -command "$IE = New-object -ComObject 'InternetExplorer.Application'; $IE|Get-Member"

work pretty well.

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Yep, that's it, cheers.

$Read = ""

$iPid = Run(@SystemDir & '\WindowsPowerShell\v1.0\powershell.exe -Command $SW = New-object -ComObject  "Shell.Explorer.2"' & @CRLF & '$SW' & @CRLF & '$SW|Get-Member', "", @SW_HIDE, 0x2 + 0x4)

While ProcessExists("powershell.exe")
    $Read &= StdoutRead($iPid)
WEnd

ConsoleWrite($Read)

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

A bit shorter:

$Read = ""

$iPid = Run(@SystemDir & '\WindowsPowerShell\v1.0\powershell.exe -Command $SW = New-object -ComObject "Shell.Explorer.2";$SW;$SW|Get-Member', "", @SW_HIDE, 0x2 + 0x4)

While ProcessExists("powershell.exe")
    $Read &= StdoutRead($iPid)
WEnd

ConsoleWrite($Read)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Shorter code...

$iPid = Run(@SystemDir & '\WindowsPowerShell\v1.0\powershell.exe -Command $SW = New-object -ComObject "Shell.Explorer.2";$SW;$SW|Get-Member', "", @SW_HIDE, 0x2 + 0x4)

While ProcessExists("powershell.exe")
WEnd

ConsoleWrite(StdoutRead($iPid))

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

I didn't have to install it on my Windows 7 machine.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

PowerShell 1.0
PowerShell 1.0 was released in 2006 for Windows XP SP2, Windows Server 2003 and Windows Vista. It is an optional component of Windows Server 2008.
 
PowerShell 2.0
Windows PowerShell ISE v2.0, an integrated development environment for PowerShell scripts
PowerShell 2.0 is integrated with Windows 7 and Windows Server 2008 R2 and is released for Windows XP with Service Pack 3, Windows Server 2003 with Service Pack 2, and Windows Vista with Service Pack 1.
PowerShell V2 includes changes to the scripting language and hosting API, in addition to including more than 240 new cmdlets.

 

From wikipedia^

Although I'm sure I only have powershell 1.0 on my win 7 pro 32.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

Check the version by running the following command. Here are my results.

>powershell -command $PSVersionTable

Name                           Value
----                           -----
PSVersion                      3.0
WSManStackVersion              3.0
SerializationVersion           1.1.0.1
CLRVersion                     4.0.30319.34209
BuildVersion                   6.2.9200.16481
PSCompatibleVersions           {1.0, 2.0, 3.0}
PSRemotingProtocolVersion      2.2

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Mine are a little different.

Name Value
---- -----
CLRVersion 2.0.50727.5485
BuildVersion 6.1.7601.17514
PSVersion 2.0
WSManStackVersion 2.0
PSCompatibleVersions {1.0, 2.0}
SerializationVersion 1.1.0.1
PSRemotingProtocolVersion 2.1

 

 

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

I'm running Windows 7 Service Pack 1.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

I'm running 64 bit with the latest updates.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Good luck ;)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Name                           Value
----                           -----
PSVersion                      4.0
WSManStackVersion              3.0
SerializationVersion           1.1.0.1
CLRVersion                     4.0.30319.18444
BuildVersion                   6.3.9600.16406
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0}
PSRemotingProtocolVersion      2.2

 

 

:)

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

  • Jon unfeatured this topic

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
 Share

×
×
  • Create New...