Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 03/09/2023 in all areas

  1. For the example script it gives: 10000 rows, sorted in 3.606 seconds 100000 rows, sorted in 41.307 seconds Even if it is unlikely to have to sort 100,000 filenames, you can speed up the process by replacing the general natural comparison function (which also handles numbers in the middle of the string correctly) with a simpler one for this case: #include <ArrayPlus.au3> Local $aArray[10000] ;~ Local $aArray[100000] For $i = 0 To Ubound($aArray) - 1 $aArray[$i] = $i & ".txt" Next _ArrayShuffle($aArray) _ArrayDisplay($aArray, 'original') Local $hTimer = TimerInit() _ArraySortFlexible($aArray, _mycomp) ConsoleWrite(Ubound($aArray) & " rows, sorted in " & Round((TimerDiff($hTimer) / 1000), 3) & " seconds" & @crlf) _ArrayDisplay($aArray, 'sorted') Func _mycomp($A, $B) $A = Int($A) $B = Int($B) Return $A > $B ? 1 : $A = $B ? 0 : -1 EndFunc With this I get the following results: 10000 rows, sorted in 1.59 seconds 100000 rows, sorted in 19.582 seconds If you need even more speed, then it's the same as always: If you write code specifically for a particular use case, you can get the maximum speed for that case, but in return you lose flexibility and reusability of the code.
    2 points
  2. Thanks everyone for the responses. I got an idea of what's relevant today. argumentum Yours "to prove" confused me a little, but I understand what you mean. I saw a message in the table (pipetable.gif) about MailSlot: "Message can get lost between sender and receiver". Based on the my attempts and this information, I decided to ask the advice of experienced coders. Now I found that MailSlot no response empty messages. This may explain the rare lost messages (in my case). mistersquirrle Each child script executes cmd. As a result of StdoutRead, I will see much more than I would like. Or I won't be able to multiple messages as the commands run. I looked at IPCviaROTobjects and not found an example of receive several messages. This is probably a powerful data transfer library, but my examples show that queues are not supported and message is lost, although I may not be using it correctly. 500ms delay is set on purpose and simulates message processing time. Receiver: Local $Message = "", $OldMessage = "" While 1 IPCROT_Receiver("Example", $Message) If $Message <> $OldMessage Then ConsoleWrite($Message & @CRLF) $OldMessage = $Message Sleep(500) EndIf WEnd Sender: For $i = 0 to 9 IPCROT_Sender( "Example", "Client1. Msg " & $i ) Sleep(200) Next Nine I liked your UDF: -maintains a queue -responds empty messages -ready-made example of receiving multiple messages -all the "excess" is hidden inside the UDF. If I am going to redo my program, then will use it. And also in the future. If I will have any questions, I'll ask in the UDF topic.
    2 points
  3. Corresponding UDFs already exist for this purpose. This is how it would be implemented with the ArrayPlus UDF: #include <ArrayPlus.au3> Global $aFilenames = FileReadToArray(@ScriptDir & '\filenames.txt') _ArrayDisplay($aFilenames, 'original') ; sort natural: _ArraySortFlexible($aFilenames, __ap_cb_comp_Natural) _ArrayDisplay($aFilenames, 'sorted')
    2 points
  4. After seeing a number of threads talking about how to exchange efficiently messages between processes (Inter Process Communication), I decided to create a framework using Windows Messages WM_COPYDATA. What is new with this UDF you ask ? Well it will depends how familiar you are with IPC. One thing is sure, the simplicity of use and the fabulous speed are amazing. This is based on a Clients-Server approach. You can have an unlimited number of clients talking with a single server. You will have to define the protocol of communication between them, but the code you have to create is incredibly low. The UDF proposes 2 simple message properties of communication. The first (called data) is based on a number. You can decide what value 1,2,3, etc. means between your client and server. Server will react upon the value of the data field. Second, there is a string field where you can inscribe additional information on request, and where the server will respond to client request (if necessary). Here are the functions that I have wrapped around this : Func _WCD_CreateServer Func _WCD_CreateClient Func _WCD_GetServerHandle Func _WCD_IsServerAvailable Func _WCD_Send Func _WCD_WM_COPYDATA_CLIENT_HANDLER Func _WCD_Client_GetResponse Func _WCD_WM_COPYDATA_SERVER_HANDLER Func _WCD_Server_PeekRequest Func _WCD_Server_GetRequest Func _WCD_Server_IsRequestAvail Here an example of the server : #include <Constants.au3> #include <GUIConstants.au3> #include "WCD_IPC.au3" Opt ("MustDeclareVars", 1) $_WCD_Verbose = False ; make it True if you want to follow the convos. False is by default. Local $hServer = _WCD_CreateServer () Local $aReq, $iData While True If _WCD_Server_IsRequestAvail () Then $aReq = _WCD_Server_GetRequest () $iData = @extended Switch $iData Case 1 ; who are you _WCD_Send($hServer, $aReq[0], $iData, @ComputerName) Case 2 Switch Number($aReq[1]) Case 1 _WCD_Send($hServer, $aReq[0], $iData, @IPAddress1) Case 2 _WCD_Send($hServer, $aReq[0], $iData, @IPAddress2) Case 3 _WCD_Send($hServer, $aReq[0], $iData, @IPAddress3) Case 4 _WCD_Send($hServer, $aReq[0], $iData, @IPAddress4) Case Else _WCD_Send($hServer, $aReq[0], $iData, "Invalid parameter") EndSwitch EndSwitch EndIf Sleep (100) WEnd And the client : #include <Constants.au3> #include <GUIConstants.au3> #include "WCD_IPC.au3" Opt ("MustDeclareVars", 1) $_WCD_Verbose = True ; as for the server, you can decide to make client verbose or not Global $hWnd = _WCD_CreateClient ("Test WCD Client") Global $hWndServer = _WCD_GetServerHandle () _WCD_Send($hWnd, $hWndServer, 1) ; simple request - who are you ? Local $sString = WaitForResponse () ConsoleWrite ($sString & @CRLF) _WCD_Send($hWnd, $hWndServer, 2, "5") ; adding text to a more complex request $sString = WaitForResponse () ConsoleWrite ($sString & @CRLF) Func WaitForResponse () Local $sResp While _WCD_IsServerAvailable () $sResp = _WCD_Client_GetResponse () If $sResp <> "" Then Return $sResp Sleep (100) WEnd EndFunc As always, let me know if you got issues, comments, suggestions. I will be glad to answer. Version 2020-06-27 * Allows processes with different levels of privilege to communicate with each other WCD_IPC.au3
    1 point
  5. Hi folks, just as an tiny update for those of you who are interested in: The collection list (post #1) increased and we now have 40 members who share their code on GitHub. So don't hesitate to contribute on their projects if you like to 😇 . Best regards Sven
    1 point
  6. Some other methods to get the profile-location. the 'çlassic' method: use chrome keyboard shortcuts (using send() or sendcontrol()) for: open new window focus on adressbar paste "chrome://version" enter small wait select all copy to clipboard close window get data from clipboard and search the profile directory. the 'wmic' method: wmic process where name='chrome.exe' get commandline the result will report the currently running profile(s) the 'chrome internals' method: In Chrome\User Date there is a json file named 'Local State' Search in that file for "last_active_profiles" The result is the currently running profile(s).
    1 point
  7. @SOLVE-SMARTYes... you are actually looking for the "--user-data-dir=" portion.
    1 point
  8. Not necessarily. The user could potentially be choosing between multiple profiles at any given time. The active profile could possibly be retrieved from the command line. Here's a quick example modified from the help file -- #AutoIt3Wrapper_UseX64=Y #RequireAdmin #include <Array.au3> #include <WinAPIHObj.au3> #include <WinAPIProc.au3> Local $aAdjust, $aList = 0 ; Enable "SeDebugPrivilege" privilege for obtain full access rights to another processes Local $hToken = _WinAPI_OpenProcessToken(BitOR($TOKEN_ADJUST_PRIVILEGES, $TOKEN_QUERY)) _WinAPI_AdjustTokenPrivileges($hToken, $SE_DEBUG_NAME, $SE_PRIVILEGE_ENABLED, $aAdjust) ; Retrieve command-line arguments for all processes the system If Not (@error Or @extended) Then $aList = ProcessList('chrome.exe') For $i = 1 To $aList[0][0] $aList[$i][1] = _WinAPI_GetProcessCommandLine($aList[$i][1]) Next EndIf ; Enable SeDebugPrivilege privilege by default _WinAPI_AdjustTokenPrivileges($hToken, $aAdjust, 0, $aAdjust) _WinAPI_CloseHandle($hToken) _ArrayDisplay($aList, '_WinAPI_GetProcessCommandLine') Webdriver should be able to navigate to the sites you mentioned. Even better, I think you can just extract the information from _WD_GetSession.
    1 point
  9. Something to keep in mind (and I can't answer this about anything mentioned so far in this topic) is that when you have multiple writers/children, you may likely be overwriting data and "losing" messages. This is one good thing with just StdoutRead, you may get a lot more than you want (because of logging), but you can just adjust your children to put the "important" data/messages in a "container", like: [!This is an important message], and then parse it with something like _StringBetween. StdoutRead separates the messages by the PID of each child, so they can't overwrite each others data. Nine would have to answer it about his UDF, but with most IPC that writes information to the same 'queue', you may get an instance where 2 are writing at the same time, one completes after the first and overwrites the data from the first one because it didn't exist when it started writing. Does that make sense? AutoIt is not thread safe, some IPC methods or UDFs may be, but that could also be why you're "losing" messages. You may want to look into something like: I've used this before when I had children scripts (around 8 ) all writing loglines to a file. This cause a lot of lost data and data combined into a single line as they were all competing to write data at the same place in the file. I used that UDF to have them wait until an existing writer was done before they did theirs. I then also prefixed the log lines with the PID of the child, so when they're all writing at the same time I can filter/search by a specific PID to see just its lines. So I imagine that you can use this semaphore UDF (or just the AutoIt semaphore) to make sure that your children aren't putting data into whatever IPC you use. Also in terms of queues or stacks, I recommend checking out these two UDFs as well:
    1 point
  10. you know what, a month ago I switched from my old DELL with INTEL i7 3gen with SSD disk to brand new DELL with INTEL i5 12gen with SSD NVME disk and you know what, Now I stoped to complaining about speed with new SciTE4AutoIt3 EDIT: I also finally swithced to new 27'' LED monitor (previously I had 1x24'' and 1x22'', now I have 1x24'' and 1x27'') And work becames easier.
    1 point
  11. If anyone has the same issue in the future, here's how I manage to make it work as expected ShellExecute("http://<ip>/nagios/cgi-bin/extinfo.cgi?type=1&host=" & $psdNumber)
    1 point
  12. Thanks for testing .... I have updated the current Beta Zip with these changes: fix for date retrieval script file Added a little logic to find a variable either on the first line that matches the below in either the master or any Include file: "global.*$XYZ" or "Local.*$XYZ"... so NO Multiline support for this! "$XYZ\s*="
    1 point
  13. jugador

    Richedit TABkey

    think it's working by mixing @Musashi hint CRTL+TAB & GUICtrlCreateDummy #include <GUIConstantsEx.au3> #include <GuiRichEdit.au3> #include <WindowsConstants.au3> #include <String.au3> __Example() Func __Example() Local $iMsg Local $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 420, 550, -1, -1) Local $hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _ BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL)) Local $idBtnHelp = GUICtrlCreateButton("Help", 10, 400, 150, 35) Local $idBtnFinish = GUICtrlCreateButton("Finish", 200, 400, 150, 35) Local $id_Dummy = GUICtrlCreateDummy() Local $aAccelKeys[1][2] = [["{TAB}", $id_Dummy]] GUISetAccelerators($aAccelKeys) GUISetState(@SW_SHOW) While True $iMsg = GUIGetMsg() Select Case $iMsg = $GUI_EVENT_CLOSE _GUICtrlRichEdit_Destroy($hRichEdit) ; needed unless script crashes GUIDelete($hGui) Exit Case $iMsg = $id_Dummy _InsertEightSpaces() EndSelect WEnd EndFunc Func _InsertEightSpaces() Send('^{TAB}') EndFunc
    1 point
  14. SOLVE-SMART

    Richedit TABkey

    Yes you can. For example like this: HotKeySet('{TAB}', '_SendCtrlTabToRichEdit') Func _SendCtrlTabToRichEdit() _GUICtrlRichEdit_Deselect($hRichEdit) ; This is only to give the RichEdit control the focus. Send('^{TAB}') EndFunc This is even better than "append 8 spaces" like I suggested before 👍 . 💡 The complete example (previously by @Musashi) with the small adjustments: But as @Musashi mentioned, if you want to jump between other controls (buttons, etc.) with TAB, you can not. Best regards Sven
    1 point
  15. Should pretty obvious 2023038 1404 => 2023/03/8 14:04 => Filedate of the current script. This is for me a simple way to know which file version is used when issues are reported.
    1 point
  16. following @argumentum suggestions i made an example #include <Array.au3> Local $aArray[101] $aArray[0] = 100 For $i = 1 To $aArray[0] $aArray[$i] = $i & ".txt" Next _ArrayShuffle($aArray, 1) _ArrayDisplay($aArray, "BEFORE") _FixIt($aArray) _ArrayDisplay($aArray, "AFTER") Func _FixIt(ByRef $Array) _ArrayColInsert($Array, 1) ; Now a 2D array For $i = 1 To $Array[0][0] $Array[$i][1] = StringFormat("%010s", $Array[$i][0]) Next ;~ _ArrayDisplay($Array, "2D array") _ArraySort($Array, 0, 1, 0, 1) _ArrayColDelete($Array, 1) Return $Array EndFunc ;==>_FixIt
    1 point
  17. ..I guess you could add zeros to pad the strings like 001.txt, sort them, then remove the pad ? Or don't remove the pad and Int(001) & ".txt" ?
    1 point
  18. Musashi

    Richedit TABkey

    A quick google search reveals that TAB does not work in conjunction with RichEdit controls as you would expect from an editor, e.g. see : richedit-tab-how-to-set-to-8-characters-width In SciTE you can configure the length (indentation depth) that is triggered by TAB. However, this apparently has no effect on Richedit controls. @SOLVE-SMART 's approach works within the RichEdit control, but changes the default behavior of TAB between controls. Example : Comment the line with HotKeySet in and out to see the difference : #include <GUIConstantsEx.au3> #include <GuiRichEdit.au3> #include <WindowsConstants.au3> #include <String.au3> ;~ HotKeySet('{TAB}', '_InsertEightSpaces') ; <==== comment in and out Global $hRichEdit Example() Func Example() Local $hGui, $iMsg Local $idBtnHelp Local $idBtnFinish $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 420, 550, -1, -1) $hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _ BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL)) $idBtnHelp = GUICtrlCreateButton("Help", 10, 400, 150, 35) $idBtnFinish = GUICtrlCreateButton("Finish", 200, 400, 150, 35) GUISetState(@SW_SHOW) While True $iMsg = GUIGetMsg() Select Case $iMsg = $GUI_EVENT_CLOSE _GUICtrlRichEdit_Destroy($hRichEdit) ; needed unless script crashes Exit EndSelect WEnd EndFunc ;==>Example Func _InsertEightSpaces() _GUICtrlRichEdit_AppendText($hRichEdit, _StringRepeat(' ', 8)) EndFunc .
    1 point
  19. nope. but after some research : https://stackoverflow.com/questions/16149610/how-to-override-default-set-of-chrome-command-line-switches-in-selenium maybe this: --safebrowsing-disable-auto-update ? You can also take a look here: https://www.chromium.org/administrators/turning-off-auto-updates/
    1 point
  20. It looks like this did the trick - fixed. btw. What exactly means information in the brackets.
    1 point
  21. Since everything is on the same computer, you could use my WCD IPC (see my signature). It is very simple to use and hardly can be faster since it is based on Windows Messaging System. If you have any problem with it, I will be glad to help you out.
    1 point
  22. This UDF contains functions to make the handling of arrays more effective and elegant. Besides functions which are inspired by Python's range-create and its array-slicing, most of the functions are based on the principle of being able to specify user-defined functions for subtasks. E.g. with the classic _ArraySort() it is not possible to sort "naturally" or to sort 2D arrays by multiple columns or instead by string length or or or... With these functions here you can usually realize this in only one function call. Also the possibility to display arrays nicely formatted as string (quasi the counterpart to _ArrayDisplay) was missing until now. The function list of the UDF: Therefore, here are a few code examples for selected functions: _ArrayCreate(): _ArraySlice(): _Array2String(): _ArraySortFlexible(): _ArrayBinarySearchFlex(): _ArrayGetNthBiggestElement(): >>sourcecode and download on github<<
    1 point
×
×
  • Create New...