Sign in to follow this  
Followers 0
Skitty

Objects and AutoIt..

2 posts in this topic

#1 ·  Posted (edited)

Can some one explain to me what an object is used for and how it makes my scripting less skiddiedly do like?

Also, an example script would be nice.

What are objects for? etc.

eg-

$strComputer = "."
$objWMIServices = ObjGet("winmgmts:" & "{impersonationLevel=impersonate}!\\" & $strComputer & "\root\cimv2")
$sink = ObjCreate("WbemScripting.SWbemSink")
ObjEvent($sink,"SINK_")
$objWMIServices.ExecNotificationQueryAsync ($sink, "SELECT * FROM __InstanceOperationEvent WITHIN 5 WHERE " & "TargetInstance ISA 'Win32_LogicalDisk'")

While 1
    Sleep(500)
Wend

Func SINK_OnObjectReady($objObject, $objAsyncContext)
 If $objObject.TargetInstance.DriveType = 2 Then
        Select
            Case $objObject.Path_.Class()="__InstanceCreationEvent"
               ;USB detected
            Case $objObject.Path_.Class()="__InstanceDeletionEvent"
               ;USB removed
        EndSelect
    EndIf
EndFunc

How the hell does

$objWMIServices = ObjGet("winmgmts:" & "{impersonationLevel=impersonate}!\\" & $strComputer & "\root\cimv2")

$sink = ObjCreate("WbemScripting.SWbemSink")

ObjEvent($sink,"SINK_")

$objWMIServices.ExecNotificationQueryAsync ($sink, "SELECT * FROM __InstanceOperationEvent WITHIN 5 WHERE " & "TargetInstance ISA 'Win32_LogicalDisk'")

work???

Edited by System238

Things that I've done..

Icon Resource Editor: icon resource editor 

AutoIt Piano: a piano

AutoIt Unlocker: unlocks files when you want to delete them

Colorful tooltips: a wrapper for the tool tips UDF

Rouge GoogleBot: a full screen animation

ASciTE text editor: a text editor written in autoit

Warning: Posts by this user are subject to change or may disappear without notice.

Share this post


Link to post
Share on other sites



Event sinks are kind of jumping in at the deep end. You might want to start on easier object references and work your way up to those. Search for something easy like adding a local user:

#RequireAdmin

$oWinNT = ObjGet("WinNT://.")
$oUser = $oWinNT.Create("user", "MyNewUser")
$oUser.SetPassword("MyNewPa$$word")
$oUser.SetInfo

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0