Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 02/07/2020 in all areas

  1. 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
  2. For the moment you may not need the variable outside the if. But in the future it might change. And you will be face with an undeclared variable elsewhere if the condition is not True. Making debug a bit more tedious in large programs. I personally prefer playing it safe as it has no impact on size and speed of the script. So I always declare my vars outside a block of statement.
    1 point
  3. Well, it didn't exist back then, so that's irrelevant. Maybe stop blatantly advertising your UDF and I'd be more willing to try it. Personally, I'd rather create a3x files and shortcuts to the AutoIt executable. This really isn't the place for talking about it anyways. OP wanted to talk about enterprise solutions.
    1 point
  4. LarsJ

    Autoit variable to dot Net

    OleX.Connect($o_id, $i_args, $i_bool) does not work because $i_args is not properly converted to a safearray of variants and because $i_bool is not properly converted to a variant. There are two ways to move forward. The easiest way is to drop all AutoIt code and then make the code work in pure C# code. And then you may not need the AutoIt code at all. A more difficult way is to create a safearray and a variant in AutoIt code and then pass that data to C# code as pointers. But it's imperative to verify that the safearray and variant are correctly passed to the C# code (by printing data in the same way as in the C# code above).
    1 point
  5. You can use something like to enable/disable File and Printer Sharing for Microsoft Networks for all network adapters. #RequireAdmin _FilePrintSharing() Func _FilePrintSharing($_bEnable = True) Switch $_bEnable Case False ;~ Disable File and Printer Sharing for Microsoft Networks RunWait('PowerShell -Command "& {Get-NetAdapter | Disable-NetAdapterBinding -DisplayName ' & "'File and Printer Sharing for Microsoft Networks'" & '}"', "", @SW_HIDE) Case True ;~ Enable File and Printer Sharing for Microsoft Networks RunWait('PowerShell -Command "& {Get-NetAdapter | Enable-NetAdapterBinding -DisplayName ' & "'File and Printer Sharing for Microsoft Networks'" & '}"', "", @SW_HIDE) EndSwitch EndFunc
    1 point
  6. Check _WinAPI_EnumDisplayMonitors in help file. It will provide you the size of each monitor, so you can WinMove the IE window where ever you want...
    1 point
  7. One way : #include <Excel.au3> Global $sAnKcSbData = @ScriptDir & "\AnKcSbData.ini" Global $aSectionNames = IniReadSectionNames($sAnKcSbData) If @error Then Exit MsgBox(4096, "Error", "Error Reading Seciton Names") Global $aAnKcSbData[$aSectionNames[0] + 1][9], $iCount = 0 For $i = 1 To $aSectionNames[0] $aAnKcSbData[$iCount][0] = IniRead($sAnKcSbData, $aSectionNames[$i], "Roww", "Not Found") $aAnKcSbData[$iCount][1] = IniRead($sAnKcSbData, $aSectionNames[$i], "City", "Not Found") $aAnKcSbData[$iCount][2] = IniRead($sAnKcSbData, $aSectionNames[$i], "Vill", "Not Found") $aAnKcSbData[$iCount][3] = IniRead($sAnKcSbData, $aSectionNames[$i], "Strt", "Not Found") $aAnKcSbData[$iCount][4] = IniRead($sAnKcSbData, $aSectionNames[$i], "Iden", "Not Found") $aAnKcSbData[$iCount][5] = IniRead($sAnKcSbData, $aSectionNames[$i], "Name", "Not Found") $aAnKcSbData[$iCount][6] = IniRead($sAnKcSbData, $aSectionNames[$i], "Fath", "Not Found") $aAnKcSbData[$iCount][7] = IniRead($sAnKcSbData, $aSectionNames[$i], "Damg", "Not Found") $aAnKcSbData[$iCount][8] = IniRead($sAnKcSbData, $aSectionNames[$i], "Expl", "Not Found") If $aAnKcSbData[$iCount][1] = "USA / Texas" Then $iCount += 1 ; put all the conditions you want on this line Next ReDim $aAnKcSbData[$iCount][9] Local $oExcel = _Excel_Open() Local $oWorkbook = _Excel_BookNew($oExcel) _Excel_RangeWrite($oWorkbook, Default, $aAnKcSbData)
    1 point
  8. Subz

    Getting the text of a H3 html

    @Danp2 - @CaptainBeardsEyesBeard just edited the code it was $oButton in $oButtons which is why I was confused
    1 point
  9. LarsJ

    Autoit variable to dot Net

    You can pass the variables to C# code this way: tst00.cs using System; class TestClass { public void PassVars( int o_id, object[] i_args, int i_bool ) { Console.WriteLine( "C# code:" ); Console.WriteLine( "o_id = {0}", o_id ); Console.WriteLine( "i_args[0] = {0}", i_args[0] ); Console.WriteLine( "i_args[1] = {0}", i_args[1] ); Console.WriteLine( "i_args[2] = {0}", i_args[2] ); // Convert object to string string sStr = (string) i_args[0]; Console.WriteLine( "sStr = {0}", sStr ); Console.WriteLine( "i_bool = {0}", i_bool ); // Convert variables so that they can be passed to the Connect method. // Execute the Connect method from within the C# code. } } tst00.au3 #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 ;#AutoIt3Wrapper_UseX64=y Opt( "MustDeclareVars", 1 ) #include "DotNetAll.au3" Example() Func Example() Local $oNetCode = DotNet_LoadCScode( FileRead( "tst00.cs" ), "System.dll" ) Local $oTestClass = DotNet_CreateObject( $oNetCode, "TestClass" ) Local $o_id = 111 Local $i_args[3] = ["joe","mike","david"] Local $i_bool = -1 $oTestClass.PassVars( $o_id, $i_args, $i_bool ) EndFunc Console output C# code: o_id = 111 i_args[0] = joe i_args[1] = mike i_args[2] = david sStr = joe i_bool = -1
    1 point
  10. So if you open the PDF and then use the AutoIt Window Info tool (located in the same directory where you installed AutoIt), it should give you the title: For example (I am using PDFXchange Viewer for PDFs): Alternatively, if you have a large number of PDFs open, you could use WinList() and then filter by the title found.
    1 point
  11. If someone doesn't want to use external program, this could be an alternative : #include <Constants.au3> #include <String.au3> #include <Array.au3> #include <File.au3> Opt("MustDeclareVars", 1) Const $g_sBaseDir = "C:\Apps\Temp" Local $g_aFolders = _FileListToArray($g_sBaseDir, "*", $FLTAR_FOLDERS, True) If @error Then Exit ConsoleWrite("! @@ Error : _FileListToArray" & @CRLF) _ArrayDisplay($g_aFolders, "Folders") ; *** just for display For $i = 1 To $g_aFolders[0] ConsoleWrite("> >>>> Foldername = " & $g_aFolders[$i] & @CRLF) Zip($g_aFolders[$i] & ".zip", $g_aFolders[$i]) Next Func Zip($sZipFile, $sSourceFolder) If FileExists($sZipFile) Then Return SetError(1) ; destination file already exists If Not FileExists($sSourceFolder) Then Return SetError(2) ; source does not exist Local $hFile = FileOpen($sZipFile, $FO_CREATEPATH + $FO_OVERWRITE + $FO_BINARY) Local Const $sString = Chr(80) & Chr(75) & Chr(5) & Chr(6) & _StringRepeat(Chr(0), 18) FileWrite($hFile, $sString) FileClose($hFile) Local $oShell = ObjCreate("shell.application") If Not $oShell.NameSpace($sSourceFolder).items.count Then Return SetError(3) ; folder empty Local $iFiles = 0 For $oFile In $oShell.NameSpace($sSourceFolder).items $oShell.NameSpace($sZipFile).copyhere($oFile) Do Sleep(100) Until $oShell.NameSpace($sZipFile).items.count > $iFiles $iFiles = $oShell.NameSpace($sZipFile).items.count Next EndFunc ;==>Zip
    1 point
  12. If you want to pack all folders, then you can completely skip If StringRegExp . #include <File.au3> #include <StringConstants.au3> #include <Array.au3> Global $g_sBaseDir, $g_aFolders, $g_sCommand $g_sBaseDir = @ScriptDir $g_aFolders = _FileListToArray($g_sBaseDir, "*", $FLTAR_FOLDERS) If @error Then ConsoleWrite("! @@ Error : _FileListToArray" & @CRLF) Exit EndIf _ArrayDisplay($g_aFolders, "Folders") ; *** just for display For $i = 1 To $g_aFolders[0] ConsoleWrite("> >>>> Foldername = " & $g_aFolders[$i] & @CRLF) ; Variant 1 : without Progresswindow ;$g_sCommand = @ScriptDir & '\7za.exe a -y -tzip "' & $g_aFolders[$i] & '" "' & $g_aFolders[$i] & '"' ;RunWait ($g_sCommand, "", @SW_HIDE) ; Variant 2 : with Progresswindow $g_sCommand = @ScriptDir & '\7zG.exe a -y -tzip "' & $g_aFolders[$i] & '" "' & $g_aFolders[$i] & '"' RunWait ($g_sCommand, "", @SW_SHOW) Next
    1 point
  13. Prevent you from getting a false match on a partial word. Without the delimiters, you could search on "Ape" and get a match on "Grape"
    1 point
  14. following @water's route, this example and the one below it build a dictionary and then flex it to do things like return the language.
    1 point
  15. Or use the Dictionary object as mentioned in the threads title. How to fill the dictionary depens where you get the item/value pairs from (should be easy to retrieve the values from a file and add them to the Dictionary in just a few lines of code). So this is just a simple example: Global $oDict = ObjCreate("Scripting.Dictionary") ; Create the Dictionary Global $sItem = "Berry" Global $sValue = "Yrreb" $oDict.Add($sItem, $sValue) ; Add a member to the Dictionary MsgBox(0, "Dictionary", "Item: " & $sItem & " = " & "Value: " & $oDict.Item($sItem)) ; Retrieve a value from the Dictionary
    1 point
  16. @zeenmakr You could use an "ad hoc" function to do such thing, like the example below: Global $arrWords[6] = ["Berry", "Apple", "Orange", "Banana", "Grepe", "Carrot"] For $i = 0 To UBound($arrWords) - 1 Step 1 ConsoleWrite("The reverse word of '" & $arrWords[$i] & "' is '" & ReverseWord($arrWords[$i]) & "'." & @CRLF) Next Func ReverseWord($strText) Return Execute(StringRegExpReplace($strText, '^(\w{1})(.*)(\w{1})$', 'StringUpper("$3") & StringReverse("$2") & StringLower("$1")')) EndFunc As @Danp2 said, you may want to store the different words in an INI file, and then use the "reverse" function to do whatever you need
    1 point
  17. I create CHM file's with Precision Helper. It's pretty easy to use but you need a decent HTML editor for the pages of your manual/help file. I use BlueGriffon. Let me hear if you need more info but it's quite easy to set up. For every UDF I created a HTLM file. Of course I could have create an automatic HTML file creator tool which scans the UDF's to create HTLM pages but I didn't bother. Most UDF's have additional info like an example which need to be written. To my opinion every library and program need a manual, a CHM file and/or website. Precision Helper can also created the pages for a help manual website. For the images in my programs and in a manual I use Inkscape and the Gimp.
    1 point
×
×
  • Create New...