Jump to content

All Activity

This stream auto-updates

  1. Past hour
  2. Return statement is used to exit from the current subroutine and resume at the point in the script immediately after the instruction which called the subroutine, known as its return address. Consider the following mathematical equation. 2 + 2 = 4 Equation breakdown 2 addend + addition operator 2 addend = equality sign 4 sum The following AutoIt script will add two integers, numbers together and returns the sum. Global $iSum Func _Calculate($iA, $iB) Return $iA + $iB EndFunc $iSum = _Calculate(2, 2) ; calling instruction, return address MsgBox(0, "Sum", "The sum of 2 + 2 = " & $iSum)
  3. Today
  4. ...moreover, a Function, plays a function that in turn can Return a value. Forget programming until you can get some reading comprehension as otherwise you would not know what is been presented in front of your eyes.
  5. Then learn a bit of English. If / Then / Else / and in this case Return, is just plain English
  6. please give me a very very simple example im new and bad at ENG
  7. Thanks AspirinJunkie, I just downloaded your last version 010 which replaced version 09 Happy translations
  8. I use other themes in Windows and as such, nothing is as expected. but if the background is preset, then the other colors should be preset too. TIA
  9. Internal update worked fine for me. What version are you on? /Rex
  10. Hi all, The first addition here is a drum machine. Its based on a demo script you'll find in the midiAPI library if it looks familiar. Admittedly its more of a toy than anything else, but hey, it might help with exploring patches on an instrument I guess! The current "beat" should light up as it's played - but it can look out of whack in some cases. Essentially, beat messages are embedded in the midi stream and are processed as midi is sent from the application. Soft synths can take forever to respond to midi messages, hence the discrepancy. Also, once playback reaches beat 4 of a bar, the entire subsequent bar is loaded into memory ready for playback. Just useful to know if you're trying to race the playhead! Anyway, hope someone has a bit of fun with it
  11. The current version actually has a higher date in the comment. But this is also wrong 😉 - I obviously overlooked the date and didn't always adjust it. The current version can always be found in the github repository: https://github.com/Sylvan86/autoit-json-udf The last change there was on 21 February 2024.
  12. Here is the final reworked script taking care of UTF-8 encoding, so cyrillic characters shouldn't be a problem anymore. Now that all original text is always converted to UTF-8 (no matter they were Ascii characters, Ansi, Unicode, mix) then my initial issue with end of lines has disappeared as EOL's will be restored correctly at their right place, when the translation is done (no more workaround !) I notice the script needs the last version of AutoIt (because of Maps in Json.au3) Though some translations will work with older versions of AutoIt (because Maps aren't always used during translation, depending on the original text), it's better to use last version of AutoIt (3.3.16.1) to cover all cases. @AspirinJunkie I would like to know : this is what is found in your version of Json.au3 I found on the net : ; Title .........: JSON-UDF ; Version .......: 0.9 ; AutoIt Version : 3.3.16.1 ... ; Author(s) .....: AspirinJunkie ; Last changed ..: 2023-01-16 In case there is a newer version, could you please indicate where it can be downloaded ? Thanks to everybody involved in this script #include "Json.au3" ; (by @AspirinJunkie) #include <StringConstants.au3> ;======================== Local $sLangFROM = "auto" Local $sLangTO = "en" ; <===== change this line for the language of the translated text ;======================== Local $sInput, $sClipGet = StringToBinary(ClipGet(), $SB_UTF8) ; for example л (russian) becomes 0xD0BB For $i = 3 To StringLen($sClipGet) Step 2 ; start at 3 to bypass "0x" $sInput &= "%" & StringMid($sClipGet, $i, 2) Next Local $sTranslated = _GoogleAPITranslate($sInput, $sLangFROM, $sLangTO) ; If (Not @compiled) And ProcessExists("scite.exe") Then ; not 100% proof to bypass the 3 following ConsoleWrite, but better than nothing. If Not @compiled Then ; probably a bit faster than preceding line. It will be enough when script run from .a3x shortcut placed on Desktop. ConsoleWrite("ORIGINAL: " & BinaryToString($sClipGet, $SB_ANSI) & @crlf) ; in case of accented characters in Scite console. ConsoleWrite("----------------------------------------------------------------------------------------------------------------" & @crlf) ConsoleWrite(BinaryToString(StringToBinary($sTranslated, $SB_UTF8), $SB_ANSI) & @crlf) EndIf MsgBox(262144, "Translated From " & $sLangFROM & " To " & $sLangTO, $sTranslated) ; $MB_TOPMOST = 262144 ;============================================== Func _GoogleAPITranslate($sMytext, $sFrom, $sTo) Local $sUrl, $oHTTP, $sResponse, $JSONData, $sOutput = "", $aData $sUrl = "https://translate.googleapis.com/translate_a/single?client=gtx&sl=" & $sFrom & "&tl=" & $sTo & "&dt=t&q=" & $sMytext $oHTTP = ObjCreate("Microsoft.XMLHTTP") $oHTTP.Open("POST", $sUrl, False) $oHTTP.Send() $sResponse = $oHTTP.ResponseText $JSONData = _JSON_Parse($sResponse) If VarGetType($JSONData) = 'Array' Then $aData = $JSONData[0] If VarGetType($aData) = 'Array' Then For $i = 0 To UBound($aData) -1 $sOutput &= ($aData[$i])[0] Next EndIf EndIf Return $sOutput EndFunc ;==>_GoogleAPITranslate * Update May 11, 2024 : Added a test on @compiled to bypass (or not) all ConsoleWrite lines and the functions included in them. Though it's not 100% proof, it's better than nothing. Other ways to detect more precisely how the script was launched can be found on the Forum, for example by using _WinAPI_GetParentProcess and _WinAPI_GetProcessName, but do we really need all this just to bypass 3 ConsoleWrite lines ? Let's test on @compiled for the moment, we'll see...
  13. Update: @orbs Got it and I wasn't paying attention to the reg file which needed the full path of where I installed the .exe. Also I needed to make sure all backslashes where doubled up. Thanks!
  14. I like this option but can't seem to get it to work. Maybe since I'm using Windows 11. I created 3 text files and when I select all 3 files, I right click on any of them and choose the new context menu option. It asks me which application to open it in multiple times. I was creating a tiny app to right click on multiple files and have them zip them with my own password. Currently using my app during testing it to an array as it seems you are doing, it opens my array up 3 times (1 instance for each file selected) I was hoping your solution would just open a single instance of an array with all 3 files listed. 😕
  15. In fact it's not that hard to translate from russian to english with the script. You just need to prepare a UTF-8 input string that the google api translator will recognize, for example with these few lines of script : #include <StringConstants.au3> Local $sInput, $sClipGet = StringToBinary(ClipGet(), $SB_UTF8) ; л (russian) becomes 0xD0BB For $i = 3 To StringLen($sClipGet) Step 2 ; forget "0x" at beginning $sInput &= "%" & StringMid($sClipGet, $i, 2) Next ConsoleWrite("ClipGet() = " & BinaryToString($sClipGet, $SB_ANSI) & @crlf & @crlf) ConsoleWrite("$sClipGet = " & $sClipGet & @crlf & @crlf) ConsoleWrite("$sInput = " & $sInput & @crlf) AutoIt console : ClipGet() = а если подумать в 99,9999999999% случаев $sClipGet = 0xD0B020D0B5D181D0BBD0B820D0BFD0BED0B4D183D0BCD0B0D182D18C2020D0B22039392C393939393939393939392520D181D0BBD183D187D0B0D0B5D0B2 $sInput = %D0%B0%20%D0%B5%D1%81%D0%BB%D0%B8%20%D0%BF%D0%BE%D0%B4%D1%83%D0%BC%D0%B0%D1%82%D1%8C%20%20%D0%B2%20%39%39%2C%39%39%39%39%39%39%39%39%39%39%25%20%D1%81%D0%BB%D1%83%D1%87%D0%B0%D0%B5%D0%B2 Then you use the variable $sInput for the google api translator, it will translate correctly : Same result as translating with the Browser, yes ! I'll have to rework a bit the original script to integrate in it these new lines of script.
  16. Yesterday
  17. Ok, i didn't know this about the API. Thanks for the information. The powershell may have been shortened by a colleague who may have deleted some neccessary parts. I will investigate this. Maybe then it is better trying the webdriver. I will be back here when i have my first webdriver code done or when i fail with this task 🙂
  18. @jchd thanks for the help, unfortunately the Clipboard functions didn't solve the issue (output is still a bunch of ???) I think that as soon as Unicode is involved (russian language for example) then it will be a bit hard for the script to format the russian text as required by google api for translation. For example, let's work on a single russian character to translate, the Cyrillic Small Letter El : л Below is the Browser url that translates it correctly in english, and the text to be translated will become "%D0%BB" (UTF-8) as shown inside the url : https://www.google.com/search?tlsa=1&sca_esv=f42f57a008774f06&sca_upv=1&gbv=2&ei=oWA-ZreWF9qokdUP-5SJ4As&q=Traduire&tlitesl=ru&tlitetxt=%D0%BB&tlitetl=en л (russe) %D0%BB l (anglais) For the record, on my computer, Free Clipboard Viewer 4.0 shows this for the russian character, coded as 043B (UTF16 Big Endian) л 043B (Unicode Text Format, as indicated by Free Clipboard Viewer) All this seems correct, according to this web page, which indicates (excerpts) : л Nom: Lettre minuscule cyrillique elle[1] Nom (anglais): Cyrillic Small Letter El[2] Version Unicode: 1.1 (juin 1993)[3] Bloc: Cyrillique, U+0400 - U+04FF[4] ... Encodage UTF-8: 0xD0 0xBB Encodage UTF-16: 0x043B Encodage UTF-32: 0x0000043B So when it comes to russian translation, to match google api requirements, we should at least add this in the script : Local $sClipGet = StringToBinary(ClipGet(), $SB_UTF8) ; л (russian) becomes 0xD0BB Then we should format the input string to match google requirement, transforming "0xD0BB" to "%D0%BB" But this is only for 1 character ! Now when you see that google requires a "+" when there's a space in the input string, it would be a nightmare to check all requirements and adapt them in the script. For example, with this other russian input string : л.л google requirement for translation would be: %D0%BB.%D0%BB (a dot stays a dot) . But: StringToBinary("л.л", $SB_UTF8) ; 0xD0BB2ED0BB (a dot becomes 2E) So I guess I'll use the script only for languages using Ansi characters, but not for languages using Unicode characters (where translation via Google directly in the browser works very fine !) Thanks for reading
  19. Hi folks 👋 , please consider to take part on the WebDriver poll which is regarding which driver do you automate. Please have a quick look here and take part ==> this could help us to improve or harden the WebDriver project in the future 😇 . Thanks, best regards Sven @Mugaro
  20. Hi folks 👋 , please consider to take part on the WebDriver poll which is regarding which driver do you automate. Please have a quick look here and take part ==> this could help us to improve or harden the WebDriver project in the future 😇 . Thanks, best regards Sven @SlavaS
  21. Hi Andi ( @agivx3 ), after a research I realized that there is no API request (no POST) available for https://www.catalog.update.microsoft.com/DownloadDialog.aspx anymore. If this is the case, then you cannot download the found windows update *.msu packages. Are you sure the powershell script loads the 4 found entries? Not for me and when I debug the PS script, I see it cannot work (at least not in that way which was provided by you in this post). What do you want exactly? Please describe the bigger goal behind all of this? Is it to download the newest cumulative updates for a specific maschine and that's it? If yes, then your possibilities to achieve this are less then thought before. You can try UIA or WebDriver to get this automation done. But please, write some code and try something to show your participation. I won't write it all for you 🧐 . Best regards Sven Question: Do you speak german by any chance? Update: This looks promising ==> https://github.com/ryan-jan/MSCatalog 😁 ==> but it's still Powershell
  22. Built-in update feature for ISN Autoit studio not working. I click "check for updates" in the main menu, the application detects there is a more up-to-date version available, the program exits to "apply the update," and I am immediately met with this: Process terminates, and re-launching ISN autoit studio shows that update has not been installed. Just a heads up.
  23. Glad you have mastered it much better that others ... and of course sharing your "master piece" in our examples forum. Thanks for that!
  24. When you copy things, the clipboard stores data and allows reading it under multiple formats. Simple ClipPut is likely to paste only ANSI text, while you need Unicode. ; For your information only Func EnumFormats() _ClipBoard_Open(0) Local $f, $n = _ClipBoard_CountFormats() ConsoleWrite($n & " clipboard formats are available:" & @LF) Do $f = _ClipBoard_EnumFormats($f) If $f > 0 Then ConsoleWrite("Format " & $f & " = " & _ClipBoard_FormatStr($f) & @LF) Until $f = 0 _ClipBoard_Close() EndFunc You probably need something like that: $sText = ReadUnicodeClip() ; paste or process read data where required ; .../... Func ReadUnicodeClip() _ClipBoard_Open(0) Local $f, $s Do $f = _ClipBoard_EnumFormats($f) Until _ClipBoard_FormatStr($f) = "Unicode Text" $s = _ClipBoard_GetData($f) _ClipBoard_Close() Return $s EndFunc Format numbers change depending on context, so don't rely on magic numbers and always scan formats until the one you need is found.
  25. FYI: I solved it by forcing transpose $aSongs = _Excel_RangeRead($oWorkbook, $wsName, $cellRange, default, True)
  26. Well, I tried to delete the above post - but I can't. SO - here is another one. In this I changed the file name from DDW.au3 to WinDD.au3. I did this because I realized most (if not all) Windows based functions start with "Win" or "_Win". So I changed it to WinDD. Anyway, Here it is: #cs     Copyright (c) 2020 TarreTarreTarre <tarre.islam@gmail.com>     Permission is hereby granted, free of charge, to any person obtaining a copy     of this software and associated documentation files (the "Software"), to deal     in the Software without restriction, including without limitation the rights     to use, copy, modify, merge, publish, distribute, sublicense, and/or sell     copies of the Software, and to permit persons to whom the Software is     furnished to do so, subject to the following conditions:     The above copyright notice and this permission notice shall be included in all     copies or substantial portions of the Software.     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR     IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,     FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE     AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER     LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,     OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE     SOFTWARE. #ce #AutoIt3Wrapper_Au3Check_Parameters=-q -d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w 7 #include-once ; #FUNCTION# ========================================================================================================= ; Name ..........: WinDD ; Description ...: Displays useful information about a variable or object in the console ; Syntax ........: WinDD($any[, $exit = True], $timeout=0) ; Parameters ....: $any                 - anything. ;                  $exit                - [optional] an boolean value. Default is True. ; Return values .: None ; Author ........: TarreTarreTarre and Mark Manning (only made changes) ; Modified ......: May 9, 2024 ; Remarks .......: Made it so this works for MsgBox ; Related .......: ; Link ..........: ; Example .......: No ; =================================================================================================================== Global $__WinDD_String = ""; Func WinDD($any, $exit = True, $timeout=0)    ;    0 = YOU have to close the dialog     $__WinDD_String = @crlf & "--->Starting Debug" & @crlf & @crlf;     __WinDD($any, 0)     $__WinDD_String &= @crlf & "<---Exiting Debug" & @crlf;     MsgBox( $MB_SYSTEMMODAL, "WinDD Debug Information", $__WinDD_String, $timeout );     If $exit Then Exit EndFunc   ;==>WinDD #Region Internals Func __WinDD($any, $depth)     Switch VarGetType($any)         Case "Array"             __WinDD_Array($any, $depth)         Case "Object" And ObjName($any) == "Dictionary"             $__WinDD_String &= "- ";             __WinDD_ScriptingDictionary($any, $depth)         Case Else             $__WinDD_String &= (IsObj($any) ? '! ' : '> ');             __WinDD_Other($any)     EndSwitch EndFunc   ;==>__WinDD Func __WinDD_Array($array, $depth, $curI = Null, $curJ = Null, $ignoreTabs = False)     Local Const $rows = UBound($array)     Local Const $cols = UBound($array, 2)     Local $cur, $oInfo, $cwColor     If $cols == 0 Then         $curI = VarGetType($curI) == "Int32" ? StringFormat("[%d] => ", $curI) : ""         $__WinDD_String &= _             (">" & __GetTabs($depth, $ignoreTabs) & StringFormat('%s(Array:%d) [', $curI, $rows) & @LF);         For $i = 0 To $rows - 1             $cur = $array[$i]             $oInfo = __GetDataInfo($cur)             $cwColor = IsObj($cur) ? (ObjName($cur) == "Dictionary" ? '-' : '!') : '>'             If IsArray($cur) Then                 __WinDD_Array($cur, $depth + 1, $i) ;                $__WinDD_String &= ("> " & $sTabs & "]" & @LF);             ElseIf IsObj($cur) And ObjName($cur) == "Dictionary" Then                 $__WinDD_String &= ("- " & __GetTabs($depth + 1) & StringFormat('[%d] => ', $i));                 __WinDD_ScriptingDictionary($cur, $depth + 1, True)             Else                 $__WinDD_String &= ($cwColor & " " & __GetTabs($depth + 1) & _                     StringFormat('[%d] (%s:%s) => "%s"', $i, $oInfo.item("type"), _                     $oInfo.item("length"), $oInfo.item("value")) & @LF);             EndIf         Next     Else         $curI = VarGetType($curI) == "Int32" ? ($depth == 1 ? StringFormat("[%d] => ", $curI) : StringFormat("[%d][%d] => ", $curI, $curJ)) : ""         $__WinDD_String &= (">" & __GetTabs($depth, $ignoreTabs) & _             StringFormat('%s(Array:%d:%d) [', $curI, $rows, $cols) & @LF);         For $i = 0 To $rows - 1             For $j = 0 To $cols - 1                 $cur = $array[$i][$j]                 $oInfo = __GetDataInfo($cur)                 $cwColor = IsObj($cur) ? (ObjName($cur) == "Dictionary" ? '-' : '!') : '>'                 If IsArray($cur) Then                     __WinDD_Array($cur, $depth + 1, $i, $j)                 ElseIf IsObj($cur) And ObjName($cur) == "Dictionary" Then                     $__WinDD_String &= ("- " & __GetTabs($depth + 1) & _                         StringFormat('[%d][%d] => ', $i, $j));                     __WinDD_ScriptingDictionary($cur, $depth + 1, True)                 Else                     $__WinDD_String &= ($cwColor & " " & __GetTabs($depth + 1) & _                         StringFormat('[%d][%d] (%s:%s) => "%s"', $i, $j, $oInfo.item("type"), _                         $oInfo.item("length"), $oInfo.item("value")) & @LF);                 EndIf             Next         Next     EndIf     $__WinDD_String &= ("> " & __GetTabs($depth) & "]" & @LF); EndFunc   ;==>__WinDD_Array Func __WinDD_ScriptingDictionary($object, $depth, $ignoreTabs = False)     $__WinDD_String &= (__GetTabs($depth, $ignoreTabs) & _         StringFormat('(Scripting.Dictionary:%d) {', $object.count()) & @LF), 5 );     For $item In $object         Local $key = $item         Local $value = $object.item($key)         Local $oInfo = __GetDataInfo($value)         If IsObj($value) And ObjName($value) == "Dictionary" Then             $__WinDD_String &= (StringFormat("- " & __GetTabs($depth + 1) & "[%s] => ", $key));             __WinDD_ScriptingDictionary($value, $depth + 1, True)         ElseIf IsArray($value) Then             $__WinDD_String &= ("> " & __GetTabs($depth + 1) & StringFormat('[%s] => ', $key));             __WinDD_Array($value, $depth + 1, Null, Null, True)         Else             $__WinDD_String &= ("- " & __GetTabs($depth + 1) & _                 StringFormat('[%s] (%s:%s) => "%s"', $key, $oInfo.item("type"), _                 $oInfo.item("length"), $oInfo.item("value")) & @LF);         EndIf     Next     $__WinDD_String &= ("- " & __GetTabs($depth) & "}" & @LF); EndFunc   ;==>__WinDD_ScriptingDictionary Func __WinDD_Other($any)     Local Const $oInfo = __GetDataInfo($any)       $__WinDD_String &= (StringFormat('(%s:%s) "%s"', $oInfo.item("type"), _         $oInfo.item("length"), $oInfo.item("value")) & @LF); EndFunc   ;==>__WinDD_Other Func __GetDataInfo($any)     Local Const $oRet = ObjCreate("Scripting.Dictionary")     Local $type = VarGetType($any)     Local $value = $any     Local $length = StringLen($any)     Switch $type         Case "UserFunction"             ContinueCase         Case "Function"             $value = FuncName($any)             $length = StringLen($value)         Case "Object"             $type = ObjName($any)             $length = ObjName($any, 2) ; Descriptobn             $value = ObjName($any, 6) ; Clisid         Case "String"             Local $str = $any             $str = StringReplace($str, @LF, "\LF")             $str = StringReplace($str, @CR, "\CR")             $str = StringReplace($str, @CRLF, "\CRLF")             $str = StringReplace($str, @TAB, "\TAB")             $value = $str         Case "Binary"             $value = BinaryLen($any)         Case "Keyword" And $length == 0             $value = "NULL"     EndSwitch     $oRet.add("type", $type)     $oRet.add("length", $length)     $oRet.add("value", $value)     Return $oRet EndFunc   ;==>__GetDataInfo Func __GetTabs($depth, $ignoreTabs = False)     If $ignoreTabs Then Return ""     Local $sTabs     For $i = 0 To $depth - 1         $sTabs &= "    " ; @TAB     Next     Return $sTabs EndFunc   ;==>__GetTabs #EndRegion Internals Same filename though but that's because it is inside of the directory. Autoit-DD-1.1.0.zip
  27. Hmmm... I'm specifying range "A1:P555" which is only about 5000 cells. I'm still getting this error. FYI: @extended = "-2147352571"
  28. @jchd hello ! Your knowledge in translation & encoding is required I would like to translate this Russian sentence in english : а если подумать 1) If I do it from my Opera Browser, using Google translation service, it works fine : Complete Opera URL is : https://www.google.com/search?tlsa=1&sca_esv=f42f57a008774f06&sca_upv=1&gbv=2&ei=DSM-ZtX0BvaRxc8P74iQqA8&q=Traduire&tlitesl=ru&tlitetxt=%D0%B0+%D0%B5%D1%81%D0%BB%D0%B8+%D0%BF%D0%BE%D0%B4%D1%83%D0%BC%D0%B0%D1%82%D1%8C&tlitetl=en We can extract from the URL the russian text that has been correctly translated : %D0%B0+%D0%B5%D1%81%D0%BB%D0%B8+%D0%BF%D0%BE%D0%B4%D1%83%D0%BC%D0%B0%D1%82%D1%8C 2) Now I try to do same with the AutoIt script from my preceding post (the one that uses Google API and JSON.au3), with this change made before : ;======================== Local $sLangFROM = "ru" Local $sLangTO = "en" ;======================== Then we copy to the clipboard the original russian sentence (select it, then ctrl+c) and we run the script, this is the "wrong" result displayed in the Console & MessageBox : 3) If I replace the $sUrl line in the script, not using $sMytext anymore, but replacing it with the literal russian text extracted from Opera URL : ; $sUrl = "https://translate.googleapis.com/translate_a/single?client=gtx&sl=" & $sFrom & "&tl=" & $sTo & "&dt=t&q=" & $sMytext $sUrl = "https://translate.googleapis.com/translate_a/single?client=gtx&sl=" & $sFrom & "&tl=" & $sTo & "&dt=t&q=" & _ "%D0%B0+%D0%B5%D1%81%D0%BB%D0%B8+%D0%BF%D0%BE%D0%B4%D1%83%D0%BC%D0%B0%D1%82%D1%8C" Now the translation is correct. So I got this issue with original russian text, but not with original german, spanish, turkish, english, french (etc...) languages. Do you have an idea why it happens and how could it be solved ? Because the preceding script is really useful, you can create a shortcut of the script on the Desktop and as soon as you got foreign sentence(s) to translate, a simple click on the shortcut should do it (with of course : Local $sLangFROM = "auto" in the script) Thanks for reading
  1. Load more activity
×
×
  • Create New...