Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 06/23/2017 in all areas

  1. Ok, just thinking... why would you use IE to use some web service that uses google translator to translate some file? And go thru all this "automation" stuff? Wouldn't it be easier to use google translator directly, without IE, and without the use of third party web service? Maybe (but only maybe) like this: #include "WinHttp.au3" $sAddress = "https://translate.googleusercontent.com/translate_f" $sOutputLang = "fr" $sFileToUpload = FileOpenDialog("Choose file", "", "Text file (*.txt)") If Not $sFileToUpload Then Exit $sForm = _ '<form action="' & $sAddress & '" method="post" enctype="multipart/form-data">' & _ ' <input type="file" name="file"/>' & _ ; ' <input name="sl" />' & _ ' <input name="tl" />' & _ ' <input name="js" />' & _ ' <input name="prev" />' & _ ' <input name="hl" />' & _ ' <input name="ie" />' & _ ' <input name="text" />' & _ ' <input name="edit-text" />' & _ '</form>' ; Initialize and get session handle $hOpen = _WinHttpOpen("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36 Edge/15.15063") $hConnect = $sForm ; will pass form as string so this is for coding correctness because $hConnect goes in byref ; Fill form $sHTML = _WinHttpSimpleFormFill($hConnect, $hOpen, _ Default, _ "name:file", $sFileToUpload, _ "name:sl", "auto", _ "name:tl", $sOutputLang) $iErr = @error ; Close handles _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) If $iErr Then MsgBox(4096, "Error", "Error number = " & @error) Else Local $aData = StringRegExp($sHTML, "(?si)<\s*pre(?:[^\w])\s*(.*?)(?:(?:<\s*/pre\s*>)|\Z)", 3) If @error Then MsgBox(4096, "Error", "Check the console output!") ConsoleWrite($sHTML & @CRLF) Else $hOutputFile = FileOpen($sFileToUpload & "_" & $sOutputLang & ".txt", 130) FileWrite($hOutputFile, $aData[0]) FileClose($hOutputFile) ;~ ConsoleWrite($aData[0] & @CRLF) EndIf EndIf
    2 points
  2. water

    Excel, unique ref

    Fast version (only a single write to Excel): #include <Excel.au3> Global $oExcel = _Excel_Open() Global $oWorkbook = _Excel_BookOpen($oExcel, @ScriptDir & "\test.xlsx") Global $iFirstRow = $oWorkbook.ActiveSheet.UsedRange.Row ; Row number of the first used row Global $iRows = $oWorkbook.ActiveSheet.UsedRange.Rows.Count ; Number of rows in the used range Global $iCount = 1 Global $iColumn = $oWorkbook.ActiveSheet.UsedRange.Columns.Count + 1 ; Column to write the unique id to Global $aReference[$iRows][1] For $i = 0 To $iRows - 1 $aReference[$i][0] = "reference" & StringFormat("%04i", $i + 1) Next _Excel_RangeWrite($oWorkbook, Default, $aReference , _Excel_ColumnToLetter($iColumn) & $iFirstRow)
    2 points
  3. InnI

    [SOLVED] GDI animation Help

    #include <GDIPlus.au3> _GDIPlus_Startup() $hImage = _GDIPlus_ImageLoadFromFile("CD.png") $aDim = _GDIPlus_ImageGetDimension($hImage) $hBufImg = _GDIPlus_BitmapCreateFromScan0($aDim[0], $aDim[1]) $hBufGraph = _GDIPlus_ImageGetGraphicsContext($hBufImg) _GDIPlus_GraphicsTranslateTransform($hBufGraph, $aDim[0] / 2, $aDim[1] / 2) $iBackColor = 0xFFFFFFF0 $hGUI = GUICreate("CD Animation", $aDim[0], $aDim[1]) GUISetBkColor($iBackColor) GUISetState() $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) $iAngle = 5 ; rotate speed Do _GDIPlus_GraphicsRotateTransform($hBufGraph, $iAngle) _GDIPlus_GraphicsClear($hBufGraph, $iBackColor) _GDIPlus_GraphicsDrawImage($hBufGraph, $hImage, -$aDim[0] / 2, -$aDim[1] / 2) _GDIPlus_GraphicsDrawImage($hGraphics, $hBufImg, 0, 0) Until GUIGetMsg() = -3 _GDIPlus_ImageDispose($hBufImg) _GDIPlus_ImageDispose($hImage) _GDIPlus_GraphicsDispose($hBufGraph) _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_Shutdown()
    1 point
  4. mikell

    File Get Size

    The 2nd For/Next loop is useless #include <File.au3> #include <Array.au3> Global $a, $b $a = _FileListToArrayEx(@ScriptDir, '*.visf') ; _ArrayDisplay($a) For $i = 1 to $a[0] $b = StringSplit($a[$i], "\") ;~ ConsoleWrite($b[$b[0] - 1] & '_' & $b[$b[0]] & ' ' & FileGetSize($a[$i]) & @CRLF) FileWrite(@ScriptDir & '\result.txt', $b[$b[0] - 1] & '_' & $b[$b[0]] & ' ' & FileGetSize($a[$i]) & @CRLF) Next
    1 point
  5. Deye

    Refresh icons

    PedroWarlock, With a simple google search "assoc autoit site:www.autoitscript.com" here is one hit To refresh for changes without restarting explorer.exe you can use: _WinAPI_PostMessage($HWND_BROADCAST, $WM_COMMAND, 41504, Null) or _WinAPI_ShellChangeNotify($SHCNE_ASSOCCHANGED, $SHCNF_FLUSH) whichever works for you
    1 point
  6. Put this at the top of your code: #AutoIt3Wrapper_UseX64=Y
    1 point
  7. My regexes are infinitely better because of the regex gamesmanship exhibited by folks like JGunich and Mikell. The desire to foolproof something against edgecases before the question is fully formed is part of the learning, you just learned something else instead. Helping the OP in their efforts is secondary to getting all that shit on one line first. I would attribute most of my success with Splunk and WQL directly to learning PCRE in this forum. The ability to write good RegEx is as marketable as any other language, the enjoyment of it even moreso. And I have found the best place to learn regex is not some other website, it is right here. The user picks any regular expression or any string and says that, 'my regex is the best' or 'this cant be done' , and a lessonplan will be personalized. For $0. Wouldnt use it for this task tho, I would read the notepad into an array, and as long as those colons are reliable (I know mine isnt). #include<array.au3> local $array[7] $array[0]='::Dub.com Toolbar' $array[1]='|{8e5025c2-8ea3-430d-80b8-a14151068a6d}' $array[2]='|{A957F04C-49F4-4375-8C8A-D04B769EFE47}' $array[3]='|{1bc82e67-afbc-434a-aae9-eb0776452f05}' $array[4]='|{4D84CC03-383C-4BB1-A485-B263A03E9FF1}' $array[5]='::1k.FM Toolbar' $array[6]='|{3a9262ef-45b5-46fc-b460-7053539c9176}' For $i = ubound($array) - 2 to 0 step - 1 If stringleft($array[$i], 2) = "::" Then $array[$i + 1] = $array[$i + 1] & " ; " & $array[$i] _ArrayDelete($array , $i) EndIf Next _ArrayDisplay($array)
    1 point
  8. Try declaring $pos[2] before the whole script EDIT: Local $pos[2] $test = GUICreate("test") GUICtrlCreateLabel("Mouse coord.:", 300, 5) GUICtrlCreateLabel("X:", 300, 20) GUICtrlCreateLabel("Y:", 350, 20) $X = GUICtrlCreateInput($pos[0], 275, 35, 40, 20) $y = GUICtrlCreateInput($pos[1], 335, 35, 40, 20) GUISetState(@SW_SHOW, $test) While 1 $pos = MouseGetPos() GUICtrlSetData($X, $pos[0]) GUICtrlSetData($y, $pos[1]) Sleep(10) WEnd This works fine for me
    1 point
  9. This actually helps a lot. Can you please post some simpler example (adding two numbers). Original language source and complete function in AutoIt using machine code. That would help me with patterns. I will try to comprehend.
    1 point
  10. I absolutely love the simplicity of your machine code functions. I found them to be beautiful (like a beautiful woman). Probably I'm crazy and everything, khm, khm... You should make a tutorial on how to get machine code. Don't be lazy, do it. You should find rewarding having people learn of you. Yes, you are right, seems that now they are as fast. Return variable of DllStructCreate() in our case is local and releasing allocated memory by setting this variable to 0 is not needed. That was my thinking. Is this true, but completely true? About splitting... That should be done very consideringly to avoid possible mistakes due to the fact how base64 encoding is done (3 --> 4). Size of the portions would also depend on how long is every line of output sting (@CRLF we add for SMTP servers). So, portion lenght should be (4*3*LINE_BREAK)*n. "n" should be determined experimentally to accomplish best performance. Maybe would be faster, but looping with AutoIt is relatively slow... Someone should do it and test it. I updated first post (still no error checking). This how Wards _Base64Encode() looks with me: Func _Base64Encode($Data, $LineBreak = 76) Local $Opcode = "0x5589E5FF7514535657E8410000004142434445464748494A4B4C4D4E4F505152" _ & "535455565758595A6162636465666768696A6B6C6D6E6F707172737475767778" _ & "797A303132333435363738392B2F005A8B5D088B7D108B4D0CE98F0000000FB6" _ & "33C1EE0201D68A06880731C083F901760C0FB6430125F0000000C1E8040FB633" _ & "83E603C1E60409C601D68A0688470183F90176210FB6430225C0000000C1E806" _ & "0FB6730183E60FC1E60209C601D68A06884702EB04C647023D83F90276100FB6" _ & "730283E63F01D68A06884703EB04C647033D8D5B038D7F0483E903836DFC0475" _ & "0C8B45148945FC66B80D0A66AB85C90F8F69FFFFFFC607005F5E5BC9C21000" Local $CodeBuffer = DllStructCreate("byte[" & BinaryLen($Opcode) & "]") DllStructSetData($CodeBuffer, 1, $Opcode) $Data = Binary($Data) Local $Input = DllStructCreate("byte[" & BinaryLen($Data) & "]") DllStructSetData($Input, 1, $Data) $LineBreak = Floor($LineBreak / 4) * 4 Local $OputputSize = Ceiling(BinaryLen($Data) * 4 / 3) $OputputSize = $OputputSize + Ceiling($OputputSize / $LineBreak) * 2 + 4 Local $Ouput = DllStructCreate("char[" & $OputputSize & "]") DllCall("user32.dll", "none", "CallWindowProc", "ptr", DllStructGetPtr($CodeBuffer), _ "ptr", DllStructGetPtr($Input), _ "int", BinaryLen($Data), _ "ptr", DllStructGetPtr($Ouput), _ "uint", $LineBreak) Return DllStructGetData($Ouput, 1) EndFunc It's beautiful, right? Specially when you think what job it does. ... I'm crazy
    1 point
  11. rasim

    Makeing a checklist

    Example: #include <GuiConstants.au3> $hGui = GUICreate("Test GUI", 200, 100) $checkbox = GUICtrlCreateCheckbox("Run notepad", 50, 45, 80, 16) GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE ExitLoop Case $checkbox If GUICtrlRead($checkbox) = $GUI_CHECKED Then Run("notepad.exe") WinWait("[Class:Notepad]") ControlSend("[Class:Notepad]", "", "Edit1", "Hello world!", 1) GUICtrlSetState($checkbox, $GUI_UNCHECKED) EndIf EndSwitch WEnd
    1 point
×
×
  • Create New...