cycle4passion

COM JS

Apr 22nd, 2017
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;https://autohotkey.com/board/topic/56987-com-object-reference-autohotkey-l/#entry358974
  2. sc := ComObjCreate("ScriptControl")
  3.  
  4. ;// define the Language
  5. sc.Language := "JScript"
  6.  
  7. ;// define the JScript
  8. script =
  9. (
  10. string = '';
  11. obj = { 'Name':'AutoHotkey', 'URL':'www.AutoHotkey.com', 'Color':'Green' };
  12. for (i in obj)
  13.    string += i + ' = ' + obj[i] + '\n';
  14. )
  15.  
  16. ;// execute the JScript
  17. sc.ExecuteStatement(script)
  18.  
  19. ;// extract a value from the JScript
  20. MsgBox, 0, JScript Variable "string":, % sc.Eval("string")
  21.  
  22. ;// extract an Object from the JScript
  23. obj := sc.Eval("obj")
  24. MsgBox, 0, Elements from the JScript Object:, % "Name: " obj.Name "`nURL: " obj.URL
Advertisement