Jump to content

Recommended Posts

Posted (edited)

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:

  Reveal hidden contents

 

Posted

That is pretty ace.

  Reveal hidden contents

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

Monkey's are, like, natures humans.

Posted (edited)

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

Edited by water

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted

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.

Posted

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

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted (edited)

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:

  Reveal hidden contents

 

Posted

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.

Posted

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:

  Reveal hidden contents

 

Posted

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.

Posted

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

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted
  Quote
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.

Posted

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:

  Reveal hidden contents

 

Posted (edited)

Mine are a little different.

  Quote
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.

Posted

I'm running Windows 7 Service Pack 1.

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted

I'm running 64 bit with the latest updates.

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted

Good luck ;)

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted
  Quote
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.

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
×
×
  • Create New...