Leaderboard
Popular Content
Showing content with the highest reputation on 03/30/2021 in all areas
-
.. I do however think there should be some sort of support for deleting array entries in the UDF and we probably could even include it in the objdelete() UDF by testing whether the supplied variable is an Obj or Array....agree? ... so basically combining the existing with your logic. Jos2 points
-
Introduction JSON (Javascript Object Notation) is a popular data-interchange format and supported by a lot of script languages. On AutoIt, there is already a >JSON UDF written by Gabriel Boehme. It is good but too slow, and not supports unicode and control characters very well. So I write a new one (and of course, fast one as usual). I use a machine code version of JSON parser called "jsmn". jsmn not only supports standard JSON, but also accepts some non-strict JSON string. See below for example. Important Update!! I rename the library from jsmn.au3 to json.au3. All function names are changed, too. Decoding Function Json_Decode($Json) $Json can be a standard or non-standard JSON string. For example, it accepts: { server: example.com port: 80 message: "this looks like a config file" } The most JSON data type will be decoded into corresponding AutoIt variable, including 1D array, string, number, true, false, and null. JSON object will be decoded into "Windows Scripting Dictionary Object" retuned from ObjCreate("Scripting.Dictionary"). AutoIt build-in functions like IsArray, IsBool, etc. can be used to check the returned data type. But for Object and Null, Json_IsObject() and Json_IsNull() should be used. If the input JSON string is invalid, @Error will be set to $JSMN_ERROR_INVAL. And if the input JSON string is not finish (maybe read from stream?), @Error will be set to $JSMN_ERROR_PART. Encoding Function Json_Encode($Data, $Option = 0, $Indent = "\t", $ArraySep = ",\r\n", $ObjectSep = ",\r\n", $ColonSep = ": ") $Data can be a string, number, bool, keyword(default or null), 1D arrry, or "Scripting.Dictionary" COM object. Ptr will be converted to number, Binary will be converted to string in UTF8 encoding. Other unsupported types like 2D array, dllstruct or object will be encoded into null. $Option is bitmask consisting following constant: $JSON_UNESCAPED_ASCII ; Don't escape ascii charcters between chr(1) ~ chr(0x1f) $JSON_UNESCAPED_UNICODE ; Encode multibyte Unicode characters literally $JSON_UNESCAPED_SLASHES ; Don't escape / $JSON_HEX_TAG ; All < and > are converted to \u003C and \u003E $JSON_HEX_AMP ; All &amp;amp;amp;s are converted to \u0026 $JSON_HEX_APOS ; All ' are converted to \u0027 $JSON_HEX_QUOT ; All " are converted to \u0022 $JSON_PRETTY_PRINT ; Use whitespace in returned data to format it $JSON_STRICT_PRINT ; Make sure returned JSON string is RFC4627 compliant $JSON_UNQUOTED_STRING ; Output unquoted string if possible (conflicting with $JSMN_STRICT_PRINT) Most encoding option have the same means like PHP's json_enocde() function. When $JSON_PRETTY_PRINT is set, output format can be change by other 4 parameters ($Indent, $ArraySep, $ObjectSep, and $ColonSep). Because these 4 output format parameters will be checked inside Jsmn_Encode() function, returned string will be always accepted by Jsmn_Decode(). $JSON_UNQUOTED_STRING can be used to output unquoted string that also accetped by Jsmn_Decode(). $JSON_STRICT_PRINT is used to check output format setting and avoid non-standard JSON output. So this option is conflicting with $JSON_UNQUOTED_STRING. Get and Put Functions Json_Put(ByRef $Var, $Notation, $Data, $CheckExists = False) Json_Get(ByRef $Var, $Notation) These functions helps user to access object or array more easily. Both dot notation and square bracket notation can be supported. Json_Put() by default will create non-exists objects and arrays. For example: Local $Obj Json_Put($Obj, ".foo", "foo") Json_Put($Obj, ".bar[0]", "bar") Json_Put($Obj, ".test[1].foo.bar[2].foo.bar", "Test") Local $Test = Json_Get($Obj, '["test"][1]["foo"]["bar"][2]["foo"]["bar"]') ; "Test" Object Help Functions Json_ObjCreate() Json_ObjPut(ByRef $Object, $Key, $Value) Json_ObjGet(ByRef $Object, $Key) Json_ObjDelete(ByRef $Object, $Key) Json_ObjExists(ByRef $Object, $Key) Json_ObjGetCount(ByRef $Object) Json_ObjGetKeys(ByRef $Object) Json_ObjClear(ByRef $Object) These functions are just warps of "Scripting.Dictionary" COM object. You can use these functions if you are not already familiar with it. == Update 2013/05/19 == * Add Jsmn_Encode() option "$JSMN_UNESCAPED_ASCII". Now the default output of Json_Encode() is exactly the same as PHP's json_encode() function (for example, chr(1) will be encoded into u0001). $JSON_UNESCAPED_ASCII ; Don't escape ascii charcters between chr(1) ~ chr(0x1f) == Update 2015/01/08 == * Rename the library from jsmn.au3 to json.au3. All function names are changed, too. * Add Json_Put() and Json_Get() * Add Null support * Using BinaryCall.au3 to loading the machine code. == Update 2018/01/13== (Jos) * Add JsonDump() to list all Json Keys and their values to easily figure out what they are. == Update 2018/10/01== (Jos) * Fixed JsonDump() some fields and values were not showing as discussed here - tnx @TheXman . == Update 2018/10/01b== (Jos) * Added Json_ObjGetItems, Tidied source and fixed au3check warnings - tnx @TheXman . == Update 2018/10/28== (Jos) * Added declaration for $value to avoid au3check warning - tnx @DerPensionist == Update 2018/12/16== (Jos) * Added another declaration for $value to avoid au3check warning and updated the version at the top - tnx @maniootek == Update 2018/12/29== (Jos) * Changed Json_ObjGet() and Json_ObjExists() to allow for multilevel object in string. == Update 2019/01/17== (Jos) * Added support for DOT notation in JSON functions. == Update 2019/07/15== (Jos) * Added support for reading keys with a dot inside when using a dot as separator (updated) == Update 2021/11/18== (TheXman) * Update details in below post: == Update 2021/11/20== (TheXman) * Minor RegEx update, no change to the functionality or result._Json(2021.11.20).zip1 point
-
Notify - New version 17 Mar 22
pixelsearch reacted to Melba23 for a topic
[NEW VERSION] - 17 Mar 22 Added: A new function _Notify_Size which allows you to adjust the size of the notification from its default 160x40. Please read the function header to see the max/min sizes that you can set for the width and height - the function returns informative @error/@extended values if these are not respected. Regardless of the size set, each notification will still display only 2 lines of text with the size of font used set automatically by the UDF. New UDF in the zip below. Previous changes: Changelog.txt A while ago I was asked to help port an AHK UDF to AutoIt. This was not too difficult and I found it useful myself (as a replacement for ConsoleWrite when debugging compiled scripts among other things). I have been polishing it for a while and thought I might release it in case it proves useful to anyone else. The notifications produced by Notify are small 2-line boxes that pop out of the edge of the display one above the other (you can select which side and in which direction they appear) - you can have as many as you want although only as many as can fit on your display will appear, the others will appear as soon as there is room. You can select whether they will retract after a certain time and/or when clicked. Colours and font are user-definable, and you can add an icon or image (bmp, jpg, gif or png) if you wish. When a notification retracts, the others move to leave space for more (you can select a smoooth slide or an instant move) - run the examples to see them in action. If you find the default sizing of the notifications is not to your liking you can change it by amending these values in the UDF (lines #354-356): ; Set default auto-sizing Notify dimensions Local $iNotify_Width_max = 300 Local $iNotify_Width_min = 150 Local $iNotify_Height = 40 A zip containing the UDF, example scripts and my StringSize UDF (which is also required): Notify.zip As usual happy for comments and/or compliments. M231 point -
Computer Plucker is a fork and a "restoration" of Computer stats utility by @Rogue5099 (link) You can obtain various data about local machine, as from the screenshot. But my goal is not (only) to provide another PC stats tool, but to develop a very basic remote inventory tool, like (a small subset of) the abandoned Spiceworks or the Microsoft SCCM. So this script can be deployed on a machine as a standalone executable (yes you need only ONE file to distribute) , and launching the .EXE it installs itself to a folder (es. c:\autoit\computerplucker) In tools menù you can set two tasks and not only one for creating every week a file.ini with all the data of the machine. another one for creating every week a file.ini with all the data of the machine PLUS uploading a CRYPTED record of the machine in a free mysql DB online For my needs, I am deploying the .exe and schedule the second task, uploading data one time a week. In tools menù you will find also commands for: manual creating the .ini data file to upload the data in crypted records to upload the data in clear text records (for testing..) total uninstall of ComputerPlucker, with a simple security code. many other tasks in not so logical order.. next version I have to tidy the menù... So my plan is to deploy this on my machines, and have the data in a online DB, this DB will be for me only a "cache" for data records to be downloaded (and deleted) by another script. As today the account of this TEST DB is embedded in code, using the "File to Base64 String' Code Generator" by @UEZ (used also for embedding icons and XML task definitions) Local $mysqlhost = "sql11.freemysqlhosting.net" Local $mysqlport = "3306" Local $mysqldb = "sql11403701" Local $mysqluser = "sql11403701" Local $mysqlpsw = "QtL7T9U5GV" The DB is one table of 30 mysql tinytext fields... very simple indeed... You can try to upload data to this DB and access (phpmyadmin or a random mysql browser app) to see the results. Or you can use my ComputerPluckerDBbrowser (see at the end of this post) a script to collect and manage the data. PRIVACY warning: you are uploading data of your PC account and PC data, test as your risk (or test in another account...) I also created a small post in a blog for not so geek friends, and I have a more advanced version of the data browser, you can have more info lookin' here. 😀 Attached you will find the code, and all the necessary includes are at this >link<. ComputerPlucker.EXE is downloadable >HERE< ComputerPluckerDBbrowser.EXE is downloadable >HERE< ComputerPluckerDBbrowser_LITE.au3 ComputerPlucker.au31 point
-
Send barcode input to 2 different applications
TheXman reacted to FrancescoDiMuro for a topic
Hi @rbabler, and to the AutoIt forum Here we can assist you with your script, but to get you started, you may look at Excel UDF (list of functions here) to automate the Excel part, and IE UDF or WebDriver UDF to deal with the webpage. You'll find a lot of examples which you can play with, so, just modify and test them to see if they fit your needs. If you have any question or issue with your script, please don't be afraid and post it with the related question(s)1 point -
Passing argument to a running AutoIT EXE - (Moved)
argumentum reacted to OhBobSaget for a topic
@argumentum Oh that is nice then if i don't need SQLLite and all the DB handling. I will try the last @nine solution and yours and see what i prefer Will report soon Again, thanks for your good ideas1 point -
A Non-Strict JSON UDF (JSMN)
argumentum reacted to TheXman for a topic
Now you are starting to get into the differences between JSON parsers, like jsmn which this UDF is based on, and JSON processors like jq. Parsers are great for getting and, sometimes, putting specific pieces of data. Although JSON processors have the ability to parse data too, they excel when it comes to manipulating JSON, such as in the case of deleting, adding, inserting, splicing, splitting, reformatting, and other functions changing JSON data and its structures as well as gathering information from JSON datasets by summing, averaging, and gathering other types of information from complete JSON datasets. For most people, parsing is all they need (or think they need). But for those that really work with JSON datasets, parsers are not powerful enough for most tasks, and that is where processors shine. I think it would be great to add processor-type functionality to the json.au3 library. But jsmn was not really designed for processing JSON. So trying to take the json.au3 library from a great JSON parser to a great JSON processor would be a interesting and fun project. But it is a whole different ballgame. 😉1 point -
How to get variable value with 'document.parentwindow.execScript'?
Letraindusoir reacted to Nine for a topic
IDK. Since it works for me. Try different value of emulation ? ; IE11 edge mode: 11001 (0x2AF9) ; IE11: 11000 (0x2AF8) ; IE10: 10001 (0x2711) ; IE10: 10000 (0x02710) ; IE 9: 9999 (0x270F) ; IE 9: 9000 (0x2328) ; IE 8: 8888 (0x22B8) ; IE 8: 8000 (0x1F40) ; IE 7: 7000 (0x1B58)1 point -
How to get variable value with 'document.parentwindow.execScript'?
Letraindusoir reacted to Nine for a topic
Eval is not working anymore with ObjCreate("InternetExplorer.Application"). Here's another way : #include <Constants.au3> #include <IE.au3> #include <Array.au3> Example2() Func Example2 () Local $hGUI = GUICreate("Browser", @DesktopWidth / 2, @DesktopHeight / 2) ;GUISetState() ;Show GUI Global $oIE = ObjCreate("Shell.Explorer.2") $hIE = GUICtrlCreateObj($oIE, 0, 0, @DesktopWidth / 2, @DesktopHeight / 2) $oIE.navigate('about:blank') $arr = StringSplit($oIE.Document.parentWindow.eval('function tt() {var fruits = [];fruits[0] = "pear";fruits[1] = "peach";' & _ 'fruits[2] = "pineapple";fruits[3] = "strawberry"; return fruits[0]+"|"+fruits[1]+"|"+fruits[2]+"|"+fruits[3];}; tt();'), "|", $STR_NOCOUNT) _ArrayDisplay($arr) EndFunc1 point -
If that question was directed towards me: Although I would rarely disagree that additional, relevant, functionality is a good thing, adding functionality to a UDF library when that functionality already exists seems a bit unnecessary and duplicative. JSON arrays are still just arrays. There's already a very effective UDF that deletes array entries, _ArrayDelete(). What would be the benefit of the json.au3 file having its own function that basically does the same thing? Furthermore, how would you implement it in this case where it may have multiple criteria for the selection of an item that needs to be deleted? I mean I know it can be done, but is it really worth the effort when there is already a whole UDF library dedicated to array maintenance and manipulation? This was just my off-the-cuff opinion. If I have misunderstood the direction or tenor of your question, please forgive me.1 point
-
Problems after upgrading to Windows 10
argumentum reacted to Dana for a topic
It looks like running the program as admin and turning off UAC fixed it. Still not clear why that would cause a random failure like this, unless something (Excel integration?) was just on the hairy edge of timing out. A little over 1000 cycles with no error last night and this morning. I'm using Excel so others can find and view the data without having to worry about the import options.1 point -
@TheOne23 Yes... It's called _WD_UpdateDriver and you should be able to find some examples of proper usage on the forum.1 point
-
I took the initiative and create a free account that anyone can use for testing xMatters. Details are -- https://autoittester.xmatters.com/ User - Autoit Password - Tester So, now you should be able to supply a script that anyone can run to observe the outcome.1 point
-
Uploaded a new version of the SciTE4AutoIt3.exe v21.316.1639.1
seadoggie01 reacted to Jos for a topic
This would have to be a proposal to the original version a SciTE, which I use to create our version, as I don't want to make too many changes in the core source. Jos1 point -
My earlier code had a typo (execScript vs ExecuteScript). Once you fix that, the code will run like I posted as long as the page already uses jQuery. If not, then run _jQuerify first. Here's an example using the first HTML file you posted, which doesn't load jQuery by default -- #include <ie.au3> Local $oIE = _IECreate(@ScriptDir & "\test.htm") _jQuerify($oIE) $ss = '$(function(){$("li").each(function(index,element){$(element).css("opacity",(index+1)/10);$(element).css("border","5px solid red");})});' $oIE.document.parentwindow.execScript($ss) ; #FUNCTION# ==================================================================================================================== ; Name ..........: _jQuerify ; Description ...: ; Syntax ........: _jQuerify(Byref $oIE) ; Parameters ....: $oIE - Object variable of an InternetExplorer.Application. ; Return values .: an object variable pointing to the jQuery library ; Author ........: Chimp ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: ; =============================================================================================================================== Func _jQuerify(ByRef $oIE) Local $jsEval, $jQuery, $otherlib = False ; create a reference to the javascript eval() function $oIE.document.parentWindow.setTimeout('document.head.eval = eval', 0) Do Sleep(250) $jsEval = Execute('$oIE.Document.head.eval') Until IsObj($jsEval) ; if jQuery is not already loaded then load it If $jsEval("typeof jQuery=='undefined'") Then ; check if the '$' (dollar) name is already in use by other library If $jsEval("typeof $=='function'") Then $otherlib = True Local $oScript = $oIE.document.createElement('script'); $oScript.type = 'text/javascript' ; If you want to load jQuery from a disk file use the following statement ; where i.e. jquery-1.9.1.js is the file containing the jQuery source ; (or also use a string variable containing the whole jQuery listing) ;~ $oScript.TextContent = FileRead(@ScriptDir & "\jquery-1.9.1.js") ; <--- from a file ; If you want to download jQuery from the web use this statement $oScript.src = 'https://code.jquery.com/jquery-latest.min.js' ; <--- from an url $oIE.document.getElementsByTagName('head').item(0).appendChild($oScript) Do Sleep(250) Until $jsEval("typeof jQuery == 'function'") EndIf Do Sleep(250) $jQuery = $jsEval("jQuery") Until IsObj($jQuery) If $otherlib Then $jsEval('jQuery.noConflict();') Return $jQuery EndFunc ;==>_jQuerify1 point
-
Button doesn't work over an image
behdadsoft reacted to BrewManNH for a topic
Dog ate your help file?1 point