Leaderboard
Popular Content
Showing content with the highest reputation on 03/03/2020 in all areas
-
Try this instead of using String*, will save you a lot of effort : #include <Constants.au3> #include <IE.au3> Opt ("MustDeclareVars", 1) Local $oIE = _IECreate() Local $sHTML = FileRead ("YourFile.html") _IEDocWriteHTML ($oIE, $sHTML) _IELoadWait ($oIE) Local $cTags = _IETagNameGetCollection ($oIE, "a") Local $sList = "", $sAtt For $oTag in $cTags $sAtt = $oTag.getAttribute("href") If $sAtt = "" Then ContinueLoop $sList &= $sAtt & @CRLF Next MsgBox ($MB_SYSTEMMODAL,"",$sList)2 points
-
Scrollbars Made Easy - New version 27 Jan 22
pixelsearch reacted to Melba23 for a topic
[New Version] - 27 Jan 22 New: The GUIScrollbar_Ex UDF now recognises Win-D and taskbar desktop clearance commands and runs the correct minimize/restore code automatically. The previous UDF _Minimize and _Restore commands have been superceded by a single _EventMonitor function which runs in the script idle loop. This is a script-breaking change, but I hope that the additional functionality is worth the small effort it will take to alter your scripts. New UDFs, examples in zip file below. Previous changes: Changelog.txt Are you bemused by scrollbars? > Do you find them too difficult to use? > Then you need the GUIScrollbars_Ex UDF! Just download the zip at the end of the post and run this short script with the UDF in the same folder. No tricky calculations, no complicated functions to master - just easy to use, accurate scrollbars with one command! [size=5]#include <guiconstantsex.au3> #include "GUIScrollbars_Ex.au3" ; Create GUI with red background $hGUI = GUICreate("Test", 500, 500) GUISetBkColor(0xFF0000, $hGUI) ; Create a 1000x1000 green label GUICtrlCreateLabel("", 0, 0, 1000, 1000) GUICtrlSetBkColor(-1, 0x00FF00) GUISetState() ; Generate scrollbars - Yes, this is all you need to do!!!!!!!!!!!!!!!!!!!! _GUIScrollbars_Generate($hGUI, 1000, 1000) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd[/size] Try it today and see how easy it is! I have been trying for some time to understand how scrollbars work and how to get them closely to match the area I want to display. After much research and headscratching I have come up with 2 UDFs which I hope will be of use to others. Apologies for the length of this post, but scrollbars are complex beasts and as I did this mainly for the less experienced user I want to make sure that they understand what is going on. The 2 UDFs are: GUIScrollbars_Ex.au3 - This gives you scrollbars sized to your GUI in one simple command - with no other includes or commands needed. The UDF is designed for those who would not normally use scrollbars because the whole process looks too complicated. It also includes a command to enable you to scroll page by page, thus making it easy to scroll to anywhere on the GUI with only simple calulations based on the values you used to create the GUIs. [New] Ability to have recalculated scrollbars on resizeable GUIs. GUIScrollbars_Size.au3 - This calculates the Page and Max numbers for the user to feed into the _GUIScrollbar_SetScrollInfoPage/Max commands. The UDF is aimed at the more experienced user and is particularly useful when you have a GUI with a dynamic scroll size (i.e. adding or subtracting controls to the scrollable area as the script runs). First, a short tutorial for those who are interested in how the scrollbars affect your GUI and what it is that the UDFs calculate: All the files mentioned here are in a downloadable zip file at the end of the post. GUIScrollbars_Size.au3 As mentioned previously, the GUIScrollbars_Size.au3 UDF is aimed at the more experienced user who wants to use the full range of _GUIScrollbar comands, but would like a quick way of getting the required Page and Max values. It uses no other include files so you will need to include GUIScrollbars.au3 yourself, as well as the necessary GUIRegisterMsg and procedures for WM_VSCROLL and WM_HSCROLL. The syntax is simple - the size of the scrollable GUI and either the handle of the GUI you have created to hold the scrollbars or the size of the one you are going to create. It returns a 6-element array including the Page and Max values for the scrollbars and factors to compensate for the "shrinkage" of the GUI if you had already drawn some controls and wished to add others. Of interest, the returned Max value is biased not to clip the edges of the GUI - reducing it by 1 makes a tighter fit but can lead to some clipping. (If that does not make sense, please see the tutorial above for more details) The Size_Example_1 script to show the UDF in action - the "Pass Size" button shows the effect of creating the scrollbars BEFORE the controls, the "Pass Handle" button shows what happens if the scrollbars are created AFTER the controls. If you do not understand why there is a difference - go and read the tutorial above ! You will need to have the GUIScrollbar_Size.au3 UDF in the same folder. Where this UDF really helps is if you have a scrollable GUI of variable size - if the number of controls varies with user selections for example. All you need to do is to rerun the UDF with the new size of the scrollable GUI and it produces a new Max value for you to use. The Size_Example_2 script shows how the function enables you to dynamically size your scrollbars depending on the number of controls required. As before it requires the GUIScrollbar_Size.au3 UDF in the same folder. -------- Now the "simple" GUIScrollbars_Ex.au3 (which is actually the more complex internally as you would expect). This UDF is intended to be the single point of call for creating scrollbars on a GUI - it will automatically add the GUIScrollbars UDF and the WM_VSCROLL and WM_HSCROLL GUIRegisterMsg commands and procedures to your script - so you need no commands other than those within the UDF itself. These commands are _GUIScrollbars_Generate and _GUIScrollbars_Scroll_Page. As you might expect, _GUIScrollbars_Generate generates scrollbars for your GUI. It is usually called AFTER you have added all the controls and all you need to use it is the GUI handle and the size of the underlying GUI you want to scroll. If you so wish, you can also decide to generate the scrollbars BEFORE the controls on the scrollable GUI, and you can choose if you want to risk not quite reaching the edge of the GUI when the scrollbars are at the maximum position. So a basic call could be as simple as: _GUIScrollbars_Generate ($hGUI, 1000, 1000) which would put scrollbars on the $hGUI window allowing a 1000x1000 underlying GUI to be displayed. _GUIScrollbars_Scroll_Page lets you scroll a page at a time. If your GUI was 200 pixels wide, you would have 1000/200 = 5 pages to scroll before reaching the edge - no need to know what the actual Page and Max values are, just use this simple division based on the number you use to draw the GUIs. So: _GUIScrollbars_Scroll_Page ($hGUI, 3) would scroll to the third page - it would display the area between 400 and 600 pixels of the full 1000 pixel width. If you ask for a page over the maximum available, you just scroll to the maximum position - asking for page 1 resets you to the origin. Ex_Example_1 shows the UDF working. You can decide whether to have both or just one scrollbar, whether to create the scrollbars before or after the controls, and whether you want the maximum scroll to be tight to the edge or leave a border. Just select the options you want - the script selects a random width and height for both the scrollbar GUI and the underlying GUI - and press the "Scroll" button to show a single page scroll down and/or right followed by a scroll to the bottom right corner of the GUI. There are labels to let you see the size of the GUI and the accuracy of the page scrolls (please read the tutorial above to understand why these are almost certainly inaccurate). The script requires the GUIScrollbars_Ex.au3 UDF in the same folder. Ex_Example_2 is a really simple example to show how easy generating scrollbars can now become! As you can see - no other includes, no GUIRegisterMsg commands, no WM_H/VSCROLL procedure functions. Just accurate scrolling and proportional thumb sizes. Ex_Example_3 shows the automatic calculation of control positions. Ex_Example_4 shows how to initiate the cursor keys to scroll the GUI as well. [New] Ex_Example_5 shows how to use the new _GUIScrollbarsEx_Resizer function. I hope these 2 UDFs are useful to AutoIt users - I certainly find them so. Here is a zip file with the UDFs and examples: Scrollbars.zip My grateful thanks to the authors of the GUIScrollbars and WinAPI UDFs for their code, some of which I have plundered. And as always I welcome constructive criticism and/or effusive congratulations. M231 point -
Apache + AutoIt = HTTPS API on AutoIt
Marc reacted to argumentum for a topic
I can TCP/IP in AutoIt, hence, make a HTTP deamon. Now, how can I HTTPS to use SSL !?? Well, Apache has this "mod_proxy.so" module that can let me have SSL and what not is in Apache. All that is needed is to tell Apache what I wanna do by editing httpd.conf . # Implements a proxy/gateway for Apache. # 1. Open /Applications/XAMPP/etc/httpd.conf # 2. Enable the following Modules by removing the # at the front of the line. # - LoadModule rewrite_module modules/mod_rewrite.so # - LoadModule proxy_module modules/mod_proxy.so # - LoadModule proxy_http_module modules/mod_proxy_http.so # # 3. Copy and Paste below to the bottom of httpd.conf # <IfModule mod_proxy.c> ProxyRequests On <Proxy *> Order deny,allow Allow from all </Proxy> ProxyVia Off ProxyPreserveHost Off ProxyPass /home/ http://127.0.0.1:84/home/ ProxyPassReverse /home/ http://127.0.0.1:84/home/ SetEnv proxy-nokeepalive 1 # ..since we are not using "keep-alive", we are using "close" </IfModule> ...et voila I'm using XAMPP ( https://www.apachefriends.org/download.html ) and this is my solution to avoid coding in PHP, as I feel more comfortable coding in AutoIt. A "muli-thread or concurrency" can be done by forking the socket ( https://www.autoitscript.com/forum/topic/199177-fork-udf-ish/ ) but responses are under 20 ms., so I feel fine with a single thread. I modified an example ( attached below ), so can try out the concept. PS: I am not an Apache guru. I just discovered this and it opens a world of possibilities. In my case, I'm thinking of an API to query SQLite PS2: I'm not gonna make Poll but do click like if you do 201673-json-http-post-serverlistener.au31 point -
Gui full of Buttons!
SkysLastChance reacted to Gianni for a topic
I don't know if it can help. <Here> I put an example of how to create a "matrix" of controls (buttons or, if desired, other controls) using a custom function. 40x40 are a lot of buttons, however here is an (quick and dirty) example using that function. The buttons created do not have a variable name for each of them, but the function returns an array where each element contains the reference to a button. I hope it will be useful to you. #include <EditConstants.au3> Example() Func Example() Local $hGui = GUICreate("Matrix of controls", 100, 100, 10, 10) ; create a matrix of controls (see function header for parameters details) Local $aMyMatrix = _GuiControlPanel("Button", 40, 40, 25, 15, 3, 75) ; resulting dimensions Local $iWidth = ($aMyMatrix[0])[11] Local $iHeight = ($aMyMatrix[0])[12] ; resize the GUI to fit buttons WinMove($hGui, '', Default, Default, $iWidth + 10, $iHeight + 10) GUISetState() ; create a "console" to view click action $hConsole = GUICtrlCreateEdit('Click any button', 3, 3, $iWidth, 70, BitOR($ES_READONLY, $ES_MULTILINE)) GUICtrlSetBkColor(-1, 0) GUICtrlSetColor(-1, 0x00FF00) GUICtrlSetFont(-1, 40, 0, 0, "Courier New") ; Main loop - check which control was clicked ; --------- Do $GUIGetMsg = GUIGetMsg() ; scan all buttons to check if one was pressed For $i = 1 To UBound($aMyMatrix) - 1 If $GUIGetMsg = $aMyMatrix[$i] Then GUICtrlSetData($hConsole, "Click on button " & $i) EndIf Next Until $GUIGetMsg = -3 ; -3 = $GUI_EVENT_CLOSE EndFunc ;==>Example ; ; #FUNCTION# ==================================================================================================================== ; Name...........: _GuiControlPanel ; Description ...: Creates a rectangular panel with adequate size to contain the required amount of controls ; and then fills it with the same controls by placing them according to the parameters ; Syntax.........: _GuiControlPanel( $ControlType, $nrPerLine, $nrOfLines, $ctrlWidth, $ctrlHeight, $xPos = 0, $yPos = 0, $xBorder, $yBorder, $xSpace = 1, $ySpace = 1) ; Parameters ....: $ControlType - Type of controls to be generated ("Button"; "Text"; ..... ; $nrPerLine - Nr. of controls per line in the matrix ; $nrOfLines - Nr. of lines in the matrix ; $ctrlWidth - Width of each control ; $ctrlHeight - Height of each control ; $xPanelPos - x Position of panel in GUI ; $yPanelPos - y Position of panel in GUI ; $xBorder - distance from lateral panel's borders to the matrix (width of left and right margin) default = 0 ; $yBorder - distance from upper and lower panel's borders to the matrix (width of upper and lower margin) default = 0 ; $xSpace - horizontal distance between the controls ; $ySpace - vertical distance between the controls ; $Group - if you want to group the controls (true or false) ; $sGrpTitle - title of the group (ignored if above is false) ; Return values .: an 1 based 1d array containing references to each control ; element [0] contains an 1d array containing various parameters about the panel ; Author ........: Gianni Addiego (Chimp) ; Modified.......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: ; =============================================================================================================================== Func _GuiControlPanel($ControlType, $nrPerLine, $nrOfLines, $ctrlWidth, $ctrlHeight, $xPanelPos = 0, $yPanelPos = 0, $xBorder = 0, $yBorder = 0, $xSpace = 1, $ySpace = 1, $Group = False, $sGrpTitle = "") Local Static $sAllowedControls = "|Label|Input|Edit|Button|CheckBox|Radio|List|Combo|Pic|Icon|Graphic|" If Not StringInStr($sAllowedControls, '|' & $ControlType & '|') Then Return SetError(1, 0, "Unkown control") Local $PanelWidth = (($ctrlWidth + $xSpace) * $nrPerLine) - $xSpace + ($xBorder * 2) Local $PanelHeight = (($ctrlHeight + $ySpace) * $nrOfLines) - $ySpace + ($yBorder * 2) Local $hGroup If $Group Then If $sGrpTitle = "" Then $xPanelPos += 1 $yPanelPos += 1 $hGroup = GUICtrlCreateGroup("", $xPanelPos - 1, $yPanelPos - 7, $PanelWidth + 2, $PanelHeight + 8) Else $xPanelPos += 1 $yPanelPos += 15 $hGroup = GUICtrlCreateGroup($sGrpTitle, $xPanelPos - 1, $yPanelPos - 15, $PanelWidth + 2, $PanelHeight + 16) EndIf EndIf ; create the controls Local $aGuiGridCtrls[$nrPerLine * $nrOfLines + 1] Local $aPanelParams[14] = [ _ $ControlType, $nrPerLine, $nrOfLines, $ctrlWidth, $ctrlHeight, _ $xPanelPos, $yPanelPos, $xBorder, $yBorder, $xSpace, $ySpace, $PanelWidth, $PanelHeight, $hGroup] For $i = 0 To $nrPerLine * $nrOfLines - 1 ; coordinates 1 based $col = Mod($i, $nrPerLine) + 1 ; Vertical position within the grid (row) $iVtab $row = Int($i / $nrPerLine) + 1 ; Horizontal position within the grid (column) $iHtab $left = $xPanelPos + ((($ctrlWidth + $xSpace) * $col) - $xSpace) - $ctrlWidth + $xBorder $top = $yPanelPos + ((($ctrlHeight + $ySpace) * $row) - $ySpace) - $ctrlHeight + $yBorder $text = $i + 1 ; "*" ; "." ; "(*)" $aGuiGridCtrls[$i + 1] = Execute("GUICtrlCreate" & $ControlType & "($text, $left, $top, $ctrlWidth, $ctrlHeight)") Next If $Group Then GUICtrlCreateGroup("", -99, -99, 1, 1) ; close group $aGuiGridCtrls[0] = $aPanelParams Return $aGuiGridCtrls EndFunc ;==>_GuiControlPanel1 point -
Here is a cleaned up version. I have altered the function name from _GDIPlus_ImageCompare to _ImageCompare_GDIPlus to better distinguish it from the standard _GDIPlus_* functions. I have also removed the time measuring. Who wants to know the duration of the comparison can set TimerInit etc. itself. I hope this meets your demands . ; This directive is not mandatory : #AutoIt3Wrapper_Au3Check_Parameters=-q -d -w 1 -w 2 -w 3 -w 4 -w 6 -w 7 #include <GDIPlus.au3> Global $g_hImg1, $g_hImg2, $g_bCompareResult, $g_iSizeMismatch _GDIPlus_Startup() $g_hImg1 = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\Pic1.jpg") $g_hImg2 = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\Pic2.jpg") $g_bCompareResult = _ImageCompare_GDIPlus($g_hImg1, $g_hImg2) $g_iSizeMismatch = @error MsgBox(BitOR(4096,64), "Report", "Compare Images = " & $g_bCompareResult & @CRLF & "Size mismatch = " & $g_iSizeMismatch) _GDIPlus_ImageDispose($g_hImg1) _GDIPlus_ImageDispose($g_hImg2) _GDIPlus_Shutdown() Func _ImageCompare_GDIPlus($hImage1, $hImage2) Local Const $iWidth = _GDIPlus_ImageGetWidth($hImage1), $iHeight = _GDIPlus_ImageGetHeight($hImage1) If ($iWidth <> _GDIPlus_ImageGetWidth($hImage2)) Then Return SetError(1, 0, False) If ($iHeight <> _GDIPlus_ImageGetHeight($hImage2)) Then Return SetError(2, 0, False) Local $tBitmapData1 = _GDIPlus_BitmapLockBits($hImage1, 0, 0, $iWidth, $iHeight, $GDIP_ILMREAD, $GDIP_PXF32ARGB) Local $tBitmapData2 = _GDIPlus_BitmapLockBits($hImage2, 0, 0, $iWidth, $iHeight, $GDIP_ILMREAD, $GDIP_PXF32ARGB) Local $iScan1 = DllStructGetData($tBitmapData1, "Scan0") Local $iScan2 = DllStructGetData($tBitmapData2, "Scan0") Local $iResult = DllCall("msvcrt.dll", "int:cdecl", "memcmp", "ptr", $iScan1, "ptr", $iScan2, "int", $iHeight * $iWidth * 4)[0] _GDIPlus_BitmapUnlockBits($hImage1, $tBitmapData1) _GDIPlus_BitmapUnlockBits($hImage2, $tBitmapData2) Return SetError(0, 0, $iResult = 0) EndFunc ;==>_ImageCompare_GDIPlus1 point
-
I would suggest a couple of things to streamline the code. You do not need to create the 2 $tPixel structures. Also $Stride is not required anymore. So use $iW*$iH*4 for the count. Save you a few lines of code. Not that I am finicky, but...well maybe I am1 point
-
Nine is right, to compare to full range of bitmap blocks you have to use $iW * $iH * $4 or DllStructGetSize($tPixel1) instead not to miss the last memory blocks in the compare functions. My formular doesn't cover the full range!1 point
-
@Larsj Thanks for pointing me in the right direction. I have to say that I did wonder about the use of StringLeft, but when that line executed without error I figured it may have been OK. Unfortunately I'm still struggling with a lot of the detail at this point. My understanding of the development process is that we need to identify and find the window, which is a "drill down" process starting from the desktop and then having identified the Window, identify the control and perform some action. When I describe it like that, it seems fairly straight-forward; but as I get into the detail I soon get lost. So looking at your code: We start with the Desktop, I understand that Then we goto the Shell_TrayWnd, I understand that Then we goto Dropbox, I don't understand that When I look at UIASpy on my system I see the following: Pane: Desktop1 Pane: Taskbar (Shell_TrayWnd) Pane: TrayNotifyWnd Pane: SysPager ToolBar Button:Dropbox 91.4.548Syncing paused Now of course if your example works and I don't have to "drill down" as I describe above that's great. But I need to understand how you worked that out. So in your example you have gone directly from the 2nd level in the "chain", to the destination Window/object (Dropbox). There are also quite a few examples that have been posted on how to use UIA. Generally I often refer to an example involving Notepad as it is a pretty "simple" app and so examples are usually straight-forward. But I'm not sure that the Notepad example is the most applicable for me in this case? My next question is probably going to be how to write the code to click on the Dropbox button; but hopefully you will be able to refer me to a more relevant example that I can use as a reference for this script. I have to say that my impression is that this UI Automation development environment that you have created - or provided access to via AutoIt - is extremely powerful. And if I can master the basics then there is a lot that can be done. But the learning curve seems a little steep. The irony is that in pseudocode what I want to do is really quite simple Left-click on Dropbox icon on the ToolBar Dropbox Window appears Left-click on Dropbox button (Access and manage your Dropbox settings) A menu will appear Which will have a number of items, one of which will either be Pause syncing Resume syncing Left-click on either menu item which is present It is quite simple and at this stage I have no idea how to do it. Cheers VW1 point
-
Grab all URLs in "a href" tags from local file to array
FrancescoDiMuro reacted to mikell for a topic
You're joking I presume This is a typical example on "how to use regular expressions" #Include <Array.au3> $txt = FileRead("test.html") $res = StringRegExp($txt, 'a href="(h[^"]+)', 3) _ArrayDisplay($res) But the try using _StringBetween in post #1 was not so bad ...1 point -
@Musashi Why are you leaving out the last four bytes of the structure ? It should be : DllCall("msvcrt.dll", "int:cdecl", "memcmp", "ptr", $iScan1, "ptr", $iScan2, "int", $iH * $iW * 4) ; or another way DllCall("msvcrt.dll", "int:cdecl", "memcmp", "ptr", $iScan1, "ptr", $iScan2, "int", DllStructGetSize($tPixel1))1 point
-
Here are 3 code snippets. The first will create a sample DB with 10 years of recordings for 3 devices polled every 15' and varying tempratures. It takes about 3 minutes to run, produce about 1M rows (~59Mb DB). #include <SQLite.au3> Local Const $SQLITE_DLL = "C:\SQLite\bin\sqlite3.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) Local $hDB = _SQLite_Open("temper.sq3") Local $s = "CREATE TABLE if not exists Data (Id INTEGER PRIMARY KEY not null, Stamp int not null default (strftime('%s','now')), Device int not null, Value real not null);" & _ "CREATE INDEX if not exists ixDataDeviceStamp ON Data (Stamp, Device);" & _ "CREATE INDEX if not exists ixDataStampDevice ON Data (Device, Stamp);" _SQLite_Exec($hDB, $s) _SQLite_SetTimeout($hDB, 3600000) Local Const $iDevices = 3 Local $Stamp = "2010-01-01 00:00:00", $Stop = "2020-03-01 00:00:00" Local $aRefTemp[$iDevices] = [23.2, 39.4, 46.1], $aTemp = $aRefTemp _SQLite_Exec($hDB, "begin immediate") Do _SQLite_Exec($hDB, "insert into Data (Stamp, Device, Value) values " & _ "(strftime('%s', '" & $Stamp & "'), 1, " & $aTemp[0] & "), " & _ "(strftime('%s', '" & $Stamp & "'), 2, " & $aTemp[1] & "), " & _ "(strftime('%s', '" & $Stamp & "'), 3, " & $aTemp[2] & ");") ; progress in time $Stamp = StringReplace(_DateAdd("n", 15 , $Stamp), '/', '-') ; make temperatures more or less randomly change a bit For $i = 0 To $iDevices - 1 $aTemp[$i] = Round($aRefTemp[$i] * (1.0 + Sin(Random(0, 2 * 3.141592653589793)) / 15.0), 2) Next Until $Stamp > $Stop _SQLite_Exec($hDB, "commit") _SQLite_Close($hDB) _SQLite_Shutdown() The second is an example on how you would use that schema to insert new data in such a DB. #include <SQLite.au3> ; include for RS485 communication Local Const $SQLITE_DLL = "C:\SQLite\bin\sqlite3.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) Global $hDB = _SQLite_Open("temper.sq3") Local $s = "CREATE TABLE if not exists Data (Id INTEGER PRIMARY KEY not null, Stamp int not null default (strftime('%s','now')), Device int not null, Value real not null);" & _ "CREATE INDEX if not exists ixDataDeviceStamp ON Data (Stamp, Device);" & _ "CREATE INDEX if not exists ixDataStampDevice ON Data (Device, Stamp);" _SQLite_Exec($hDB, $s) _SQLite_SetTimeout($hDB, 3600000) ; ; here init RS485 UDF as needed ; ; # of devices and storage for polling a period Global Const $iDevices = 3 Global $aTemp[$iDevices] AdlibRegister(LogTemp, 15 * 60 * 1000) While 1 ; have something here to exit this endless loop Sleep(100) WEnd ; ; close RS485 link if needed ; _SQLite_Close($hDB) _SQLite_Shutdown() Func LogTemp() ; get current datetime stamp Local $Stamp = _NowCalc_Check() ; ; poll devices and store read values in $aTemp ; Local $sSQL = "insert into Data (Stamp, Device, Value) values (strftime('%s', '" & $Stamp & "'), 1, " & $aTemp[0] & ")" For $i = 1 To UBound($aTemp) - 1 $sSQL &= ", (strftime('%s', '" & $Stamp & "'), " & $i + 1 & ", " & $aTemp[$i] & ")" Next _SQLite_Exec($hDB, $sSQL) ; optionally, test @error and deal with it if != 0 EndFunc ; Melba23 contribution for stable stamp reading Func _NowCalc_Check() Local $sRet, $sCheck Do $sCheck = @SEC $sRet = @YEAR & "/" & @MON & "/" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC Until @SEC = $sCheck Return $sRet EndFunc ;==>_NowCalc_Check The third shows how to query the DB for some queries. #include <SQLite.au3> Const $SQLITE_DLL = "C:\SQLite\bin\sqlite3.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) Local $hDB = _SQLite_Open("temper.sq3") Local $aRows, $iRows, $iCols ; minimum,maximum and average temperatures of each device during the year 2019 Local $s = "select device, min(value) Min, max(value) Max, round(avg(value), 2) Average from data where Stamp between strftime('%s', '2019-01-01') and strftime('%s', '2019-12-31') group by device" _SQLite_GetTable2d($hDB, $s, $aRows, $iRows, $iCols) _SQLite_Display2DResult($aRows) ; 1 hour before and 1 hour after the max temp of device #2 $s = "with dt (st) as (select stamp from data where device = 2 and value = (select max(value) from data where device = 2) limit 1) " & _ "select datetime(stamp, 'unixepoch') Period, Value from data, dt where device = 2 and stamp between dt.st - 3600 and dt.st + 3600" _SQLite_GetTable2d($hDB, $s, $aRows, $iRows, $iCols) _SQLite_Display2DResult($aRows) ; history of temperature from device #3 during Jan 17 2019 $s = "select datetime(stamp, 'unixepoch') Period, value from data where device = 3 and date(stamp, 'unixepoch') like '2019-01-17%'" _SQLite_GetTable2d($hDB, $s, $aRows, $iRows, $iCols) _SQLite_Display2DResult($aRows) _SQLite_Close($hDB) _SQLite_Shutdown() As you'll see in the SCiTe console, querying such a DB is very fast, even if storing timestamps as Unix epoch requires conversion to a human-readable form for computing time differences easily or just display. Of course, all of this is just a toy which may not be correct to fit all of your requirements.1 point
-
Your if are badly formatted. It should be : If $WDAY = 3 OR $WDAY = 4 Then Also @HOUR returns a string not a numeric. Finally you should consider using a Web Browser UDF, instead of mouseClicks (WebDriver for Firefox).1 point
-
1 point
-
Codecrypter version 3.1 is released; a major upgrade, made possible by the incorporation of TheXman's CryptoNG suite (with permission, of course). Many thanks to TheXman for allowing me to incorporate Bcrypt dll calls (works in 32/64-bit, in Win7 and up), which perform almost as fast as Ward's machine code routines, wherever Bcrypt is available (NB perhaps not on WinXP and earlier OS versions, so if you're maintaining paleoware, stick to Ward's algo). For now, only AES encryption is actively supported, but any coder familiar with CryptoNG will be able to swap that for any other symmetric encryption algorithm by changing one global variable. I've taken this opportunity to fix a whole ream of minor bugs (why did no-one tell me before that obfuscation messed with WinAPI_UniqueHardwareID calls?!), and re-tested the various encryption options (on helloworld, goodbyeworld, farewellworld, and a few other random scripts). However, since a lot of refactoring has taken place, it is likely that new bugs will now rear their repugnant visage. If you do encounter such a beastie, please also test whether it goes away when you select the alternate encryption engine (Ward's vs TheXman's), and let me know in this thread either way. And if you want me to have a look at your issue, please make the effort to post the smallest-possible reproducer script with your question/bug-report. Thanks. There's also a new, short and simple HowToGuide (CodeCrypter explained in five easy steps), and some minor edits in the FAQ. Hope you like it.1 point
-
Welcome to the wonderful world of computers! Once a program exists that is built to run on a fully known hardware under a fully known OS, there is nothing on Earth that can block someone having access to both the program and the hardware specifications from setting up an environment (e.g. a debugger, a simulator, an emulator, whatever) allowing a complete reverse-engineering of said program, ruining any attempt to "hide" itself from preying eyes. Of course, any hardware or software complexity introduced to make the process harder will inevitably increase the time or cost of the reverse-engineering. What that means is that we're in a bullet vs. shield situation: the harder the shield, the more expensive the bullet. The moral in every security issue is: determine the price that the attacker would gain by stealing your "secret" and put obstacles in place to make the cost of buglary significantly higher. That applies as well to every program, whatever language and platform. AutoIt is cheap in this regard since it doesn't embed a strong enough barrier to make access to the source particularly hard, but other development toolchains don't escape the rule even if some are by construction more expensive to reverse-engineer.1 point
-
Why AutoIt, and not another language like C# or Python?
EnigmaScript reacted to mLipok for a topic
I will answer by reverse your question. I do not know C# and do not know Python. From 2004 my only one programming language is AutoIt. I have my own small bussines and I hire 3 people. AutoIt scripts which I made for my clients, are generating about 1/4 of my company incomes. Why I should use other programming language ? EDIT: currently in 2020 I hire 4 people1 point -
change text of a label
Professor_Bernd reacted to somdcomputerguy for a topic
Use GUICtrlSetData like this $var = GUICtrlCreateLabel(... GUICtrlSetData($var...1 point