Creates a reference to a COM object from the given classname.
ObjCreate ( "classname" [, "servername" [, "username" [, "password"]]] )
Use ObjCreate() if you want to have a new instance of the referring application.
If you want to connect to an existing process, use ObjGet() instead.
Keep in mind that not all computers have the same set of Objects. So always check for errors after calling ObjCreate(). To check errors use ObjEvent().
The following requirements apply if you want to access objects on remote computers:
GUICtrlCreateObj, IsObj, ObjEvent, ObjGet, ObjName
#include <MsgBoxConstants.au3>
; Counting the number of open shell windows
Local $oShell= ObjCreate ("shell.application"); Get the Windows Shell Object
Local $oShellWindows= $oShell.Windows(); Get the collection of open shell Windows
If IsObj ($oShellWindows)Then
Local $sString= ""; String for displaying purposes
For $oWndIn $oShellWindows; Count all existing shell windows
$sString&=$oWnd.LocationName&@CRLF
Next
MsgBox ($MB_SYSTEMMODAL,"","Shell Windows:"&@CRLF &"You have the following shell windows:"&@CRLF &@CRLF &$sString)
EndIf
#include <MsgBoxConstants.au3>
; Open the MediaPlayer on a REMOTE computer
Local $oRemoteMedia= ObjCreate ("MediaPlayer.MediaPlayer.1","name-of-remote-computer")
If Not @error Then
MsgBox ($MB_SYSTEMMODAL,"Remote ObjCreate Test","ObjCreate() of a remote Mediaplayer Object successful !")
$oRemoteMedia.Open(@WindowsDir &"\media\tada.wav"); Play sound if file is present
Else
MsgBox ($MB_SYSTEMMODAL,"Remote ObjCreate Test","Failed to open remote Object. Error code: "&Hex (@error ,8))
EndIf