Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 03/28/2020 in all areas

  1. Hi, All! I have wanted for a very long time to contribute with something to our community, not only to gain great ideas and examples from all of you guys! Respect for everything you have shared! I don't pretend that this is something great but it works. At least for me. I have made search in this forum and couldn't find a solution so that's why I am sharing this with you: Get's what it is in the clipboard and auto translate it to Bulgarian. You can always change the outcome language. If you have better ideas, or ideas how to improve this code it would be great. #include <IE.au3> $translateText = clipget() $textResault = TranslateFromGGL($translateText,"bg") ConsoleWrite($textResault) Func TranslateFromGGL($sTextToTranslate,$ToLanguageCode) $URL = "https://translate.google.com/?um=1&ie=UTF-8&hl=en&client=tw-ob#view=home&op=translate&sl=auto&tl=" & $ToLanguageCode & "&text=" & $sTextToTranslate Global $oIE = _IECreate($URL, 0, 0, 1) $oTranslated = GetObj("span","class","tlid-translation translation",$oIE) If @error Then $oIE.quit $TranslateFromGGL = "It was not able to translate your request" Exit EndIf Local $html = $oTranslated.innerText If @error Then $TranslateFromGGL = "It was not able to trasnlate your request!" Else $TranslateFromGGL = $html EndIf $oIE.quit Return $TranslateFromGGL EndFunc Func GetObj($Tag, $Attribute, $AttributeValue, $oIE = $oIE) $aTags = _IETagNameGetCollection($oIE, $Tag) For $aTag In $aTags If StringLower($Attribute) = "innertext" Then If StringInStr($aTag.innerText, $AttributeValue) > 0 Then $GetObj = $aTag ExitLoop EndIf ElseIf StringLower($Attribute) = "class" Or StringLower($Attribute) = "classname" Then If StringInStr($aTag.classname, $AttributeValue) > 0 Then $GetObj = $aTag ;MsgBox("","","found" & $aTag.innerText) ExitLoop EndIf Else If StringInStr($aTag.getAttribute($Attribute), $AttributeValue) > 0 Then $GetObj = $aTag ExitLoop EndIf EndIf Next If $GetObj = "" Then Else Return $GetObj EndIf EndFunc ;==>GetObj
    2 points
  2. I was asking @eltorro serveral times for any support for XML DOM wrapper (COM) - with no success So I took matters into my hands ..... I want to present XMLWrapperEx.au3 - BETA Version Want to join to the project ? Here is some description: ; #INDEX# ======================================================================================================================= ; Title .........: XMLWrapperEx.au3 ; AutoIt Version : 3.3.10.2++ ; Language ......: English ; Description ...: Functions to use for reading and writing XML using msxml. ; Remarks .......: BETA Version ; Author ........: mLipok ; Version .......: "1.1.1.01" ; _XML_MiscProperty_UDFVersion() #CS This UDF is created on the basis of: https://www.autoitscript.com/forum/topic/19848-xml-dom-wrapper-com/ For this reason, I attach also the last known (to me) previous version ($_XMLUDFVER = "1.0.3.98" _XMLDomWrapper_1.0.3.98_CN.au3 ) For the same reason I continue to recognize the achievements of the work of my predecessors (they are still noted in each Function header). . . . . !!!!!!!!! This is BETA VERSION (all could be changed) !!!!!!!!! . . . WORK IN PROGRES INFORMATION: For now 2015-09-01 the descripion (Function Header) can not entirely correctly describe the function. TODO: in many places I used "TODO" as a keyword to find what should be done in future . I want to: PREVENT THIS: The unfortunate nature of both the scripts is that the func return results are strings or arrays instead of objects. .     I want to: USE THIS CONCEPT:     .   All function should use Refernce to the object as first Function parameter     .   All function should return in most cases objects. There should be separate functions to Change Object collection to array     .   All function should use COM Error Handler in local scope.     .   All function should return @error which are defined in #Region XMLWrapperEx.au3 - @ERROR Enums     .    All function should have the same naming convention     .    All variables should have the same naming convention     .    There should not to be any Global Variable - exception is $g__oXMLDOM_Events     .   It should be possible easy to use XML DOM Events     .        https://msdn.microsoft.com/en-us/library/ms764697(v=vs.85).aspx     .   It should be possible easy to Debug     .    Ultimately, you should be able to do anything with your XML without having to use your own Error Handler. #CE More info inside zip archive. This UDF can be downloaded from here: REMARK: This UDF was formerly named: XMLWrapperEx.au3
    1 point
  3. DFerrato

    The GuiBuilder Return

    Hello to all. My name is Daniel, I am original of the Argentina and 9 months ago about that development in Autoit, after having passed through other languages type Basic I found a model of development which adapts to my tastes and I am comfortable, but my performance to generate new applications was slow due to the lack of GUI Builder. I found a model of development which adapts to my tastes and I am comfortable, but my performance to build new applications was slow due to lack of a generator of GUI. This situation led me to find a project open-source which adapted to my needs. Review several of the programs appointed by TheSaint, opting to improve and complete 'GuiBuilder Resurrected' publish by baroquebob; when I did was not (or not view the GUIBuilderNxt update by jaberwacky). Below I dedicate some paragraph to this. Also probe (and I was surprised) with Koda , but they are not open-source. (the ISN Studio is super , but very complex for my) Well, here I leave you the link to download, I do so with the idea that you can use it, give me your opinion and help me improve it. Equally here leave you a list of characteristics, all the changes were designed and implemented in a way that respects the job before made by CyberSlug, Roy, TheSaint and Bob ; without radical changes continuing what they started. * New control 'Pick color' * New properties 'Backgroud Color' and 'Style' * New Functions Export file (.au3) and 'Test' * Other function not finalizated.Yet * Improve Documentation. Wait for your comments... Regards Daniel guibuilder_0.9.3.zip
    1 point
  4. Musashi

    Simple Google Translate

    InetRead() itself is ok, but it does not seem to work with longer texts, because "," appears multiple times as a delimiter. Global $g_sMytext, $g_sFrom, $g_sTo, $g_Url, $g_oHTTP, $g_sData $g_sMytext = 'This is an English text to be translated into Italian. ' & _ 'The Moderation team will do their best to act in fair and reasonable manner. Sanctions will ' & _ 'only be applied as a last resort and any action taken will be explained in the relevant thread. ' & _ 'If moderation action is taken, you will need to acknowledge this through a dialog or you ' & _ 'will be unable to post further in the forum. Please note that this dialog is not an agreement ' & _ 'that the warning was justified - it is only there so that members are aware that moderation ' & _ 'action has been taken and that they may have certain restrictions applied to their account. ' & _ 'If you feel that you have been unfairly moderated then contact the Moderator concerned - ' & _ 'using a PM or the "Report" button is preferable to opening a new thread (although new members ' & _ 'may have to do this). But do be aware that the Moderation team has the final word - the rules ' & _ 'are set out by the site owner and you are only welcome here if you respect his wishes.' $g_sFrom = "en" $g_sTo = "it" $g_Url = "https://translate.googleapis.com/translate_a/single?client=gtx&sl=" & $g_sFrom & "&tl=" & $g_sTo & "&dt=t&q=" & $g_sMytext ConsoleWrite("+ Source : " & @CRLF & $g_sMytext & @CRLF) ; Variation 1 : $g_oHTTP = ObjCreate("Microsoft.XMLHTTP") $g_oHTTP.Open("POST", $g_Url, False) $g_oHTTP.Send() $g_sData = StringRegExpReplace($g_oHTTP.ResponseText, '.*?\["(.*?)(?<!\\)"[^\[]*', "$1" & @CRLF) ConsoleWrite("> Result Musashi : " & @CRLF & $g_sData & @CRLF) ConsoleWrite("! -------------------------------------------------------------- " & @CRLF) ; Variation by CYCho : $g_sData = BinaryToString(InetRead($g_Url), 4) $g_sData = StringMid($g_sData, 5, StringInStr($g_sData, '","')-5) & @CRLF ConsoleWrite("> Result CYCho : " & @CRLF & $g_sData & @CRLF) We need a better RegEx . EDIT : Result from Google (in both cases) :
    1 point
  5. CYCho

    Simple Google Translate

    @Velislav and @Musashi, Thank you for great ideas. What if I use Inetread()? And regular expression is always a sour grape for me. Global $g_sMytext, $g_sFrom, $g_sTo, $g_Url, $g_oHTTP, $g_sData $g_sMytext = 'This is an English text to be translated into Italian.' $g_sFrom = "en" $g_sTo = "it" $g_Url = "https://translate.googleapis.com/translate_a/single?client=gtx&sl=" & $g_sFrom & "&tl=" & $g_sTo & "&dt=t&q=" & $g_sMytext $g_sData = BinaryToString(InetRead($g_Url), 4) $g_sData = StringMid($g_sData, 5, StringInStr($g_sData, '","')-5) & @CRLF ConsoleWrite("+ Source : " & $g_sMytext & @CRLF) ConsoleWrite("> Result : " & $g_sData & @CRLF)
    1 point
  6. Musashi

    Simple Google Translate

    Some time ago, I created a Q&D code snippet that uses the Microsoft.XMLHTTP object. However, the regular expression still needs some fine-tuning . ; Example : ; -> Source (engl.) : This is an English text to be translated into Italian. ; -> Result (ital.) : Questo è un testo inglese da tradurre in italiano. Global $g_sMytext, $g_sFrom, $g_sTo, $g_Url, $g_oHTTP, $g_sData $g_sMytext = "This is an English text to be translated into Italian." $g_sFrom = "en" $g_sTo = "it" $g_Url = "https://translate.googleapis.com/translate_a/single?client=gtx&sl=" & $g_sFrom & "&tl=" & $g_sTo & "&dt=t&q=" & $g_sMytext $g_oHTTP = ObjCreate("Microsoft.XMLHTTP") $g_oHTTP.Open("POST", $g_Url, False) $g_oHTTP.Send() $g_sData = StringRegExpReplace($g_oHTTP.ResponseText, '.*?\["(.*?)(?<!\\)"[^\[]*', "$1" & @CRLF) ConsoleWrite("+ Source : " & $g_sMytext & @CRLF) ConsoleWrite("> Result : " & $g_sData & @CRLF) Language codes ->: https://developers.google.com/admin-sdk/directory/v1/languages
    1 point
  7. TheDcoder

    Setup Scite for C

    I don't have the answer to your question, but I do know that there are a few guides for SciTE that give you instructions on setting up custom menu options But I am not making this whole post about advice that you already know, I am here to share my experience with an IDE/Editor for C. To start, I do not like the huge bulked up IDEs which come with a ton of features and also setup the compiler for you... no, I am not into those so I am not going to recommend them, but if you want to check them out there are plenty of options out there. I think the perfect balance between an IDE and just a plain text editor needs to be found, and I found that in Geany Geany is light-weight but also has support for all the basic features like code highlighting, auto-completion, options/buttons to run basic commands to build your code, and the most important feature: embedded terminal Geany natively supports C, so it supports the syntax etc. out of the box, and it even has handy options to switch between headers and source code. It also has an healthy set of plugins which can extend the editor, my favourite plugins are the project manager and git changebar. So I suggest you give it a try 👍
    1 point
  8. The following shows a couple of ways to process an array of JSON objects. The examples are over-simplified and do not contain any error checking. You can add your own error checking, code optimization, and modification of the logic as needed. #Include <json.au3> ;<== Change to your location Global Const $JSON_DATA = _ '{' & _ ' "result":{' & _ ' "items":[' & _ ' {"name":"Becky", "age":8},' & _ ' {"name":"Dave", "age":6},' & _ ' {"name":"Ashley", "age":7}' & _ ' ]' & _ ' }' & _ '}' for_in_next_example() for_next_example() Func for_in_next_example() ConsoleWrite("For...In...Next Example" & @CRLF) Local $oJson = Json_Decode($JSON_DATA) ;Decode JSON string Local $aoItems = Json_Get($oJson, ".result.items") ;Get array of "Items" objects Local $sName Local $iAge For $oItem in $aoItems $sName = Json_Get($oItem, ".name") $iAge = Json_Get($oItem, ".age") ConsoleWrite($sName & " is " & $iAge & @CRLF) Next ConsoleWrite(@CRLF) EndFunc Func for_next_example() ConsoleWrite("For...Next Example" & @CRLF) Local $oJson = Json_Decode($JSON_DATA) ;Decode JSON string Local $aoItems = Json_Get($oJson, ".result.items") ;Get array of "Items" objects Local $iItemCount = UBound(Json_Get($oJson, ".result.items")) Local $sName Local $iAge For $i = 0 To $iItemCount - 1 $sName = Json_Get($aoItems[$i], ".name") $iAge = Json_Get($aoItems[$i], ".age") ConsoleWrite($sName & " is " & $iAge & @CRLF) Next ConsoleWrite(@CRLF) EndFunc Output: For...In...Next Example Becky is 8 Dave is 6 Ashley is 7 For...Next Example Becky is 8 Dave is 6 Ashley is 7
    1 point
  9. But why don't you directly access the array$a_test or store the data in a new array instead of dynamically creating variables?
    1 point
  10. That link is now broken. But maybe this one might be helpful for some https://blog.csdn.net/analogous_love/article/details/42264605
    1 point
×
×
  • Create New...