Leaderboard
Popular Content
Showing content with the highest reputation on 11/05/2015 in all areas
-
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
-
I have already published a lot of AutoIt UDF about algorithm, but all of them only support 32 bits or so called X86 system. Recently I got a computer with Windows 7 64 bits, so I finally added X64 support to most of my old projects. Besides, I also added some new. For example, some compression algorithm and SHA3 Candidates. Following are the algorithms list: Checksum CRC16 CRC32 ADLER32 Compression FastLZ LZF LZMA LZMAT MiniLZO QuickLZ Encode Base64 ARC4 XXTEA DES AES Hash Checksums (CRC16/CRC32/ADLER32) MD2 MD4 MD5 SHA1 SHA2 (SHA224/256/384/512) SHA3 Candidates BLAKE BMW (Blue Midnight Wish) CUBEHASH ECHO SHABAL SKEIN Some points to mention: All of the subroutines have one or more examples to demonstrate the usage. Since the function and usage of subroutine are easy to understand. A complete subroutines and parameters list are unavailability now. Sorry for my lazy. All of the subroutines here invoked by Lazycat's method (through CallWindowProc API). My MemoryDLL UDF is not necessary this time. Although MemoryFuncCall (part of MemoryDLL) is still good, but inevitably, it is slower than CallWindowProc. Some subroutines have the same name with my old machine code version UDF. But for some reason, I rearrange the position of the parameters. Please not mix up. If you notice, yes, checksums are duplicated. But they receive different parameters. One is the old style, and another use the same interface as other hashes. Choose what you like, but don't use them in the same time. Some algorithm already supported by the standard UDF "Encryption.au3". But I still provide them, because some system lack of the full support of Windows Crypt Library. If you are looking for only one hash algorithm, for example, used in encryption, I suggested "SHABAL_TINY.au3". Although it is a bit slower then SHABAL, but it is smaller, and it supports different size of output (from 32 to 512 bits).AutoIt Machine Code Algorithm Collection.zip1 point
-
Just as note: https://regex101.com/r/wW9fX3/1 closing paranthesis ....1 point
-
I don't see the point of it, at least not from the pseudo example you posted, as it is no different from... Switch $iWildInteger Case 1 MsgBox($MB_OK, "AutoIt Forums", "The value of $iWildInteger is " & 1 & '.') Case Else MsgBox($MB_OK, "AutoIt Forums", "The value of $iWildInteger is " & 2 & ' or else.') EndSwitch1 point
-
So what is stopping you from creation a LUA function in personalTools.lua in %localappdata\AutoIt v3\SciTE to do this for you with an assigned shortcut? Jos1 point
-
I've recorded a slightly different version as https://regex101.com/r/rU1iI6/1 This one scans a series of lines with IPs and select the valid LAN ones (use option 3 then to obtain the resulting array). Paste the regexp in the "tester" page and read the "explanation" text. You'll certainly agree that this text reads like pseudo-code (it is, in fact) which one can obviously translate into an ad hoc set of function calls and simple block constructs. Granted creating correct complex regexps requires a little bit of "regexp thinking" due to the particular way matching attempts work. It always helps translate the regexp goal into plain english in the "explanation" box style, then convert that into PCRE syntax. Some advanced features require good experience but this isn't breaking news. Very few AutoIt noobs don't start coding for a complex 5-GUI app using custom skin and requiring hooking dozens of cryptic Windows messages.1 point
-
Get control id on a right click.
spudw2k reacted to gottygolly for a topic
Thanks for the help man, I guess all that I needed was the $GUI_EVENT_SECONDARYUP variable. Re-made it into GUIOnEventMode form since that is what my script is in. #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Form1", 615, 438, 192, 124) Opt("GUIOnEventMode",1) GUISetOnEvent(-3,"_exit") $Button1 = GUICtrlCreateButton("Button1", 96, 72, 145, 105) $Button2 = GUICtrlCreateButton("Button2", 316, 232, 145, 105) GUISetOnEvent($GUI_EVENT_SECONDARYUP,"button") GUISetState() While 1 Sleep(10) WEnd Func _exit() Exit EndFunc Func button() $p = GUIGetCursorInfo($Form1) MsgBox(0,"","ID: "&$p[4]&@CRLF&GUICtrlRead($p[4])) EndFuncThanks for the help!1 point -
I'm not so sure: RegExps have a very precise semantics (despite a rather cryptic syntax), contrary to human spoken/writen languages which all have a fuzzy multi-level semantics and a fairly complex and often distorded syntax. Basic example: "The horse is out of the barn". This can refer to a bacteria, virus, bug or invasive plant, some news (true fact or made up rumor), a computer worm, a groundshaking secret that should never have been revealed, the launch of some marketting campaign, mission Apollo 38, an actual horse, ... It would be pretty simple to convert PCRE syntax into a series of function calls and simple structures, both comparable to, say, AutoIt. BTW, the (?x) option at the start of the regexp allows subsequent unsignificant whitespaces, only to ease reading the thing. Also the use of an internal subroutine (named byte) is handy in this use case to avoid duplication of long patterns.1 point
-
Brilliant that jchd. Thanks. If aliens visited our planet and thought our language was RegEx, I think they'd just go home without even trying to say hello.1 point
-
1 point
-
So let's try dancing: Local $aIPs = [ _ "10.0.0.0", "10.1.2.3", "10.255.255.255", _ "172.16.0.0", "172.25.1.2.3", "172.31.255.255", _ "192.168.0.0", "192.168.1.2", "192.168.255.255", _ "12.34.56.78", "123.456.789.0", "192.168.0.555" _ ] For $MyIP In $aIPs ConsoleWrite($MyIP & " is a" & (_Valid_LAN_IP($MyIP) ? " " : "n in") & "valid LAN IP address" & @LF) Next Func _Valid_LAN_IP($ip) Return StringRegExp($ip, _ "(?x) (?(DEFINE) (?<byte> 2[0-4]\d | 25[0-5] | 1\d\d | [1-9]?\d) )" & _ " ^ (" & _ " 10 (\.(?&byte)){3} | " & _ " 172 \. ( 1 [6-9] | 2\d | 3[01] ) (\.(?&byte)){2} | " & _ " 192 \. 168 (\.(?&byte)){2} | " & _ ") $") EndFunc1 point
-
I think you should do it in a loop: Global $iBegin = TimerInit() While DirGetsize("C:\check") < 104939573 Then Sleep(5000) ; Check every 5 seconds WEnd $iTime = Round((TimerDiff($begin))/1000, 2) Msgbox(0, "Time to download", $iTime & " seconds")1 point
-
Did you read this: https://www.autoitscript.com/forum/topic/157420-controlling-new-ie-windows-that-have-opened-from-clicking-links/ http://www.vbaexpress.com/forum/showthread.php?49411-What-is-Internet-Explorer_TridentDlgFrame http://www.vbforums.com/showthread.php?632962-read-text-from-IE-pop-up-window ??1 point
-
Agree in general, but it wears off a little after being here for this long ... sorry for that.1 point
-
ISN AutoIt Studio [old thread]
vinhphamvn reacted to ISI360 for a topic
Hi vinhphamvn! Here you have the latest update for the ISN AutoIt Studio. Just extract the files in the ISN AutoIt Studio directory an overwrite existing files. Click to download NOTE: This is a work in progress update!! So it´s not fully completet and tested. But it already contains a lot of UDF-8 fixes wich you can test.1 point -
Gpedit.msc silent value change
ViciousXUSMC reacted to jguinch for a topic
If I'm not mistaken, each Administrative Templates entry correspond to a registry value. Since it's a computer policy, you can write it in the HKLM\Software hive. (to find the registry entries for your need, look at RegShot utility - for example (it's a great tool for comparing 2 registry/files shots). But if you really want to modify the local policies, Jon's way seems to be the only one...1 point -
JD's Auto Speed Tester The links below are extremely out of date now, but i am using so many external files now that it's probably better to DL the proper installer although the script links below still gives you a good idea of what the script looks like. Screen Shots :- Main window (just demo data) Averages window:- Some of the Settings :- Download :- Proper up to date Installer lives HERE With this program you can set it to do regular internet speed tests in the background and it enables you to see at a glance what your speeds are doing over the course of the hour/day/week. It will generate a CSV log file and can also create JPG`s of the graph. The memory usage i have managed to get down to bellow 2MB whilst in "sleep" mode (in tray) so a very small footprint. ############################### If you want a look at one of the old scripts ########################################### Previous DL's 72 speedtester_graph_13.0.au3 hope this works ok as the finished app is built with an installer now so not %100 sure if it will work with just this part of the script, although i have tried as best i can to make sure it does if you want the config option "run on windows startup" to work you will need to compile to JDAutoSpeedTester.exe and put it into a folder called and located @ " C:\Program Files\JDast\JDAutoSpeedTester.exe " there may be a problem with non-included UDF's iv used so ill provide them (hope i haven't forgotten any) im sure you know what to do with them :- FTP_Ex.au3 ReduceMemory.au3 ###################################################################################################### JD's Clip Catch (With Screen Shot Helper) The contents of the standard Windows clipboard change as you use it to copy and paste various types of information. But your data isn't stored for a long time - when you turn off the computer or just copy another piece of information, the data is lost. In most cases, that isn't a problem, but have you ever needed the text you copied 30 minutes or an hour ago? Maybe your computer is acting up and the program you are using hasn't saved the data, or maybe you copied some interesting information from a web page, but got distracted and forgot to paste it where you wanted? Or you may simply want to recall what you were doing on your computer a month or a year ago. There are many cases in which you might want to review your clipboard contents. Well this is the solution! At any moment, you can view the clipboard history, copy the necessary item back into the Windows clipboard or paste it into an application. All you have to do is press the "Ctrl+0", "crtl+shift+up cursor" or "crtl+shift+down cursor" key combination. Add ability to hold open the edit window click "lock edit box" to be used as a quick edit area for quick note taking, editing clips before pasting, adding clips together etc.. & then when you click "unlock edit box" it will save this new edit to the captured list for use whenever u need. also quick screen capture if you press "print screen" keyboard button the pic is saved along with any other pic's you may have copied/cut as a .jpg in the picture folder (be aware what the max pic folder size is set to as if its set to small the pic will be deleted when you copy/cut another pic). What Can ClipCatch Do For Me? Save a lot of time, day by day Enable quick access to recently copied data for reuse Help find the data copied a day or a week ago. Take & save quick screen shots. Take very quick notes, add to , remove from etc.. & saved automatically (when "unlocking" the editbox (taking it out of note taking mode))Screen Shots of ClipCatch :- 3 other Skins of the 26 included. And the most helpful bit, the quick clip box looks something like this (dependent on users skin & Transparency choice). DOWNLOAD :- Update 28/08/10 Now with skins & and an installer ! (p.s. Must add a thx to Valuater for his XSkin UDF contribution ) Clip Catch 4.3 ############################### If you want a look at one of the old scripts ########################################### update 06/06/09 Previous Number DL's 29 Clip_catch_3.8.au3 ###################################################################################################### Default keys:- ctrl+0 ______________ (zero, not number pad) show/hide main windows.ctrl+9_______________Quick note:- take a quick notes, mix clips. auto saved to the captured listctrl+8_______________Screen Shot with focus control (ver 3.3+) (main windows do NOT need to be open to do this)ctrl+shift+up cursor ___ scroll backward through captured clips (main windows do NOT need to be open to do this, & clipboard will hold whatever clip was last displayed so you can directly Ctrl+V paste)ctrl+shift+down _______scroll forward through captured clips (main windows do NOT need to be open to do this, & clipboard will hold whatever clip was last displayed so you can directly Ctrl+V paste)ctrl+shift+right ________When you have a picture in the quick clip box this key combo will change it from pasting the path of the picture to the actual picture itself (like pasting into paint).ctrl+shift+left _________When you have a picture in the quick clip box this key combo will change it from pasting the picture to the actual path to the picture.26/05/09 ver 3.5 Have now added the ability for the user to set the hot keys they wish to use. Also improved the Freehand Screen shot section. Again this does normally have an installer but im sure it will work ok. if you want the option "run on windows startup" to work you will need to compile JDClipCatch.exe and put it into a folder called and located @ " C:\Program Files\JDClipCatch\JDClipCatch.exe " iv been scripting for a little while and i know my scripts are most probably pretty messy but any input from you guys is always appreciated1 point
-
In my new program, I need custom buttons of system dialog. After search on the internet, I found the way. Instead of using GUICreate, this code just hook the system dialog. The hook type is WH_CBT, See MSDN for more information. Except button text, is there any other interesting thing can be modified ? ; ============================================================================= ; MsgBoxEx And InputBoxEx Examples ; Purpose: Custom Buttons Of System Dialog ; Author: Ward ; ============================================================================= #Include <WinAPI.au3> MsgBoxEx("Button1|Button2", 1, "MsgBoxEx", "Test") MsgBoxEx("|Button3||||Button1|Button2", 3, "MsgBoxEx", "Test") InputBoxEx("Button1|Button2", "InputBoxEx", "Prompt") Func MsgBoxEx($CustomButton, $Flag, $Title, $Text, $Timeout = 0, $Hwnd = 0) Assign("MsgBoxEx:CustomButton", $CustomButton, 2) Local $CBT_ProcCB = DllCallbackRegister("MsgBoxEx_CBT_Proc", "long", "int;hwnd;lparam") Local $CBT_Hook = _WinAPI_SetWindowsHookEx($WH_CBT, DllCallbackGetPtr($CBT_ProcCB), 0, _WinAPI_GetCurrentThreadId()) Local $Ret = MsgBox($Flag, $Title, $Text, $Timeout, $Hwnd) Local $Error = @Error _WinAPI_UnhookWindowsHookEx($CBT_Hook) DllCallbackFree($CBT_ProcCB) Assign("MsgBoxEx:CustomButton", 0, 2) Return SetError($Error, 0, $Ret) EndFunc Func MsgBoxEx_CBT_Proc($nCode, $wParam, $lParam) If $nCode = 5 Then ; HCBT_ACTIVATE Local $CustomButton = StringSplit(Eval("MsgBoxEx:CustomButton"), "|") For $i = 1 To $CustomButton[0] ControlSetText($wParam, "", $i, $CustomButton[$i]) Next EndIf Return _WinAPI_CallNextHookEx(0, $nCode, $wParam, $lParam) EndFunc Func InputBoxEx($CustomButton, $Title, $Prompt, $Default = "", $Password = "", $Width = Default, $Height = Default, $Left = Default, $Top = Default, $Timeout = Default, $Hwnd = Default) Assign("InputBoxEx:CustomButton", $CustomButton, 2) Local $CBT_ProcCB = DllCallbackRegister("InputBoxEx_CBT_Proc", "long", "int;hwnd;lparam") Local $CBT_Hook = _WinAPI_SetWindowsHookEx($WH_CBT, DllCallbackGetPtr($CBT_ProcCB), 0, _WinAPI_GetCurrentThreadId()) Local $Ret = InputBox($Title, $Prompt, $Default, $Password, $Width, $Height, $Left, $Top, $Timeout, $Hwnd) Local $Error = @Error _WinAPI_UnhookWindowsHookEx($CBT_Hook) DllCallbackFree($CBT_ProcCB) Assign("InputBoxEx:CustomButton", 0, 2) Return SetError($Error, 0, $Ret) EndFunc Func InputBoxEx_CBT_Proc($nCode, $wParam, $lParam) If $nCode = 5 Then ; HCBT_ACTIVATE Local $CustomButton = StringSplit(Eval("InputBoxEx:CustomButton"), "|") For $i = 1 To $CustomButton[0] ControlSetText($wParam, "", $i, $CustomButton[$i]) Next EndIf Return _WinAPI_CallNextHookEx(0, $nCode, $wParam, $lParam) EndFunc1 point
-
Multiple mouse cursor - (Locked)
xdelage reacted to TheLaughingMan for a topic
HotKeySet("{ESC}", "_exit") HotKeySet("{F10}", "_secondMouse") $mouse = MouseGetPos() $dll = DllOpen("user32.dll") $toggle = 0 #include <Misc.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> #include <StaticConstants.au3> $MiceX2 = GUICreate("MiceX2", 184, 92, 192, 124) $xDistanceInput = GUICtrlCreateInput("200", 128, 0, 49, 21) $xInfoLabel = GUICtrlCreateLabel("X Distance from Mouse", 8, 4, 114, 17) $yInfoLabel = GUICtrlCreateLabel("Y Distance from Mouse", 8, 28, 114, 17) $yDistanceInput = GUICtrlCreateInput("0", 128, 24, 49, 21) $hotkeyInfo1 = GUICtrlCreateLabel("Start = F10", 16, 48, 83, 17) $hotkeyInfo1 = GUICtrlCreateLabel("Stop = F9", 16, 64, 83, 17) $hotkeyInfo2 = GUICtrlCreateLabel("Exit = ESC", 16, 78, 54, 17) GUISetState(@SW_SHOW) Opt("GUIOnEventMode", 1) ; Change to OnEvent mode GUISetOnEvent($GUI_EVENT_CLOSE, "_exit") _load() While 1 Sleep(100) WEnd Func _secondMouse() While 1 Sleep(25) $mouse = MouseGetPos() ToolTip("^", $mouse[0] + GUICtrlRead($xDistanceInput) - 10, $mouse[1] + GUICtrlRead($yDistanceInput)) If _IsPressed("01", $dll) Then _mouseClick() If _IsPressed("1B", $dll) Then _save() Exit EndIf If _IsPressed("78", $dll) Then ToolTip("") ExitLoop EndIf WEnd EndFunc ;==>_secondMouse Func _mouseClick() ToolTip("") MouseUp("left") MouseMove($mouse[0] + GUICtrlRead($xDistanceInput), $mouse[1] + GUICtrlRead($yDistanceInput), 0) MouseDown("left") Sleep(50) MouseUp("left") MouseMove($mouse[0], $mouse[1], 0) ToolTip("^", $mouse[0] + GUICtrlRead($xDistanceInput), $mouse[1] + GUICtrlRead($yDistanceInput)) EndFunc ;==>_mouseClick Func _exit() DllClose($dll) _save() Exit EndFunc ;==>_exit Func _save() IniWrite(@ScriptDir & "\MouseX2.ini", "Distance", "X", GUICtrlRead($xDistanceInput, 1)) IniWrite(@ScriptDir & "\MouseX2.ini", "Distance", "Y", GUICtrlRead($yDistanceInput, 1)) EndFunc ;==>_save Func _load() GUICtrlSetData($xDistanceInput, IniRead(@ScriptDir & "\MouseX2.ini", "Distance", "X", "200")) GUICtrlSetData($yDistanceInput, IniRead(@ScriptDir & "\MouseX2.ini", "Distance", "Y", "0")) EndFunc ;==>_load Tested it on two windows of Paint, and it works well1 point