Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 12/20/2020 in all areas

  1. Happy holidays to all p.s. It looks best on a solid, homogeneous background. To move the tree click on the colored balls and drag. To "turn off" the tree click on it (to set the focus) and then press esc Have fun #include <GUIConstants.au3> #include <WinAPISys.au3> HotKeySet("{ESC}", "_TheEnd") Global $AlphaKey = 0x000000, $hLayer[6], $iWidth = 310, $iHeight = 290, $sBall = '♥' Global Const $aColors[6] = [0x00FF00, 0XFF0000, 0X0040FF, 0XFFFF00, 0X00FFFF, 0XFF00FF] ; 0xRRGGBB Global $a[] = ['.', '~', "'", $sBall, "'", '~', '.', '*', ' '], $tree = $a[8] & $a[7] & @CRLF, _ $hTreeGUI, $ndx, $sGotString, $sGetString, $ChristmasBalls, $sRandomBalls, $iNrOfBalls, $vDummy $hTreeGUI = GUICreate('', $iWidth, $iHeight, Default, Default, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST)) GUISetBkColor($AlphaKey, $hTreeGUI) _WinAPI_SetLayeredWindowAttributes($hTreeGUI, $AlphaKey, 0, $LWA_COLORKEY) GUISetState() For $i = 0 To 14 $tree &= StringRight($a[8], 15 - ($i + 1)) For $x = 0 To ($i + 1) * 2 $tree &= $a[Mod($ndx, 7)] $ndx += 1 Next $tree &= @CRLF If $i < 6 Then $hLayer[$i] = GUICtrlCreateLabel("", 0, 0, $iWidth, $iHeight, -1, $GUI_WS_EX_PARENTDRAG) $vDummy = GUICtrlSetFont(-1, 12, 800, 0, "Courier new") + GUICtrlSetColor(-1, $aColors[$i]) + GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) EndIf Next ; RegExp thanks to @seadoggie01 https://www.autoitscript.com/forum/topic/200770-how-to-clean-a-string-by-regexp/?do=findComment&comment=1440488 $ChristmasBalls = StringRegExpReplace($tree, "(*UCP)(?s)[^\Q" & $sBall & @CRLF & "\E]", " ") ; keep only balls StringReplace($ChristmasBalls, $sBall, $sBall) $iNrOfBalls = @extended GUICtrlSetData($hLayer[0], $tree) ; StringRegExpReplace($tree, "(*UCP)(?s)[\Q" & $a[7] & "\E]", " ")) While Sleep(2000) $sRandomBalls = $ChristmasBalls $RemainingBalls = $iNrOfBalls For $i = 1 To Random(5, $RemainingBalls - 5, 1) $sRandomBalls = StringReplace($sRandomBalls, StringInStr($sRandomBalls, $sBall, 0, Random(1, $RemainingBalls, 1)), " ") $RemainingBalls -= 1 Next For $i = 1 To 5 $sGetString = GUICtrlRead($hLayer[$i]) ; StringReplace(GUICtrlRead($hLayer[$i]), $a[7], " ") $sGotString = $sGetString For $ii = 1 To $RemainingBalls If StringMid($sGetString, StringInStr($sRandomBalls, $sBall, 0, $ii), 1) = $sBall Then $sGetString = StringReplace($sGetString, StringInStr($sRandomBalls, $sBall, 0, $ii), " ") EndIf Next If $sGotString <> $sGetString Then GUICtrlSetData($hLayer[$i], $sGetString) Next GUICtrlSetData($hLayer[Random(1, 5, 1)], $sRandomBalls) WEnd Func _TheEnd() If WinActive("[ACTIVE]") = $hTreeGUI Then Exit GUIDelete($hTreeGUI) EndFunc ;==>_TheEnd
    4 points
  2. Today, I will share my work with image search in inactive windows (windows that run in the background) with tolerances (variations). After a long time of searching and using image search UDF on the internet. I combined all of that with my experienced and created a UDF name HandleImgSearch. I have embedded the .dll file in this script so it doesn't need any external files, just include it and run. However, this UDF uses a pure AutoIT loop to make the multiple positions returned work so it may be slower if you set the $MaxImg to a high number. Some highlights: Very fast with imagesearchdll embedded, no external files required. Tolerances and Max Images are supported. Optimized. Use with a handle or full screen easily. Included global functions, so you can run multiple functions in one capture. Examples used for testing included. Notes: Only used to compile to 32-bit AutoIt version (It can completely run on Windows 64-bit) The image used for searching should be in a "24-bit Bitmap" format. I included the $IsUser32 variable in some places like _GlobalImgInit, _HandleCapture. This variable allowed you to use DllCall with the "PrintWindow" parameter instead of _WinAPI_BitBlt with $SRCCOPY. $IsUser32 = True is useful for the window explorer handle, $IsUser32 = False is useful for the emulator handle (NoxPlayer handle example included). If hwnd parameter equals "", it will use the whole screen instead. Functions: Global Functions: Run multiple functions with one capture. _GlobalImgInit: Initialization variables. _GlobalImgCapture: Capture the handle. _GlobalGetBitmap: Get captured bitmap handle. _GlobalImgSearch: This is the main function of this UDF. _GlobalGetPixel: Get pixel color in the captured image. _GlobalPixelCompare: Compare pixel color with captured image pixel color. Handle Functions: Capture every time. _HandleImgSearch: This is the main function of this UDF. Search for images in the handle of the window with the tolerance and maximum image options. _BmpImgSearch: Search the picture in the picture instead of the handle. _HandleGetPixel: Get pixel in the handle image. _HandlePixelCompare: Compare color with pixel color of handle image. _HandleCapture: Capture handle screen. Source code: v1.0.5 (First release): https://github.com/vnniz/HandleImgSearch/releases/tag/v1.0.5 v2.0.0 (14/04/2023): https://github.com/vnniz/HandleImgSearch/releases/tag/v2.0.0 Thanks to: ImageSearchDLL (Author: kangkeng 2008) MemoryCall (Author: Joachim Bauch) BinaryCall (Author: Ward) GAMERS - Asking for help with ANY kind of game automation is against the forum rules. DON'T DO IT.
    1 point
  3. water

    Multiple PixelSearch Help

    Working with Mouse* and Pixel* functions isn't very reliable as they depend on screen size and resolution, window position etc. Can you please tell us which application you try to automate? Most of the time there are better ways to do what you want to do.
    1 point
  4. In fact, there is no automatic conversion from Default entry parameter and the actual default parameter inscribed in the func statement. It is all reserved to the programmer of the function to assign the defaulted value when the function is called with Default keyword. The programmer must do something like this : If $FunctionParameter = Default Then $FunctionParameter = <Default Value> ; where <Default Value> is the value appearing in the Func statement This is why you can use Default in some functions, and not in some others...
    1 point
  5. How about posting your script to show us what you're doing? IniDelete will, if you do not specify a key, delete the entire section. The example code below creates 5 sections, and then deletes the third. For $a = 1 To 5 IniWrite(@DesktopDir & "\my.ini", "NewSection" & $a, "MyKey", "Val") Next Sleep(1000) IniDelete(@DesktopDir & "\my.ini", "NewSection3")
    1 point
  6. Moved to the appropriate forum, as the Developer General Discussion forum very clearly states: Moderation Team
    1 point
  7. Dan_555

    Dan's misc. Scripts

    Hi, this is my version of the Peg Solitaire Game in Autoit It was inspired by the http://www.mathematische-basteleien.de/solitaire.htm game (which is, by the look, almost identical). It has the Standard Board and additionally 14 different Board setups. The Game starts with randomly selected challenge. It has an Undo and Edit functions. ;This game was inspired by the http://www.mathematische-basteleien.de/solitaire.htm #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GuiConstants.au3> Global $Appname = "Peg Solitaire", $Appname01 = $Appname $Form1 = GUICreate($Appname, 510, 416, 255, 271) $Group1 = GUICtrlCreateGroup("Presets", 383, 2, 124, 413) Dim $Button[14] Dim $GameType[17][2] $GameType[00][0] = "" $GameType[01][0] = "Standard" $GameType[02][0] = "Pyramid 16" $GameType[03][0] = "Pyramid 9" $GameType[04][0] = "Mirror" $GameType[05][0] = "Greek Cross" $GameType[06][0] = "Latin Cross" $GameType[07][0] = "Ship" $GameType[08][0] = "Submarine" $GameType[09][0] = "Y-Pentomino" $GameType[10][0] = "T-Pentomino" $GameType[11][0] = "V-Pentomino" $GameType[12][0] = "P-Pentomino" $GameType[13][0] = "L-Pentomino" $GameType[14][0] = "O-Pentomino" $GameType[15][0] = "Pasted Level" $GameType[00][1] = "000000000000000000000000000000000" $GameType[01][1] = "111111111111111101111111111111111" $GameType[02][1] = "000010001110001111101111111000000" $GameType[03][1] = "000010001110001111100000000000000" $GameType[04][1] = "000000001110000111000011100010000" $GameType[05][1] = "000010000100001111100001000010000" $GameType[06][1] = "000000000100000111000001000010000" $GameType[07][1] = "000000001100001111000000000000000" $GameType[08][1] = "000000000100001111100000000000000" $GameType[09][1] = "000000000100000011000000100001000" $GameType[10][1] = "000000000000000111000001000010000" $GameType[11][1] = "000000000000000011100001000010000" $GameType[12][1] = "000000000110000011000001000000000" $GameType[13][1] = "000000000100000010000001100000000" $GameType[14][1] = "000000000000000011000001100000000" $GameType[15][1] = "000000000000000000000000000000000" $Button[00] = GUICtrlCreateButton("Standard", 391, 25, 108, 22) For $x = 1 To 13 $Button[$x] = GUICtrlCreateButton($GameType[$x + 1][0], 391, 50 + (26 * $x), 108, 22) Next GUICtrlCreateGroup("", -99, -99, 1, 1) $Group2 = GUICtrlCreateGroup("Edit", 4, 2, 132, 44) $B_Edit = GUICtrlCreateButton("Off", 6, 15, 32, 22) GUICtrlSetFont(-1, 10, 800, 0, "Arial") GUICtrlSetTip(-1, "On : Edit levels (Click to toggle)" & @CRLF & "Off: Play the Game" & @CRLF & "Resets the Undo !") $B_Cls = GUICtrlCreateButton("Cls", 38, 15, 32, 22) $B_UsePasted = GUICtrlCreateButton("Use Pasted", 70, 15, 64, 22) GUICtrlSetTip(-1, "Play the Game from the 'Level Data' input box.") GUICtrlCreateGroup("", -99, -99, 1, 1) GUICtrlCreateLabel("Level Data:", 18, 50, 55, 20) $i_Numbers = GUICtrlCreateInput("", 75, 48, 210, 20, $ES_Number) GUICtrlSetLimit($i_Numbers, 33) $Label1 = GUICtrlCreateLabel("Peg Solitaire", 138, 0, 245, 45) GUICtrlSetFont(-1, 30, 800, 0, "Arial") $Group3 = GUICtrlCreateGroup("Game", 3, 65, 377, 350) GUICtrlCreateGroup("", -99, -99, 1, 1) $b_Undo = GUICtrlCreateButton("Undo", 339, 49, 41, 19) Local $x, $y, $ox = -1, $oy = -1, $cx, $cy Local $edit = -1 GUICtrlSetState($B_Cls, $GUI_DISABLE) Dim $GameField[8][8] Dim $UndoBuffer[200] $UndoBuffer[0] = 0 For $y = 1 To 7 For $x = 1 To 7 If $y = 1 Or $y = 2 Or $y = 6 Or $y = 7 Then $tmptxt = " " If $x >= 3 And $x <= 5 Then $GameField[$x][$y] = GUICtrlCreateButton($tmptxt, (-30) + ($x * 48), 26 + ($y * 48), 48, 48) GUICtrlSetFont(-1, 30, 800, 0, "Arial") Else $GameField[$x][$y] = -1 EndIf Else $GameField[$x][$y] = GUICtrlCreateButton($tmptxt, (-30) + ($x * 48), 26 + ($y * 48), 48, 48) GUICtrlSetFont(-1, 30, 800, 0, "Arial") EndIf Next Next BoardSetup(Random(1, 14)) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $b_Undo if $ox > -1 Then ChangeSquare($ox, $oy, "o") $ox=-1 $oy=-1 EndIf Undo() WinSetTitle($Form1, "", $Appname01) Case $B_UsePasted $tmptxt = GUICtrlRead($i_Numbers) $GameType[15][1] = $tmptxt BoardSetup(15) Case $B_Cls $ox = -1 $oy = -1 BoardSetup() Case $B_Edit $edit = -$edit If $ox > -1 Then ChangeSquare($ox, $oy, "o") $ox = -1 $oy = -1 EndIf OnOff(($edit < 0) ? 0 : 1) $Appname01 = $Appname & " - Playing: Edited board." WinSetTitle($Form1, "", $Appname01) $UndoBuffer[0] = 0 Case Else If $nMsg > 0 Then ;Check Game type Buttons: For $x = 0 To 13 If $nMsg = $Button[$x] Then BoardSetup($x + 1) $ox = -1 $oy = -1 $UndoBuffer[0] = 0 EndIf Next ;Check Board buttons: For $btny = 1 To 7 For $btnx = 1 To 7 If $nMsg = $GameField[$btnx][$btny] Then $tmp = GUICtrlRead($GameField[$btnx][$btny]) If $edit = -1 Then ;Game play code: If $tmp = " " Then If Jump($btnx, $btny, $ox, $oy) = 1 Then ;Successful jump $ox = -1 $oy = -1 EndIf $tmptxt = GetBoard() GUICtrlSetData($i_Numbers, $tmptxt) If StringFind($tmptxt, "1") = 1 Then WinSetTitle($Form1, "", $Appname & " : *** Well Done ***") ElseIf $tmp == "o" Then If $ox = -1 Then $ox = $btnx $oy = $btny ChangeSquare($ox, $oy, "O") Else ChangeSquare($ox, $oy, "o") $ox = $btnx $oy = $btny ChangeSquare($ox, $oy, "O") EndIf EndIf Else ;Edit board: If $tmp = " " Then ChangeSquare($btnx, $btny, "o") ElseIf $tmp = "o" Then ChangeSquare($btnx, $btny, " ") EndIf $tmptxt = GetBoard() GUICtrlSetData($i_Numbers, $tmptxt) WinSetTitle($Form1, "", $Appname01) EndIf EndIf Next Next EndIf EndSwitch WEnd Func UndoAdd() If $UndoBuffer[0] < 998 Then $UndoBuffer[0] = $UndoBuffer[0] + 1 $tmptxt = GetBoard() $UndoBuffer[$UndoBuffer[0]] = $tmptxt EndIf EndFunc ;==>UndoAdd Func Undo() If $UndoBuffer[0] >= 1 Then $tmptxt = $UndoBuffer[$UndoBuffer[0]] $UndoBuffer[0] = $UndoBuffer[0] - 1 $GameType[16][1] = $tmptxt BoardSetup(16) EndIf EndFunc ;==>Undo Func StringFind($txt, $s) Local $nr = 0 For $x = 1 To StringLen($txt) If StringMid($txt, $x, 1) == $s Then $nr = $nr + 1 Next Return $nr EndFunc ;==>StringFind Func OnOff($x) Local $tmp = "on" If $x = 0 Then $tmp = "off" GUICtrlSetState($B_Cls, $GUI_DISABLE) Else GUICtrlSetState($B_Cls, $GUI_ENABLE) EndIf GUICtrlSetData($B_Edit, $tmp) EndFunc ;==>OnOff Func Jump($x, $y, $ox, $oy) Local $tmpx = Abs($ox - $x) Local $tmpy = Abs($oy - $y) Local $dir = 0 If $tmpx = 0 And $tmpy = 2 Then $dir = ($oy - $y) > 0 ? $y + 1 : $y - 1 If GUICtrlRead($GameField[$x][$dir]) == "o" Then UndoAdd() ChangeSquare($x, $y, "o") ChangeSquare($x, $dir, " ") ChangeSquare($ox, $oy, " ") Return 1 EndIf ElseIf $tmpy = 0 And $tmpx = 2 Then $dir = ($ox - $x) > 0 ? $x + 1 : $x - 1 If GUICtrlRead($GameField[$dir][$y]) == "o" Then UndoAdd() ChangeSquare($x, $y, "o") ChangeSquare($dir, $y, " ") ChangeSquare($ox, $oy, " ") Return 1 EndIf EndIf Return 0 EndFunc ;==>Jump Func ChangeSquare($x, $y, $txt) GUICtrlSetData($GameField[$x][$y], $txt) EndFunc ;==>ChangeSquare Func BoardSetup($a = 0) Local $w = 0, $x, $y, $z Local $tmptxt = "", $tmptxt1 = "" If $a < 16 Then $Appname01 = $Appname & " - Playing: " & $GameType[$a][0] WinSetTitle($Form1, "", $Appname01) $UndoBuffer[0] = 0 EndIf For $y = 1 To 7 For $x = 1 To 7 $z = 0 $tmptxt = " " If $y = 1 Or $y = 2 Or $y = 6 Or $y = 7 Then If $x >= 3 And $x <= 5 Then $z = 1 Else $z = 1 EndIf If $z = 1 Then $w = $w + 1 $tmptxt1 = StringMid($GameType[$a][1], $w, 1) $tmptxt = ($tmptxt1 = "1") ? "o" : " " ChangeSquare($x, $y, $tmptxt) EndIf Next Next GUICtrlSetData($i_Numbers, GetBoard()) EndFunc ;==>BoardSetup Func GetBoard() Local $tmptxt = "" For $y = 1 To 7 For $x = 1 To 7 $z = 0 If $y = 1 Or $y = 2 Or $y = 6 Or $y = 7 Then If $x >= 3 And $x <= 5 Then $z = 1 Else $z = 1 EndIf If $z = 1 Then $tmptxt = $tmptxt & _Txt2num(GUICtrlRead($GameField[$x][$y])) EndIf Next Next Return $tmptxt EndFunc ;==>GetBoard Func _Txt2num($txt) If $txt = " " Then Return "0" If $txt = "o" Then Return "1" EndFunc ;==>_Txt2num Func CW($txt, $crlf = 1) Local $nl = "" If $crlf = 1 Then $nl = @CRLF ConsoleWrite($txt & $nl) EndFunc ;==>CW Have Fun !
    1 point
  8. This is why I called it a proof of concept. Maybe I'll work some more on this or maybe not. But feel free to bring it a step further.
    1 point
  9. I'm mainly using two scripting languages: AutoIt and Perl. Today I'm mostly using AutoIt. In the past mostly Perl. I've long had an idea of integrating AutoIt and Perl to be able to generate and collect data in Perl scripts and display data in AutoIt GUIs. Over the past few months, I've been working on examples about ROT objects and their use in IPC techniques. I've tested the ideas with regard to AutoIt/Perl integration. It seems to work. Install PerlTo use the Perl programming language on a Windows PC, the program must be installed. I'm using ActivePerl from ActiveState. An alternative distribution is Strawberry Perl. ActivePerl seems to be the easiest to use. Strawberry Perl is more advanced and includes a complete C/C++ compiler. The interesting Perl module for AutoIt/Perl integration is the Win32::OLE module. It's the module that makes Perl a COM compatible programming language. Remember to add this module to your Perl installation. PerlScript Be careful not to confuse Perl with PerlScript. PerlScript is a Perl module developed by ActiveState and is only a small part of the ActivePerl package for Windows. PerlScript is an ActiveX Scripting Engine for the Perl language to use Perl to create dynamic content on the Microsoft web server (in the same way as it can be done with VBScript and JScript). First attemptServer.au3 (Examples\0) First attempt\): #include <GUIConstantsEx.au3> #include "..\..\Includes\IRunningObjectTable.au3" Example() Func Example() Local $hGui = GUICreate( "AutoIt/Perl integration", 300, 100 ) Local $sText = "Run Client.pl:" & @CRLF & _ "Open a Command Prompt in current folder." & @CRLF & _ "Key in ""Perl Client.pl"" and hit the Enter key." & @CRLF & _ "Or ""Perl Client.pl >Client.txt"" to get output in file." GUICtrlCreateLabel( $sText, 20, 20, 260, 60 ) GUISetState( @SW_SHOW, $hGui ) Local $sDataTransfer = "DataTransfer" ROT_RegisterObject( Default, $sDataTransfer ) ; Default => Object = Dictionary object While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd GUIDelete( $hGui ) EndFunc In the first attempt, we'll simply test whether the GetObject() function in a Perl script is at all able to recognize the ROT object (the dictionary object), and thus return something similar to a dictionary object. This is more or less the same as we did in the VBScript example in the bottom half of this post. So far, no data is stored in the ROT object. This Perl snippet copied from Win32::OLE can be used to test whether the ROT object is recognized. The code snippet prints object and class information: Win32::OLE->EnumAllObjects( sub { my $Object = shift; my $Class = Win32::OLE->QueryObjectType( $Object ); printf "Object = %s, Class = %s\n", $Object, $Class; } ); Client.pl: use strict; use Win32::OLE; my $oObj = Win32::OLE->GetObject( "DataTransfer" ); Win32::OLE->EnumAllObjects( sub { my $Object = shift; my $Class = Win32::OLE->QueryObjectType( $Object ); printf "Object = %s, Class = %s\n", $Object, $Class; } ); Output: Object = Win32::OLE=HASH(0x71b5a8), Class = IDictionary It looks good. The ROT object is recognized as a kind of HASH object (sometimes called associative array, dictionary or map) of class IDictionary. This corresponds to the fact that the ROT object is actually a dictionary object. Data from AutoIt to PerlSimple dataNow we can store simple data in the ROT object this way. Server.au3 (Examples\1) AutoIt to Perl\1) Simple data\): Local $oDataTransfer = ObjGet( $sDataTransfer ) ; Dictionary object $oDataTransfer( "$iInt" ) = 123 $oDataTransfer( "$fFlt" ) = 123.456 $oDataTransfer( "$sStr" ) = "String" Client.pl: use strict; use Win32::OLE; my $oObj = Win32::OLE->GetObject( "DataTransfer" ); print "$oObj->{'$iInt'}\n"; print "$oObj->{'$fFlt'}\n"; print "$oObj->{'$sStr'}\n"; Output: 123 123.456 String 1D arrayServer.au3 (Examples\1) AutoIt to Perl\2) 1D array\): Local $oDataTransfer = ObjGet( $sDataTransfer ) ; Dictionary object Local $aArray = [ 123, 123.456, "String" ] $oDataTransfer( "$aArray" ) = $aArray Client.pl: use strict; use Win32::OLE; my $oObj = Win32::OLE->GetObject( "DataTransfer" ); print "@{$oObj->{'$aArray'}}\n"; Output: 123 123.456 String Note that internal data types of array elements are preserved. 2D arrayServer.au3 (Examples\1) AutoIt to Perl\2) 2D array\): Local $oDataTransfer = ObjGet( $sDataTransfer ) ; Dictionary object Local $aArray[1000][10] For $i = 0 To 1000 - 1 For $j = 0 To 10 - 1 $aArray[$i][$j] = $i & "/" & $j Next Next $oDataTransfer( "$aArray" ) = $aArray Client.pl: use strict; use Win32::OLE; my $oObj = Win32::OLE->GetObject( "DataTransfer" ); foreach my $aRow ( @{$oObj->{'$aArray'}} ) { print "@{$aRow}\n"; } Output: 0/0 1/0 2/0 3/0 4/0 5/0 6/0 7/0 8/0 9/0 10/0 11/0 12/0 13/0 14/0 15/0 ... 0/1 1/1 2/1 3/1 4/1 5/1 6/1 7/1 8/1 9/1 10/1 11/1 12/1 13/1 14/1 15/1 ... 0/2 1/2 2/2 3/2 4/2 5/2 6/2 7/2 8/2 9/2 10/2 11/2 12/2 13/2 14/2 15/2 ... 0/3 1/3 2/3 3/3 4/3 5/3 6/3 7/3 8/3 9/3 10/3 11/3 12/3 13/3 14/3 15/3 ... 0/4 1/4 2/4 3/4 4/4 5/4 6/4 7/4 8/4 9/4 10/4 11/4 12/4 13/4 14/4 15/4 ... 0/5 1/5 2/5 3/5 4/5 5/5 6/5 7/5 8/5 9/5 10/5 11/5 12/5 13/5 14/5 15/5 ... 0/6 1/6 2/6 3/6 4/6 5/6 6/6 7/6 8/6 9/6 10/6 11/6 12/6 13/6 14/6 15/6 ... 0/7 1/7 2/7 3/7 4/7 5/7 6/7 7/7 8/7 9/7 10/7 11/7 12/7 13/7 14/7 15/7 ... 0/8 1/8 2/8 3/8 4/8 5/8 6/8 7/8 8/8 9/8 10/8 11/8 12/8 13/8 14/8 15/8 ... 0/9 1/9 2/9 3/9 4/9 5/9 6/9 7/9 8/9 9/9 10/9 11/9 12/9 13/9 14/9 15/9 ... Rows and columns are swapped in the Perl array. Dict objServer.au3 (Examples\1) AutoIt to Perl\4) Dict obj\): Local $oDataTransfer = ObjGet( $sDataTransfer ) ; Dictionary object Local $oDict = ObjCreate( "Scripting.Dictionary" ) $oDict( "$iInt" ) = 123 $oDict( "$fFlt" ) = 123.456 $oDict( "$sStr" ) = "String" $oDataTransfer( "$oDict" ) = $oDict Client.pl: use strict; use Win32::OLE; my $oObj = Win32::OLE->GetObject( "DataTransfer" ); print "${$oObj->{'$oDict'}}{'$iInt'}\n"; print "${$oObj->{'$oDict'}}{'$fFlt'}\n"; print "${$oObj->{'$oDict'}}{'$sStr'}\n"; Output: 123 123.456 String Data from Perl to AutoItSimple dataServer.au3 (Examples\2) Perl to AutoIt\1) Simple data\): #include "..\..\..\Includes\IRunningObjectTable.au3" Example() Func Example() Local $sDataTransfer = "DataTransfer" ROT_RegisterObject( Default, $sDataTransfer ) ; Default => Object = Dictionary object RunWait( @ComSpec & " /c " & "Perl Client.pl", "", @SW_HIDE ) Local $oDataTransfer = ObjGet( $sDataTransfer ) ; Dictionary object MsgBox( 0, "AutoIt/Perl integration", "$oDataTransfer( ""$iInt"" ) = " & $oDataTransfer( "$iInt" ) & @CRLF & _ "$oDataTransfer( ""$fFlt"" ) = " & $oDataTransfer( "$fFlt" ) & @CRLF & _ "$oDataTransfer( ""$sStr"" ) = " & $oDataTransfer( "$sStr" ) ) EndFunc Client.pl: use strict; use Win32::OLE; my $oObj = Win32::OLE->GetObject( "DataTransfer" ); $oObj->{'$iInt'} = 123; $oObj->{'$fFlt'} = 123.456; $oObj->{'$sStr'} = "String"; Output: $oDataTransfer( "$iInt" ) = 123 $oDataTransfer( "$fFlt" ) = 123.456 $oDataTransfer( "$sStr" ) = String 1D arrayServer.au3 (Examples\2) Perl to AutoIt\2) 1D array\): #include "..\..\..\Includes\IRunningObjectTable.au3" #include <Array.au3> Example() Func Example() Local $sDataTransfer = "DataTransfer" ROT_RegisterObject( Default, $sDataTransfer ) ; Default => Object = Dictionary object RunWait( @ComSpec & " /c " & "Perl Client.pl", "", @SW_HIDE ) Local $oDataTransfer = ObjGet( $sDataTransfer ) ; Dictionary object Local $aArray = $oDataTransfer( "$aArray" ) _ArrayDisplay( $aArray ) EndFunc Client.pl: use strict; use Win32::OLE; my $oObj = Win32::OLE->GetObject( "DataTransfer" ); my @aArray = ( 123, 123.456, "String" ); $oObj->{'$aArray'} = \@aArray; Output: 123 123.456 String 2D arrayServer.au3 (Examples\2) Perl to AutoIt\3) 2D array\): #include "..\..\..\Includes\IRunningObjectTable.au3" #include <Array.au3> Example() Func Example() Local $sDataTransfer = "DataTransfer" ROT_RegisterObject( Default, $sDataTransfer ) ; Default => Object = Dictionary object RunWait( @ComSpec & " /c " & "Perl Client.pl", "", @SW_HIDE ) Local $oDataTransfer = ObjGet( $sDataTransfer ) ; Dictionary object Local $aArray = $oDataTransfer( "$aArray" ) _ArrayDisplay( $aArray ) EndFunc Client.pl: use strict; use Win32::OLE; my $oObj = Win32::OLE->GetObject( "DataTransfer" ); my @aArray; for( my $i = 0; $i < 10; $i++ ) { for( my $j = 0; $j < 1000; $j++ ) { $aArray[$i][$j] = $j . "/" . $i; } } $oObj->{'$aArray'} = \@aArray; Output: 0/0 0/1 0/2 0/3 0/4 0/5 0/6 0/7 0/8 0/9 1/0 1/1 1/2 1/3 1/4 1/5 1/6 1/7 1/8 1/9 2/0 2/1 2/2 2/3 2/4 2/5 2/6 2/7 2/8 2/9 3/0 3/1 3/2 3/3 3/4 3/5 3/6 3/7 3/8 3/9 4/0 4/1 4/2 4/3 4/4 4/5 4/6 4/7 4/8 4/9 5/0 5/1 5/2 5/3 5/4 5/5 5/6 5/7 5/8 5/9 6/0 6/1 6/2 6/3 6/4 6/5 6/6 6/7 6/8 6/9 7/0 7/1 7/2 7/3 7/4 7/5 7/6 7/7 7/8 7/9 8/0 8/1 8/2 8/3 8/4 8/5 8/6 8/7 8/8 8/9 9/0 9/1 9/2 9/3 9/4 9/5 9/6 9/7 9/8 9/9 10/0 10/1 10/2 10/3 10/4 10/5 10/6 10/7 10/8 10/9 11/0 11/1 11/2 11/3 11/4 11/5 11/6 11/7 11/8 11/9 12/0 12/1 12/2 12/3 12/4 12/5 12/6 12/7 12/8 12/9 13/0 13/1 13/2 13/3 13/4 13/5 13/6 13/7 13/8 13/9 14/0 14/1 14/2 14/3 14/4 14/5 14/6 14/7 14/8 14/9 15/0 15/1 15/2 15/3 15/4 15/5 15/6 15/7 15/8 15/9 ... Dict objServer.au3 (Examples\2) Perl to AutoIt\4) Dict obj\): #include "..\..\..\Includes\IRunningObjectTable.au3" #include <Array.au3> Example() Func Example() Local $sDataTransfer = "DataTransfer" ROT_RegisterObject( Default, $sDataTransfer ) ; Default => Object = Dictionary object RunWait( @ComSpec & " /c " & "Perl Client.pl", "", @SW_HIDE ) Local $oDataTransfer = ObjGet( $sDataTransfer ) ; Dictionary object Local $aDict = $oDataTransfer( "$aDict" ) _ArrayDisplay( $aDict ) EndFunc Client.pl: use strict; use Win32::OLE; my $oObj = Win32::OLE->GetObject( "DataTransfer" ); my %oDict = ( '$iInt' => 123, '$fFlt' => 123.456, '$sStr' => "String" ); my @aDict = ( [ keys %oDict ], [ values %oDict ] ); $oObj->{'$aDict'} = \@aDict; Output: $iInt 123 $fFlt 123.456 $sStr String 7z-fileThe 7z-file contains source code for the UDF and examples. You need AutoIt 3.3.12 or later. Tested on Windows 7 and Windows 10. Comments are welcome. Let me know if there are any issues. AutoItAndPerl.7z
    1 point
×
×
  • Create New...