Leaderboard
Popular Content
Showing content with the highest reputation on 06/07/2023 in all areas
-
Ok, I will unlock that last topic and cleanup the last couple of posts in this thread in a couple of minutes to clean things up, but please don't go crazy with creating topics.2 points
-
Yep, I am here early in the day (for me) for a change. This was because I discovered a bug in my program, introduced recently when I modified the device (drive) checking function. I forgot to replace one instance of a variable. I did not have my external drive plugged in when I started the program today, and so the stored value for my working drive (with Kobo clone folders) was replaced by a non existent location, when I told it to find the drive after I plugged it in. And I haven't tested the other stuff yet with my device, because I realized I hadn't yet grabbed all the source cover images and put them in that folder. The new MARK ability and NEXT button use allowed me to quickly sort that out, but during that process I discovered that some ISBN were much longer than normal. As the Title input is much longer than my longest ebook title listed, I was able to increase the length of the ISBN input until it was long enough to display all characters for the long instances. DOWNLOAD Kobo Cover Fixer.au3 (58 downloads) SEE THE FIRST POST in this topic for the latest version. 121.15 kB And here's the icon I created back when I started the program, ready for the eventual compile. Fixer.ico I am hoping to do the testing today, though an adaption to another of my programs is chafing at the bit to get done, so I will work on at least some of that first, while the ideas are fresh.1 point
-
@n3wbie Here is some reading material for you which might be helpful. https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation https://en.wikipedia.org/wiki/Salt_(cryptography)1 point
-
Looking at your script and its output, it appears that you are still trying to get a good grasp of how to process XML nodes and how to get individual values. Personally, I find it much easier and faster to work with the actual XML DOM objects than to use XML UDF's. Plus, there's a lot less overhead. Below, you will find an example that produces the exact same array as my xml2json example above. Of course it could have been done in several different ways. I just chose to do it that way because it uses the exact same logic as what I used in the previous XML2JSON example. As you can see, working with the XML DOM objects is not that much different than using some of the XML UDF's. As you can also see, if you just need to get information from an XML file, the script using the xml2json method is far less code and much easier to create, modify and maintain. I hope the example helps you understand some of the concepts related to XML node processing. Example using XML DOM objects: #AutoIt3Wrapper_AU3Check_Parameters=-w 3 -w 4 -w 5 -w 6 -d #include <Constants.au3> #include <Array.au3> Const $gkXML = _ '<?xml version="1.0" encoding="UTF-8"?>' & _ '<gpx>' & _ ' <metadata>' & _ ' <name>Some name</name>' & _ ' </metadata>' & _ ' <trk>' & _ ' <name>Track 1</name>' & _ ' <trkseg>' & _ ' <trkpt lat="48.81782" lon="2.24906">' & _ ' <ele>123</ele>' & _ ' <time>Dummy time</time>' & _ ' </trkpt>' & _ ' <trkpt lat="48.81784" lon="2.24906">' & _ ' <ele>456</ele>' & _ ' </trkpt>' & _ ' </trkseg>' & _ ' </trk>' & _ ' <trk>' & _ ' <name>Track 2</name>' & _ ' <trkseg>' & _ ' <trkpt lat="48.81782" lon="2.24906">' & _ ' <ele>321</ele>' & _ ' </trkpt>' & _ ' <trkpt lat="48.81784" lon="2.24906">' & _ ' <ele>654</ele>' & _ ' </trkpt>' & _ ' </trkseg>' & _ ' </trk>undefinedundefinedundefined' & _ '</gpx>' xml_example() Func xml_example() Local $oComErr = ObjEvent("AutoIt.Error", "com_error_handler") #forceref $oComErr Local $oTrackNodes = Null, _ $oTrackPointNodes = Null Local $sTrackName = "" Local $aTrackPoints[0][5] With ObjCreate("Msxml2.DOMDocument.6.0") ;Load XML document object from the string .PreserveWhitespace = True .loadXML($gkXML) If .parseError.errorCode Then Exit MsgBox($MB_ICONERROR + $MB_TOPMOST, "XML PARSING ERROR", .parseError.reason) ;Select all track nodes $oTrackNodes = .selectNodes('//trk') If Not IsObj($oTrackNodes) Then Return MsgBox($MB_ICONERROR, "Error", "No track nodes found." & @error) ;For each track node For $oTrackNode in $oTrackNodes ;Save track name $sTrackName = $oTrackNode.selectSingleNode("./name").text ;Select all child segment track points $oTrackPointNodes = $oTrackNode.selectNodes('./trkseg/trkpt') If Not IsObj($oTrackNodes) Then Return MsgBox($MB_ICONERROR, "Error", "No track points found." & @error) ;For each child segment track point For $oTrackPointNode in $oTrackPointNodes With $oTrackPointNode ;Add specified values to the array _ArrayAdd($aTrackPoints, _ $sTrackName & "|" & _ .getAttribute("lat") & "|" & _ .getAttribute("lon") & "|" & _ .selectSingleNode("./ele").text & "|" & _ (IsObj(.selectSingleNode("./time")) ? .selectSingleNode("./time").text : "") _ ;Handle optional node ) EndWith Next Next EndWith ;Display array _ArrayDisplay($aTrackPoints, "GPS Exchange Info", "", 0, Default, "Name|Lat|Long|Elevation|Time") EndFunc Func com_error_handler($oError) With $oError ConsoleWrite(@CRLF & "COM ERROR DETECTED!" & @CRLF) ConsoleWrite(" Error ScriptLine....... " & .scriptline & @CRLF) ConsoleWrite(" Error Number........... " & StringFormat("0x%08x (%i)", .number, .number) & @CRLF) ConsoleWrite(" Error WinDescription... " & StringStripWS(.windescription, $STR_STRIPTRAILING) & @CRLF) ConsoleWrite(" Error RetCode.......... " & StringFormat("0x%08x (%i)", .retcode, .retcode) & @CRLF) ConsoleWrite(" Error Description...... " & StringStripWS(.description , $STR_STRIPTRAILING) & @CRLF) EndWith Exit EndFunc Resulting array:1 point
-
Just saying that you need to read/modify XML & HTML (or JSON) doesn't provide enough detail to be able to suggest which tool(s) might be best for the job. The most important parts that you left out are details like what type of information are you trying to gather (values, calculations, transformations, grouping, etc.), in what format you need it, and any other constraints or restrictions that you may have. Also, the best tool for processing or reading data, may not be the best tool for modifying or writing that data. For example, you posted a simple script HERE where you seem to be trying to read (process) an XML dataset and output some values. Of course there are several ways to do it. For the sake of this example, let's assume that you wanted to gather the GPS track points from the XML dataset in order to do further processing of them, I would've probably done it something like the example below. If your XML (or JSON) datasets are large and speed is a concern, then the example below would be one of the quickest ways to process the data and generate the result. On one of my older Win 7 PC's, the small example below took about 0.003 seconds to convert the XML to JSON and about 0.055 seconds to process the JSON to get the result. The time it would take to process much larger datasets would be incremental not linear. Example based on post HERE: #AutoIt3Wrapper_AU3Check_Parameters=-w 3 -w 4 -w 5 -w 6 -d #include <Constants.au3> #include <Array.au3> #include <xml2json\xml2json.au3> ;<== Modify path as needed #include <jq\jq.au3> ;<== Modify path as needed Const $gkJqExe = "C:\Utils\jq\jq-win64.exe" ;<== Modify as needed Const $gkXML = _ '<?xml version="1.0" encoding="UTF-8"?><gpx><metadata><name>S' & _ 'ome name</name></metadata><trk><name>Track 1</name><trkseg><' & _ 'trkpt lat="48.81782" lon="2.24906"><ele>123</ele><time>Dummy' & _ ' time</time></trkpt><trkpt lat="48.81784" lon="2.24906"><ele' & _ '>456</ele></trkpt></trkseg></trk><trk><name>Track 2</name><t' & _ 'rkseg><trkpt lat="48.81782" lon="2.24906"><ele>321</ele></tr' & _ 'kpt><trkpt lat="48.81784" lon="2.24906"><ele>654</ele></trkp' & _ 't></trkseg></trk></gpx>' Const $gkJqTrackPointsFilter = _ '.gpx.trk[] #For each gpx track' & @CRLF & _ '| .name as $track_name # Save the track name' & @CRLF & _ '| .trkseg.trkpt[] # For each segment track point' & @CRLF & _ '| [$track_name, .lat, .lon, .ele, .time] # Create an array of specified values' & @CRLF & _ '| join("|") # Ouput the array as a list of |-separated-values' xml2json_jq_example() Func xml2json_jq_example() Local $sJson = "", _ $sResult = "" Local $aResult[0][5] ;Initialize jq by declaring path to exe _jqInit($gkJqExe) If @error Then Return MsgBox($MB_ICONERROR, "_jqInit Error", "@error = " & @error) ;Transform XML to JSON $sJson = _Xml2Json($gkXML) If @error Then Return MsgBox($MB_ICONERROR, "_Xml2Json Error", "@error = " & @error) ;Display JSON ConsoleWrite("Transformed Xml to JSON" & @CRLF) ConsoleWrite(_jqPrettyPrintJson($sJson) & @CRLF & @CRLF) ;Process JSON data set to get values of interest (in desired format) $sResult = _jqExec($sJson, $gkJqTrackPointsFilter) If @error Then Return MsgBox($MB_ICONERROR, "_jqExec Error", $sResult) ;Display result ConsoleWrite("jq Result" & @CRLF) ConsoleWrite($sResult & @CRLF & @CRLF) ;Add result to an array and display it _ArrayAdd($aResult, $sResult) _ArrayDisplay($aResult, "GPS Exchange Info", "", 0, Default, "Name|Lat|Long|Elevation|Time") EndFunc Console output from example: Transformed Xml to JSON { "gpx": { "metadata": { "name": "Some name" }, "trk": [ { "name": "Track 1", "trkseg": { "trkpt": [ { "lat": "48.81782", "lon": "2.24906", "ele": "123", "time": "Dummy time" }, { "lat": "48.81784", "lon": "2.24906", "ele": "456" } ] } }, { "name": "Track 2", "trkseg": { "trkpt": [ { "lat": "48.81782", "lon": "2.24906", "ele": "321" }, { "lat": "48.81784", "lon": "2.24906", "ele": "654" } ] } } ] } } jq Result Track 1|48.81782|2.24906|123|Dummy time Track 1|48.81784|2.24906|456| Track 2|48.81782|2.24906|321| Track 2|48.81784|2.24906|654| Array generated from the example: Transforming XML to JSON for processing gives you a lot more flexibility and power in gathering information from the dataset. Also, you can usually get those results much faster than parsing data using the XML DOM and then processing that parsed data in AutoIt. For the record, I can think of one or 2 rare cases where processing XML using the XML DOM would be better (not faster) than processing the XML as JSON. But as I said, those cases are rare. If you truly need to write or modify XML, then using functions that use the XML DOM (whether it's one of the xml UDF's or the COM objects themselves) is probably one of the best methods. There are tools that transform JSON to XML, but I haven't had a need to use them and haven't dug too deeply into researching their usefulness. If nothing else, the Xml2Json and jq UDF's give you more tools in your tool belt. Using the best tool(s) for the job, whichever they may be, always gets the job done more effectively and efficiently.1 point
-
1 point
-
Always on top feature
MichaelCrawley reacted to mistersquirrle for a topic
Another option if it's a GUI that you're creating is to use the ExStyle for $WS_EX_TOPMOST: #include <WindowsConstants.au3> #include <GUIConstants.au3> Global $hGui = GUICreate('Au3Gui', 200, 100, -1, -1, -1, $WS_EX_TOPMOST) GUISetState(@SW_SHOW, $hGui) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE GUIDelete($hGui) Exit EndSwitch WEnd1 point -
Usually you start a thread in the Example Scripts forum (Example: Active Directory UDF) where you describe your UDF. Post #1 usually holds a link to the latest version of your UDF. I have stored all my UDFs in the Files section of the forum, others store their work on GitHub etc. etc. Two things to consider: The number of constants. If there are only a few I simply define them in the UDF file itself. Magic numbers. It does not matter where this constants are defined. Just create this constants so they can be used in the UDF and your script. No, you should define them in a separate file when they are used by the scripter. When the constants are used internally in the UDF then you can define them in the UDF file. But his are no iron rules. I do not think it makes sense to create an additonal file for just a few constants. This problem is caused by the latest update of the forum software. I hope it can be solved in the near future. You can't. The help file that comes with AutoIt consists of the AutoIt and hte SciTE help. But you can have a look at the Simple Library Docs Generator to create a CHM file and at Advanced.Help to call this help file when the cursor is on a line calling a function of your UDF. Hope I could answer some of your questions.1 point