Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 03/01/2021 in all areas

  1. Here is an example for using getter as a object method #include "AutoItObject_Internal.au3" #include <Array.au3> $oObject = IDispatch() $oObject.key = "initial value of key" $oObject.__defineGetter('key', getter) $oObject.key $oObject.key() $oObject.key('A') $oObject.key(123, 456) $oObject.key('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','X','Y','Z') ConsoleWrite($oObject.key&@CRLF) Func getter($AccessorObject) Local Static $counter = 0 Local $oArguments = $AccessorObject.arguments Local $iArguments = $oArguments.length Local $aArguments = $oArguments.values ConsoleWrite(StringFormat("getter invoked with %d number of parameters:\n", $iArguments)) Local $i For $i = 0 To $iArguments - 1 Step +1 ConsoleWrite(StringFormat("\targument [%02d]: (%s) %s\n", $i + 1, VarGetType($aArguments[$i]), $aArguments[$i])) Next Local $returnVal = $AccessorObject.val $counter += 1 $AccessorObject.val = StringFormat('this property has been accessed for read %d times', $counter) Return $returnVal EndFunc Oh it already is On line 434: VariantCopy($pVarResult, $tPropertyTarget) Should be: VariantCopy($pVarResult, $tPropertyTarget.Variant) You were parsing in a struct, where a ptr was expected I'm not sure, but maybe you need to look at __assign Example: #include <AutoItObject_Internal.au3> $cFoo=IDispatch() func cFoo_Method1($self) ;~ whatever we want to have shared as a method printing a property of the current object ConsoleWrite($self.parent.Property1) endfunc $cFoo.Method1 = cFoo_Method1 $oFoo1=$cFoo ;~ Have independent propertyvalues $oFoo1.Property1="Hello world 1" $oFoo2=IDispatch() $oFoo2.__assign($oFoo1) $oFoo2.Property1="Hello world 2" MsgBox(0, "", $oFoo1.Property1) MsgBox(0, "", $oFoo2.Property1) MsgBox(0, "", FuncName($oFoo1.Method1)) MsgBox(0, "", FuncName($oFoo2.Method1)) A side note: If you are looking into a more class like usage, I am working on another project for that au3Class (powered by AutoItObject_Internal). It does have the downside of requiring transpiling the code before running it, but allows for great overview. I am working on adding support for class extending, traits and interfaces
    2 points
  2. I liked the clean interface of the "new" _ArrayDisplay and being able to sort but I missed being able to pick rows and copy them and being able to exit to the script. The _DebugArrayDisplay adds those but doesn't have the sorting. So I wrote an overlaying interface that would add copy, and exit to the existing _ArrayDisplay without actually changing it. It also lets you chose whether you return the row(s) index or the it's value. It's defaults to returning a value but if you'd rather it defaulted to returning an index feel free to change $a = 0 to $a = 1. In the example press "Enter" when you have highlighted your choices, or press esc to return without a choice or press x to exit the script. In the Example swap the commenting on the "$aItemx =" lines to return index(es) instead of values. Note you can still pass all the parameters you would use on the normal _ArrayDisplay. Example: #include "ad_ex.au3" Global $aItem2[4] = ["one", "two", "three", "four"] $aItemx = _ad($aItem2, "Press Enter") ;~ $aItemx = _ad($aItem2, "Press Enter",1) If $aItemx = -1 Then ConsoleWrite("No Pick" & @CRLF) If IsArray($aItemx) Then For $i = 1 To $aItemx[0] ConsoleWrite($aItemx[$i] & @CRLF) Next EndIf ConsoleWrite("Done" & @CRLF) Exit UDF: ;_ArrayDisplay with extras copy and exit keys return index or value ;$array,Title,0 or 1 Return-> 0=value 1=index #include-once #include <array.au3> #include <misc.au3> #include <GuiListView.au3> ; #FUNCTION# ==================================================================================================================== ; Name ..........: _ad ; Description ...: Added the ability to return selected rows by index number or value. Exit the script immediately. To the _ArrayDisplay() ; Syntax ........: _ad(Byref $aI[, $t = ""[, $a = 0[, $sArrayRange = ""[, $iFlags = 0[, $vUser_Separator = Default[, ; $sHeader = Default[, $iMax_Colwidth = Default]]]]]]]) ; Parameters ....: $aI - [in/out] array to display ; $t - [optional] Title Default is "". ; $a - [optional] Return Value(0) or Index(1) Default is 0. ; ; Variables below are a pass through of the normal _ArrayDisplay parameters ; ; $sArrayRange - [optional] a string value. Default is "". ; $iFlags - [optional] an integer value. Default is 0. ; $vUser_Separator - [optional] a variant value. Default is Default. ; $sHeader - [optional] a string value. Default is Default. ; $iMax_Colwidth - [optional] an integer value. Default is Default. ; Return values .: Array of either value(s) or index(es) or -1 if there was no pick ; Author ........: Wolflake ; Modified ......: ; Remarks .......:Select your rows press Enter to return you choices. Press x to exit script. Press escape to return without a choice. ; Related .......: ; Link ..........: ; Example .......: Yes ; =============================================================================================================================== Func _ad(Const ByRef $aI, $t = "", $a = 0, $sArrayRange = "", $iFlags = 0, $vUser_Separator = Default, $sHeader = Default, $iMax_Colwidth = Default) ;start keychk and arraydisplay ToolTip("Press Enter to copy", 650, 300) Sleep(750) ToolTip("", 500, 300) Global $s AdlibRegister("_ChkKey", 100) ;turn on key checking _ArrayDisplay($aI, $t, $sArrayRange, $iFlags, $vUser_Separator, $sHeader, $iMax_Colwidth) $aItem = _ChkKey($a) ;get the data from picks If Not IsArray($aItem) Then Return -1 If $a = 0 Then ;pull data instead of index For $i = 1 To $aItem[0] $aItem[$i] = $aI[$aItem[$i]] Next EndIf Return $aItem EndFunc ;==>_ad Func _ChkKey($a=0) Static Local $hForm1, $aItem, $dll = DllOpen("user32.dll") If $hForm1 = "" Then $hForm1 = WinGetHandle("[Active]") EndIf If Not WinActive($hForm1) And WinExists($hForm1) Then ; don't run while not active but run to get data Return ;don't check for keys EndIf If _IsPressed("58") Then Exit ; x If _IsPressed("1B", $dll) Then ; esc AdlibUnRegister("_ChkKey") Send("{esc}") Return -1 EndIf If _IsPressed("0D", $dll) Then ; Enter ;get picks, note the control id for the list is 3 AdlibUnRegister("_ChkKey") While _IsPressed("0D", $dll) Sleep(20) WEnd $hlist = ControlGetHandle("[active]", "", "[CLASS:SysListView32; INSTANCE:1]") $aItem = _GUICtrlListView_GetSelectedIndices($hlist, True) ;~ ConsoleWrite("Count " & $aItem[0] & @CRLF) For $i = 1 To $aItem[0] ;~ ConsoleWrite("row " & _GUICtrlListView_GetItemText(3, $aItem[$i]) & @CRLF) ;~ ConsoleWrite("Value " & _GUICtrlListView_GetItemText(3, $aItem[$i],1) & @CRLF) ;~ ConsoleWrite("Index " & $aItem[$i] & " ") $aItem[$i] = StringMid(_GUICtrlListView_GetItemText($hlist, $aItem[$i]), 5) Next ;~ ConsoleWrite(@CRLF) Sleep(100) Send("{esc}") EndIf AdlibRegister("_ChkKey", 100) Return $aItem EndFunc ;==>_ChkKey
    1 point
  3. water

    Newbie in Sweden

    @pseakins As Axiom uses "myscript1.exe" in his example I assume he wants to close his own scripts. I suggest to do it the other way round. Grab the Process-ID of your GUI script (macro @AutoItPID) and pass it as parameter to the scripts you start. Then let your scripts check if the main process still exists (ProcessExist). If not end the script. So you just need to end the GUI and all other scripts will end automatically. The check can either be done in a loop or by Adlibregister.
    1 point
  4. pseakins

    Newbie in Sweden

    @water I don't think Axiom wants to close the script he is in. Have you tried the help? Position your cursor over "ProcessClose" and press F1. The help will tell you all you need to know about this function including examples. And, yes, you can have a script like your example.
    1 point
  5. @Tynoe Subz gave you the solution, so, thanks him too
    1 point
  6. Easiest method: While ProcessExists("DataGather.exe") ProcessClose("DataGather.exe") Wend
    1 point
  7. Hi @Tynoe, and welcome to the AutoIt forum Take a look at ProcessClose() to do what you're looking for, and post your code if you have any problem
    1 point
  8. Because Koda's main web page (http://koda.darkhost.ru/page.php?id=download) isn't working, here is latest Koda 1.7.3 for download: koda_1.7.3.0.zip
    1 point
  9. New UX Window in AutoIt v3 Watch Full Source Code : Link
    1 point
  10. SleepyXtreme, Building on SadBunny's suggestion... ; ; ; #include <array.au3> ;--------------------------------------------- ; define arrays ;--------------------------------------------- local $list[300][4] ; 300 windows max local enum $title, $handle, $pid, $exe ; enumerations for array offsets ;--------------------------------------------- ; get array of windows and populate $list ;--------------------------------------------- local $a1 = winlist() ; get list of windows for $i = 0 to $a1[0][0] ; and copy title, handle and pid to $list array $list[$i][$title] = $a1[$i][$title] ; window title $list[$i][$handle] = $a1[$i][$handle] ; window handle $list[$i][$pid] = wingetprocess($a1[$i][$handle]) ; owning process id next ;--------------------------------------------- ; get array of processes and populate $list ;--------------------------------------------- local $a2 = processlist() ; get list of processes for $i = 0 to $a1[0][0] for $j = 0 to $a2[0][0] if $list[$i][2] = $a2[$j][1] then $list[$i][3] = $a2[$j][0] ; and copy process name to $list array Next next _arraysort($list,1,0,0,2) ; sort the array by $pid desc redim $list[$i][4] _arraydisplay($list) ;--------------------------------------------- ; format output to console ;--------------------------------------------- local $savepid = '', $out = '' for $i = 0 to ubound($list) - 1 if $i = 0 then $out &= stringformat('%-10s%-15s',$list[$i][$pid],$list[$i][$exe]) & @crlf $savepid = $list[$i][$pid] endif if $list[$i][$pid] = '' then exitloop if $savepid = $list[$i][$pid] then if $list[$i][$title] <> '' then $out &= @tab & @tab & $list[$i][$title] & @crlf else if $i <> 0 then $out &= stringformat('%-10s%-15s',$list[$i][$pid],$list[$i][$exe]) & @crlf $savepid = $list[$i][$pid] endif next consolewrite($out & @lf) kylomas
    1 point
×
×
  • Create New...