Jump to content

TheDcoder

Active Members
  • Posts

    7,103
  • Joined

  • Days Won

    88

Everything posted by TheDcoder

  1. @jchd I see, it would be easy enough to process fixed-format XML I guess... Thanks for example
  2. @jchd I'd not classify writing RegEx for converting XML to JSON "easy", I recently tried to do something similar (stripping elements from XML) using RegEx and even it was not too easy with some trivial bug . Unless someone has already written RegEx for converting XML -> JSON?
  3. Does SQLite handle the converstion from XML to JSON as well? If not, how would we convert fixed-format XML to JSON?
  4. No worries, didn't take offense I think the same, but you can always try and see, would be nice if they implement it
  5. I see, quite advanced stuff then. I was kind of hoping there was an easier way. Maybe I should open a ticket about this and see what the Devs think?
  6. Good stuff @Mobius, I recall checking out AutoCamo a few years ago, but never downloaded it and had a proper look... until now that is, I see that you have discontinued it (which is sad), but we can salvage something from your project. Can you give us a brief explanation how you made it possible to have a custom seed?
  7. I agree. A practical example and the reason why I am looking forward to this feature is because I develop a program called ProxAllium, it is a frontend for Tor which is a security related software, I won't go into much detail, but I will say that users of Tor and the Tor project take security/trustworthiness somewhat more seriously than normal people. In order for a software to be accepted by the community, the binaries should ideally be reproducible, so that they can verify that it has indeed been compiled from the public source code. Unfortunately it is impossible to do this in AutoIt as tokenization adds a random factor to the compile process That is only one of the many advantages of reproducible builds, more incentives and advantages can be found here: https://reproducible-builds.org/ Also, the wikipedia entry on this topic: https://en.wikipedia.org/wiki/Deterministic_compilation It is a valuable technique which open source software can take advantage of
  8. @milkmoron I am not aware of any other easier alternative, but you can starting by reading the linked posts and examples in the first post: Good luck
  9. I guess msxml is not made for parsing HTML... problems start popping up as soon as I start fixing them . Here are some functions people might find useful if they are working with HTML... ; Use this function to remove the contents of script tags (some symbols confuse the parser) Func StripScriptTagContent(ByRef $sHtml) $sHtml = StringRegExpReplace($sHtml, '(*UCP)(?si)<script.*?>.*?<\/script>', '<script>Truncated</script>') EndFunc ; Use this function to automatically generate end tags for void tags, a bad workaround and will generate invalid HTML, but it works for analysis purposes Func CleanseVoidTags(ByRef $sHtml) Local Static $aVoidTags = ['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'link', 'meta', 'param', 'source', 'track', 'wbr'] For $sTag In $aVoidTags $sHtml = StringRegExpReplace($sHtml, '(*UCP)(?si)(<' & $sTag & ' .*?>)', '\0</' & $sTag & '>') Next EndFunc The parser has started to complain about undefined entities (Reference to undefined entity 'nbsp'). I guess I will write my own parser for now... sigh.
  10. Please read the forum rules before posting, any discussion related to decompiling tools is forbidden!
  11. @mLipok Sorry, I was on Linux and I was planning to write a reproducer script when I switch to Windows. Here is the script: #include "XML\XML.au3" Global $oErrorHandler = ObjEvent("AutoIt.Error", ErrFunc_CustomUserHandler_MAIN) _XML_ComErrorHandler_UserFunction(ErrFunc_CustomUserHandler_XML) Main() Func Main() Local $sHtml = '<html><head><link href="main.css" rel="stylesheet"></head></html>' Local $oXMLDoc = _XML_CreateDOMDocument(Default) ConsoleWrite('+> Create DOMDocument: ' & XML_My_ErrorParser(@error) & @CRLF) _XML_LoadXML($oXMLDoc, $sHtml, 'xhtml', False) ConsoleWrite('+> Load XML: ' & XML_My_ErrorParser(@error) & @CRLF) ConsoleWrite(_XML_ErrorParser_GetDescription($oXMLDoc) & @CRLF) ; ... EndFunc Func ErrFunc_CustomUserHandler_MAIN($oError) ConsoleWrite(@ScriptName & " (" & $oError.scriptline & ") : MainScript ==> COM Error intercepted !" & @CRLF & _ @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _ @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _ @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _ @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _ @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _ @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _ @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _ @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _ @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF) EndFunc Func ErrFunc_CustomUserHandler_XML($oError) ConsoleWrite(@ScriptDir & '\XMLWrapperEx.au3' & " (" & $oError.scriptline & ") : UDF ==> COM Error intercepted ! " & @CRLF & _ @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _ @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _ @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _ @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _ @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _ @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _ @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _ @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _ @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF) EndFunc ; #FUNCTION# ==================================================================================================================== ; Name ..........: XML_My_ErrorParser ; Description ...: Changing $XML_ERR_ ... to human readable description ; Syntax ........: XML_My_ErrorParser($iXMLWrapper_Error, $iXMLWrapper_Extended) ; Parameters ....: $iXMLWrapper_Error - an integer value. ; $iXMLWrapper_Extended - an integer value. ; Return values .: description as string ; Author ........: mLipok ; Modified ......: ; Remarks .......: This function is only example of how user can parse @error and @extended to human readable description ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func XML_My_ErrorParser($iXMLWrapper_Error, $iXMLWrapper_Extended = 0) Local $sErrorInfo = '' Switch $iXMLWrapper_Error Case $XML_ERR_SUCCESS $sErrorInfo = '$XML_ERR_SUCCESS=' & $XML_ERR_SUCCESS & @CRLF & 'All is ok.' Case $XML_ERR_GENERAL $sErrorInfo = '$XML_ERR_GENERAL=' & $XML_ERR_GENERAL & @CRLF & 'The error which is not specifically defined.' Case $XML_ERR_COMERROR $sErrorInfo = '$XML_ERR_COMERROR=' & $XML_ERR_COMERROR & @CRLF & 'COM ERROR OCCURED. Check @extended and your own error handler function for details.' Case $XML_ERR_ISNOTOBJECT $sErrorInfo = '$XML_ERR_ISNOTOBJECT=' & $XML_ERR_ISNOTOBJECT & @CRLF & 'No object passed to function' Case $XML_ERR_INVALIDDOMDOC $sErrorInfo = '$XML_ERR_INVALIDDOMDOC=' & $XML_ERR_INVALIDDOMDOC & @CRLF & 'Invalid object passed to function' Case $XML_ERR_INVALIDATTRIB $sErrorInfo = '$XML_ERR_INVALIDATTRIB=' & $XML_ERR_INVALIDATTRIB & @CRLF & 'Invalid object passed to function.' Case $XML_ERR_INVALIDNODETYPE $sErrorInfo = '$XML_ERR_INVALIDNODETYPE=' & $XML_ERR_INVALIDNODETYPE & @CRLF & 'Invalid object passed to function.' Case $XML_ERR_OBJCREATE $sErrorInfo = '$XML_ERR_OBJCREATE=' & $XML_ERR_OBJCREATE & @CRLF & 'Object can not be created.' Case $XML_ERR_NODECREATE $sErrorInfo = '$XML_ERR_NODECREATE=' & $XML_ERR_NODECREATE & @CRLF & 'Can not create Node - check also COM Error Handler' Case $XML_ERR_NODEAPPEND $sErrorInfo = '$XML_ERR_NODEAPPEND=' & $XML_ERR_NODEAPPEND & @CRLF & 'Can not append Node - check also COM Error Handler' Case $XML_ERR_PARSE $sErrorInfo = '$XML_ERR_PARSE=' & $XML_ERR_PARSE & @CRLF & 'Error: with Parsing objects, .parseError.errorCode=' & $iXMLWrapper_Extended & ' Use _XML_ErrorParser_GetDescription() for get details.' Case $XML_ERR_PARSE_XSL $sErrorInfo = '$XML_ERR_PARSE_XSL=' & $XML_ERR_PARSE_XSL & @CRLF & 'Error with Parsing XSL objects .parseError.errorCode=' & $iXMLWrapper_Extended & ' Use _XML_ErrorParser_GetDescription() for get details.' Case $XML_ERR_LOAD $sErrorInfo = '$XML_ERR_LOAD=' & $XML_ERR_LOAD & @CRLF & 'Error opening specified file.' Case $XML_ERR_SAVE $sErrorInfo = '$XML_ERR_SAVE=' & $XML_ERR_SAVE & @CRLF & 'Error saving file.' Case $XML_ERR_PARAMETER $sErrorInfo = '$XML_ERR_PARAMETER=' & $XML_ERR_PARAMETER & @CRLF & 'Wrong parameter passed to function.' Case $XML_ERR_ARRAY $sErrorInfo = '$XML_ERR_ARRAY=' & $XML_ERR_ARRAY & @CRLF & 'Wrong array parameter passed to function. Check array dimension and conent.' Case $XML_ERR_XPATH $sErrorInfo = '$XML_ERR_XPATH=' & $XML_ERR_XPATH & @CRLF & 'XPath syntax error - check also COM Error Handler.' Case $XML_ERR_NONODESMATCH $sErrorInfo = '$XML_ERR_NONODESMATCH=' & $XML_ERR_NONODESMATCH & @CRLF & 'No nodes match the XPath expression' Case $XML_ERR_NOCHILDMATCH $sErrorInfo = '$XML_ERR_NOCHILDMATCH=' & $XML_ERR_NOCHILDMATCH & @CRLF & 'There is no Child in nodes matched by XPath expression.' Case $XML_ERR_NOATTRMATCH $sErrorInfo = '$XML_ERR_NOATTRMATCH=' & $XML_ERR_NOATTRMATCH & @CRLF & 'There is no such attribute in selected node.' Case $XML_ERR_DOMVERSION $sErrorInfo = '$XML_ERR_DOMVERSION=' & $XML_ERR_DOMVERSION & @CRLF & 'DOM Version: ' & 'MSXML Version ' & $iXMLWrapper_Extended & ' or greater required for this function' Case $XML_ERR_EMPTYCOLLECTION $sErrorInfo = '$XML_ERR_EMPTYCOLLECTION=' & $XML_ERR_EMPTYCOLLECTION & @CRLF & 'Collections of objects was empty' Case $XML_ERR_EMPTYOBJECT $sErrorInfo = '$XML_ERR_EMPTYOBJECT=' & $XML_ERR_EMPTYOBJECT & @CRLF & 'Object is empty' Case Else $sErrorInfo = '=' & $iXMLWrapper_Error & @CRLF & 'NO ERROR DESCRIPTION FOR THIS @error' EndSwitch Local $sExtendedInfo = '' Switch $iXMLWrapper_Error Case $XML_ERR_COMERROR, $XML_ERR_NODEAPPEND, $XML_ERR_NODECREATE $sExtendedInfo = 'COM ERROR NUMBER (@error returned via @extended) =' & $iXMLWrapper_Extended Case $XML_ERR_PARAMETER $sExtendedInfo = 'This @error was fired by parameter: #' & $iXMLWrapper_Extended Case Else Switch $iXMLWrapper_Extended Case $XML_EXT_DEFAULT $sExtendedInfo = '$XML_EXT_DEFAULT=' & $XML_EXT_DEFAULT & @CRLF & 'Default - Do not return any additional information' Case $XML_EXT_XMLDOM $sExtendedInfo = '$XML_EXT_XMLDOM=' & $XML_EXT_XMLDOM & @CRLF & '"Microsoft.XMLDOM" related Error' Case $XML_EXT_DOMDOCUMENT $sExtendedInfo = '$XML_EXT_DOMDOCUMENT=' & $XML_EXT_DOMDOCUMENT & @CRLF & '"Msxml2.DOMDocument" related Error' Case $XML_EXT_XSLTEMPLATE $sExtendedInfo = '$XML_EXT_XSLTEMPLATE=' & $XML_EXT_XSLTEMPLATE & @CRLF & '"Msxml2.XSLTemplate" related Error' Case $XML_EXT_SAXXMLREADER $sExtendedInfo = '$XML_EXT_SAXXMLREADER=' & $XML_EXT_SAXXMLREADER & @CRLF & '"MSXML2.SAXXMLReader" related Error' Case $XML_EXT_MXXMLWRITER $sExtendedInfo = '$XML_EXT_MXXMLWRITER=' & $XML_EXT_MXXMLWRITER & @CRLF & '"MSXML2.MXXMLWriter" related Error' Case $XML_EXT_FREETHREADEDDOMDOCUMENT $sExtendedInfo = '$XML_EXT_FREETHREADEDDOMDOCUMENT=' & $XML_EXT_FREETHREADEDDOMDOCUMENT & @CRLF & '"Msxml2.FreeThreadedDOMDocument" related Error' Case $XML_EXT_XMLSCHEMACACHE $sExtendedInfo = '$XML_EXT_XMLSCHEMACACHE=' & $XML_EXT_XMLSCHEMACACHE & @CRLF & '"Msxml2.XMLSchemaCache." related Error' Case $XML_EXT_STREAM $sExtendedInfo = '$XML_EXT_STREAM=' & $XML_EXT_STREAM & @CRLF & '"ADODB.STREAM" related Error' Case $XML_EXT_ENCODING $sExtendedInfo = '$XML_EXT_ENCODING=' & $XML_EXT_ENCODING & @CRLF & 'Encoding related Error' Case Else $sExtendedInfo = '$iXMLWrapper_Extended=' & $iXMLWrapper_Extended & @CRLF & 'NO ERROR DESCRIPTION FOR THIS @extened' EndSwitch EndSwitch ; return back @error and @extended for further debuging Return SetError($iXMLWrapper_Error, $iXMLWrapper_Extended, _ '@error description:' & @CRLF & _ $sErrorInfo & @CRLF & _ @CRLF & _ '@extended description:' & @CRLF & _ $sExtendedInfo & @CRLF & _ '') EndFunc ;==>XML_My_ErrorParser You can see that in the output it says "End tag 'head' does not match the start tag 'link'", which means the parser is unable to deal with single/void/non-closing tags
  12. @mLipok This document will not be parsed, unless you remove the link tag: <html> <head> <meta charset="utf-8"> <link href="main.css" rel="stylesheet"> <title>My test page</title> </head> <body> <p>This is my page</p> </body> </html>
  13. Has anyone managed to parse HTML with this UDF? I am having problems with "void tags" (tags which don't have the closing counterpart), I get errors during parsing... msxml complains about the mismatching closing tag (</head>) for <link>
  14. I didn't notice that at all! Very surprising and interesting... I am not sure what is going wrong in this case, and I reckon we cannot test furthur as we cannot remove the remaining symbols in the expression. I have to change the title yet again... maybe I should make it more generic.
  15. Hello Melba, I agree that using parentheses is a good practice and it certainly helps the interperter know what is in your mind. And you are indeed correct about it "linearly" evaluating the expression and mistaking the = operator for being used for assignment this code proves it: Local $aArray = ["Foo", "Bar", "Baz"] ; Works (no equal operator) ConsoleWrite($aArray[$aArray[0] <> "Foo" ? 1 : 2] & @CRLF) ; Doesn't work ConsoleWrite($aArray[$aArray[0] = "Foo" ? 1 : 2] & @CRLF) ConsoleWrite($aArray[$aArray[0] == "Foo" ? 1 : 2] & @CRLF) As I was writing my reply, @jchd came up with exactly what I was trying to demonstrate. Kudos and thanks This would only require correcting the context in which the expressions are evaluated inside the square brackets of an array, so that = doesn't get mistaken. Small correction: We do have that, it is the case-sensitive comparision operator , but as I have demonstrated in my code above, it still doesn't work.
  16. I am not sure, this works and there is no assignment going on: ; Works ConsoleWrite(1?1:2 & @CRLF)
  17. Sorry, yes, you are correct. I made an edit to mention that
  18. Thanks @LarsJ, the bug only happens if there is a ternary operator it seems. It is interesting because the interpreter still claims that the brackets are unbalanced even if there is only a single pair of them in the statement, maybe the code which handles ternary operator is at fault.
  19. Thank you for the reply @Melba23, I am afraid I would have to disagree with you, while it is true that the help file suggests wrapping a ternary expression in brackets, that doesn't mean it should be required, especially when there are no other operators in the expression. I would hardly classify evaluating the expression and using the result as the value "reading your mind". I absolutely see no room ambiguity or any other interpretations, only a single operator is used in this case. Please do enlighten me, why is this considered poor coding syntax? I don't think it is better to wrap an expression with a single operator in brackets. I agree that it should not be expected to manage every edge case but I would not call it an edge case as it is quite logical to think that an expression should be evaluated before it is used.
  20. Hello everyone, I am back with yet another strange behaviour in AutoIt While working on my project I stumbled upon this weird error in this script: Local $aArray = ["Foo", "Bar", "Baz"] ; Works ConsoleWrite($aArray[($aArray[0] = "Foo" ? 1 : 2)] & @CRLF) ; Doesn't work ConsoleWrite($aArray[$aArray[0] = "Foo" ? 1 : 2] & @CRLF) I am using the ternary operator to dynamically select a different element based on the value inside another element, instead of going the more traditional and simple (as in concept) approach of using If...Else The problem is that the interperter thinks the square brackets are unbalanced . It works if I wrap the entire expression inside curvy brackets (parentheses) I would like to see what the developers have to say about this . IMO this is definitley a bug in the interpreter's parser, I would be happy to open a ticket if we determine that this needs to be fixed.
  21. I think we are confusing ourselves if OP wants to check if a checkbox is ticked in the GUI created by his script or if he is trying to automate another application. It looks like the latter but to just make sure: @CaptainBeardsEyesBeard Are you trying to automate a program or are you working with your own GUI?
  22. @Earthshine Well we are obviously looking for something which we can easily use in AutoIt code, and it is simpler to add more AutoIt code rather than learning C# and writing your program in it
  23. ; Try this Local $iPercentage = 0 Local $sPercentage = StringFormat('%.1f', $iPercentage) ConsoleWrite($sPercentage & @CRLF)
×
×
  • Create New...