Jump to content

major_lee

Active Members
  • Posts

    37
  • Joined

  • Last visited

Everything posted by major_lee

  1. versatile and quick method to click on color. pause key pauses and resets color. the color that is mouse when activated is clicked while that color. end quits the script #cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.16.0 Author: #IAmMajor Script Function: autoClick while mouse color is on toggle. #ce ---------------------------------------------------------------------------- $color = getColor() $pause = True HotKeySet("{end}", "stop") HotKeySet("{pause}", "pause") Func pause() If ($pause) Then $color = getColor() $pause = False Else $pause = True EndIf EndFunc ;==>pause Func stop() Exit EndFunc ;==>stop Func getColor() Local $aPos = MouseGetPos() Return PixelGetColor($aPos[0], $aPos[1]) EndFunc ;==>getColor While 1 If (Not $pause) Then If (getColor() == $color) Then MouseClick("Primary") Else Sleep(10) EndIf Else Sleep(1000) EndIf WEnd Also an offset version, i know some times color is as the mouse. Subtacting mouse position by defined as offset=5 #cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.16.0 Author: #IAmMajor Script Function: autoClick while mouse color is on toggle. #ce ---------------------------------------------------------------------------- $offset = 5 $color = getColor() $pause = True HotKeySet("{end}", "stop") HotKeySet("{pause}", "pause") Func pause() If ($pause) Then $color = getColor() $pause = False Else $pause = True EndIf EndFunc ;==>pause Func stop() Exit EndFunc ;==>stop Func getColor() Local $aPos = MouseGetPos() Return PixelGetColor($aPos[0]-$offset, $aPos[1]-$offset) EndFunc ;==>getColor While 1 If (Not $pause) Then If (getColor() == $color) Then MouseClick("Primary") Else Sleep(10) EndIf Else Sleep(1000) EndIf WEnd
  2. Playlist sorting example added. If i can find time/effort to make the examples functional with vimeo I will. Which mostly just has to do with formatting the data and RSS. extracting from internet such as , date, creator, title information. then assigning that correctly to the xml playlist. then it can be processed with this to sort by newest published. vimeoDownloader/playlistSort.au3 at main · majorangle/vimeoDownloader (github.com) #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseX64=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <File.au3> #include <Array.au3> Local Const $sFilePath = 'E:\downlink\' & "playlist.xspf" Local Const $sFilePath_sort = 'E:\downlink\' & "playlist_sorted.xspf" Local $hFileOpen = FileOpen($sFilePath, $FO_READ) Local $oXML = ObjCreate("Microsoft.XMLDOM") Local $data[0][4], $sString $oXML.load($sFilePath) $oParameters = $oXML.SelectNodes("//playlist/trackList/track") For $oParameter In $oParameters Local $sFill = String($oParameter.SelectSingleNode("./date").text) & '|' & _ String($oParameter.SelectSingleNode("./location").text) & '|' & _ String($oParameter.SelectSingleNode("./creator").text) & '|' & _ String($oParameter.SelectSingleNode("./title").text) ConsoleWrite('!' & $sFill & @CRLF) _ArrayAdd($data, $sFill) Next _ArraySort($data, 1) _ArrayDisplay($data, "AFTER QuickSort descending") ;~ $data1 = _ArraySort($data, 0, 3, 6) FileDelete($sFilePath_sort) If Not FileWrite($sFilePath_sort, '<?xml version="1.0"?>' & @CRLF) Then ConsoleWrite("An error occurred whilst writing the temporary file.") EndIf ; Open the file for writing (append to the end of a file) and store the handle to a variable. Local $hFileOpen = FileOpen($sFilePath_sort, $FO_APPEND) If $hFileOpen = -1 Then ConsoleWrite("An error occurred whilst writing the temporary file.") EndIf If @error = 1 Then MsgBox($MB_SYSTEMMODAL, "", "Path was invalid.") Exit EndIf If @error = 4 Then MsgBox($MB_SYSTEMMODAL, "", "No file(s) were found.") Exit EndIf FileWriteLine($hFileOpen, '<playlist>') FileWriteLine($hFileOpen, '<trackList>') FileWriteLine($hFileOpen, @CRLF) For $i = 0 To UBound($data, 1) - 1 FileWriteLine($hFileOpen, '<track>') FileWriteLine($hFileOpen, '<date>' & $data[$i][0] & '</date>') FileWriteLine($hFileOpen, '<location>' & $data[$i][1] & '</location>') FileWriteLine($hFileOpen, '<creator>' & $data[$i][2] & '</creator>') FileWriteLine($hFileOpen, '<title>' & $data[$i][3] & '</title>') FileWriteLine($hFileOpen, '</track>') FileWriteLine($hFileOpen, @CRLF) Next FileWriteLine($hFileOpen, @CRLF) FileWriteLine($hFileOpen, '</trackList>') FileWriteLine($hFileOpen, '</playlist>') FileClose($hFileOpen)
  3. I don't understand your reply, how can I help you?
  4. This is a more advanced playlist with titles. If i find time to get it functional and not an example then I will but I don't have to time to deal with it at the moment. Example video Adult Swim SMALLS Presents: S.T.A.R.H.A.W.K.S. on Vimeo Reference RSS https://vimeo.com/adultswim/videos/rss Each user has a folder with the data.ini Example(E:\downlink\adultswim\data.ini) File: E:\downlink\newyorktimes\508927445.mp4 Additional user would be as such, E:\downlink\newyorktimes\data.ini Containing Almost Famous: The Lost Astronaut on Vimeo While section is clearly the video id and the video id is the 380740025.mp4 Example location would be. E:\downlink\newyorktimes\380740025.mp4 #include <File.au3> $dir = 'E:\downlink\' Local Const $sFilePath = $dir & 'playlist.xspf' Local $sString FileDelete($sFilePath) If Not FileWrite($sFilePath, '<?xml version="1.0" encoding="UTF-8"?>' & @CRLF) Then ConsoleWrite("An error occurred whilst writing the temporary file.") EndIf ; Open the file for writing (append to the end of a file) and store the handle to a variable. Local $hFileOpen = FileOpen($sFilePath, $FO_APPEND) If $hFileOpen = -1 Then ConsoleWrite("An error occurred whilst writing the temporary file.") EndIf ; List all the files and folders in the desktop directory using the default parameters and return the full path. Local $aFileList = _FileListToArray($dir, Default, $FLTA_FOLDERS, True) If @error = 1 Then MsgBox($MB_SYSTEMMODAL, "", "Path was invalid.") Exit EndIf If @error = 4 Then MsgBox($MB_SYSTEMMODAL, "", "No file(s) were found.") Exit EndIf FileWriteLine($hFileOpen, '<playlist>') FileWriteLine($hFileOpen, '<trackList>') FileWriteLine($hFileOpen, @CRLF) For $vElement In $aFileList $sString = $sString & $vElement & @CRLF ConsoleWrite($vElement & @CRLF) ; Assign a Local variable the search handle of all files in the current directory. Local $hSearch = FileFindFirstFile($vElement & '\*.mp4') ; Check if the search was successful, if not display a message and return False. If $hSearch = -1 Then ConsoleWrite("Error: No files/directories matched the search pattern." & @CRLF) Else ; Assign a Local variable the empty string which will contain the files names found. Local $sFileName = "" While 1 $sFileName = FileFindNextFile($hSearch) ; If there is no more file matching the search. If @error Then ExitLoop ConsoleWrite($sFileName & @CRLF) FileWriteLine($hFileOpen, '<track>') FileWriteLine($hFileOpen, '<location>'&$vElement & '\' & $sFileName&'</location>') $title = IniRead($vElement & '\data.ini', StringTrimRight($sFileName, 4), 'title', Null) FileWriteLine($hFileOpen, '<title>'& StringReplace($title,'&','')&'</title>') $author = IniRead($vElement & '\data.ini', StringTrimRight($sFileName, 4), 'author', Null) FileWriteLine($hFileOpen, '<creator>'&$author&'</creator>') FileWriteLine($hFileOpen, '</track>') FileWriteLine($hFileOpen, @CRLF) WEnd EndIf ; Close the search handle. FileClose($hSearch) Next FileWriteLine($hFileOpen, @CRLF) FileWriteLine($hFileOpen, '</trackList>') FileWriteLine($hFileOpen, '</playlist>') FileClose($hFileOpen)
  5. Useful addition vimeoDownloader/playlistGen.au3 at main · majorangle/vimeoDownloader (github.com) Functional with published version. Capable to generating playlist with many folders, for example each user having their own folder. #include <File.au3> $dir = @ScriptDir Local Const $sFilePath = $dir & '\playlist.m3u' Local $sString FileDelete($sFilePath) If Not FileWrite($sFilePath, "#EXTM3U" & @CRLF) Then ConsoleWrite("An error occurred whilst writing the temporary file.") EndIf ; Open the file for writing (append to the end of a file) and store the handle to a variable. Local $hFileOpen = FileOpen($sFilePath, $FO_APPEND) If $hFileOpen = -1 Then ConsoleWrite("An error occurred whilst writing the temporary file.") EndIf ; List all the files and folders in the desktop directory using the default parameters and return the full path. Local $aFileList = _FileListToArray($dir, Default, $FLTA_FOLDERS, True) If @error = 1 Then MsgBox($MB_SYSTEMMODAL, "", "Path was invalid.") Exit EndIf If @error = 4 Then MsgBox($MB_SYSTEMMODAL, "", "No file(s) were found.") Exit EndIf For $vElement In $aFileList $sString = $sString & $vElement & @CRLF ConsoleWrite($vElement & @CRLF) ; Assign a Local variable the search handle of all files in the current directory. Local $hSearch = FileFindFirstFile($vElement & '\*.mp4') ; Check if the search was successful, if not display a message and return False. If $hSearch = -1 Then ConsoleWrite("Error: No files/directories matched the search pattern." & @CRLF) EndIf ; Assign a Local variable the empty string which will contain the files names found. Local $sFileName = "" While 1 $sFileName = FileFindNextFile($hSearch) ; If there is no more file matching the search. If @error Then ExitLoop ConsoleWrite($sFileName & @CRLF) ; Display the file name. $title = IniRead($vElement & '\data.ini', StringTrimRight($sFileName, 4), 'title', Null) FileWriteLine($hFileOpen, $vElement & '\' & $sFileName) WEnd ; Close the search handle. FileClose($hSearch) Next FileClose($hFileOpen)
  6. Problems with a bad connection. I try to watch videos online and they play a few seconds then stop. Over and over. Seeking through videos would also cause problems and the videos would have to start over, loading. Also reduces wasting bandwidth by watching the same video multiple times. Additionally save space by scaling the video and audio down. After some consideration I though about an elaborate way to resolve this problem, by landing a rover on mars and ....... ,yet then decided I can simply accomplish it with autoit. After some research while considering different approaches I found the best way to do it with RSS feeds.RSS feed downloading. The most practicable use is downloading while away. To watch videos later. A example of feeds file with RSS links feeds https://vimeo.com/adultswim/videos/rss https://vimeo.com/channels/bestoftheyear2016/videos/rss https://vimeo.com/channels/bestofthemonth/videos/rss https://vimeo.com/channels/bestofstaffpicks2017/videos/rss https://vimeo.com/newyorktimes/videos/rss https://vimeo.com/gopro/videos/rss https://vimeo.com/user703283/videos/rss in the folder it creates data.ini which associates the file with vlc title, there are some errors from the split. edit2 fix v1.16 logData($user[1], $user[2], $file) which later can be use for videoplaying main.au3 ; major - Version 1.17 #include <InetConstants.au3> #include <File.au3> Opt("WinTitleMatchMode", 2) $sFilePath = @ScriptDir & "\feeds" Local $iCountLines = _FileCountLines($sFilePath) ConsoleWrite("$iCountLines" & ":" & $iCountLines & @CRLF) Local $hFileOpen = FileOpen($sFilePath, $FO_READ) Local $oXML = ObjCreate("Microsoft.XMLDOM") Local $titleInfo For $i = 1 To $iCountLines $sFileRead = FileReadLine($hFileOpen, $i) $url = $sFileRead If (@error) Then ConsoleWrite($i & ":" & "ExitLoop ... FileReadLine ERROR" & @CRLF) ExitLoop Else ConsoleWrite($i & ":" & $url & @CRLF) Local $sFile = @ScriptDir & "/rss.xml" Local $hDownload = InetGet($url, $sFile, $INET_FORCERELOAD) InetClose($hDownload) $oXML.load($sFile) $oParameters = $oXML.SelectNodes("/rss/channel/item") For $oParameter In $oParameters $oVideoId = $oParameter.SelectSingleNode("./link").text $split = StringSplit($oVideoId, '/') $file = $split[$split[0]] ConsoleWrite('+' & "link:" & $oVideoId & @CRLF) ConsoleWrite('+' & "file:" & $file & @CRLF) $fSaveDir = @ScriptDir & "\downlink\" If (FileExists($fSaveDir) == 0) Then DirCreate($fSaveDir) EndIf $fSave = $fSaveDir & $file & ".mp4" If (FileExists($fSave) == 0) Then ;https://wiki.videolan.org/Transcode ;https://wiki.videolan.org/Documentation:Modules/transcode/ ;https://wiki.videolan.org/Documentation:Streaming_HowTo/Command_Line_Examples/ ;;;;;; vb="1024" is bitrate adjust or remove for better quyality. 1024 is for lower bandwidth $pram = ' -vvv "' & $oVideoId & '" --qt-notification=0 --sout=#transcode{vcodec="h264",vb="1024",fps="25",vfilter=canvas{width=960,height=540},acodec="mp3",ab="12","channels=2",samplerate="32000"}:standard{access="file",dst=' & $fSave & '} vlc://quit"' ConsoleWrite('+' & 'C:\Progra~2\VideoLAN\VLC\vlc.exe' & $pram & @CRLF) Local $iPID = ShellExecute("vlc.exe", $pram, @ProgramFilesDir & "\VideoLAN\VLC\") Sleep(5000) $title = StringTrimRight(WinGetTitle("VLC"), 19) ConsoleWrite('>' & $iPID & ":" & $title & @CRLF) $user = StringSplit($title, '-') For $i = 2 To $user[0] ; Loop through the array returned by StringSplit to display the individual values. If ($i > 2) Then ;; needs tested to confirm replacing - $titleInfo = $titleInfo & "-" & $user[$i] Else $titleInfo = $titleInfo & $user[$i] EndIf Next ConsoleWrite('+' & $titleInfo & @CRLF) logData($user[1], $titleInfo, $file) ConsoleWrite('>' & $iPID & ":::ProcessWaitClose" & @CRLF) ProcessWaitClose($iPID) Else ConsoleWrite('!' & "Pass:::" & $fSave & @CRLF) EndIf Next ConsoleWrite($i & ":" & $sFileRead & @CRLF) EndIf Next Func logData($user, $title, $code) Local Const $sFilePath = $fSaveDir & "data.ini" ConsoleWrite($sFilePath & @CRLF) ConsoleWrite('+' & $user & ":" & $title & ":" & $code & @CRLF) IniWrite($sFilePath, $user, $code, $title) EndFunc ;==>logData Additionally, I haven't spent extensive time to testing it. It's functional for me after a few test. I am not sure if scaling video down through vlc effects download bandwidth. VLC could be downloading the HD version then scaling down through the pc. Might be something to look into. I will not endorse/support this use for other websites. Edit 2 - replaceCode ; Version 1.16 $title = WinGetTitle("VLC") ConsoleWrite('>' & $iPID & ":" & $title & @CRLF) $user = StringSplit($title, '-') logData($user[1], $user[2], $file) This remove most failures in title split. For data.ini video info Edit 3 - : fix split with for loop, add version identifier ; Version 1.17 $title = StringTrimRight (WinGetTitle("VLC"), 19 ) ConsoleWrite('>' & $iPID & ":" & $title & @CRLF) $user = StringSplit($title, '-') For $i = 2 To $user[0] ; Loop through the array returned by StringSplit to display the individual values. If ($i > 2) Then ;; needs tested to confirm replacing - $titleInfo = $titleInfo & "-" $user[$i] Else $titleInfo = $titleInfo & $user[$i] EndIf Next ConsoleWrite('+' & $titleInfo & @CRLF) logData($user[1], $titleInfo, $file) Edit 4 - Comments added vimeoDownload_descritpions.au3 The most simple version. If you don't want all the extra stuff and just want to learn from it with experimentation. Trimmed down to 16 lines vimeoDownload_basic.au3 Edit 5 - Line 43 added --qt-start-minimized to background the tasks. $pram = ' -vvv --qt-start-minimized "' & $oVideoId & '" --qt-notification=0 --sout=#transcode{vcodec="h264",vb="1024",fps="25",vfilter=canvas{width=960,height=540},acodec="mp3",ab="12","channels=2",samplerate="32000"}:standard{access="file",dst=' & $fSave & '} vlc://quit"' All Source files. majorangle/vimeoDownloader: Download vimeo videos from RSS feeds while away. (github.com) VLC is required Official download of VLC media player, the best Open Source player - VideoLAN If you have any questions I'll do my best to help.
  7. I thought I was going to have to do this. just a rough draft. $string = "945" ConsoleWrite(@CRLF & "isStringNumber: " & $string & " - " & isStringNumber($string) & @CRLF) $string = "uys" ConsoleWrite(@CRLF & "isStringNumber: " & $string & " - " & isStringNumber($string) & @CRLF) Func isStringNumber($str) Local $iLength = StringLen($str) $return = False For $i = 1 To $iLength For $ii = 48 To 57 If Asc ( StringLeft($str, 1) ) == $ii Then $return = True ExitLoop Else $return = False EndIf Next $str = StringTrimLeft($str, 1) Next Return $return EndFunc ;==>isStringNumber
  8. Yes, my issue was thinking about a string not knowing its a int. while the return was 0 still being a number. In this situation i can work around it. As understood 0 being a number and if the string was 0 in the first place then there would be a conflict. I think what would happen is splits[2] = 0 THEN IsNumber(Number($splits[2])) = 1
  9. Here is everything. Looks solid now. summary of data.ini clearData.au3 #include <FileConstants.au3> #include <MsgBoxConstants.au3> #include <WinAPIFiles.au3> #include <File.au3> ConsoleWrite("BOOT" & @CRLF&@CRLF) Example() Func Example() Local Const $sFilePath = (@ScriptDir & "\data.ini") Local Const $sFilePath1 = (@ScriptDir & "\temp.ini") ; Open the file for reading and store the handle to a variable. FileDelete($sFilePath1) Local $hFileOpen = FileOpen($sFilePath, $FO_READ ) Local $hFileOpen1 = FileOpen($sFilePath1, $FO_APPEND) If $hFileOpen = -1 Or $hFileOpen1 = -1 Then ConsoleWrite("An error occurred when reading the file." & @CRLF) Return False Else ; Read the fist line of the file using the handle returned by FileOpen. Local $sFileRead = FileReadLine($hFileOpen) For $i = 1 To _FileCountLines ( $sFilePath ) $sFileRead = FileReadLine($hFileOpen, $i) If (@error) Then ConsoleWrite($i&":"&"ExitLoop" & @CRLF) ExitLoop Else $splits = StringSplit($sFileRead, '=') If ($splits[0] <= 1) Then FileWriteLine($hFileOpen1, $sFileRead) ConsoleWrite($i&":"&$sFileRead & @CRLF) Else If (IsNumber(Number($splits[2])) And Number($splits[2]) <= 10 And Number($splits[2]) <> 0) Then ConsoleWrite($i&":wipe:"&$splits[1] & "=" & $splits[2] & @CRLF) Else FileWriteLine($hFileOpen1, $sFileRead) ConsoleWrite($i&":"&$splits[1] & "=" & $splits[2] & @CRLF) EndIf EndIf EndIf Next EndIf FileClose($hFileOpen) FileCopy($sFilePath1,$sFilePath, $FC_OVERWRITE ) EndFunc ;==>Example
  10. The problem was, IsNumber($splits[2])                     If (IsNumber($splits[2]) And $splits[2] <= 10) Then Documentation remarks says, If the variable is a numeric value represented as a string, then IsNumber() will return 0. Therefor the solution is. If (IsNumber(Number($splits[2])) And Number($splits[2]) <= 10 And Number($splits[2]) <> 0) Then
  11. goes to show what a little reading gets you.. but still , maybe there is a better way?
  12. $splits = StringSplit($sFileRead, '=') If ($splits[0] > 1) Then If (IsNumber($splits[2]) And $splits[2] <= 10) Then ConsoleWrite($splits[1] & "::" & $splits[2] & @CRLF) EndIf EndIf I'm not sure if its just me or what is going on but its not working how i expected??? I am just cleaning up an ini file. If the value is greater then 10 then we want to delete that line. Also has to bypass keys or values that are not numbers. I'm also open to more effective approaches to accomplishing the task. Such as for loop _FileCountLines but that didn't work right for me. so i did if error flag exitloop which works well. Full code in quotes. … I read If the variable is a numeric value represented as a string, then IsNumber() will return 0. I suspect I would have to chr cycle to verify a value. then push it to a int()?
  13. Many things will be impacting it. Baseline makes a big difference. Is the environment the same being ran? My baseline was just closing down every other process so they could be ran independently. GOod enough for me. I ran a few test with the internet open and there was 1-2 second difference in the numbers. Is it being compiled or ran through SciTE? How is the program/code being prioritized with the cpu? Version of windows? To really understand it would need to be broken down entirely. How the compiler, assembly and processor. Each thing could be impacting it significantly, the software, hardware, firmware and variation of versions. I dont think I'm really qualified to say, if I did say, everything(programs,software,hardware) else impacting it without a proper baseline. is the simple answer. Until that point is reached, then the baselines are not accurate enough to really determine which is faster. I think a easy way to do a proper baseline might be run windows in safe mode? Is that still possible? never tried in this version of windows.. lol
  14. It can all be done in other languages. It's just a quick and easy solution to use au3. For example. GetCursorPos function (winuser.h) - Win32 apps | Microsoft Docs From my experience, learning autoit will improve your understanding of how windows works and your capacity to comprehend C/C#/C++ and the other languages. Additionally, it takes less then a minute to download autoit. Visual Studios can take hours. Also taking up less space.
  15. I use it as a quick easy solution (most of the time) . I do C# or others. Python, simply put, security issues. MutliThreading I would consider C#/C/C++ I think MutliThreading been covered by autoit but i haven't took the time to learn about it. Which makes C# easier for multithreading solutions.
  16. I would consider it a significant difference for my system. #AutoIt3Wrapper_UseX64 = N Local $sBasedOn="JockoDundee with major_lee edit", $iIter=1000000, $sOut, $t=TimerInit() Local $dataStream="10101010", $arr[1112] $arr[0]="0" $arr[1]="1" $arr[10]="2" $arr[11]="3" $arr[100]="4" $arr[101]="5" $arr[110]="6" $arr[111]="7" $arr[1000]="8" $arr[1001]="9" $arr[1010]="A" $arr[1011]="B" $arr[1100]="C" $arr[1101]="D" $arr[1110] ="E" $arr[1111]="F" For $n=1 To $iIter $sbyte = $dataStream $sOut = Null Local $bArray[StringLen ( $sbyte )/4+1] $bArray[0] = (StringLen ( $sbyte )/4) for $z = 1 To $bArray[0] $bArray[$z] = $arr[StringLeft($sbyte, 4)] $sbyte = StringTrimLeft ( $sbyte, 4 ) $sOut=$sOut&$bArray[$z] Next $sOut=$sOut &" "& Dec($sOut) Next $t=TimerDiff($t) ConsoleWrite("Based on code from: "& $sBasedOn & @CRLF& " Check: "& $sOut &" "& @CRLF &" "& $iIter &" Iterations in "& $t/1000 &" Seconds" &@CRLF&@CRLF) #AutoIt3Wrapper_UseX64 = Y Local $sBasedOn="JockoDundee with major_lee edit", $iIter=1000000, $sOut, $t=TimerInit() Local $dataStream="10101010", $arr[1112] $arr[0]="0" $arr[1]="1" $arr[10]="2" $arr[11]="3" $arr[100]="4" $arr[101]="5" $arr[110]="6" $arr[111]="7" $arr[1000]="8" $arr[1001]="9" $arr[1010]="A" $arr[1011]="B" $arr[1100]="C" $arr[1101]="D" $arr[1110] ="E" $arr[1111]="F" For $n=1 To $iIter $sbyte = $dataStream $sOut = Null Local $bArray[StringLen ( $sbyte )/4+1] $bArray[0] = (StringLen ( $sbyte )/4) for $z = 1 To $bArray[0] $bArray[$z] = $arr[StringLeft($sbyte, 4)] $sbyte = StringTrimLeft ( $sbyte, 4 ) $sOut=$sOut&$bArray[$z] Next $sOut=$sOut &" "& Dec($sOut) Next $t=TimerDiff($t) ConsoleWrite("Based on code from: "& $sBasedOn & @CRLF& " Check: "& $sOut &" "& @CRLF &" "& $iIter &" Iterations in "& $t/1000 &" Seconds" &@CRLF&@CRLF) Yes I figured I would forget to address that. lol
  17. If you read this page Function Chr (autoitscript.com) and play around with the Example, I'm sure you will find your solution. Here is a Debug Example (Function Chr) of my own that maybe better to understand running it in sciTE to break down what is happening in the console output. #include <MsgBoxConstants.au3> $debug = True Local $sText = "" For $i = 65 To 90 $sText = $sText & Chr($i) ; Or $sText &= Chr($i) can be used as well. If ($debug) Then ConsoleWrite("$i-" & $i & @CRLF) ConsoleWrite("$sText-" & $sText & @CRLF) ConsoleWrite("Chr($i)-" & Chr($i) & @CRLF) ConsoleWrite(@CRLF) ;; break line EndIf Next MsgBox($MB_SYSTEMMODAL, "Uppercase alphabet", $sText) ; Display the characters between 65 to 90.
  18. I didn't even see that.
  19. First you need to assign it to a string. Second split the string. StringSplit - AutoIt Wiki (autoitscript.com) Third. create a counter Keyword For...To...Step...Next (autoitscript.com) Then you want to assign the counter to ASCIIcode CHR Function Chr (autoitscript.com)
  20. I think its only fair to extend the code to handle more then the limited bytes as originally assumed. Local $sBasedOn="JockoDundee with major_lee edit", $iIter=1000000, $sOut, $t=TimerInit() Local $dataStream="10101010", $arr[1112] $arr[0]="0" $arr[1]="1" $arr[10]="2" $arr[11]="3" $arr[100]="4" $arr[101]="5" $arr[110]="6" $arr[111]="7" $arr[1000]="8" $arr[1001]="9" $arr[1010]="A" $arr[1011]="B" $arr[1100]="C" $arr[1101]="D" $arr[1011]="E" $arr[1111]="F" For $n=1 To $iIter $sbyte = $dataStream $sOut = Null Local $bArray[StringLen ( $sbyte )/4+1] $bArray[0] = (StringLen ( $sbyte )/4) for $z = 1 To $bArray[0] $bArray[$z] = $arr[StringLeft($sbyte, 4)] $sbyte = StringTrimLeft ( $sbyte, 4 ) $sOut=$sOut&$bArray[$z] Next $sOut=$sOut &" "& Dec($sOut) Next $t=TimerDiff($t) ConsoleWrite("Based on code from: "& $sBasedOn & @CRLF& " Check: "& $sOut &" "& @CRLF &" "& $iIter &" Iterations in "& $t/1000 &" Seconds" &@CRLF&@CRLF)
  21. This is cool, cause I'm learning a lot, all the different ways it can be done. I've never even considered using COM objects. Local $sBasedOn="argumentum", $iIter=1000000, $t=TimerInit() Local $sResult, $sbyteOriginal="10101010", $dec Local $o = ObjCreate("Scripting.Dictionary") $o.Add("0000", "0") $o.Add("0001", "1") $o.Add("0010", "2") $o.Add("0011", "3") $o.Add("0100", "4") $o.Add("0101", "5") $o.Add("0110", "6") $o.Add("0111", "7") $o.Add("1000", "8") $o.Add("1001", "9") $o.Add("1010", "A") $o.Add("1011", "B") $o.Add("1100", "C") $o.Add("1101", "D") $o.Add("1110", "E") $o.Add("1111", "F") For $n=1 To $iIter $sResult = "" $sbyte = $sbyteOriginal Do $sResult &= $o.Item(StringLeft($sbyte, 4)) $sbyte = StringTrimLeft($sbyte, 4) Until $sbyte = "" $sOut = $sResult &" "& Dec($sResult) Next $t=TimerDiff($t) ConsoleWrite("Based on code from: "& $sBasedOn & @CRLF& " Check: "& $sOut &" "& @CRLF &" "& $iIter &" Iterations in "& $t/1000 &" Seconds" &@CRLF&@CRLF)
  22. Here are my result with three same baseline test. Local $sBasedOn="nine", $iIter=1000000, $sOut, $t=TimerInit() Local $input="10101010", $bin, $ival, $iLen=8, $base=2 For $n=1 To $iIter $iVal = 0 For $i = 0 to $iLen - 1 $iVal += Dec(StringMid($input, $iLen - $i, 1)) * ($base^$i) Next $sOut=Hex(Int($iVal)) &" "& Int($iVal) Next $t=TimerDiff($t) ConsoleWrite("Based on code from: "& $sBasedOn & @CRLF& " Check: "& $sOut &" "& @CRLF &" "& $iIter &" Iterations in "& $t/1000 &" Seconds" &@CRLF&@CRLF) Local $sBasedOn="jhcd", $iIter=1000000, $sOut, $t=TimerInit() Local $input="10101010", $bin, $aDll=DllOpen("msvcrt.dll") For $n=1 To $iIter $bin=DllCall($aDll, "int64:cdecl", "_wcstoi64", "wstr", $input, "ptr*", 0, "int", 2)[0] $sOut=Hex($bin) &" "& $bin Next $t=TimerDiff($t) ConsoleWrite("Based on code from: "& $sBasedOn & @CRLF& " Check: "& $sOut &" "& @CRLF &" "& $iIter &" Iterations in "& $t/1000 &" Seconds" &@CRLF&@CRLF) Local $sBasedOn="Musashi", $iIter=1000000, $sOut, $t=TimerInit() Local $input="10101010", $aArr, $dec For $n=1 To $iIter $aArr = StringSplit($input, "", 2) $dec = 0 For $i = UBound($aArr) - 1 To 0 Step -1 If $aArr[$i] = "1" Then $dec = BitXOR($dec, BitShift(1, -(UBound($aArr) - 1 - $i))) $sOut=Hex($dec) &" "& $dec EndIf Next Next $t=TimerDiff($t) ConsoleWrite("Based on code from: "& $sBasedOn & @CRLF& " Check: "& $sOut &" "& @CRLF &" "& $iIter &" Iterations in "& $t/1000 &" Seconds" &@CRLF&@CRLF) Local $sBasedOn="JockoDundee", $iIter=1000000, $sOut, $t=TimerInit() Local $sbyte="10101010", $arr[1112] $arr[0]="0" $arr[1]="1" $arr[10]="2" $arr[11]="3" $arr[100]="4" $arr[101]="5" $arr[110]="6" $arr[111]="7" $arr[1000]="8" $arr[1001]="9" $arr[1010]="A" $arr[1011]="B" $arr[1100]="C" $arr[1101]="D" $arr[1011]="E" $arr[1111]="F" For $n=1 To $iIter $sOut=$arr[StringLeft($sByte,4)] & $arr[StringRight($sByte,4)] $sOut=$sOut &" "& Dec($sOut) Next $t=TimerDiff($t) ConsoleWrite("Based on code from: "& $sBasedOn & @CRLF& " Check: "& $sOut &" "& @CRLF &" "& $iIter &" Iterations in "& $t/1000 &" Seconds" &@CRLF&@CRLF) Global $sBasedOn = "Chimp", $iIter = 1000000, $sOut, $t = TimerInit() Global $sbyte = "10101010" Global Enum $0000, $0001, $0010, $0011, $0100, $0101, $0110, $0111, $1000, $1001 Global $1010 = "A", $1011 = "B", $1100 = "C", $1101 = "D", $1110 = "E", $1111 = "F" For $n = 1 To $iIter $sOut = Eval(StringLeft($sbyte, 4)) & Eval(StringRight($sbyte, 4)) $sOut = $sOut & " " & Dec($sOut) Next $t = TimerDiff($t) ConsoleWrite("Based on code from: " & $sBasedOn & @CRLF & " Check: " & $sOut & " " & @CRLF & " " & $iIter & " Iterations in " & $t / 1000 & " Seconds" & @CRLF & @CRLF) Global $sBasedOn="Chimp with major_lee edit", $iIter = 1000000, $sOut, $t = TimerInit() Global Enum $0000, $0001, $0010, $0011, $0100, $0101, $0110, $0111, $1000, $1001 Global Const $1010 = "A", $1011 = "B", $1100 = "C", $1101 = "D", $1110 = "E", $1111 = "F" Global $dataStream = "10101010" For $n = 1 To $iIter $sbyte = $dataStream $sOut = Null Local $bArray[StringLen ( $sbyte )/4+1] $bArray[0] = (StringLen ( $sbyte )/4) for $z = 1 To $bArray[0] $bArray[$z] = Eval(StringLeft($sbyte, 4)) $sbyte = StringTrimLeft ( $sbyte, 4 ) $sOut=$sOut&$bArray[$z] Next $sOut=$sOut &" "& Dec($sOut) Next $t = TimerDiff($t) ConsoleWrite("Based on code from: "& $sBasedOn & @CRLF& " Check: "& $sOut &" "& @CRLF &" "& $iIter &" Iterations in "& $t/1000 &" Seconds" &@CRLF&@CRLF)
  23. lol, I do understand that arrays are said to be significantly faster. such as how you did it just in general programming. It's significantly slower, but is doing more too. I think this maybe the most practical approach. Global $iIter = 100000, $sOut, $t = TimerInit() Global Enum $0000, $0001, $0010, $0011, $0100, $0101, $0110, $0111, $1000, $1001 Global Const $1010 = "A", $1011 = "B", $1100 = "C", $1101 = "D", $1110 = "E", $1111 = "F", $cow = "mooo" Global Const $dataStream = "1110111110101101010011010100" For $n = 1 To $iIter Global $sbyte = $dataStream Local $bArray[StringLen ( $sbyte )/4+1] $bArray[0] = (StringLen ( $sbyte )/4) for $z = 1 To $bArray[0] $bArray[$z] = Eval(StringLeft($sbyte, 4)) $sbyte = StringTrimLeft ( $sbyte, 4 ) Next Next $t = TimerDiff($t) For $z = 1 To $bArray[0] ConsoleWrite(" Check: " & $bArray[$z] & " Dec:" &Dec($bArray[$z])& " " &@CRLF ) Next ConsoleWrite($iIter & " Iterations in " & $t / 1000 & " Seconds" & @CRLF & @CRLF)
  24. ok, I understand it now. thanks I learned some about the enums and eval. In that solution and JockoDundees', if the $input was not always 4,and,4 it wouldn't work, Global $sbyte = "101110101110"
×
×
  • Create New...