Jump to content

anyone clever enough for this?


Recommended Posts

#include <array.au3>
Dim $attribs[3][2]
$attribs[0][0] = "method"
$attribs[0][1] = "user.getlovedtracks"
$attribs[1][0] = "api_key"
$attribs[1][1] = 'aa72a3b1161d33d0eba36f986fa1fb43'
$attribs[2][0] = "user"
$attribs[2][1] = "JRSmile"
$res = __lastfm_send($attribs)
ConsoleWrite($res & @CRLF)


Func __lastfm_send($attribs)
    Local $namespace
    If (Not IsArray($attribs)) Or (UBound($attribs, 0) <> 2) Then Return SetError(1, 0, False)
    $f = ObjCreate("pocketXMLRPC.Factory")
    $mystruct = ObjCreate("PocketXMLRPC.Struct")
    For $i = 0 To UBound($attribs) - 1
        If $attribs[$i][0] = "method" Then
            $tmp = StringSplit($attribs[$i][1],".", 1)
            $method = $tmp[2]
            $namespace = $tmp[1]
        Else
            Execute("$mystruct." & $attribs[$i][0] & ' = ' & "$attribs[$i][1]" & '')
            ConsoleWrite("$mystruct." & $attribs[$i][0] & ' = ' & "$attribs[$i][1]" & ' ==> ' & $attribs[$i][1] & @CRLF)
        EndIf
    Next
    $mystruct.user = $attribs[2][1] ; comment theese two lines out to see what i want to do.
        $mystruct.api_key = $attribs[1][1] ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    
    $objReq = $f.Proxy("http://ws.audioscrobbler.com/2.0/", $namespace & ".")
    $r = Execute("$objreq." & $method & "($mystruct)")
    $mystruct = 0
    $f = 0
    $r = StringReplace($r, '\"', '"')
    Return $r
EndFunc   ;==>__lastfm_send

if i assign the .user and the .api_key without execute it works, if i assign them via execute it does not work, anyone got a clue?

ps: PocketXMLRPC can be found here (awesome work of code)

Edited by JRSmile
$a=StringSplit("547275737420796F757220546563686E6F6C75737421","")
For $b=1 To UBound($a)+(-1*-1*-1)step(2^4/8);&$b+=1*2/40*µ&Asc(4)
Assign("c",Eval("c")&Chr(Dec($a[$b]&$a[$b+1])));''Chr("a")&"HI"
Next ;time_U&r34d,ths,U-may=get$the&c.l.u.e;b3st-regards,JRSmile;
MsgBox(0x000000,"",Eval("c"));PiEs:d0nt+*b3.s4d.4ft3r.1st-try:-)
Link to comment
Share on other sites

  • Moderators

I assume by you asking "Is anyone clever enough", you meant, clever enough not to download the executable without using a sandbox.

Edit:

Just FYI, I believe this subject has been talked about before. I remember weaponx or psaltyDS in the conversation. Can't remember if there was ever a positive conclusion.

Edit2:

I hope you understand my first post was because you didn't provide a link to review the information ... just a hard link to download an executable.

In addition, if memory serves me right (mind you, that post was probably 1+ years ago), I believe they used ScriptingDictionary .

Edit3:

http://www.autoitscript.com/forum/index.php?showtopic=82448

http://www.autoitscript.com/forum/index.php?showtopic=71878

Edited by SmOke_N

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

thanks for the links, unfortunately it doesn't work as expected, i can read out the attribut of $res = execute($obj.attrib) but if i want to set it the same way, it doesnt work.

like: Execute($obj.attrib = "test")

$a=StringSplit("547275737420796F757220546563686E6F6C75737421","")
For $b=1 To UBound($a)+(-1*-1*-1)step(2^4/8);&$b+=1*2/40*µ&Asc(4)
Assign("c",Eval("c")&Chr(Dec($a[$b]&$a[$b+1])));''Chr("a")&"HI"
Next ;time_U&r34d,ths,U-may=get$the&c.l.u.e;b3st-regards,JRSmile;
MsgBox(0x000000,"",Eval("c"));PiEs:d0nt+*b3.s4d.4ft3r.1st-try:-)
Link to comment
Share on other sites

i tested further, even this doe's not work:

Execute("$mystruct.user = 'aa72a3b1161d33d0eba36f986fa1fb43'")
    Execute("$mystruct.api_key = 'JRSmile'")
$a=StringSplit("547275737420796F757220546563686E6F6C75737421","")
For $b=1 To UBound($a)+(-1*-1*-1)step(2^4/8);&$b+=1*2/40*µ&Asc(4)
Assign("c",Eval("c")&Chr(Dec($a[$b]&$a[$b+1])));''Chr("a")&"HI"
Next ;time_U&r34d,ths,U-may=get$the&c.l.u.e;b3st-regards,JRSmile;
MsgBox(0x000000,"",Eval("c"));PiEs:d0nt+*b3.s4d.4ft3r.1st-try:-)
Link to comment
Share on other sites

  • Moderators

thanks for the links, unfortunately it doesn't work as expected, i can read out the attribut of $res = execute($obj.attrib) but if i want to set it the same way, it doesnt work.

like: Execute($obj.attrib = "test")

And this doesn't work?
Execute("$obj.attrib = test")
Or something similar?

Don't know really, but it seems that they covered this in the other links I provided.

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

will have a look again but i predict, no, its a bug in execute...

EDIT1:

http://www.autoitscript.com/forum/index.php?showtopic=82448

http://www.autoitscript.com/forum/index.php?showtopic=71878

both threads don't use execute to set objects, just get them :-(

thanks anyway, i created a ticket maybe valik can help us :-)

Edited by JRSmile
$a=StringSplit("547275737420796F757220546563686E6F6C75737421","")
For $b=1 To UBound($a)+(-1*-1*-1)step(2^4/8);&$b+=1*2/40*µ&Asc(4)
Assign("c",Eval("c")&Chr(Dec($a[$b]&$a[$b+1])));''Chr("a")&"HI"
Next ;time_U&r34d,ths,U-may=get$the&c.l.u.e;b3st-regards,JRSmile;
MsgBox(0x000000,"",Eval("c"));PiEs:d0nt+*b3.s4d.4ft3r.1st-try:-)
Link to comment
Share on other sites

I think Execute is working as expected. The description: "Returns the value of the evaluated expression."

It is a read-only function, which can render the variables passed to it. In this example you can see that $var does not change from 1 to 2.

$oSC = ObjCreate("Scripting.Dictionary")
$oSC("Test1") = "Test #1"
$oSC.Add("Test2", "Test #2")
Execute('$oSC("Test3") = "Test #3"')

$var = 1
Execute('$var = 2')

ConsoleWrite($oSC("Test1") & @CRLF)
ConsoleWrite($oSC("Test2") & @CRLF)
ConsoleWrite($oSC("Test3") & @CRLF)
ConsoleWrite($var & @CRLF)
Link to comment
Share on other sites

I think Execute is working as expected. The description: "Returns the value of the evaluated expression."

It is a read-only function, which can render the variables passed to it. In this example you can see that $var does not change from 1 to 2.

$oSC = ObjCreate("Scripting.Dictionary")
$oSC("Test1") = "Test #1"
$oSC.Add("Test2", "Test #2")
Execute('$oSC("Test3") = "Test #3"')

$var = 1
Execute('$var = 2')

ConsoleWrite($oSC("Test1") & @CRLF)
ConsoleWrite($oSC("Test2") & @CRLF)
ConsoleWrite($oSC("Test3") & @CRLF)
ConsoleWrite($var & @CRLF)

thanks to making things clear, but damn, this was the only way i could imagine preventing me from writing 1000th lines of code ...

$a=StringSplit("547275737420796F757220546563686E6F6C75737421","")
For $b=1 To UBound($a)+(-1*-1*-1)step(2^4/8);&$b+=1*2/40*µ&Asc(4)
Assign("c",Eval("c")&Chr(Dec($a[$b]&$a[$b+1])));''Chr("a")&"HI"
Next ;time_U&r34d,ths,U-may=get$the&c.l.u.e;b3st-regards,JRSmile;
MsgBox(0x000000,"",Eval("c"));PiEs:d0nt+*b3.s4d.4ft3r.1st-try:-)
Link to comment
Share on other sites

How many properties are there going to be? I would write it like this:

#include <array.au3>
Dim $attribs[3] = ["user.getlovedtracks",'aa72a3b1161d33d0eba36f986fa1fb43',"JRSmile"]

$res = __lastfm_send($attribs)
ConsoleWrite($res & @CRLF)


Func __lastfm_send($attribs)
    Local $method, $namespace
    
    If (Not IsArray($attribs)) Or (UBound($attribs) <> 3) Then Return SetError(1, 0, False)
    $f = ObjCreate("pocketXMLRPC.Factory")
    $mystruct = ObjCreate("PocketXMLRPC.Struct")
    
    $tmp = StringSplit($attribs[$i][1],".", 1)
    $method = $tmp[2]
    $namespace = $tmp[1]

    $mystruct.method = $method
    $mystruct.api_key = $attribs[1]
    $mystruct.user = $attribs[2]
   
    $objReq = $f.Proxy("http://ws.audioscrobbler.com/2.0/", $namespace & ".")
    $r = Execute("$objreq." & $method & "($mystruct)")
    $mystruct = 0
    $f = 0
    $r = StringReplace($r, '\"', '"')
    Return $r
EndFunc   ;==>__lastfm_send
Link to comment
Share on other sites

How many properties are there going to be? I would write it like this:

#include <array.au3>
Dim $attribs[3] = ["user.getlovedtracks",'aa72a3b1161d33d0eba36f986fa1fb43',"JRSmile"]

$res = __lastfm_send($attribs)
ConsoleWrite($res & @CRLF)


Func __lastfm_send($attribs)
    Local $method, $namespace
    
    If (Not IsArray($attribs)) Or (UBound($attribs) <> 3) Then Return SetError(1, 0, False)
    $f = ObjCreate("pocketXMLRPC.Factory")
    $mystruct = ObjCreate("PocketXMLRPC.Struct")
    
    $tmp = StringSplit($attribs[$i][1],".", 1)
    $method = $tmp[2]
    $namespace = $tmp[1]

    $mystruct.method = $method
    $mystruct.api_key = $attribs[1]
    $mystruct.user = $attribs[2]
   
    $objReq = $f.Proxy("http://ws.audioscrobbler.com/2.0/", $namespace & ".")
    $r = Execute("$objreq." & $method & "($mystruct)")
    $mystruct = 0
    $f = 0
    $r = StringReplace($r, '\"', '"')
    Return $r
EndFunc   ;==>__lastfm_send
I think you missed something.

C:\Documents and Settings\Gortstraat_41\Bureaublad\Test File.au3 (15) : ==> Variable used without being declared.:
$tmp = StringSplit($attribs[$i][1],".", 1)
$tmp = StringSplit($attribs[^ ERROR

AlmarM

Edited by AlmarM

Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

Link to comment
Share on other sites

I think you missed something.

C:\Documents and Settings\Gortstraat_41\Bureaublad\Test File.au3 (15) : ==> Variable used without being declared.:
 $tmp = StringSplit($attribs[$i][1],".", 1)
 $tmp = StringSplit($attribs[^ ERROR

AlmarM

You're right. I wasn't actually running the code.

#include <array.au3>
Dim $attribs[3] = ["user.getlovedtracks",'aa72a3b1161d33d0eba36f986fa1fb43',"JRSmile"]

$res = __lastfm_send($attribs)
ConsoleWrite($res & @CRLF)


Func __lastfm_send($attribs)
    Local $method, $namespace
    
    If (Not IsArray($attribs)) Or (UBound($attribs) <> 3) Then Return SetError(1, 0, False)
    Local $f = ObjCreate("pocketXMLRPC.Factory")
    Local $mystruct = ObjCreate("PocketXMLRPC.Struct")
    
    $tmp = StringSplit($attribs[0],".", 1)
    $method = $tmp[2]
    $namespace = $tmp[1]

    $mystruct.method = $method
    $mystruct.api_key = $attribs[1]
    $mystruct.user = $attribs[2]
   
    $objReq = $f.Proxy("http://ws.audioscrobbler.com/2.0/", $namespace & ".")
    $r = Execute("$objreq." & $method & "($mystruct)")
    $r = StringReplace($r, '\"', '"')
    Return $r
EndFunc   ;==>__lastfm_send
Link to comment
Share on other sites

I will have to add all parameters for all functions the api provides into aa switch case statement, then only the method itself can be called dynamically... :-) will do it in excel to prevent errors and stunned fingers:-)

$a=StringSplit("547275737420796F757220546563686E6F6C75737421","")
For $b=1 To UBound($a)+(-1*-1*-1)step(2^4/8);&$b+=1*2/40*µ&Asc(4)
Assign("c",Eval("c")&Chr(Dec($a[$b]&$a[$b+1])));''Chr("a")&"HI"
Next ;time_U&r34d,ths,U-may=get$the&c.l.u.e;b3st-regards,JRSmile;
MsgBox(0x000000,"",Eval("c"));PiEs:d0nt+*b3.s4d.4ft3r.1st-try:-)
Link to comment
Share on other sites

I will have to add all parameters for all functions the api provides into aa switch case statement, then only the method itself can be called dynamically... :-) will do it in excel to prevent errors and stunned fingers:-)

I don't understand what else you need. If you give more detail I might be able to provide a workaround.

Link to comment
Share on other sites

Is this in the ballpark, or am I on another planet (regarding what you're trying to do) ...

$test1 = 0
$var = 1
Execute(Assign("test" & $var, 2))
MsgBox(1,"",$test1)

Edit: Or, if you can't declare the variables in advance:

#Region;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Run_AU3Check=n
#EndRegion;**** Directives created by AutoIt3Wrapper_GUI ****
$var = 1
Execute(Assign("Test" & $var, 2))
MsgBox(1,"",$test1)
Edited by Spiff59
Link to comment
Share on other sites

Is this in the ballpark, or am I on another planet (regarding what you're trying to do) ...

$test1 = 0
  $var = 1
  Execute(Assign("test" & $var, 2))
  MsgBox(1,"",$test1)

Edit: Or, if you can't declare the variables in advance:

#Region;**** Directives created by AutoIt3Wrapper_GUI ****
  #AutoIt3Wrapper_Run_AU3Check=n
  #EndRegion;**** Directives created by AutoIt3Wrapper_GUI ****
  $var = 1
  Execute(Assign("Test" & $var, 2))
  MsgBox(1,"",$test1)
None of this makes sense. The result from Assign is either 1 or 0. That would be like Execute(1). Edited by weaponx
Link to comment
Share on other sites

None of this makes sense. The result from Assign is either 1 or 0. That would be like Execute(1).

I wouldn't have posted the equivalent of an "Execute(1)" statement, what would be the purpose of that.

He's trying to construct a variable name on-the-fly and assign it a value here:

Execute("$mystruct." & $attribs[$i][0] & ' = ' & "$attribs[$i][1]" & '')

That's what my example does. Rather than hard-coding the "2", it would be closer to his code like this:

$test9 = 77
$var = 9
$value = 25
Execute(Assign("test" & $var, $value))
MsgBox(1,"",$test9)

If you can't declare the variable names before you create/assign them, just turn off compiler warnings.

Link to comment
Share on other sites

tried with assign but i don't think assign and objects work well.

$a=StringSplit("547275737420796F757220546563686E6F6C75737421","")
For $b=1 To UBound($a)+(-1*-1*-1)step(2^4/8);&$b+=1*2/40*µ&Asc(4)
Assign("c",Eval("c")&Chr(Dec($a[$b]&$a[$b+1])));''Chr("a")&"HI"
Next ;time_U&r34d,ths,U-may=get$the&c.l.u.e;b3st-regards,JRSmile;
MsgBox(0x000000,"",Eval("c"));PiEs:d0nt+*b3.s4d.4ft3r.1st-try:-)
Link to comment
Share on other sites

i created a function overview with all attributes needed.

funcs.rar

$a=StringSplit("547275737420796F757220546563686E6F6C75737421","")
For $b=1 To UBound($a)+(-1*-1*-1)step(2^4/8);&$b+=1*2/40*µ&Asc(4)
Assign("c",Eval("c")&Chr(Dec($a[$b]&$a[$b+1])));''Chr("a")&"HI"
Next ;time_U&r34d,ths,U-may=get$the&c.l.u.e;b3st-regards,JRSmile;
MsgBox(0x000000,"",Eval("c"));PiEs:d0nt+*b3.s4d.4ft3r.1st-try:-)
Link to comment
Share on other sites

got it to work, its bad but the only way i could imagine:

Dim $attribs[3][2]
$attribs[0][0] = "method"
$attribs[0][1] = "user.getlovedtracks"
$attribs[1][0] = "api_key"
$attribs[1][1] = 'aa72a3b1161d33d0eba36f986fa1fb43'
$attribs[2][0] = "user"
$attribs[2][1] = "JRSmile"

MsgBox(0, Default, __lastfm_send($attribs))

Func __lastfm_send($attribs)
    If (Not IsArray($attribs)) Or (UBound($attribs, 0) <> 2) Then Return SetError(1, 0, False)
    Local $func, $file, $line, $pid, $params, $method, $namespace
    For $i = 0 To UBound($attribs) - 1
        If $attribs[$i][0] = "method" Then
            $tmp = StringSplit($attribs[$i][1],".", 1)
            $method = $tmp[2]
            $namespace = $tmp[1]
        Else
            $params &= "$mystruct." & $attribs[$i][0] & ' = "' & $attribs[$i][1] & '"'& @CRLF
        EndIf
    Next
    $func &= '#NoTrayIcon' & @CRLF
    $func &= '$f = ObjCreate("pocketXMLRPC.Factory")' & @CRLF
    $func &= '$'&$namespace&' = $f.Proxy("http://ws.audioscrobbler.com/2.0/", "'&$namespace&'.")' & @CRLF
    $func &= '$mystruct = ObjCreate("PocketXMLRPC.Struct")' & @CRLF
    $func &= $params
    $func &= '$r = $'&$namespace&'.'&$method&'($mystruct)' & @CRLF
    $func &= '$mystruct = 0' & @CRLF
    $func &= '$f = 0' & @CRLF
    $func &= 'ConsoleWrite($r)' & @CRLF
    $file = Random(10000, 99999, 1) & ".au3"
    FileWrite($file, $func)
    $pid = Run('"' & @AutoItExe & '" /AutoIt3ExecuteScript "' & $file & '"' & "", "", @SW_HIDE, 2)
    While 1
        $line = StdoutRead($pid)
        If @error Then ExitLoop
        If $line <> "" Then ExitLoop
    WEnd
    FileDelete($file)
    Return StringReplace($line, '\"', '"')
EndFunc   ;==>__lastfm_send
$a=StringSplit("547275737420796F757220546563686E6F6C75737421","")
For $b=1 To UBound($a)+(-1*-1*-1)step(2^4/8);&$b+=1*2/40*µ&Asc(4)
Assign("c",Eval("c")&Chr(Dec($a[$b]&$a[$b+1])));''Chr("a")&"HI"
Next ;time_U&r34d,ths,U-may=get$the&c.l.u.e;b3st-regards,JRSmile;
MsgBox(0x000000,"",Eval("c"));PiEs:d0nt+*b3.s4d.4ft3r.1st-try:-)
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...