Jump to content

There must be an easier way to define a variable object property


Exit
 Share

Recommended Posts

I'm looking for a simple way to get an object property defined in a variable.

$o = ObjCreate("InternetExplorer.Application")
$o.navigate("http://www.autoitscript.com")
$o.visible = 1
Sleep(1000)

Dim $title1, $title2, $title3
$sProperty = "title"

$title1 = $o.document.title
$title2 = Execute("$o.document." & $sProperty)
;~ $title3 = $o.document.$sProperty     ; uncomment to see the error

ConsoleWrite("Title1: " & $title1 & @CRLF)
ConsoleWrite("Title2: " & $title2 & @CRLF)
ConsoleWrite("Title3: " & $title3 & @CRLF)

$o.quit()

Title1 is the hardcoded way.

Title2 is using a variable and Execute() function.

Please uncomment Title3 and get the error.

There must be a simpler method to get a variable property than using Execute().

Any ideas ?

App: Au3toCmd              UDF: _SingleScript()                             

Link to comment
Share on other sites

  • Moderators

Simpler than calling 1 function?  What's the issue really?

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...