Jump to content

Search the Community

Showing results for tags 'conversion'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Location


WWW


Interests

Found 8 results

  1. Here is a simple program that some of you might appreciate. It is a more full fleshed out version of something I worked on a while back as a proof of concept. I will just quote the information found in the Program Information dialog. Older Screenshot INItoSQL DB.zip INItoSQL DB v1.1.zip (see Post #3 for update details) INItoSQL DB v1.4.zip (see Post #4 for update details) INItoSQL DB v1.6.zip (see Post #7 for update details) BIG THANKS to ResNullius for huge speed improvement etc. Program requires the sqlite3.dll, not included, but easily enough obtained. I have also included the beginnings of a new UDF (SimpleSQL_UDF) I am working, which you can use with the included 'Check conversion.au3' file to check a resulting conversion ... just modify the values for a few variables to suit your situation. I've not yet gotten around to coding a testing/checking results script, so I recommend the following open source program, which I have been using for some time. It was here, but is now here at GitHub - DB Browser for SQLite
  2. After much searching I finally found a method to get eMails from an Exchange eMail account inbox. I was hoping for AutoIT or vbscript but I couldn't find any that would read the inbox messages without using Outlook. I needed this because I'm testing a web-form that generates an eMail sent to a shared mailbox "not what my current outlook is configured for". so, I needed to connect to a different account, then get the inbox messages, and see if the auto-generated eMail message body contains what I submitted in the form. I found a PowerShell script that was close and modified it to do just what I want, but I'd still like it to run in AutoIT but I'm not sure how to use the Microsoft.Exchange.WebServices.dll Anybody have some ideas? #To Launch! # C:\Windows\System32> powershell -ExecutionPolicy ByPass #This launches PowerShell and allows execution of .ps1 files # PS C:\Windows\System32> . "C:\Temp\eMail\getInbox.ps1" #The period . in front of the .ps1 file forces PS to display results on-screen # Where is the EWS .DLL file that you are using # Get the installer from https://www.microsoft.com/en-us/download/details.aspx?id=42022 # We only need 2 dll's from the install and they can be stored anywhere: "Microsoft.Exchange.WebServices.Auth.dll" & "Microsoft.Exchange.WebServices.dll" $EWSdll = "C:\Temp\eMail\Microsoft.Exchange.WebServices.dll" # Where do you want the output text file to be saved $Output = "C:\Temp\eMails.txt" # replace with your email address $email = "MyemailAddress@work.net" # only need to populate these if you're impersonating... $username = "myemail" $password = "Sup3rS3cre+" $domain = "ad.work.net" # load the assembly : point to the dll in the location you have the .dll file [void] [Reflection.Assembly]::LoadFile($EWSdll) # set ref to exchange, first references 2007, 2nd is 2010 (default) #$s = New-Object Microsoft.Exchange.WebServices.Data.ExchangeService([Microsoft.Exchange.WebServices.Data.ExchangeVersion]::Exchange2007_SP1) $s = New-Object Microsoft.Exchange.WebServices.Data.ExchangeService # use first option if you want to impersonate, otherwise, grab your own credentials with the 3rd one. not sure what the 2nd one is for $s.Credentials = New-Object Net.NetworkCredential($username, $password, $domain) ##$s.Credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials #$s.UseDefaultCredentials = $true # discover the url from your email address $s.AutodiscoverUrl($email) # get a handle to the inbox $inbox = [Microsoft.Exchange.WebServices.Data.Folder]::Bind($s,[Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::Inbox) #create a property set (to let us access the body & other details not available from the FindItems call) $psPropertySet = new-object Microsoft.Exchange.WebServices.Data.PropertySet([Microsoft.Exchange.WebServices.Data.BasePropertySet]::FirstClassProperties) $psPropertySet.RequestedBodyType = [Microsoft.Exchange.WebServices.Data.BodyType]::Text; # If you have a set number of items you want to get, use this and insert the # in the () # $items = $inbox.FindItems(5) # If you want to retrieve all items (Server limit is usually at 1000) then use this line # Details on the max returned by server: https://blogs.msdn.microsoft.com/exchangedev/2010/03/12/throttling-policies-and-the-ewsfindcountlimit/ $items = $inbox.FindItems($inbox.TotalCount) # Put some counts at the top of the output Write-host "Total Inbox count: $($inbox.TotalCount)" Write-host "Unread count: $($inbox.UnreadCount)" #These two lines, write the output to the specified text file Add-Content $Output "Total Inbox count: $($inbox.TotalCount)" Add-Content $Output "Unread count: $($inbox.UnreadCount)" foreach ($item in $items.Items) { # load the property set to allow us to get to the body $item.load($psPropertySet) # Get the Body text as-is $bod = $item.Body.Text #if you only want a short summary of the Body, then comment the above line and un-comment these 4 lines # $bod = $item.Body.Text -replace '\s+', ' ' # $bodCutOff = (100,$bod.Length | Measure-Object -Minimum).Minimum # $bod = $bod.Substring(0,$bodCutOff) # $bod = "$bod..." # output the results - first of all the From, Subject, References and Message ID write-host "====================================================================" Write-host "From: $($item.From.Name)" Write-host "Subject: $($item.Subject)" Write-host "Body: $($bod)" write-host "====================================================================" "" # Output the results to the specified Text file Add-Content $Output "" Add-Content $Output "====================================================================" Add-Content $Output "From: $($item.From.Name)" Add-Content $Output "Subject: $($item.Subject)" Add-Content $Output "Body:",$($bod) Add-Content $Output "====================================================================" Add-Content $Output "" } #see these URLs for more info # EWS Stuff # folder members: https://msdn.microsoft.com/en-us/library/microsoft.exchange.webservices.data.folder_members%28v=exchg.80%29.aspx # exporting headers: https://www.allabout365.com/2010/10/export-email-headers-exchange-powershell/ # read emails with EWS: https://social.technet.microsoft.com/Forums/en-US/3fbf8348-2945-43aa-a0bc-f3b1d34da27c/read-emails-with-ews?forum=exchangesvrdevelopment Thanks, Mike
  3. This is a small app I wrote awhile back to batch FFMPEG commands of videos. I have a camcorder that saves to a file type .mts and I wanted to convert them to .mp4 but was too lazy to write out the commands one at a time in the CMD window. NOTES: You will need to download ffmpeg, as it is the application doing the actual conversions (http://ffmpeg.org/). It can only do one directory at a time, it will not do recursive directories. The defaults are set up to convert .mts files to .mp4, if you want to change the input, output and command line options you can, however, you may need to read the documentation at the ffmpeg website. If you want to change the input file type, do this before opening the input browse button. The software will steal focus to communicate with the command line interface, It is best to set up a conversion job and leave the computer alone until it is done (hence the option to shutdown after converting files). If you try to use the computer while it is running chances are it will fail to convert one or more videos. Video processing can be PCU intensive, this application was designed to be set and forget. If you don't want to scale down to 720p remove " -s 1280x720 " from command line, remove " -r 30 " if you don't want the frame rate set to 30fps, if you do not require deinterlacing remove " - vf yadif=1 " from the command line options. You can choose to delete the original video files after they are converted to save disc space, but it pays to test one file first to make sure they convert correctly before batch deleting the original files (they are sent to the recycle bin, so you can restore them until you empty the recycle bin). AutoIt Code: ; Build by Marc Rosewarne 2012 ; Works with ffmpeg to automate commandline inputs and converts all files in a selected folder. ;--------------------------------- REQUIRED INCLUDES & GLOBAL VARS -------------------------------------; Opt("WinTitleMatchMode", 3) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase #include <GuiConstants.au3> #include <GuiListView.au3> #include <Array.au3> ;----------------------------------------------- MAIN GUI ---------------------------------------------------; $mainWin = GuiCreate("ffmpeg batch convertion automator", 650, 400) ;VID FILES LOCATION GuiCtrlCreateGroup("Input Video File Type and Location", 15, 15, 620, 180) $vidFileType = GuiCtrlCreateInput(".mts", 25, 35, 30, 20) $vidSourceDir = GuiCtrlCreateInput("Set Input File(s) Location", 60, 35, 500, 20) $vidSetSourceDir = GuiCtrlCreateButton("Browse", 565, 34, 60, 22) $vidSourceList = GuiCtrlCreateEdit("Video Files: ", 25, 65, 600, 105) $vidSourceNum = GUICtrlCreateLabel("Files Found: 0", 25, 173, 110, 15) $vidFilesConverted = GUICtrlCreateLabel("Files Converted: 0", 260, 173, 110, 15) $vidFilesDeleted = GUICtrlCreateLabel("Files Deleted: 0", 500, 173, 110, 15) GUICtrlCreateGroup ("",-99,-99,1,1) ;close group ; CONVERTION OPTIONS GuiCtrlCreateGroup(" ffmpeg.exe Location and Commands ", 15, 200, 620, 100) $ffmpegExeLocation = GuiCtrlCreateInput("Set ffmpeg.exe Location", 25, 218, 535, 20) $ffmpegBrowseBtn = GuiCtrlCreateButton("Browse", 565, 217, 60, 22) GUICtrlCreateLabel("Set ffmpeg commandline: ", 25, 250, 160, 15) GUICtrlCreateLabel(" ffmpeg -i [input] ", 25, 270, 80, 15) $ffmpegCommand = GuiCtrlCreateInput("-vf yadif=1 -s 1280x720 -r 30 -vcodec mpeg4 -b:v 15M -acodec libmp3lame -b:a 192k", 105, 268, 450, 20) GUICtrlCreateLabel("[output].", 560, 270, 40, 15) $convertedFileType = GuiCtrlCreateInput("mp4", 600, 268, 30, 20) GUICtrlCreateGroup ("",-99,-99,1,1) ;close group ; EXTRA OPTIONS GuiCtrlCreateGroup(" Post Convertion Options ", 15, 310, 620, 40) $deleteInput = GUICtrlCreateCheckbox( "Delete original video files", 25, 325) GUICtrlCreateLabel("Computer:", 360, 327, 80, 15) $o1 = GuiCtrlCreateRadio("Reboot", 420, 323, 50) $o2 = GuiCtrlCreateRadio("Shutdown", 485, 323, 65) $o3 = GuiCtrlCreateRadio("Nothing", 560, 323, 60) GuiCtrlSetState(-1, $GUI_CHECKED) GUICtrlCreateGroup ("",-99,-99,1,1) ;close group ; GO! BUTTON $startVidExport = GUICtrlCreateButton(">>> Convert Video Files >>>", 15, 363, 620, 22) GUICtrlSetState(-1, $GUI_DISABLE) $proggy = GuiCtrlCreateProgress(15, 363, 620, 22) GUICtrlSetState($proggy, $GUI_HIDE) GUISetState(@SW_SHOW) ;---------------------------------------------- FUNCTIONS -------------------------------------------------------; Func vidSourceDir() ;---SET SOURCE FILE LOCATION $message = "Select folder/drive location to find " & StringUpper(StringTrimLeft(GUICtrlRead($vidFileType), 1)) & " files." $var = FileSelectFolder($message, "") If @error Then MsgBox(4096,"","No Folder Selected!") Return Else GUICtrlSetData($vidSourceDir, $var) GUICtrlSetData($vidSourceList, GUICtrlRead($vidSourceList) & @CRLF & " > Analysing directory structure - please wait...") EndIf ;---ERROR CHK REQUIRED FIELDS B4 MOVING ON If GUICtrlRead($vidSourceDir) = "" OR GUICtrlRead($vidSourceDir) = "Set Input File(s) Location" Then MsgBox(64, "User Error", "No Source Location Set." & @LF & "Requested action will now terminate.") Return Else If NOT FileExists(GUICtrlRead($vidSourceDir)) Then MsgBox(64, "User Error", "The Source Location Does Not Exsist." & @LF & "Requested action will now terminate.") Return EndIf EndIf ;---SEARCH FOR FILES IN SELECTED DIRECTORY $fileTotal = DirGetSize( $var,1) Global $fileCount = 0 Global $vidSourceFiles[$fileTotal[1]][2] $search = FileFindFirstFile(GUICtrlRead($vidSourceDir) & "\*" & GUICtrlRead($vidFileType)) $var = GUICtrlRead($vidSourceDir) GUICtrlSetData($vidSourceList , StringUpper(StringTrimLeft(GUICtrlRead($vidFileType), 1)) & " Files: ") findvidFiles($search, $var) If $fileCount <> 0 Then ReDim $vidSourceFiles[$fileCount][2] EndIf FileClose($search) If $fileCount <> 0 Then GUICtrlSetState($startVidExport, $GUI_ENABLE) EndIf EndFunc Func ffmpegExeLoc() ;---SET FFMPEG.exe LOCATION $message2 = "Select ffmpeg.exe location." $var2 = FileOpenDialog($message2, @ProgramFilesDir & "\", "(ffmpeg.exe)") If @error Then MsgBox(4096,"","No Folder Selected!") Return Else GUICtrlSetData($ffmpegExeLocation, $var2) EndIf ;---ERROR CHK REQUIRED FIELDS B4 MOVING ON If GUICtrlRead($ffmpegExeLocation) = "" OR GUICtrlRead($ffmpegExeLocation) = "Set ffmpeg.exe Location" Then MsgBox(64, "User Error", "No FFMPEG.exe Set." & @LF & "Requested action will now terminate.") Return Else If NOT FileExists(GUICtrlRead($ffmpegExeLocation)) Then MsgBox(64, "User Error", "The FFMPEG.exe Location Does Not Exsist." & @LF & "Requested action will now terminate.") Return EndIf EndIf EndFunc Func findvidFiles($search, $var) ;---FIND FILES & ADD TO ARRAY CALLED BY vidSourceDir() While (True) $file = FileFindNextFile($search) If @error Then ExitLoop EndIf $vidSourceFiles[$fileCount][0] = $file $vidSourceFiles[$fileCount][1] = $var GUICtrlSetData($vidSourceNum , "Files Found: " & $fileCount+1) GUICtrlSetData($vidSourceList , GUICtrlRead($vidSourceList) & @CRLF & " > Video File Found: " & $var & "\" & $file) $fileCount += 1 WEnd EndFunc Func batchFFMPEGConverts() ;---ERROR CHK REQUIRED FIELDS B4 MOVING ON If GUICtrlRead($ffmpegExeLocation) = "" OR GUICtrlRead($ffmpegExeLocation) = "Set ffmpeg.exe Location" Then MsgBox(64, "User Error", "No FFMPEG.exe Set." & @LF & "Requested action will now terminate.") Return Else If NOT FileExists(GUICtrlRead($ffmpegExeLocation)) Then MsgBox(64, "User Error", "The FFMPEG.exe Location Does Not Exsist." & @LF & "Requested action will now terminate.") Return EndIf EndIf GUICtrlSetState($startVidExport, $GUI_DISABLE) GUICtrlSetState($startVidExport, $GUI_HIDE) GUICtrlSetState($proggy, $GUI_SHOW) Global $xmlFile Global $count = 100/$fileCount If NOT WinExists("C:\Windows\system32\cmd.exe") Then Run("C:\Windows\system32\cmd.exe", "", @SW_MAXIMIZE) EndIf WinActivate("C:\Windows\system32\cmd.exe") WinWaitActive("C:\Windows\system32\cmd.exe") ;create _converted directory DirCreate(GUICtrlRead($vidSourceDir) & "\_converted") ;---LOOP THROUGH VIDEO FILES AND SEND FFMPEG COMMAND TO CONVERT IT. FOR $i = 0 to UBound($vidSourceFiles)-1 $file = $vidSourceFiles[$i][0] $source = $vidSourceFiles[$i][1] $xmlFile = $source & "\" & $file ;write out ffmpeg commandline here WinActivate("C:\Windows\system32\cmd.exe") WinWaitActive("C:\Windows\system32\cmd.exe") Send(GUICtrlRead($ffmpegExeLocation) & " -i """ & $xmlFile & """ " & GUICtrlRead($ffmpegCommand) & " """ & $source & "\_converted\" & StringTrimRight($file, 3) & GUICtrlRead($convertedFileType) & """{ENTER}") ;update progress bar If $count*($i+1) = 100 Then GUICtrlSetData($proggy, 99) Else GUICtrlSetData($proggy, ($count*($i+1))) EndIf WinWait("C:\Windows\system32\cmd.exe") ;change converted number. GUICtrlSetData($vidFilesConverted, "Files Converted: " & $i+1) NEXT GUICtrlSetData($proggy, 100) WinClose("C:\Windows\system32\cmd.exe") ;delete original video files If GUICtrlRead($deleteInput) = 1 Then $msg = MsgBox(65, "Delete Original Video Files", "'Delete original video files after convertion' has been selected. This will happen in 10 seconds. Click 'Cancel' to cancel file deletion. (Files will be moved to recycle bin, they can be restored from there untill you empty the recycle bin.)", 10) If $msg <> 2 Then FOR $i = 0 to UBound($vidSourceFiles)-1 $vidFile = $vidSourceFiles[$i][1] & "\" & $vidSourceFiles[$i][0] ; if file exsist, delete it If FileExists($vidFile) Then FileRecycle($vidFile) EndIf ;change deleted number. GUICtrlSetData($vidFilesDeleted, "Files Deleted: " & $i+1) GUICtrlSetData($proggy, (100-$count*($i+1))) NEXT EndIf EndIf ;shutdown/reboot If GUICtrlRead($o1) = 1 Then $msg = MsgBox(65, "Automated Reboot", "Computer will reboot in 10 seconds. Click 'Cancel' to cancel reboot.", 10) If $msg <> 2 Then Shutdown(6) Exit EndIf EndIf If GUICtrlRead($o2) = 1 Then $msg = MsgBox(65, "Automated Shutdown", "Computer will shutdown in 10 seconds. Click 'Cancel' to cancel shutdown.", 10) If $msg <> 2 Then Shutdown(5) Exit EndIf EndIf GUICtrlSetState($proggy, $GUI_HIDE) GUICtrlSetData($proggy, 0) GUICtrlSetState($startVidExport, $GUI_SHOW) GUICtrlSetState($startVidExport, $GUI_ENABLE) EndFunc ;------------------------------------------------ LOOP -------------------------------------------------------; While 1 $msg = GUIGetMsg(1) Select Case $msg[0] = $vidSetSourceDir vidSourceDir() Case $msg[0] = $startVidExport batchFFMPEGConverts() Case $msg[0] = $ffmpegBrowseBtn ffmpegExeLoc() Case $msg[0] = $GUI_EVENT_CLOSE Exit EndSelect WEnd Hopefully someone may find it usefull? Enjoy.
  4. Trying to find a quick way to convert 30k+ WordPerfect files into Word. Will probably run it locally from an admin machine or server so user permissions won't affect it. My idea was just to open the file, select all, copy, open new word doc, paste, file, save.... What would be the best way to go about scripting something in this way?
  5. This code is a subset of an AutoIt tool I wrote for the classic DOS word-processor XyWrite. The tool allows 7-bit Ascii encoding of XyWrite Programming Language programs, with "readability aids" that mimic the way this code looks natively on the DOS screen. This is a special 7-bit encoding that we've used for many years in the XyWrite community to discuss XPL code on the XyWrite Mailing List. But that's neither here nor there. The present subset consists of three utilities, which I offer here for what they're worth. The first, DVIEW.AU3, takes a binary file and displays it in the default Windows text editor, displaying only Ascii chars 32-127, the other chars being represented by ".". The command-line usage is: DVIEW.AU3 <file_in><Enter> The second, DREAD.AU3 (that's "Dee-Read", not "dread" ), provides a similar display, except that characters outside the Ascii 32-127 range are represented by "{nnn}", where "nnn" is the 3-digit decimal Ascii number. (The initial "D" in these utilities' names stands for "decimal".) The output from DREAD.AU3 can be edited to make simple patches to binary files. The output file is named DREAD.TXT. The usage is: DREAD.AU3 <file_in><Enter> The third utility, DWRITE.AU3, takes DREAD output and writes it back to disk as a binary file. So, once you edit the output from DREAD, you write it to disk with: DWRITE.AU3 <file_in><Enter> The default file_in is DREAD.TXT -- i.e., the output of DREAD.AU3. The output file is named DWRITE.BIN, which can be renamed as desired. You'll see that each of these scripts processes the input file character by character. If there's a faster way of doing this, for example by manipulating bit patterns, I'd be pleased to hear about it. Here are the three scripts. Enjoy. ; DVIEW.AU3 -- AutoIt v3 [CarlD rev.9/27/15] ; Display a decimal view of a binary file ; ; Usage: ; DREAD.AU3 file_in ProgressOn(@ScriptName,"Working") Global $iLnLen = 0; Line length meter Local $sTmp = ""; Temp string var Local $sInFile = @ScriptDir & "\DVIEW.IN" If $CmdLine[0] > 0 Then $sInFile = $CmdLine[1] If Not FileExists($sInFile) Then ProgressOff() MsgBox(16, @Scriptname, $sInFile & " does not exist!", 3) Exit EndIf Local $sTmpFile = @ScriptDir & "\DVIEW.TMP" Local $sOutFile = @ScriptDir & "\DVIEW.TXT" If FileExists($sTmpFile) Then FileDelete($sTmpFile) If FileExists($sOutFile) Then FileDelete($sOutFile) Local $hWrIn = FileOpen($sInFile, 16); Handle for source file Local $sToEncode = FileRead($hWrIn); Binary (hex) string to encode FileClose($hWrIn) Global $sEncoded = ""; Encoded output (string) Local $aEncoded = HexToDec($sToEncode); Binary (hex) to decimal array Local $iAsc = ""; Decimal Ascii number of current char ; Loop through each byte of input string For $i = 1 To UBound($aEncoded) - 1 $iAsc = StringFormat("%03u", $aEncoded[$i]) $sTmp = "" If $iAsc > 31 And $iAsc < 128 Then $sTmp = Chr($aEncoded[$i]) Else $sTmp = "." EndIf $sTmp = AddCrLf($sTmp) If $iLnLen = 0 And $sTmp = "." Then $sTmp = "{046}" If $iLnLen = 0 And $sTmp = ">" Then $sTmp = "{062}" $sEncoded &= $sTmp Next ; Trim double CrLf to one; change trailing space to "{032}" If StringRight($sEncoded, 2) = @CRLF Then _ $sEncoded = StringTrimRight($sEncoded, 2) If StringRight($sEncoded, 1) = " " Then _ $sEncoded = StringTrimRight($sEncoded, 1) & "{032}" ; Add header and footer Local $sHeader = "DVIEW v1.0" & @CRLF $sEncoded = $sHeader & "b-gin [" & $sInFile & "]" & @CRLF & _ $sEncoded & @CRLF & "-nd DVIEW" & @CRLF ; Write output file Local $hWrOut = FileOpen($sTmpFile, 2) FileWrite($sTmpFile, $sEncoded) FileClose($hWrOut) FileMove($sTmpFile, $sOutFile, 1) ProgressSet(100, "Done") Sleep(2000) ProgressOff() ShellExecute($sOutFile) ; --------- Function DeFinitions --------- Func HexToDec($sHexIn); Convert hex string to decimal array $aHexChars = StringSplit($sHexIn, "") Local $aHexIn[UBound($aHexChars) / 2] Local $j = 0 For $i = 1 To UBound($aHexChars) Step 2 If $i + 1 <= UBound($aHexChars) Then $aHexIn[$j] = $aHexChars[$i] & $aHexChars[$i + 1] $j += 1 Else ExitLoop EndIf Next Local $aDecOut[UBound($aHexIn)] For $i = 0 To UBound($aHexIn) - 1 $aDecOut[$i] = Dec($aHexIn[$i]) Next Return $aDecOut EndFunc ;==>HexToDec Func AddCrLf($sIn); Add line breaks to output $iLnLen += StringLen($sIn) If $iLnLen > 74 Then $sIn &= @CRLF $iLnLen = 0 EndIf Return $sIn EndFunc ;==>AddCrLf ; DREAD.AU3 -- AutoIt v3 [CarlD rev.9/27/15] ; Display a decimal view of a binary file ; ; Usage: ; DREAD.AU3 file_in ProgressOn(@ScriptName,"Working") Global $iLnLen = 0; Line length meter Local $sTmp = ""; Temp string var Local $sInFile = @ScriptDir & "\DREAD.IN" If $CmdLine[0] > 0 Then $sInFile = $CmdLine[1] If Not FileExists($sInFile) Then ProgressOff() MsgBox(16, @Scriptname, $sInFile & " does not exist!", 3) Exit EndIf Local $sTmpFile = @ScriptDir & "\DREAD.TMP" Local $sOutFile = @ScriptDir & "\DREAD.TXT" If FileExists($sTmpFile) Then FileDelete($sTmpFile) If FileExists($sOutFile) Then FileDelete($sOutFile) Local $hWrIn = FileOpen($sInFile, 16); Handle for source file Local $sToEncode = FileRead($hWrIn); Binary (hex) string to encode FileClose($hWrIn) Global $sEncoded = ""; Encoded output (string) Local $aEncoded = HexToDec($sToEncode); Binary (hex) to decimal array Local $iAsc = ""; Decimal Ascii number of current char ; Loop through each byte of input string For $i = 1 To UBound($aEncoded) - 1 $iAsc = StringFormat("%03u", $aEncoded[$i]) $sTmp = "" If $iAsc > 31 And $iAsc < 128 Then $sTmp = Chr($aEncoded[$i]) Else $sTmp = "{" & $iAsc & "}" EndIf $sTmp = AddCrLf($sTmp) If $iLnLen = 0 And $sTmp = "." Then $sTmp = "{046}" If $iLnLen = 0 And $sTmp = ">" Then $sTmp = "{062}" $sEncoded &= $sTmp Next ; Trim double CrLf to one; change trailing space to "{032}" If StringRight($sEncoded, 2) = @CRLF Then _ $sEncoded = StringTrimRight($sEncoded, 2) If StringRight($sEncoded, 1) = " " Then _ $sEncoded = StringTrimRight($sEncoded, 1) & "{032}" ; Add header and footer Local $sHeader = "DeeREAD v1.0" & @CRLF $sEncoded = $sHeader & "b-gin [" & $sInFile & "]" & @CRLF & _ $sEncoded & @CRLF & "-nd DeeREAD" & @CRLF ; Write output file Local $hWrOut = FileOpen($sTmpFile, 2) FileWrite($sTmpFile, $sEncoded) FileClose($hWrOut) FileMove($sTmpFile, $sOutFile, 1) ProgressSet(100, "Done") Sleep(2000) ProgressOff() ShellExecute($sOutFile) ; --------- Function DeFinitions --------- Func HexToDec($sHexIn); Convert hex string to decimal array $aHexChars = StringSplit($sHexIn, "") Local $aHexIn[UBound($aHexChars) / 2] Local $j = 0 For $i = 1 To UBound($aHexChars) Step 2 If $i + 1 <= UBound($aHexChars) Then $aHexIn[$j] = $aHexChars[$i] & $aHexChars[$i + 1] $j += 1 Else ExitLoop EndIf Next Local $aDecOut[UBound($aHexIn)] For $i = 0 To UBound($aHexIn) - 1 $aDecOut[$i] = Dec($aHexIn[$i]) Next Return $aDecOut EndFunc ;==>HexToDec Func AddCrLf($sIn); Add line breaks to output $iLnLen += StringLen($sIn) If $iLnLen > 74 Then If $sIn = " " Then $sIn = "{032}" $sIn &= @CRLF $iLnLen = 0 EndIf Return $sIn EndFunc ;==>AddCrLf ; DWRITE.AU3 -- AutoIt v3 [CarlD rev.9/27/15] ; Write DVIEW encoding as binary file ; ; Usage: ; DWRITE.AU3 file_in ; Output is sent to @ScriptDir & "DWRITE.BIN" ProgressOn(@ScriptName,"Working") Local $sInFile = @ScriptDir & "\DREAD.TXT" If $CmdLine[0] > 0 Then $sInFile = $CmdLine[1] If Not FileExists($sInFile) Then ProgressOff() MsgBox(16, @Scriptname, $sInFile & " does not exist!", 3) Exit EndIf Local $sTmpFile = @ScriptDir & "\DWRITE.TMP" Local $sOutFile = @ScriptDir & "\DWRITE.BIN" Local $hWrIn = FileOpen($sInFile); Handle for source file Local $sMaster = FileRead($hWrIn); Master string to decode FileClose($hWrIn) Local $sToDecode = "" Local $aTmp = "" ; Remove header|footer If StringLeft($sMaster, 9) = "DeeREAD v" Then _ $sMaster = StringTrimLeft($sMaster, StringInStr($sMaster, "]")) If StringRight($sMaster, 13) = "-nd DeeREAD" & @CRLF Then _ $sMaster = StringTrimRight($sMaster, 13) Local $sFinished = "" Local $iChunkSz = 512 Local $iAdd = 0 ; - - - - - - Main Loop - - - - - - While $sMaster If StringLen($sMaster) > $iChunkSz Then $sToDecode = StringLeft($sMaster, $iChunkSz) $sMaster = StringTrimLeft($sMaster, $iChunkSz) If StringRight($sToDecode, 2) <> @CRLF Then $iAdd = 1 + StringInStr($sMaster, @CRLF) $sToDecode &= StringLeft($sMaster, $iAdd) $sMaster = StringTrimLeft($sMaster, $iAdd) EndIf Else $sToDecode = $sMaster $sMaster = "" EndIf ; Strip CrLfs $sToDecode = StringReplace($sToDecode, @CRLF, "") ; "{nnn}" ==> 1-byte Ascii char; Local $aTmp = StringSplit($sToDecode, "{") Local $iAsc = -1 For $i = 1 To UBound($aTmp) - 1 $iAsc = StringLeft($aTmp[$i], 3) If StringInStr($aTmp[$i], "}") = 4 And _ StringIsDigit($iAsc) Then If $iAsc > -1 And $iAsc < 256 Then $sToDecode = StringReplace($sToDecode, "{" & _ StringLeft($aTmp[$i], 4), Chr($iAsc)) EndIf EndIf Next $sFinished &= $sToDecode $sToDecode = "" WEnd ; - - - - - End Main Loop - - - - - ; Write output file Local $hWrOut = FileOpen($sTmpFile, 2) FileWrite($sTmpFile, $sFinished) FileClose($hWrOut) FileMove($sTmpFile, $sOutFile, 1) ProgressOff() MsgBox(0, @ScriptName, "Output in " & $sOutFile, 5) ; Done
  6. This is a script I made to enable me to be able to combine either something non-alcoholic with something alcoholic and know how much to add (easy on a calculator) but then also to be able to deal with two alcoholic drinks and know how much of the second one will be needed to get to a desired strength (much much harder to figure out). It runs through by adding the second alcoholic liquid in increments of 0.5 ml until it meets exactly or the first number that exceeds the desired strength. It simplifies the whole process since it just tries all the combinations rather that doing complicated math to equate one thing to another and try and work it that way. it is very easy to use. Supply it with the original liquid, whether its wine or lemonade etc, then the strength of that liquid in % or 0 for non-alcoholic drink. Then set the percentage of the alcoholic liquid you will be using to add to the first liquid and what strength you would like your drink to be. Hit the button and you get your answer. AutoItSetOption('TrayAutoPause', 0) Global $OrigQty, $OrigStr, $AddStr, $DesiredStr, $Result #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #region ### START Koda GUI section ### Form= $Form1 = GUICreate("Alcohol Calculator", 288, 188, -1, -1) $OrigQty = GUICtrlCreateInput("150", 16, 16, 121, 21, $ES_CENTER) $OrigStr = GUICtrlCreateInput("12.5", 152, 16, 121, 21, $ES_CENTER) $AddStr = GUICtrlCreateInput("40", 16, 72, 121, 21, $ES_CENTER) $Label1 = GUICtrlCreateLabel("Amount of original liquid", 16, 40, 115, 17) $Label2 = GUICtrlCreateLabel("Strength of original liquid", 152, 40, 119, 17) $Label3 = GUICtrlCreateLabel("Strength of alcohol to use", 16, 96, 128, 17) $DesiredStr = GUICtrlCreateInput("20", 152, 72, 121, 21, $ES_CENTER) $Label4 = GUICtrlCreateLabel("Desired alcohol strength", 152, 96, 118, 17) $calculate = GUICtrlCreateButton("Calculate", 104, 120, 83, 25) $Result = GUICtrlCreateInput("", 5, 152, 277, 21, $ES_CENTER) GUICtrlSetFont(-1, 8, 400, 0, "MS Sans Serif") GUISetState(@SW_SHOW) #endregion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $calculate Strength(GUICtrlRead($OrigQty), GUICtrlRead($OrigStr), GUICtrlRead($AddStr), GUICtrlRead($DesiredStr)) EndSwitch WEnd ; #FUNCTION# ==================================================================================================================== ; Name ..........: Desired alcoholic strength calculator ; Description ...: This example code lets you calculate how much of an alcoholic drink to add to something else to make the resulting drink a certain strength. ; Syntax ........: Strength($MillilitersOfOriginalDrink, $StrengthOfOriginalDrink, $StrengthOfAddedLiquid, $DesiredStrength) ; Parameters ....: $MillilitersOfOriginalDrink- How much of a certain drink you start out with (either alcoholic or otherwise). ; $StrengthOfOriginalDrink- If the original drink is alcoholic then put the percentage here else put 0. ; $StrengthOfAddedLiquid- What strength of alcohol do you have to work with?. ; $DesiredStrength - How strong do you want your resulting drink to be?. ; Return values .: Text string with the needed information. ; Author ........: Wesley G aka Morthawt ; =============================================================================================================================== Func Strength($MillilitersOfOriginalDrink, $StrengthOfOriginalDrink, $StrengthOfAddedLiquid, $DesiredStrength) If $DesiredStrength > $StrengthOfAddedLiquid And $StrengthOfOriginalDrink > 0 Then MsgBox(0, 'Error', 'Your desired strength exceeds the strength of the liquid used to provide extra alcohol content.') Exit ElseIf $DesiredStrength <= $StrengthOfOriginalDrink And $StrengthOfOriginalDrink <> 0 Then MsgBox(0, 'Error', 'Your desired strength is lower than is even possible with the chosen liquids.' & @CRLF & @CRLF & 'Pick a higher desired strength.') Exit EndIf Local $Amount = 0, $AlcoholContent = 0 $ConstAlc = $MillilitersOfOriginalDrink * ($StrengthOfOriginalDrink / 100) $StrengthOfAddedLiquid = $StrengthOfAddedLiquid / 100 Do $Amount += 0.5 ; This is the increment of milliliters we will go up each time to try and reach the desired amount of strength. $AlcoholContent = Round(((($ConstAlc + ($Amount * $StrengthOfAddedLiquid)) / ($MillilitersOfOriginalDrink + $Amount)) * 100), 2) Until $AlcoholContent >= $DesiredStrength GUICtrlSetData($Result, 'Add ' & $Amount & 'ml of alcoholic liquid to get to ' & $AlcoholContent & '%') Return 1 EndFunc ;==>Strength
  7. Peers: (binary model), the peers value may be a string consisting of multiples of 6 bytes. First 4 bytes are the IP address and last 2 bytes are the port number. All in network (big endian) notation. The list of peers is length 50 by default. How can I convert the attached? http://en.wikipedia.org/wiki/Endianness#Big-endian I've tried BinaryToString with no luck. Thanks in advance. Peers.txt
  8. Hi all, I need to convert a .csv file that after conversion will fill an array for futher usage. function used/not used: stringsplit(), stringregexp(),stringinstr(), stringreplace() I know the best way is to use stringsplit given a delimiter (,). But this is not possible here since: Here is some lines fo the .csv Game Title,Quantity,For Sale,Platform,Rating,Number,New After Life,5,2,PC,PG1,23332,Yes Max Payne,4,0,Wii,PG3,109,No Fifa 2009,11,2,DS,PG2,976,Yes "Hellgate, London",3,2,PC,PG2,112,No Logitech Mouse,12,4,mouse, ,No Pinball 2010,1,1,PS3,PG1,065,No As you can see: "Hellgate, London",3,2,PC,PG2,112,No will not work with stringsplit() since the "," it's inside the name of the object Logitech Mouse,12,4,mouse, ,No Here I have blank spaces between "," and the field "Rating" is missing. This is due to the .csv format. When Platform <> PC,Wii,DS,PS1,PS2,PS3,XB,X3 then I need to set Platform = Hardware and Rating = the value found in place of platform (in this case Platform = N, Rating = Hardware) Once this is finished and I have my array built, I need to add 2 more columns to it. I get the columns _arraysearch()ing between the just created array and another file (.xlm). If i found the item I need I add the prices, if not, skip. So now I use this code (working): $exportfile = @ScriptDir & "\filelist.csv" Dim $mydb Global $file2ftp = @TempDir & "\temp2db.txt" Dim $csv_list[1][7] Global $rows Func _exp2db_x() Local $iCounter = 0, $array2db[10000] Local $user2db Local $k = 0 Dim $csv_array _FileReadToArray($exportfile, $csv_array) _FileReadToArray($price_file, $mydb) _ArraySort($mydb) $begin = TimerInit() For $i = 1 To UBound($csv_array) - 1 If StringInStr($csv_array[$i], ", ,") Then ; i'm looking for a ", ," in lines $string = StringReplace($csv_array[$i], ", ,", ",@,", 1) ; if found I change it Else $string = $csv_array[$i] EndIf If StringInStr($string, ", ") Then $string = StringReplace($string, ", ", "^", 1); If I find "," inside the name I need to change it $name_s = _StringBetween($string, "", ",") $name = _cleanfordb($name_s[0]) ; Need to reconvert name with "," and remove " if present $string = StringReplace($string, ",", "*", 1) ; since I can't use stringsplit() i need different separators $string = StringReplace($string, ",", "#", 1) ; since I can't use stringsplit() i need different separators $forsale = StringRegExp($string, "#(.*?),", 1) ; for sale If $forsale[0] > 0 Then $k +=1 $string = StringReplace($string, ",", "_", 1) ; since I can't use stringsplit() i need different separators $platform = StringRegExp($string, "_(.*?),", 1) ;platform $rating = StringRegExp($string, ",(.*?),", 1) ;rating If $platform[0] <> "PC" And $platform[0] <> "DS" And $platform[0] <> "Wii" And $platform[0] <> "XB" And $platform[0] <> "X3" And $platform[0] <> "Junk" Then $rating[0] = "Hardware" ; fixed value $platform[0] = "N" ; fixed value EndIf If $platform[0] = "Junk" Then $rating[0] = $platform[0] $platform[0] = "None" EndIf $new = StringRight($string, 2) ; just lasr 2 chars for last item in row If $new = "es" Then $new = "Yes" ReDim $csv_list[$k + 1][7] $csv_list[$k][0] = $name $csv_list[$k][1] = $platform[0] If $rating[0] <> "@" Then $csv_list[$k][2] = $rating[0] $csv_list[$k][3] = $new $csv_list[$k][4] = $forsale[0] ; now I build the string to check vs the main db (I need a partial search) $string = "<z:row c0='" & _normalize_db($csv_list[$k][0]) & "' Rating='" & $csv_list[$k][2] & "' New='" & $csv_list[$k][3] & "' Platform='" & $csv_list[$k][1] ; _normalize_db just change exotic chars into xml_readable sequence $check_string = _ArraySearch($mydb, $string, 39, UBound($mydb), 0, 1) ; first 38 lines is the xml header so I can skip If $check_string <> -1 Then $csv_list[$k][5] = _sellp($check_string) ; I can have 2 possible prices in main DB, best price and street price. If bestprice = 0 I'll use StreetPrice EndIf Next ConsoleWrite("Time to complete: " & TimerDiff($begin) & @CRLF) EndFunc ;==>_exp2db_x Func _cleanfordb($k) If StringInStr($k, "^") Then $k = StringReplace($k, "^", ", ") ; ^ If StringInStr($k, '"') Then $k = StringMid($k, 2, StringLen($k) - 2) Return $k EndFunc ;==>_cleanfordb Func _sellp($cc) $p = StringRegExp($mydb[$cc], "c6='(.*?)' c7",1) If $p[0] = 0 Then $p = StringRegExp($mydb[$cc], "c7='(.*?)'/>",1) Return $p[0] EndFunc ;==>_sellp Time to complete is 137,000ms, 2'17'', for 1,243 lines of csv (and 30,000 lines of main DB) I need to work, during normal phases, with 10,000 to 30,000 lines so time to complete will be really too high. I ask you, great programmers, if there is a way to optimize this routine (i'm not able to modify the csv since I get it this way from the Store Application Thanks! M.
×
×
  • Create New...