Jump to content

Search the Community

Showing results for tags 'objects'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office


  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start



Member Title




Found 9 results

  1. Hi all, I've recently be kinda forced into trying to learn OOP within AutoIt. I'm trying to convert XML into objects I guess instead of trying to parse it into arrays within arrays. An example is below: <User> <roles> <role>Agent</role> <role>Supervisor</role> </roles> </user> How can I convert this? Would <roles> be $User.Roles? If so would the children be $User.Roles.Role.Agent and $User.Roles.Role.Supervisor? If not, how do I reference each Object? Any assistance would be appreciated. I tried to understand XML.au3 but I'm so confused trying to wrap my head around this.
  2. Hi all, My work has recently switched from a Win32 based application to a web based application. Thankfully there's an API for me to attach to now but I have a few questions since I'm using Objects now for some parts of my scripts... Do I need to run ObjCreate("winhttp.winhttprequest.5.1") everytime before any object stuff or can I just run it once at the beginning of my script and reuse it? Is $oHTTP.Open("GET", <url>) followed by $oHTTP.Send() pretty much the same as INetRead and can I use them interchangeably? Do I need to somehow delete the Object after creating it at the end of my script? - Answered by Helpfile Thanks!
  3. HI I am wanting to know what my CPU temp is but don't know what object to use. I don't relay know how objget works so would not know where to start. I have seen people integrate things like windows speech to text into their scripts but don't know how they know what object to use! How do I find the right object? And how dose it work? Thanks Jacob
  4. Hi, How to work easily and fast with the oleview.exe which Displays the Object COM from Windows and other programs~
  5. I'm trying to create a remote object using the example script on the ObjCreate function reference page: #include <MsgBoxConstants.au3> ;Open the MediaPlayer ona REMOTE computer Local $oRemoteMedia = ObjCreate("WMPlayer.OCX", "W2RATD5NGK32", "W2RATD5NGK32\administrator", "Win7Pilot") If Not @error Then MsgBox($MB_SYSTEMMODAL, "Remote ObjCreate Test", "ObjCreate() of a remote Mediaplayer Object successful !") $oRemoteMedia.openPlayer(@WindowsDir & "\media\tada.wav") ; Play sound if file is present Else MsgBox($MB_SYSTEMMODAL, "Remote ObjCreate Test", "Failed to open remote Object. Error code: " & Hex(@error, 8)) EndIfThe message returns: Failed to open remote Object. Error Code: 80004002 I've tried researching this error but haven't found any useful info. All I know are these requirements below and I know for sure that the services are running, and the script is being executed as x64 with admin rights. I'm now at a dead end and not sure how to further troubleshoot this error. Also, the script runs fine when I use my own hostname. Any ideas?
  6. Kernel Objects Information Sample output of Object Handles probing _ I've assembled a number of UDF's which use "undocumented" features of the O/S over the years. And this here would be the latest, and possibly the last (I hope?). The purpose of this UDF is to query kernel objects in the system. It's actually a pretty big UDF that ties together a lot of functionality, and hopefully makes it more accessible. With the UDF you can: Query a Kernel Object for 'hidden' information using its handle: Object Type and stats (_ObjectGetTypeInfoUD), Attributes and Access (_ObjectGetBasicInfoUD), Kernel Object Name (_ObjectGetNameUD), etc Query certain Kernel Event Objects for current states:Event, IoCompletion and Mutex ("Mutant") signal states (and more), Semaphore counts, Timer's remaining time, etc Get a list of opened File handles and filenames (there's already a few UDF's dedicated to that, though) Collect all the current handles held by the O/S and its processes, using specific filters, and get information on what the object is and its current state Kernel Objects Inspector script _ What's an Object you say? Whats a Kernel? Whats an NT? Gosh, maybe you shouldn't be here - go read Youtube. As Windows programmers, we make use of these Kernel Objects all the time... Object Types List Some of the most common System Objects: Token, Process, Thread, Event, Mutant (Mutex), Semaphore, Timer, File (includes NamedPipe and Mailslot), Key (Registry Key) Anytime you work with these objects, you are generating new objects at the kernel level. Luckily, the O/S allows above 16 million handles per process (see Pushing the Limits of Windows: Handles by Mark Russinovich), so this isn't a concern. However, if an individual process has in excess of 16K handles, there will be some trunacted values returned from the NT API call as it only returns 16-bit values for handles. See >this post where I try to describe this in better detail. However, this is no longer a problem with the latest update, which restores the upper bits of handles through a simple wraparound detection technique. There's more to say, but perhaps its best to show what functions are available. From the NTKernelObjectsInfo UDF Header: Querying time issues: Note that any call to query handles (_NTObjGetHandlesUD, _NTObjGetHandlesInfoEx) relies on a call to NtQuerySystemInformation, which gathers information on EVERY handle held by the system and it's processes. This can take a few seconds! Be patient. (Also, _NTObjBuildTypesIndexMap calls it indirectly) IMPORTANT: Be a little careful with looking for 'File' objects on Vista and Win7.. on XP there's already some safeguards which unfortunately prevent detecting certain objects. Newer versions of the O/S don't seem to have problems with threaded probing of File objects, but there may be some cases.. The Console output is still a bit noisy, but its good for analyzing where there's problems in reading handles, or analyzing "File" handles which can cause major problems, especially in the case of NamedPipes. Some example UDFs are included: NTSystemObjectsList: displays a list of System Object Types NTKernelObjectsCollectExample: A collection query at its simplest (see below for this example) NTKernelObjectsSelfExamine: creates a number of different Objects before listing everything NTKernelObjectsInspect: Inspect Kernel Objects with Filtering options from a GUI This GUI needs work! Notice that with the ArrayDisplay function, there is a 'Run User Func' option which will display any extra info retrieved for the object (see ExInfo column). NTKernelObjectsSpam: Creates a crapload of Kernel Objects. This is mostly useless, but its here to demonstrate how NTKernelObjectsInspect now is able to report correct handle values beyond 65,536 NTKernelObjectsCollectExample In this example I query only 2 processes for handles, and use exclusion criteria to remove "File" and "EtwRegistration" from the resultant list. ; =========================================================================================================== ; <NTKernelObjectsCollectExample.au3> ; ; Pretty barebones example of NTKernelObjectsInfo, showing the ease with which objects can be collected ; Uses multipe query types, multiple processes, and multiple Object Types with exclusion rules ; ; Author: Ascend4nt ; =========================================================================================================== #include "NTKernelObjectsInfo.au3" #include <Array.au3> ; -= FLAGS to Tweak Object Querying =- ; Force Win2000/XP Attribute skipping (must appear AFTER #include): ;$g_NTKO_bNamedPipeProtect = True ; Alternatively set own: ;$g_NTKO_sFileAttribSkipList = "0x0012019F|" ; Additionally, can force BadMask Skipping to OFF (not recommended): ;$g_NTKO_bSkipBadMasks = False ; Other queries available, although less often used: ; $NTOBJ_QUERYBY_PID (example: @AuotItPID), $NTOBJ_QUERYBY_OBJTYPE (ex: 28), and $NTOBJ_QUERYBY_HANDLE (actual object handle) $aRet = _NTObjGetHandlesInfoEx($NTOBJ_QUERYBY_PROCESSNAME, "firefox.exe|autoit3.exe", _ $NTOBJ_QUERYBY_OBJTYPENAME + $NTOBJ_QUERY_EXCLUDE, "File|EtwRegistration") ConsoleWrite("Errors: " & @error & ", @extended = " & @extended & @CRLF) _ArrayDisplay($aRet, "_NTObjGetHandlesInfoEx") Thanks for testing this out! Change History: NTKernelObjects.zip ~prev Downloads: 55
  7. Hi, First , I don't know nothing about COM and I saw this script : #include <MsgBoxConstants.au3> Example() Func Example() ; Error monitoring. This will trap all COM errors while alive. ; This particular object is declared as local, meaning after the function returns it will not exist. Local $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc") ; Create Internet Explorer object Local $oIE = ObjCreate("InternetExplorer.Application") ; Check for errors If @error Then Return $oIE.Visible = True ; set visibility ; Custom sink object Local $oIEEvents = ObjEvent($oIE, "_IEEvent_", "DWebBrowserEvents2") ; Navigate somewhere $oIE.navigate("http://www.google.com/") ; Check for errors while loading If @error Then $oIE.Quit() Return EndIf ; Wait for page to load While 1 If $oIE.readyState = "complete" Or $oIE.readyState = 4 Then ExitLoop Sleep(10) WEnd EndFunc ... Now I want to know how can I find & list ALL those possible "functions" of a specific COM object ( those .Visible, .navigate, .readyState ... ), since I can't find those things nowhere listed
  8. I've been thinking about this for the last couple of weeks, and I've finally got around to putting together a proof of concept. As far as OOP goes, Javascript is a pretty damn good language -- very flexible, but lets look at some code. Here is a two button form for AutoIt written in Javascript. var $=this; var hgui; this.MsgHandler_=function (m){ if (m==$.AutoIt.GUI_EVENT_CLOSE) { $.AutoIt.GUIDelete(hgui); return true; }else if (m==button1) { $.AutoIt.Run("notepad.exe"); }else if (m==button2) { alert('Thanks from a javascript alert box!'); } return false; } var button1,button2; function Example1(){ var msg; hgui=$.AutoIt.GUICreate("My Gui",400,500); button1=$.AutoIt.GUICreateButton("Run Notepad",10,10,200,30); button2=$.AutoIt.GUICreateButton("Press Me",10,40,200,30); $.AutoIt.GUISetState($.AutoIt.SW_SHOW,hgui); } Example1(); This code would reside in an external file and be called by AutoIt. I've created a framework in AutoIt using AutoItObject that is just big enough to make this code work. Basically I am creating an AutoItObject, tacking on some core AutoIt functions and constants, and sending it off to play in Javascript land. There is much more to be tacked on. Other than this AutoItObject being a proxy for AutoIt functionality, there is a Javascript COM object into which the javascript file is loaded, and a message loop that calls back into the javascript. The framework is 300 lines of code. Before I extend this, I want to know if AutoIt ALREADY has a COM object I that I can use like this. But I am thinking that even if it does, this hand-coded way would be better because you can make the calls pass objects instead of parameters. Here is the framework: #include <AutoItObject.au3> #include <GUIConstants.au3> Global $thisfile=@ScriptFullPath; Global $logg=$thisfile&".log.txt"; Global $jsfile=$thisfile&".js"; ;e C:\batch\borg\TestJsaio.au3.js ;fret not, you do not need, will be a no-op if not exist Global Const $snarl="C:\batch\Snarl_CMD.exe"; ; need script exit for AIO shutdown OnAutoItExitRegister("EvtScriptExit") _AutoItObject_StartUp() ; error handler Global $oError $oError = ObjEvent("AutoIt.Error", "_ErrFunc") ; JScript Com globals Global $_ComObj_proxy Global $_com Global $_Js JScriptInit() ;;;;;;;;;;;;;;;;;;;;;;;;;;done inits ;;;;;;;;;;; begin framework ; set up a mini framework of AutoIt Functions/constants and stick them on an object Global $AutoItForCom=_AutoItObject_Create(); ;_AutoItObject_AddMethod(ByRef $oObject, $sName, $sAutoItFunc, $fPrivate = False) _AutoItObject_AddMethod($AutoItForCom,"GUICreate","GUICreate_AI") _AutoItObject_AddMethod($AutoItForCom,"GUISetState","GUISetState_AI") _AutoItObject_AddMethod($AutoItForCom,"GUIGetMsg","GUIGetMsg_AI") _AutoItObject_AddMethod($AutoItForCom,"GUIDelete","GUIDelete_AI") _AutoItObject_AddMethod($AutoItForCom,"MsgBox","MsgBox_AI") _AutoItObject_AddMethod($AutoItForCom,"GuiCreateButton","GuiCreateButton_AI") _AutoItObject_AddMethod($AutoItForCom,"Run","Run_AI") ;_AutoItObject_AddProperty(ByRef $oObject, $sName, $iFlags = $ELSCOPE_PUBLIC, $vData = "") _AutoItObject_AddProperty($AutoItForCom, "SW_SHOW", $ELSCOPE_PUBLIC+$ELSCOPE_READONLY, @SW_SHOW) _AutoItObject_AddProperty($AutoItForCom, "GUI_EVENT_CLOSE", $ELSCOPE_PUBLIC+$ELSCOPE_READONLY, $GUI_EVENT_CLOSE) ;;; here are the tie-ins that the object will call Func GUICreate_AI($me,$title,$width,$height) #forceref $me ;GUICreate ( "title" [, width [, height [, left [, top [, style [, exStyle [, parent]]]]]]] ) Local $rv=GUICreate($title,$width,$height) Return $rv EndFunc Func GUISetState_AI($me,$flag,$hwnd) #forceref $me ;GUISetState ( [flag [, winhandle]] ) Local $rv=GUISetState($flag,HWnd($hwnd));need to covert Int32 Return $rv EndFunc Func GUIGetMsg_AI($me,$advanced) #forceref $me Local $rv= GUIGetMsg ($advanced) Return $rv EndFunc Func GUIDelete_AI($me,$winhandle) #forceref $me Local $rv=GUIDelete($winhandle) Return $rv EndFunc Func MsgBox_AI($me,$flag,$title,$text) #forceref $me ;MsgBox ( flag, "title", "text" [, timeout [, hwnd]] ) Local $rv=MsgBox($flag,$title,$text) Return $rv EndFunc Func GUICreateButton_AI($me,$text,$left,$top,$width=Default,$height=Default,$style=Default,$exstyle=Default) #forceref $me ;GUICtrlCreateButton ( "text", left, top [, width [, height [, style [, exStyle]]]] ) Local $rv=GUICtrlCreateButton ( $text, $left, $top, $width, $height, $style, $exstyle) Return $rv EndFunc Func Run_AI($me,$program,$wkdir=Default,$show_flag=Default,$opt_flag=Default) #forceref $me ;Msg2("run",$program) Local $rv; If False Then ElseIf @NumParams==2 Then $rv=Run($program) ElseIf @NumParams==3 Then $rv=Run($program,$wkdir) ElseIf @NumParams==4 Then $rv=Run($program,$wkdir,$show_flag) ElseIf @NumParams==5 Then $rv=Run($program,$wkdir,$show_flag,$opt_flag) EndIf ;Run ( "program" [, "workingdir" [, show_flag [, opt_flag]]] ) ;Local $rv=Run($program,$wkdir,$show_flag,$opt_flag) Return $rv EndFunc ;;;;;;;;;;;;;;;; end of tie-ins ;;;;;;;;;; setup JScript COM obj Global $jso=NewComObj() ; import our AutoIt Proxy into the jso $jso.set("AutoIt", $AutoItForCom) ; read our javascript file Global $ftext=FileRead($jsfile) ; set the file text up as a Main function $jso.set_function("Main", "", $ftext) ; need to run our message loop in autoit code, but pass it back to JS land here $jso.set_function("MsgHandler", "m", "return eval('this.MsgHandler_(m)');") ; hold on to your britches... ; this call will run through the js file and the file must do a setup and have a callback MsgHandler_ $jso.Main() ;; Message Loop Local $end_if_true Local $m While True $m=GUIGetMsg(0) $end_if_true=$jso.MsgHandler($m) ;Msg($end_if_true); If $end_if_true Then ExitLoop EndIf WEnd Exit ;; the only thing worth looking at below this point is the _ComObj_init and friends ;;;;;;;;;;;;;;;functions Func EvtScriptExit() ;Msg("EvtScriptExit") _AutoItObject_Shutdown() ;_logline('EvtScriptExit') ;If IsObj($MidiMgr) Then ; $MidiMgr.Terminate() ;EndIf EndFunc Func Msg($s) MsgBox(0,$thisfile,$s) EndFunc Func Msg2($t,$s) MsgBox(0,$t,$s) EndFunc Func logclear() FileDelete($logg) EndFunc Func _logline($line) logline($line) EndFunc Func logline($line) Local $fh1=FileOpen($logg,1); If $fh1<>-1 Then FileWriteLine($fh1,$line) FileClose($fh1) EndIf EndFunc Func logsnarl($line) logerr($line) snarl(10,'Fatal Error',$line) EndFunc Func snarl($i,$t,$s) If Not FileExists($snarl) Then Return EndIf $s1=StringReplace($s,'"',"'") $t1=StringReplace($t,'"',"'") $cmd=$snarl&' snShowMessage '&$i&' "'&$t1&'" "'&$s1&'"'; Run($cmd) EndFunc ;;;;js utils ; #FUNCTION# ================================================================== ; Name : _ComObj_init ; Description : Creates MS Windows Script control and deploy it as proxy for ; AutoIt COM object binding. ; Syntax : _ComObj_init([$VBScriptSupport = false]) ; Parameter : $VBScriptSupport ; By default JScript doesn't have alert() function, it is provided ; by browser's window object. ; We can emulate this using VBScript's MsgBox function, which is ; performance hog because we need another ScriptControl instance. ; Other advantage is to be able to execute other VBScript's methods ; within function via vb.Eval() method. ; This feature is disabled by default. ; ============================================================================= Func _ComObj_init ($VBScriptSupport = false) Local $_Script $_Script = ObjCreate("ScriptControl") $_Script.Language = "JScript" $_Script.Timeout = 60000 ;$_Script.AddCode("var $=this,arrays=[],vb;function set_vbscript($) {vb=$;vb.Language='VBScript';vb.AllowUI=true;}function alert(s){if(vb)vb.Eval('MsgBox(Unescape(""'+s+'""), 0, ""Autoit"")')}function get_proxy(){return $}function new_object($){$=new Function('return{'+$+'}')();$.set=function(k, v){$[k]=v};$.unset=function(k){delete $[k]};$.set_object=function(k,$){this.set(k,new_object($))};$.set_array=function(){var v=[];for(var i=0;i<arguments.length;i++)v[i]=arguments[i];$.set(v.shift(),new_array.apply(this,v))};$.set_function=function(k,p,$){this.set(k,new_function(p,$))};return $}function new_array(){var v=[];for(var i=0;i<arguments.length;i++)v[i]=arguments[i];return v}function array_get($,k){return $[k]}function array_set($,k,v){return $[k]=v}var new_function=(function(){function F(r) {return Function.apply(this,r)}F.prototype = Function.prototype;return function(p,$){p=p.split(/\s*,\s*/);p.push($);return new F(p)}})()") ;a[a.length]=i; ;function new_array(){var v=[];for(var i=0;i<arguments.length;i++)v[i]=arguments[i];return v} Local $more= _ "$.get=function(k){return $[k]};" & _ "$.has=function(n){" & _ " for (var i in this){" & _ " if (i!=n){" & _ " continue;" & _ " }" & _ " if (!this.hasOwnProperty(i)){" & _ " continue;" & _ " }" & _ " if (typeof(this[i])=='function'){" & _ " continue;" & _ " }" & _ " return true;" & _ " };" & _ " return false;" & _ "};" & _ "$.keys=function(){" & _ " var a=[];" & _ " for (var i in this){" & _ " if (this.hasOwnProperty(i)){" & _ " if (typeof(this[i])!='function'){" & _ " a[a.length]=i;" & _ " }" & _ " }" & _ " };" & _ " return a;" & _ "};" & _ "$.set2=function(){" & _ " for(var x=0;x<arguments.length-1;x+=2){" & _ " this[arguments[x]]=arguments[x+1]" & _ " }" & _ "};" & _ "Array.prototype.item=function(n){" & _ " return this[n];" & _ "};" & _ "Array.prototype.has=function(v){" & _ " for(x=0;x<this.length;x++){" & _ " if(this[x]==v){return true;}" & _ " }" & _ " return false;" & _ "};" & _ "Array.prototype.asString=function(d){" & _ " var s='';" & _ " for(x=0;x<this.length;x++){" & _ " if(s==''){s=this[x];}else{s+=d+this[x];}" & _ " }" & _ " return s;" & _ "};" $_Script.AddCode("var $=this,arrays=[],vb;function set_vbscript($) {vb=$;vb.Language='VBScript';vb.AllowUI=true;}function alert(s){if(vb)vb.Eval('MsgBox(Unescape(""'+s+'""), 0, ""Autoit"")')}function get_proxy(){return $}function new_object($){$=new Function('return{'+$+'}')();$.set=function(k, v){$[k]=v};"&$more&"$.unset=function(k){delete $[k]};$.set_object=function(k,$){this.set(k,new_object($))};$.set_array=function(){var v=[];for(var i=0;i<arguments.length;i++)v[i]=arguments[i];$.set(v.shift(),new_array.apply(this,v))};$.set_function=function(k,p,$){this.set(k,new_function(p,$))};return $}function new_array(){var v=[];for(var i=0;i<arguments.length;i++)v[i]=arguments[i];return v}function array_get($,k){return $[k]}function array_set($,k,v){return $[k]=v}var new_function=(function(){function F(r) {return Function.apply(this,r)}F.prototype = Function.prototype;return function(p,$){p=p.split(/\s*,\s*/);p.push($);return new F(p)}})()") If $VBScriptSupport = true Then $_Script.Run("set_vbscript", ObjCreate("ScriptControl")) Return $_Script EndFunc ; ============================================================================= Func NewComObj() Local $com While True $com=$_com.new_object("") Sleep(30) If IsObj($com) Then ExitLoop EndIf WEnd Sleep(30) Return $com EndFunc Func JScriptInit() $_ComObj_proxy = _ComObj_init(true) $_com = $_ComObj_proxy.Run("get_proxy") $_Js = $_com.new_object("") $_Js.set_function("AIOSetProperty","o,n,v","o[n]=v;") EndFunc Func JS_SetProp() $_Js = $_com.new_object("") $_Js.set_function("AIOSetProperty","o,n,v","o[n]=v;") Return $_Js; EndFunc My main questions are... Why doesn't this already exist, and where is it? and... Why doesn't this already exist -- what wall am I headed for?
  9. Ok I just need to take the scroll bars away from my objects... #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Xuxinha", 800, 600) GUISetState(@SW_SHOW) #EndRegion ### END KodaGUI section ### $Obj = ObjCreate("Shell.Explorer.2") $Obj2 = ObjCreate("Shell.Explorer.2") $GX = GUICtrlCreateObj($Obj, 0, 0, 800, 250) $GX2 = GUICtrlCreateObj($Obj2, 0, 350, 800, 250) $Obj.Navigate("google.com") $Obj2.Navigate("google.com") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd
  • Create New...