Leaderboard
Popular Content
Showing content with the highest reputation on 08/26/2022 in all areas
-
objStopwatch - Stopwatch Object UDF
noellarkin reacted to kurtykurtyboy for a topic
I stumbled across this recent support thread on using multiple "stopwatches", so I thought I would have a little fun and make a full-featured stopwatch object using AutoItObject_Internal.au3 by @genius257. It's not super useful, but who doesn't like a full UDF for the simplest of tasks? This is more of a proof of concept and is not meant to be extremely accurate or reliable, but I'm still open to suggestions if anyone has any ideas for improvement. The stopwatch has the following methods: start: start (or restart) the timer and reset the accumulated timer value stop: stop/pause the timer lap: return the time since the last time lap was called or since the timer was started reset: stop and reset the timer elapsed: get the time since the last reset or since the timer was started To use a stopwatch, simply create a new object and start the timer. You can then retrieve the total elapsed time or the current lap time. #include "ObjStopwatch.au3" $oStopwatch1 = _ObjStopwatch() $oStopwatch1.start() sleep(500) consolewrite("Lap time: " & $oStopwatch1.lap() & @CRLF) sleep(500) consolewrite("Total time: " & $oStopwatch1.elapsed() & @CRLF) The .elapsed method has 1 optional parameter to set the return formatting. ; Syntax.........: _ObjStopwatch_elapsed ( [$iFormat = 0] ) ; Parameters ....: $iFormat = desired format ; - 0 = ms with decimal (same as TimerDiff()) ; - 1 = hh:mm:ss ; - 2 = hh:mm:ss:0ms ; - 3 = hh:mm:ss.0 Similarly, the .lap method has 2 optional parameters. By passing False as the 2nd parameter, you can poll the current lap time without triggering a new lap. ; Syntax.........: _ObjStopwatch_lap ( [ $iFormat = 0 [, $bNewLap = True ]] ) ; Parameters ....: $iFormat = desired format ; - 0 = ms with decimal (same as TimerDiff()) ; - 1 = hh:mm:ss ; - 2 = hh:mm:ss:0ms ; - 3 = hh:mm:ss.0 ; $bNewLap = Return the current lap time, and reset lap timer The real power of this UDF (really all thanks for AutoItObject_Internal) is the ability to create as many Stopwatch objects as you want, which you are then free to start and stop independently. #include "ObjStopwatch.au3" $oStopwatch1 = _ObjStopwatch() $oStopwatch2 = _ObjStopwatch() $oStopwatch3 = _ObjStopwatch() $oStopwatch4 = _ObjStopwatch() $oStopwatch1.start() $oStopwatch2.start() Sleep(500) $oStopwatch1.stop() Sleep(500) consolewrite("Stopwatch 1: " & $oStopwatch1.elapsed() & @CRLF) consolewrite("Stopwatch 2: " & $oStopwatch2.elapsed() & @CRLF) Lastly, here is a simple GUI example for recording the lap times of 2 different stopwatches. Updated 2022-08-29: ObjStopwatch.au3 Fixed time formatting issue. Prerequisite: AutoItObject_Internal.au3 is required. Download [HERE].1 point -
Individually, either of the following should work -- //input[@id='fuFileName'] //input[@name='fuFileName'] Just don't combine them.1 point
-
Split data in text file into text files based on dates
mikell reacted to pixelsearch for a topic
A Fishmonger feeding a Soulful cat with a Redfish (RegExFish species)1 point -
Hum hum $file1 = @scriptdir & "\01.08.2022.txt" $file2 = @scriptdir & "\1.08.2022.txt" $file3 = @scriptdir & "\1.8.2022.txt" $file4 = @scriptdir & "\1/8/2022.txt" $res1 = Execute("'" & StringRegExpReplace($file1, '(\d?\d)\D(\d?\d)\D(\d{4})(\.txt)$', "$3' & StringFormat('%02i', '$2') & StringFormat('%02i', '$1') & '$4' & '") & "'") Msgbox(0,"1", $res1) $res2 = Execute("'" & StringRegExpReplace($file2, '(\d?\d)\D(\d?\d)\D(\d{4})(\.txt)$', "$3' & StringFormat('%02i', '$2') & StringFormat('%02i', '$1') & '$4' & '") & "'") Msgbox(0,"2", $res2) $res3 = Execute("'" & StringRegExpReplace($file3, '(\d?\d)\D(\d?\d)\D(\d{4})(\.txt)$', "$3' & StringFormat('%02i', '$2') & StringFormat('%02i', '$1') & '$4' & '") & "'") Msgbox(0,"3", $res3) $res4 = Execute("'" & StringRegExpReplace($file4, '(\d?\d)\D(\d?\d)\D(\d{4})(\.txt)$', "$3' & StringFormat('%02i', '$2') & StringFormat('%02i', '$1') & '$4' & '") & "'") Msgbox(0,"4", $res4)1 point
-
GuiFlatButton UDF : Change Colors of Regular Buttons
pixelsearch reacted to kurtykurtyboy for a topic
@NMS, I'm not sure exactly what is causing this issue, but here are 2 workarounds. More investigation is required to create a proper fix... Option 1: create the GUI with the $WS_EX_COMPOSITED extended style $hGUI = GUICreate('test', 100, 100, -1, -1, BITOR($WS_POPUP, $WS_BORDER), $WS_EX_COMPOSITED) Option 2: redraw the button AFTER showing the GUI with GUISetState $buttonID = GuiFlatButton_Create('test', 10, 40, 100, 20, $BS_LEFT) GUISetState(@SW_SHOW, $hGUI) _WinAPI_RedrawWindow(GUICtrlGetHandle($buttonID)) Hope this helps.1 point -
I've made a library, based on AutoItObject UDF with the goal of implementing getter and setter functionality and make it possible to define new object properties in as few steps as possible. Thank you to @trancexx for getting me on the right track, and all users in Hooking into the IDispatch interface for the code to get me going. If I've forgotten to add credit, please let me know Example: #include "AutoItObject_Internal.au3" $myCar = IDispatch() $myCar.make = 'Ford' $myCar.model = 'Mustang' $myCar.year = 1969 $myCar.__defineGetter('DisplayCar', DisplayCar) Func DisplayCar($oThis) Return 'A Beautiful ' & $oThis.parent.year & ' ' & $oThis.parent.make & ' ' & $oThis.parent.model EndFunc MsgBox(0, "", $myCar.DisplayCar) More examples: https://github.com/genius257/AutoItObject-Internal/tree/master/Examples Version: 4.0.1 AutoItObject_Internal.au3 Documentation Edit2 (19th March 2017): First of all, sorry about the lack of updates on this project. I always start too many projects and end up ignoring old projects, if I run into problems ^^'. So I've started moving my AutoIt scripts to GitHub. I will still post the most recent script version here.1 point
-
mutex, mutex ... tell me if i can accex
evelynwminnick reacted to 636C65616E for a topic
Hey there, I don't know if this is the right place to post ... My question is really windows specific and doesn't concern autoit in first place, but as I don't want to register on other forums for a single question and as AutoIt is microsoft specific (maybe there's some ms experts here) here I am. So my question is 'quite' simple, but i will just explain some stuff before : When working on a multithreaded programm, a simple way to handle memory concurrency is to use some locks. Among them, one that i usually use is the CriticalSection : it's damn fast and really easy to implement. In some cases, when computing with high frequencies, the use of a CriticalSectionAndSpinCount enhance the perf by some great factor, by halting the thread with a spin lock before calling the kernel. Anyway what I presented (CriticalSection and CriticalSectionAndSpinCount) is a feature only usable in a single multithreaded programm. Now what I want to know: I'm currently working on a distributed programming project, in which i have some shared memory between 2 programms. There is some critical data inside this shared chunk, and i want to use a mutex to switch on and off the read and write rights, there's some computation behind the scene and the read/write is switching quite fast, so using a simple mutex will only result in slowing down the programm in a manner I can't accept. In the end, long story short : is there, on windows, a way to implement a cross programm mutex *with a spincount* ? or, at least, maybe something equivalent ? Regards, Clean1 point -
mutex, mutex ... tell me if i can accex
evelynwminnick reacted to Nine for a topic
Maybe look at those two mecanisms : https://www.guru99.com/mutex-vs-semaphore.html MSDN : https://docs.microsoft.com/en-us/dotnet/standard/threading/mutexes API : https://docs.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-createmutexa1 point