Search the Community
Showing results for tags 'scriptcontrol'.
-
Hi all. I'm playing a bit with the ScriptControl object using as base this example by @genius257. here is a very simple try, ... but it fails. what I'm doing wrong? Local $oSC = ObjCreate("ScriptControl") $oSC.Language = "JScript" $oSC.ExecuteStatement('alert("I am a javascript alert box!");') MsgBox(0,'AutoIt','Pause') Thanks
-
First of all I've been searching on the forum, and while there's been done something like this with: https://www.autoitscript.com/forum/topic/141004-comobject-proxy-seamless-windows-script-control-autoitobj/ I could not find any solution to my predicament. Is it possible to throw an error in a ScriptControl object, via AutoIt? I have a script, where AutoIt calls ScriptControl:JavaScript which in turn calls AutoIt. However i would like to be able to make AutoIt invoke an exception within ScriptControl, if the called functionality fails. Here's some code for reference: #AutoIt3Wrapper_Run_AU3Check=n #include-once #include "AutoitObject.au3" #include <WinAPIDiag.au3> $oJS = ObjCreate("ScriptControl") $oJS.Language = "JScript" $oJS.TimeOut = 0; A value of 0 means that the ScriptControl will monitor the execution of the script and will trigger the Timeout event if it determines that the script is hung. _AutoItObject_Startup() $oAutoIt = _AutoItObject_Create() _AutoItObject_AddMethod($oAutoIt, "Execute", "_Execute", False) $oJS.AddObject("AutoIt", $oAutoIt, True) OnAutoItExitRegister("_CleanUp") $_AutoItError = ObjEvent("AutoIt.Error", "_AutoItError") Func _CleanUp() ConsoleWrite("Cleaning up..."&@CRLF) $oJS = 0 $oAutoIt = 0 _AutoItObject_Shutdown() EndFunc Func _Execute($oSelf, $sString) $vReturn = Execute($sString) If @error<>0 Then Return $oJS.Eval("throw new SyntaxError();"); Does invoke exception, but not within the try/catch Return $vReturn EndFunc Func _AutoItError($oError) $oError2 = $oJS.Error ConsoleWrite( _ "Column: " & $oError2.Column & @CRLF & _ "Description: " & $oError2.Description & @CRLF & _ "HelpContext: " & $oError2.HelpContext & @CRLF & _ "HelpFile: " & $oError2.HelpFile & @CRLF & _ "Line: " & $oError2.Line & @CRLF & _ "Number: " & $oError2.Number & @CRLF & _ "Source: " & $oError2.Source & @CRLF & _ "Text: " & $oError2.Text & @CRLF _ ) $oError2.Clear() EndFunc $oJS.Eval("(function(){"& _ "try{"& _ "AutoIt.Execute('MsgBox(0,\'\', \'a\')');"& _ "AutoIt.Execute('a.b');/*error should occur here*/"& _ "AutoIt.Execute('MsgBox(0,\'\', \'b\')');"& _ "}catch(e){"& _ "AutoIt.Execute('ConsoleWrite(\'Error\'&@CRLF)');"& _ "}"& _ "})()")
-
- autoit
- javascript
-
(and 2 more)
Tagged with:
-
Hello I'm not so familiar with the scriptcontrol, can you help me with this little problem? Why is this script not working correctly? Global $oVbs = ObjCreate('MSScriptControl.ScriptControl') With $ovbs .Language = "VBScript" .AllowUI = True .AddCode('Class Test:Public Function X:X = 123:End Function:Set C = New Test') .AddCode('MsgBox IsObject(C)'); should be true, no? EndWith MsgBox(0,'',$oVbs.Eval('C').X)Also: how do I add code to the global module? Thanks, TheAutomator
- 3 replies
-
- scriptcontrol
- vbscript
-
(and 3 more)
Tagged with:
-
I looked at ScriptControl. I wonder if using this, can I do IPC solution in AutoIt. I also wonder whether some extent, ScirptControl can be compared to the use of LUA. Below is what I have read so far. http://msdn.microsoft.com/en-us/library/windows/desktop/aa365574(v=vs.85).aspx http://support.microsoft.com/kb/184739/EN-US http://msdn.microsoft.com/en-us/library/aa227413(v=vs.60).aspx http://www.microsoft.com/en-us/download/details.aspx?id=1949 '?do=embed' frameborder='0' data-embedContent>> '?do=embed' frameborder='0' data-embedContent>> '?do=embed' frameborder='0' data-embedContent>> btw. Please, share with other interesting links that according to you is worth reading on the subject (links not directly related to the AutoIt).
-
- IPC
- ScriptControl
-
(and 1 more)
Tagged with: