Sign in to follow this  
Followers 0
Exit

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

2 posts in this topic

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 ?


My UDFs, Abbrevs and Snippets
If you like my post, just click the like button :) 

Share this post


Link to post
Share on other sites



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.

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