Leaderboard
Popular Content
Showing content with the highest reputation on 07/18/2020 in all areas
-
I built my own libcurl for AutoIt based on BinaryCall UDF. libcurl - the multiprotocol file transfer library The Features: Pure AutoIt script, no DLLs needed.Build with SSL/TLS and zlib support (without libidn, libiconv, libssh2).Full easy-interface and partial multi-interface support.Data can read from or write to autoit variables or files.Smaller code size (compare to most libcurl DLL).The version information of this build: Curl Version: libcurl/7.42.1SSL Version: mbedTLS/1.3.10Libz Version: 1.2.8Protocols: ftp,ftps,http,httpsHere are the helper functions (not include in libcurl library). Curl_DataWriteCallback()Curl_DataReadCallback()Curl_FileWriteCallback()Curl_FileReadCallback()Curl_Data_Put()Curl_Data_Get()Curl_Data_Cleanup()See the example script for detail usage. Curl.zip1 point
-
No proxy. No firewall (beside win7). If it was a proxy/FW issue, shouldn't it fail with InetRead too ? I did your test with Win10 machine and it is working fine under the same local network. It seems it is the Win7 machine that has the problem. Maybe bad winhttp.dll ? I tried to explicitly open port 443 in FW without success. I tried running x64 same issue. Edit : Well I am quite lost now, I tested your script on multiple sites (Microsoft, autoit, google, yahoo, etc.) and they all work well. I couldn't find another site where it is not working except github. ReEdit : I converted your script into ObjCreate("WinHttp.WinHttpRequest.5.1"). And the exact phenomenon happens. I can read any site beside github. It must dislike me.1 point
-
memory mapped duplicated value
argumentum reacted to faustf for a topic
the scenario is : suppose exist a application A, in this application you can create some plugin in C# (also create memory mapped file), (i just do it ) , this app every X second or millisecond (depend of net traffic day ) write a data stream (in string format) in memorymapped file , i want read it with autoit , and show in app B (app B, is writing in Autoit )1 point -
OK, then please vote for the "96h/day" bill next month, applicable to France. Yes I think it'll be a valuable addon to the existing UDF. Also it would be useful to plan a revised and faster GetData2D function which would deal with actual datatypes (NULLs), but without the extra features of the current functions (size limit, pivoting), which I doubt many people use. I'd also wish I can update unifuzz to current Unicode and add/fix some functions there. All of this needs time, sorry.1 point
-
Here's complementary code to unescape JSON strings: ; unescape escape sequences in JSON strings Func _JsonTextToString($s) $s = StringTrimLeft(StringTrimRight($s, 1), 1) $s = StringReplace($s, '\"', '"') ; unescape " $s = StringReplace($s, '\b', Chr(0x08)) ; unescape backspace $s = StringReplace($s, '\f', Chr(0x0C)) ; unescape formfeed $s = StringReplace($s, '\t', @TAB) ; unescape @TAB $s = StringReplace($s, '\n', @LF) ; unescape @LF $s = StringReplace($s, '\r', @CR) ; unescape @CR $s = Execute("'" & StringRegExpReplace($s, "\\u([[:xdigit:]]{4})", "' & ChrW(0x$1) & '") & "'") ; unescape other chars in hex form \uXXXX $s = StringRegExpReplace($s, '\\([\\/])', '$1') ; unescape \ and / last Return $s EndFunc ;==>_JsonTextToString ; escape characters in strings w.r.t all relevant RFCs. Check https://jsonformatter.curiousconcept.com/ Func _StringToJsonText($s) $s = StringRegExpReplace($s, '([\\/])', '\\$1') ; escape \ and / first $s = StringReplace($s, '"', '\""') ; escape " $s = StringReplace($s, Chr(0x08), '\b') ; escape backspace $s = StringReplace($s, Chr(0x0C), '\f') ; escape formfeed $s = StringReplace($s, @TAB, '\t') ; escape @TAB $s = StringReplace($s, @LF, '\n') ; escape @LF $s = StringReplace($s, @CR, '\r') ; escape @CR $s = Execute('"' & StringRegExpReplace($s, '([\x00-\x1F\x7F-\x9F])', '" & "\\u" & Hex(AscW("$1"), 4) & "') & '"') ; escape other ctrl chars Return '"' & $s & '"' EndFunc ;==>_StringToJson ; unescape escape sequences in JSON strings Func _JsonTextToString($s) $s = StringTrimLeft(StringTrimRight($s, 1), 1) $s = StringReplace($s, '\"', '"') ; unescape " $s = StringReplace($s, '\b', Chr(0x08)) ; unescape backspace $s = StringReplace($s, '\f', Chr(0x0C)) ; unescape formfeed $s = StringReplace($s, '\t', @TAB) ; unescape @TAB $s = StringReplace($s, '\n', @LF) ; unescape @LF $s = StringReplace($s, '\r', @CR) ; unescape @CR $s = Execute("'" & StringRegExpReplace($s, "\\u([[:xdigit:]]{4})", "' & ChrW(0x$1) & '") & "'") ; unescape other chars in hex form \uXXXX $s = StringRegExpReplace($s, '\\([\\/])', '$1') ; unescape \ and / last Return $s EndFunc ;==>_JsonTextToString Escaping function named changed for symetry. Control chars appear in console if using a "good" font (e.g. DejaVu sans mono) in UTF8 mode. Please test and report. Might end up in less confidential thread.1 point
-
Since using 3rd-party apps are not prohibited in your environment, have you looked at using CMail or SwithMail? I prefer cmail and have a UDF that wraps its functionality into a single function call. I have used CMail for several years without any issues and still use it in my scripts to this day. It can handle just about anything including STARTTLS/SMTPS, inline embedded attachments, priorities, delivery status notifications, and much more. Both are command line utility but can be easily run from scripts. Also, both are very reliable, highly functional, and easy to use. If your environment doesn't have an issue with 3rd party services, then you could look at using a service like SendGrid. If you don't foresee sending more than 100 emails a day, then it's free. It offers both a SMTP Relay and an API for sending email. I have used it in the past also. It is built for high-volume mass marketing campaigns but works just as well for the occasional email alert. It is a VERY feature-rich and reliable service and it has been around for a very long time. I'm not sure what kind of region setting is causing you so much grief but since SMTP is a standard that has been around for what seems like forever, I'm sure that whatever region issue you are encountering can be overcome. You should be able to find a single solution that meets your need or maybe have a single fail-over/backup solution. Having 4 or 5 solutions, that all do the same thing, seems a bit excessive -- but what do I know, right. Yes, you're right about time being a limiting factor. I forgot about that one. Being retired, time isn't usually something I think about much anymore. But time is a very important factor that can limit what's possible.1 point
-
Edit: the cloudflare thing for this forum went toast before I could finish updating my code yesterday. Sorry again for posting unpolished code. It should now be complete and json-compliant. I refer to https://www.json.org/json-en.html and https://jsonformatter.curiousconcept.com/ Note that this version is more respectful of DB datatypes than is _SQLiteGetTable and friends. Last point: test it extensively and report. It could be a useful addon to the SQLite UDF.1 point
-
Thanks for the reminder! Here you are (just baked, bugs lurking): ; returns the result of a select query as JSON string; @extended is row count Func _SQLite_GetTableJSON($hDB, $sSQL) If __SQLite_hChk($hDB, 1) Then Return SetError(@error, 0, $SQLITE_MISUSE) Local $hQuery Local $r = _SQLite_Query($hDB, $sSQL, $hQuery) If @error Then Return SetError(2, @error, $r) If $r <> $SQLITE_OK Then __SQLite_ReportError($hDB, "_SQLite_GetTableJSON", $sSQL) _SQLite_QueryFinalize($hQuery) Return SetError(-1, 0, $r) EndIf Local $aDataNames $r = _SQLite_FetchNames($hQuery, $aDataNames) If @error Then $iError = @error _SQLite_QueryFinalize($hQuery) Return SetError(5, $iError, $r) EndIf $iColumns = UBound($aDataNames) If $iColumns <= 0 Then _SQLite_QueryFinalize($hQuery) Return SetError(-1, 0, $SQLITE_DONE) Else For $i = 0 To $iColumns - 1 $aDataNames[$i] = _StringToJson($aDataNames[$i]) Next EndIf Local $iRval_Step, $iError, $iRval_coltype, $sResult = '{"result":[', $Rval, $iRows While True $iRval_Step = DllCall($__g_hDll_SQLite, "int:cdecl", "sqlite3_step", "ptr", $hQuery) If @error Then $iError = @error _SQLite_QueryFinalize($hQuery) $sResult = "" Return SetError(3, $iError, $SQLITE_MISUSE) ; DllCall error EndIf Switch $iRval_Step[0] Case $SQLITE_ROW $iRows += 1 $sResult &= "{" For $i = 0 To $iColumns - 1 $iRval_coltype = DllCall($__g_hDll_SQLite, "int:cdecl", "sqlite3_column_type", "ptr", $hQuery, "int", $i) If @error Then Return SetError(4, @error, $SQLITE_MISUSE) ; DllCall error $sResult &= $aDataNames[$i] & ':' Switch $iRval_coltype[0] Case $SQLITE_TYPE_INTEGER $Rval = DllCall($__g_hDll_SQLite, "int64:cdecl", "sqlite3_column_int64", "ptr", $hQuery, "int", $i) If @error Then Return SetError(3, @error, $SQLITE_MISUSE) ; DllCall error $sResult &= $Rval[0] Case $SQLITE_TYPE_TEXT $Rval = DllCall($__g_hDll_SQLite, "wstr:cdecl", "sqlite3_column_text16", "ptr", $hQuery, "int", $i) If @error Then Return SetError(3, @error, $SQLITE_MISUSE) ; DllCall error $sResult &= _StringToJson($Rval[0]) Case $SQLITE_TYPE_FLOAT $Rval = DllCall($__g_hDll_SQLite, "double:cdecl", "sqlite3_column_double", "ptr", $hQuery, "int", $i) If @error Then Return SetError(3, @error, $SQLITE_MISUSE) ; DllCall error $sResult &= $Rval[0] Case $SQLITE_TYPE_NULL $sResult &= "null" Case Else ; Blob or unknown datatype at date of writing: output hex as "0x0123456789ABCDEF..." Local $vResult = DllCall($__g_hDll_SQLite, "ptr:cdecl", "sqlite3_column_blob", "ptr", $hQuery, "int", $i) If @error Then Return SetError(6, @error, $SQLITE_MISUSE) ; DllCall error Local $iColBytes = DllCall($__g_hDll_SQLite, "int:cdecl", "sqlite3_column_bytes", "ptr", $hQuery, "int", $i) If @error Then Return SetError(5, @error, $SQLITE_MISUSE) ; DllCall error Local $tResultStruct = DllStructCreate("byte[" & $iColBytes[0] & "]", $vResult[0]) $sResult &= '"' & Binary(DllStructGetData($tResultStruct, 1)) & '"' EndSwitch If $i < $iColumns - 1 Then $sResult &= "," Next $sResult &= "}," Case $SQLITE_DONE If $iRows Then $sResult = StringTrimRight($sResult, 1) $sResult &= "]}" ExitLoop Case Else _SQLite_QueryFinalize($hQuery) Return SetError(3, $iError, $iRval_Step[0]) EndSwitch WEnd _SQLite_QueryFinalize($hQuery) Return SetError(0, $iRows, $sResult) EndFunc ;==>_SQLite_GetTableJSON ; escape characters in strings w.r.t all relevant RFCs. Check https://jsonformatter.curiousconcept.com/ Func _StringToJson($s) $s = StringRegExpReplace($s, '([\\/])', '\\$1') ; escape \ and / first $s = StringReplace($s, '"', '\""') ; escape " $s = StringReplace($s, Chr(0x08), '\b') ; escape backspace $s = StringReplace($s, Chr(0x0C), '\f') ; escape formfeed $s = StringReplace($s, @TAB, '\t') ; escape @TAB $s = StringReplace($s, @LF, '\n') ; escape @LF $s = StringReplace($s, @CR, '\r') ; escape @CR $s = Execute('"' & StringRegExpReplace($s, '([\x00-\x1F\x7F-\x9F])', '" & "\\u" & Hex(AscW("$1"), 4) & "') & '"') ; escape other ctrl chars Return '"' & $s & '"' EndFunc ;==>_StringToJson Example use (cw is an advanced consolewrite for UTF8 and more): #include <SQLite.au3> Const $SQLITE_DLL = "C:\SQLite\bin\sqlite3.dll" ;<-- Change to the location of your sqlite dll ;~ Const $SQLITE_DLL = "C:\SQLite\bin\system.data.sqlite.dll" ;<-- Change to the location of your sqlite dll ; Init sqlite _SQLite_Startup($SQLITE_DLL, False, 1) If @error Then Exit MsgBox($MB_ICONERROR, "SQLite Error", "Unable to start SQLite. Check existence of DLL") ConsoleWrite("SQlite version " & _SQLite_LibVersion() & @LF & @LF) Local $hDB = _SQLite_Open() Local $sOut _SQLite_Exec($hDB, "create table T (Id integer primary key, FirstName text, LastName text, Birth text, Death text)") _SQLite_Exec($hDB, "insert into T values (10, 'Bohr', 'Niels', '1885/10/07', '1962/11/18')") _SQLite_Exec($hDB, "insert into T values (11, 'Fermi', 'Enrico', '1901/09/29', '1954/11/28')") _SQLite_Exec($hDB, "insert into T values (15, 'Albert', 'Einstein', '1879/03/14', '1955/04/18')") _SQLite_Exec($hDB, "insert into T values (19, 'Rovelli', 'Carlo', '1956/05/03', null)") _SQLite_Exec($hDB, "insert into T values (7, 'Schrödinger', 'Erwin', '1887/08/12', '1961/01/04')") _SQLite_Exec($hDB, "insert into T values (39, 'Higgs', 'Peter', '1929/05/29', null)") $sOut = _SQLite_GetTableJSON($hDB, "SELECT * from T") cw(@extended & " row" & (@extended ? "s" : "")) cw($sOut & @LF) $sOut = _SQLite_GetTableJSON($hDB, "SELECT +555555555555555 col_int, null col_null, '' col_str0, 3.1415926 col_float, -0.00031415926e117 col_floatexp, cast('xyz' as blob) col_blob, 'Árvíztűrőñ tükörfúrógépçô ŵƂǚȨǽϋϔӪӢӂ' col_str") cw(@extended & " row" & (@extended ? "s" : "")) cw($sOut & @LF) $sOut = _SQLite_GetTableJSON($hDB, "SELECT 'abc\" & Chr(0x0B) & "def'") cw(@extended & " row" & (@extended ? "s" : "")) cw($sOut & @LF) $sOut = _SQLite_GetTableJSON($hDB, "SELECT null, 0, 'aa""bb' [abc" & @TAB & "def]") cw(@extended & " row" & (@extended ? "s" : "")) cw($sOut & @LF) $sOut = _SQLite_GetTableJSON($hDB, "SELECT * from T where id = 0") cw(@extended & " row" & (@extended ? "s" : "")) cw($sOut) _SQLite_Close($hDB) _SQLite_Shutdown() Giving: SQlite version 3.32.3 6 rows {"result":[{"Id":7,"FirstName":"Schrödinger","LastName":"Erwin","Birth":"1887\/08\/12","Death":"1961\/01\/04"},{"Id":10,"FirstName":"Bohr","LastName":"Niels","Birth":"1885\/10\/07","Death":"1962\/11\/18"},{"Id":11,"FirstName":"Fermi","LastName":"Enrico","Birth":"1901\/09\/29","Death":"1954\/11\/28"},{"Id":15,"FirstName":"Albert","LastName":"Einstein","Birth":"1879\/03\/14","Death":"1955\/04\/18"},{"Id":19,"FirstName":"Rovelli","LastName":"Carlo","Birth":"1956\/05\/03","Death":null},{"Id":39,"FirstName":"Higgs","LastName":"Peter","Birth":"1929\/05\/29","Death":null}]} 1 rows {"result":[{"col_int":555555555555555,"col_null":null,"col_str0":"","col_float":3.1415926,"col_floatexp":-3.1415926e+113,"col_blob":"0x78797A","col_str":"Árvíztűrőñ tükörfúrógépçô ŵƂǚȨǽϋϔӪӢӂ"}]} 1 rows {"result":[{"'abc\\\u000Bdef'":"abc\\\u000Bdef"}]} 1 rows {"result":[{"null":null,"0":0,"abc\tdef":"aa\"bb"}]} 0 row {"result":[]} JSON doesn't support binary values; if fetched from a table, they are output as strings, e.g. "0x0123456789ABCDEF..." OTOH, SQLite has no boolean datatype, so json true and false are never used.1 point
-
speed up order by int DESC, text ASC;
Skysnake reacted to argumentum for a topic
... I was gonna use just what you said. That idea, is what brought _SQLite_FetchTypes() to life.... ..but then I thought that in the end, just like you said: "unsuspecting readers to fall into the trap", and that got me to search for more ( I could get me into a trap was one of my strong thoughts ). ...also found the use of json_object(). All this thanks to multiple tabs in the browser while testing different code on different PCs. ( I tend to act disorganized, but is all organized in my head while evaluating possibilities ) Since the JSON straight out of the query was fast, I disregarded modifying _SQLite_GetTable2d(), as adding more evaluation ( if, then , else, switch, etc. ) to the function would have made it slower. So: speed vs. practical. I chose speed. But I guess I could put together the _SQLite_GetTableJson() and share it in the forum. But it would always return: [{"name1":"value1"},{"name2":"value2"}] as I can't imagine a more flexible output. I don't know. What do you think @jchd ? Afterthought: ; #FUNCTION# ==================================================================================================================== ; Author ........: piccaso (Fida Florian), blink314 ; Modified.......: jchd ; =============================================================================================================================== Func _SQLite_GetTable2d( ... ...would you wanna have a go at it ?, ..if time permits, you are much more qualified than I am at this moment. You may take into consideration something I miss, like: should I take an INT type and return it as [{"name1":value1},{"name2":value2}] or [{"name1":"value1"},{"name2":"value2"}] ???, etc. If you don't want to code it but feel it should exist, I'll code it, but again, you are more experienced. Your move, what do you say1 point -
speed up order by int DESC, text ASC;
Skysnake reacted to argumentum for a topic
Update #2: It does "kick the heck out of anything else". Is twice as fast as PHP with MySQL/MariaDB. Tested on 2 PCs. This speed is due to getting the JSON I needed straight from SQLite with the DB in :memory:. I wanted to share this, to not leave the post with the believe that coding a whole site in AutoIt is impractical, or slower1 point -
speed up order by int DESC, text ASC;
Skysnake reacted to argumentum for a topic
I'm using MySQL but is the MariaDB flavor that comes with XAMPP. After searching with this TEXT column, I change it to CHAR(60) but to no avail. It took pretty much the same time. Then I index the heck out of it but the single indexing of both columns did not show noticeable improvement. Then I added a 21st column, with a int(11) with the date and a counter ( YYYYMMDDnn ) and that gave me the best result as is just sorting by one int. column. But, and this is a big but. The DB engine. I'd love for the implementation of the SQLite ( the UDF ), to be faster than the MySQL that comes with XAMPP, but if MS SQL is faster and as maintenance free as MySQL then I'd make the jump to MS SQL. Not the full fledged one but a "personal" or express version. Again, if SQLite is on par with these other bigger DB engines, SQLite is portable AND, that makes it beautiful in my eyes 😍 Anyways, there are so many flip-flops in a CPU. Meaning, they all are optimized code with years of development, my choice would be based in my experience and I have little. So we are biased by our own experiences and abilities. Would you care to tell me what way would you go in my case ?, no triggers or other "fancy" DB use. Just INSERT, UPDATE and SELECT. What say you ? Edit: from https:// www.sqlite.org/whentouse.html SQLite is not directly comparable to client/server SQL database engines such as MySQL, Oracle, PostgreSQL, or SQL Server since SQLite is trying to solve a different problem. SQLite does not compete with client/server databases. SQLite competes with fopen(). https://www.sqlservercentral.com/articles/single-user-performance-of-sqlite-v-sql-server is also a good read. Edit #2: I'll import the DB to SQLite, and test it. That will decide what is actually better1 point -
Hey Trashy Personally I would recommend InnoSetup for packaging a setup.exe, recommend using the Quick Start pack http://www.jrsoftware.org/isdl.php#qsp. It's extremely easy to use and will create uninstall strings, an automatic uninstaller, shortcuts to the Start Menu, Desktop (you can make this optional). This is the same software installer that AutoIT uses. With regards to Pin shortcuts to menu, it's no longer supported in Windows 10, Microsoft view the pinned areas to be personal and have made it difficult to pin items. In a company situation, you can use the PowerShell method for setting up a Windows build for deploying to staff, but would not recommend this for an installer. Just my 2 cents. Thanks1 point