Jump to content

Leaderboard

Popular Content

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

  1. I made some performance tests to get a rough indication of which data structure is most appropriate and when. For this, I measured the time needed for adding and reading out at different numbers of elements. These are the results (beware of the logarithmic scale for the axes): Especially the behavior of map is interesting: At small numbers of elements the map structure performs very well and scales quite linear with the number of elements. But then (here at 10,000 elements) there is some sort of cut and the results are getting bad. Scripting.dictionary also shows this behavior but only later a larger number of elements. Now for my question: I suspect, that the AutoIt-Map is internally implemented as hash-table and not with sorting trees. As far as I know the used hash-algorithm in a hash-table will reach the point where it start to produce a lot of collisions which leads to extra treatments. This would explain the showed behavior. But because there is a difference between AutoIt-Map, Scripting.Dictionary and System.Collections.HashTable i have to assume that these each use different hash algorithms. Does anybody know which exact hash algorithms are used internally for these? hashtable.au3 DataStructureComparison.zip
    2 points
  2. The problem that you encountered is found in the internal AutoIt code that converts proprietary AutoIt variables to standard COM data types that can be transferred to an object method. The vast majority of data types are handled correctly. However, there are still several examples of data that are not handled correctly and therefore give rise to data type mismatch errors as in your example. There are a few examples of solving the problems. These examples are all based on the VTable interface of the object and the ObjCreateInterface() function. Ie. your object must be dual interface. And the techniques are far from trivial and based on a manual handling of variants and safearrays. But because your object works in VBScript code, there is a much simpler solution, which is demonstrated in this post here. In the example in the post a data type mismatch error means that an object method cannot be executed in AutoIt code. Instead, data is passed to a VBScript as global variables through a ROT object. Then the object method can be executed successfully in the VBScript code. If necessary, method output data can be passed back to the AutoIt code through the same ROT object.
    2 points
  3. Executing Object Methods through VBScriptIn IPC Techniques through ROT Objects (Data types section) the AutoIt data types have been tested based on the example for the VarGetType() function in the help file. The data types are sent from Sender to Receiver with these results: $aArray : Array variable type. $dBinary : Binary variable type. $bBoolean : Bool variable type. $pPtr : Int32 variable type. $hWnd : Int32 variable type. $iInt : Int32 variable type. $fFloat : Double variable type. $oObject : Object variable type. $sString : String variable type. $tStruct : Not recognized as a valid variable type. $vKeyword : Keyword variable type. fuMsgBox : Not recognized as a valid variable type. $fuFunc : Not recognized as a valid variable type. $fuUserFunc : Not recognized as a valid variable type. Note that an AutoIt object is a data type that is sent correctly from one process to another through a ROT Object. What does it mean that an object is sent correctly from one process to another? This means that the object instance (the specific representation of the object) of the receiving process is exactly the same as the object instance of the sending process. The object of receiver and sender is simply the same object. It's the implementation of the ROT Object that ensures that the object of receiver and sender is the same. If an object $oHexEdit is sent from AutoIt code to VBScript code in this way: Local $sDictionaryData = "DictionaryData" ROT_RegisterObject( Default, $sDictionaryData ) ; Default => Object = Dictionary object Local $oROTobj = ObjGet( $sDictionaryData ) ; Dictionary object $oROTobj( "oHexEdit" ) = $oHexEdit and received in the VBScript code in this way: Dim oROTobj, oHexEdit Set oROTobj = GetObject( "DictionaryData" ) Set oHexEdit = oROTobj( "oHexEdit" ) then the $oHexEdit object in the AutoIt code and oHexEdit object in the VBScript code is the same object. Type mismatch errorWhat can all this be used for? This is an example of a Hex Editor ActiveX control based on this CodeProject article. A simple AutoIt implementation can look like this (HexEdit0.au3) #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 Opt( "MustDeclareVars", 1 ) #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Example() Func Example() ; Create GUI GUICreate( "Hex Editor", 420, 420 ) ; Create COM error handler Local $oMyError = ObjEvent( "AutoIt.Error", "MyErrFunc" ) ; Create Com object Local $oHexEdit = ObjCreate( "HEXEDIT.HexEditCtrl.1" ) If Not IsObj( $oHexEdit ) Then Return ConsoleWrite( "$oHexEdit ERR" & @CRLF ) ConsoleWrite( "$oHexEdit OK" & @CRLF ) ; Create ActiveX control GUICtrlCreateObj( $oHexEdit, 10, 10, 400, 400 ) ; Show GUI GUISetState() ; Load HexEditDlg.exe into ActiveX control Local $hFile = FileOpen( "HexEditDlg.exe", 16 ), $dBinary = FileRead( $hFile ), $i = FileClose( $hFile ) ; 16 = $FO_BINARY $oHexEdit.SetData( $dBinary, 0 ) ; Loop While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd #forceref $oMyError, $i EndFunc Func MyErrFunc( $oError ) ConsoleWrite(@ScriptName & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _ @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _ @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _ @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _ @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _ @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _ @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _ @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _ @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _ @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF) EndFunc The HexEdit ActiveX control must be registered in an elevated Command Prompt with HexEditorOcx\register.bat included in the 7z-file below. HexEditDlg.exe is the test file that is loaded into the ActiveX control. Also contained in the 7z-file. You can also download it all directly from the CodeProject article. HexEditDlg.exe is the demo project. When you run the script in SciTE with F5 you'll see the following COM error in the console: $oHexEdit OK HexEdit0.au3 (30) : ==> COM Error intercepted ! err.number is: 0x80020005 err.windescription: Type mismatch. err.description is: err.source is: err.helpfile is: err.helpcontext is: err.lastdllerror is: 0 err.scriptline is: 30 err.retcode is: 0x00000000 Line 30 is this line: $oHexEdit.SetData( $dBinary, 0 ) The error is due to the binary data in $dBinary not being transferred correctly to the SetData() method. The first lines of the implementation of the SetData() method in HexEditCtl.cpp (not included in the 7z-file but can be downloaded from the article) looks like this: SCODE CHexEditCtrl::SetData(VARIANT FAR* pData, long dwStartAddr) { if ( ( pData->vt != (VT_ARRAY | VT_UI1) && pData->vt != (VT_ARRAY | VT_I1) ) || ::SafeArrayGetDim(pData->parray) != 1) VARIANT FAR* pData and pData->vt == (VT_ARRAY | VT_UI1) means that the first parameter in Setdata() must be a pointer to a variant, where the data field in the variant can contain a pointer to a safearray of bytes. A safearray of bytes is also referred to as a bytearray. In AutoIt, a bytearray is represented by the Binary data type. Since there are no other data types in AutoIt that correspond to a bytearray, there is actually not really anything to do about the error. The internal AutoIt code is capable of transferring the vast majority of parameter data types to an object method in the correct way. However, there are still several examples of parameter data types being passed incorrectly resulting in a data type mismatch error. And here the VBScript code comes into play. The VBScript language is coded by Microsoft, and Microsoft obviously knows how to pass data to an object method. The idea is to transfer both the $oHexEdit object and the binary data in $dBinary to a VBScript through a ROT Object and then execute the SetData() method directly in the VBScript. Executing VBScript codeHexEdit1.au3: #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 Opt( "MustDeclareVars", 1 ) #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include "IRunningObjectTable.au3" Example() Func Example() ; Create GUI GUICreate( "Hex Editor", 420, 420 ) ; Create COM error handler Local $oMyError = ObjEvent( "AutoIt.Error", "MyErrFunc" ) ; Create Com object Local $oHexEdit = ObjCreate( "HEXEDIT.HexEditCtrl.1" ) If Not IsObj( $oHexEdit ) Then Return ConsoleWrite( "$oHexEdit ERR" & @CRLF ) ConsoleWrite( "$oHexEdit OK" & @CRLF ) ; Create ActiveX control GUICtrlCreateObj( $oHexEdit, 10, 10, 400, 400 ) ; Show GUI GUISetState() ; Load HexEditDlg.exe into ActiveX control Local $hFile = FileOpen( "HexEditDlg.exe", 16 ), $dBinary = FileRead( $hFile ), $i = FileClose( $hFile ) ; 16 = $FO_BINARY Local $sDictionaryData = "DictionaryData" ROT_RegisterObject( Default, $sDictionaryData ) ; Default => Object = Dictionary object Local $oROTobj = ObjGet( $sDictionaryData ) ; Dictionary object $oROTobj( "oHexEdit" ) = $oHexEdit $oROTobj( "dBinary" ) = $dBinary RunWait( 'wscript.exe "HexEdit1.vbs"' ) ; Loop While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd #forceref $oMyError, $i EndFunc Func MyErrFunc( $oError ) ConsoleWrite(@ScriptName & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _ @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _ @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _ @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _ @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _ @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _ @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _ @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _ @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _ @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF) EndFunc HexEdit1.vbs: Dim oROTobj, oHexEdit, dBinary Set oROTobj = GetObject( "DictionaryData" ) Set oHexEdit = oROTobj( "oHexEdit" ) dBinary = oROTobj( "dBinary" ) oHexEdit.SetData dBinary, 0 The ActiveX control in the AutoIt GUI is updated directly through the code in the VBScript: Hopefully someone will take up the challenge and implement a more complete Hex Editor. This is just a Hex Viewer. 7z-fileThe 7z-file contains all the necessary code and data. You need AutoIt 3.3.12 or later. Tested on Windows 7 and Windows 10. HexEdit is a 32 bit control. The code only runs as 32 bit code. Comments are welcome. Let me know if there are any issues. ObjectMethods.7z
    2 points
  4. Au3toCmd --- Avoid false virus positives Since many virus scanners sometimes prevent a "compiled autoit EXE" from being executed as "false positive", the "*.A3X" format is a suitable format to avoid this problem. See here for more information. In order to simplify this procedure, I wrote the Au3toCmd script. Here a *.Cmd file is generated from a *.Au3 file. The necessary files Autoit3.exe and *.A3x are added to the "*.Cmd" file as "alternate data streams" "Base64" encoded data. Now the Autoit Script can be called by clicking on the cmd file and the anti-virus scanners do not recognize the "false positive". If the short-term flashing of the CMD window bothers you, you can click the desktop shutcut that runs in a minimized window. Unfortunately, because the "alternate data streams", this CMD file cannot be distributed via FTP or email. Only a USB sti ck or removable disk formatted with NTFS can be used. As the new version now uses Base64 data instead of ADS, this statement is out of date. For reasons of compatibility, the old version was sunk into the spoiler here. The script can be called with a file name of an AU3 script as a parameter. If no name is entered, a query is made. For more information, see the header of the script. Suggestions, improvements and bug reports are welcome. Here the versions using base64 data Version: 2022.05.12 (Support blanks in pathnames) Version: 2022.06.23 (Support release candidates. Changed @CrLf to @Lf. Annual cleaning. Optimized #AutoIt3Wrapper handling) Version: 2022.07.22 (Support scripts with the same name but different content in different directories) Version: 2022.07.27 (Support blanks in usernames) Au3toCmd.au3 Version: 2022.09.01 (Optimized annual cleaning) Au3toCmd.au3
    1 point
  5. Hi Lars, I made some slight modifications in this version you don't need the external vbscript. #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 Opt( "MustDeclareVars", 1 ) #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include "IRunningObjectTable.au3" Example() Func Example() ; Create GUI GUICreate( "Hex Editor", 420, 420 ) ; Create COM error handler Local $oMyError = ObjEvent( "AutoIt.Error", "MyErrFunc" ) ; Create Com object Local $oHexEdit = ObjCreate( "HEXEDIT.HexEditCtrl.1" ) If Not IsObj( $oHexEdit ) Then Return ConsoleWrite( "$oHexEdit ERR" & @CRLF ) ConsoleWrite( "$oHexEdit OK" & @CRLF ) ; Create ActiveX control GUICtrlCreateObj( $oHexEdit, 10, 10, 400, 400 ) ; Show GUI GUISetState() ; Load HexEditDlg.exe into ActiveX control Local $hFile = FileOpen( "HexEditDlg.exe", 16 ), $dBinary = FileRead( $hFile ), $i = FileClose( $hFile ) ; 16 = $FO_BINARY Local $sDictionaryData = "DictionaryData" ROT_RegisterObject( Default, $sDictionaryData ) ; Default => Object = Dictionary object Local $oROTobj = ObjGet( $sDictionaryData ) ; Dictionary object $oROTobj( "oHexEdit" ) = $oHexEdit $oROTobj( "dBinary" ) = $dBinary Local $code= 'Dim oROTobj, oHexEdit, dBinary' $code=$code & @CRLF & 'Set oROTobj = GetObject( "DictionaryData" )' $code=$code & @CRLF & 'Set oHexEdit = oROTobj( "oHexEdit" )' $code=$code & @CRLF & 'dBinary = oROTobj( "dBinary" )' $code=$code & @CRLF & 'oHexEdit.SetData dBinary, 0' ;~ ConsoleWrite($code & @CRLF & @CRLF) Local $vbs = ObjCreate("ScriptControl") $vbs.language="vbscript" $vbs.addcode($code) ROT_Revoke($oROTobj) ; Loop While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd #forceref $oMyError, $i EndFunc Func MyErrFunc( $oError ) ConsoleWrite(@ScriptName & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _ @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _ @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _ @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _ @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _ @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _ @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _ @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _ @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _ @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF) EndFunc Thanks again for the bright solution ! ptrex
    1 point
  6. To just add a little '$' to the previous expression was not good enough ? #Include <Array.au3> $s = "Movie (0000) (part1000) (2002)" $a = stringregexp($s , "([^\\]*?)\h*\((\d+)\)$" , 3) _ArrayDisplay($a) @ReconX The best way is to translate the expression in common language , i.e. ([^\\]*?) means : "please capture 0 or more non-backslash characters (lazy way)" , or \((\d+)\) means : "please capture one or more digits enclosed with parenthesis"
    1 point
  7. Are you sure? ;-)) #include <SQLite.au3> Const $SQLITE_DLL = "C:\SQLite\bin\sqlite3.dll" ;<-- Change to the location of your sqlite dll ; Init sqlite _SQLite_Startup($SQLITE_DLL, False, 1) If @error Then Exit MsgBox($MB_ICONERROR, "SQLite Error", "Unable to start SQLite. Check existence of DLL") OnAutoItExitRegister(_SQLite_Shutdown) ConsoleWrite("SQlite version " & _SQLite_LibVersion() & @LF & @LF) ; optional! Local $hDB = _SQLite_Open() If @error Then Exit OnAutoItExitRegister(_SQ3Close) _SQLite_Exec($hDB, "create table T (k integer primary key, v char)") Local $t = TimerInit() For $i = 1 To 10000 _SQLite_Exec($hDB, "insert into T values (" & $i & ", 'abcdef')") Next Local $dt = TimerDiff($t) ConsoleWrite("10k inserts, no transaction, individual inserts took " & $dt / 1000 & "s" & @LF) _SQLite_Exec($hDB, "drop table T") _SQLite_Exec($hDB, "create table T (k integer primary key, v char)") $t = TimerInit() _SQLite_Exec($hDB, "begin exclusive") For $i = 1 To 10000 _SQLite_Exec($hDB, "insert into T values (" & $i & ", 'abcdef')") Next _SQLite_Exec($hDB, "end") Local $dt = TimerDiff($t) ConsoleWrite("10k inserts, one transaction, individual inserts took " & $dt / 1000 & "s" & @LF) _SQLite_Exec($hDB, "drop table T") _SQLite_Exec($hDB, "create table T (k integer primary key, v char)") $t = TimerInit() Local $s = "insert into T values (1, 'abcdef')" For $i = 2 To 10000 $s &= ",(" & $i & ", 'abcdef')" Next _SQLite_Exec($hDB, $s) Local $dt = TimerDiff($t) ConsoleWrite("10k inserts, one (implicit) transaction, chained inserts took " & $dt / 1000 & "s" & @LF) _SQLite_Exec($hDB, "drop table T") Func _SQ3Close() _SQLite_Close($hDB) EndFunc ;==>_SQ3Close SQlite version 3.32.3 10k inserts, no transaction, individual inserts took 5.9761773s 10k inserts, one transaction, individual inserts took 5.6808805s 10k inserts, one (implicit) transaction, chained inserts took 0.0446869s The beta is even much faster (I added test with a Map): SQlite version 3.32.3 10k inserts, no transaction, individual inserts took 1.2966753s 10k inserts, one transaction, individual inserts took 1.2246717s 10k inserts, one (implicit) transaction, chained inserts took 0.0381699s 10k inserts in a Map took 0.0103734s
    1 point
  8. ahmet already fully answered your question, giving you link to required GUI control: Note: Andreik's UDF code is AutoIt wrapper over standard Windows control msctls_hotkey32
    1 point
  9. caramen, Start from the bottom and work up: For $i = $iRows To 0 Step -1 That way you never try to access a non-existent row. M23
    1 point
  10. We have a language barrier here. I can't understand the word profit. Can you describe the problem in your language? I will then translate it into German.
    1 point
  11. @JockoDundee i added sqlite. The results are as expected because the scenario here is horrible for sqlite. In real life nobody would (at least I hope so) use single inserts and selects for such a amount of elements if it's possible to avoid. That's why i also added the results for one single insert for all elements just to show the huge difference, even if it doesn't match the actual scenario here. I already realized that - but this forum is named "technical discussion" - so why not discuss even if we are not the devs. And your hint already gave me a much further understanding. I learned - that was my intention here - so many thanks to you! @jchd Oh that looks interesting. Especially the discussion of which parameters of a hash-table have what effect. The library is C++ - i don't think it is useful to write a wrapper for it and use it in AutoIt. But maybe i make some tests with it in C++ sometime. Edit: I said i wrote my own hash-table in pure AutoIt for a better understanding. I add this structure to the comparison and i am quite surprised how well this one does. It's even better as AutoIt-maps and scripting.dictionary (only reading) at 1,000,000 elements.
    1 point
  12. //code from here to '[DISABLE]' will be used to enable the cheat Around here, we don’t ENABLE cheaters...
    1 point
  13. If I understand you correctly, change this line     $rc = FileWrite($sHostsFile, @CRLF & "127.0.0.1" & @TAB & @TAB & $sURL & @CRLF) to include extra CRLF's     $rc = FileWrite($sHostsFile, @CRLF & @CRLF & "127.0.0.1" & @TAB & @TAB & $sURL & @CRLF & @CRLF)
    1 point
  14. It would be interesting to find out what F14 gives: https://engineering.fb.com/2019/04/25/developer-tools/f14/
    1 point
  15. Have you confirmed that your VB script works successfully? What version of Step7 do you have installed? Is you Windows OS 32 or 64 bit? When you run your script in AutoIt, are you running it as 32 or 64 bit?
    1 point
  16. 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
    1 point
  17. For future googlers like me who found this topic because of the scaling issues: I was able to fix my problem by using DllCall and SetCursorPos. That matches with the numbers I get from MouseGetPos(). So instead of: MouseMove($x, $y) I used: DllCall("user32.dll", "bool", "SetCursorPos", "int", $x, "int", $y)
    1 point
  18. Why not just write the parser in Autoit? Oh, right... never mind
    1 point
  19. @Danp2, Thank you so much for testing the piece of code and finding that out. We have got a fix for that. Please refer the sixth answer here. ; #FUNCTION# =========================================================================================================== ; Name ..........: _WD_SetDropDownOption ; Description ...: Select a Drop down option by value, index or text ; Syntax ........: _WD_SetDropDownOption($sSession, $sElement, $svalue[, $iMethod = 1,]) ; Parameters ....: $sSession - Session ID from _WDCreateSession ; $sElement - Element ID from _WDFindElement ; $iMethod - [optional] an integer value. Default is 1. ; 1=Select option by value ; 2=Select option by index ; 3=Select option by text ; Return values .: Nil ; Author ........: ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _WD_SetDropDownOption($sSession, $sElement, $sValue, $iMethod = 1) Local $sJsonElement = '{"' & $_WD_ELEMENT_ID & '":"' & $sElement & '"}' Local $Query = "" Switch $iMethod Case 1 $Query = "var select = arguments[0]; for(var i = 0; i < select.options.length; i++){ if(select.options[i].value == " & "'" & $sValue & "'" & "){ select.options[i].selected = true; arguments[0].onchange();return } }" Case 2 $Query = "var select = arguments[0]; for(var i = 0; i < select.options.length; i++){ if(select.options[i].index == " & $sValue & "){ select.options[i].selected = true; arguments[0].onchange();return } }" Case 3 $Query = "var select = arguments[0]; for(var i = 0; i < select.options.length; i++){ if(select.options[i].text == " & "'" & $sValue & "'" & "){ select.options[i].selected = true; arguments[0].onchange();return } }" EndSwitch If $Query <> "" Then Local $sResponse = _WD_ExecuteScript($sSession, $Query , $sJsonElement ) Return EndFunc ;==>_WD_SetDropDownOption
    1 point
  20. Varian

    Convert *.bat to auto-it?

    This is just modified code from the AutoIT Helpfile for FileReadLine...just change null.bat to your batfile's path and name Dim $Output $File = FileOpen("null.bat", 0) ; Check if file opened for reading OK If $File = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf ; Read in lines of text until the EOF is reached While 1 $Line = FileReadLine($File) If @error = -1 Then ExitLoop If $Line <> '' Then $Output &= 'Run(@Comspec & " /c ' & $Line & '")' & @CRLF WEnd FileClose($File) FileWrite(@ScriptDir & "\NullAutoItScript.au3", $Output) This creates a new file called "NullAutoItScript.au3" that will run the batfile's code in AutoIT. If you are combining text from several batfiles, look up _FileListToArray and For Loops
    1 point
×
×
  • Create New...