Leaderboard
Popular Content
Showing content with the highest reputation on 08/24/2020 in all areas
-
I'd say scripting dictionary. It is the perfect situation to use it. Here to start you up : #include <Constants.au3> #include <Array.au3> Opt ("MustDeclareVars", 1) Local $t = TimerInit() Local $oDict = ObjCreate("Scripting.Dictionary") Local $aWord = FileReadToArray("1.txt") Local $iCount = @extended, $p For $i = 0 To $iCount - 1 If Not StringRegExp ($aWord[$i], "(*UCP)\b[\pL\d]{2,}") Then ContinueLoop $p = $aWord[$i] If $oDict.Exists($p) Then $oDict.Item($p) = $oDict.Item($p) + 1 Else $oDict.Add($p, 1) EndIf Next ConsoleWrite($iCount & "/" & $oDict.Count & @CRLF) Local $aCount[$oDict.Count][2] $p = 0 For $vKeys In $oDict $aCount[$p][0] = $vKeys $aCount[$p][1] = $oDict.item($vKeys) $p += 1 Next MsgBox($MB_SYSTEMMODAL, "", $p & "/" & TimerDiff($t)) Taking me 4.5 secs overall with your 1.txt file.4 points
-
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.au31 point
-
I don't know if you are like me, but I am always searching for that specific code I wrote over the years, but cannot find it. It was way too exhausting to look at 1k+ scripts. And Windows Explorer is not the best tool to do such exploration. So I made this little script that save me tons of time. Hope you will find it useful too. You can adjust default search folders and type of files you want to search for, but you can also change it at runtime. To use multiple filters separate them with ";" Let me know if you have any suggestion to enhance the tool. Version 2023-12-27 * Code revision : 3.3.16.1 now required Version 2023-05-10 * Sets children flag on first drawn list Version 2021-04-06 * Context menu modified to allow clipping file name and line content Version 2020-11-21 * Allows only 1 running instance of the script * Added right-click support on Tray to exit script Version 2020-06-29 * Added Copy File Name to context menu (helps to copy include files names) Version 2020-04-22 * Added icons to main buttons * Added informative box to describe progress and results of a search * Increased robustness of the GUI * Open Button enabled only under the right conditions * Added Tooltip on filter field to describe how to enter multiple criteria * Forced a minimum Window size Version 2020-04-18 * Added support of Context Menu in Tree View * Added support of Tray * Minimizes on Tray Version 2020-04-12 * Added DPI awareness * Added Enter Key functionality to start a search Version 2020-04-09 * Changed base size of the GUI to make it wider * Made the window resizable * Added Reset button * Shown busy cursor more appropriately * Corrected bug of first line displayed Thanks all for your input. SearchContent.au31 point
-
Why are you posting all these images? AutoIt3 is single threaded so will only run on one core of the CPU so will max use 25%. Post your script code (not image) in a CODEBLOCK (<>) so we can have a proper look/test with that to see what can be done to make that faster. Jos1 point
-
It is like Win7. Even if the support ended quite a bit ago, I am still using it without problem. IE will be the same, you will be able to use it for few years after end of support as long as the Web site you are automating allows the usage of IE.1 point
-
IE UDF - works with Edge?
Zedna reacted to JLogan3o13 for a topic
IE UDF is IE. For edge you're going to need to go UIAutomation or WebDriver.1 point -
You will likely need to use UI Automation.1 point
-
_WinAPI_GetBkColor - How to use it the right way?
Professor_Bernd reacted to mikell for a topic
For the Bilgus way, be careful with "symetric" colors like 0x00FF00 when doing tests. The function works if is returned _WinAPI_SwitchColor($iColor) For the guinness way, I suspect the border of the button to cause trouble because on my machine if I shift the pixels to check then it also works Local $iColor = _WinAPI_GetPixel($hDC, 3, 3) Good luck to make your choice1 point -
$sCurrentUser = $oOL.GetNameSpace("MAPI").CurrentUser.Name ; Returns the display name of the currently logged-on user $oCurrentUser = $oOL.GetNameSpace("MAPI").CurrentUser ; Returns the currently logged-on user as a Recipient object1 point
-
I assume that you are referring to the telegram UDF. Carefully read the console output in the first post. It has the URL to the UDF.1 point
-
Here is fixed/working code: see lines with this comments "(Zedna) ****************************************" #include <GUIConstantsEx.au3> #include <GuiStatusBar.au3> #include <GuiImageList.au3> ;#include <ImageListConstants.au3> #include <GuiToolbar.au3> ;#include <GuiReBar.au3> #include <ListViewConstants.au3> #include <ToolbarConstants.au3> #include <WindowsConstants.au3> #include <WinAPIConstants.au3> #include <GuiMenu.au3> #include <GuiListView.au3> #include <GuiToolTip.au3> Global Enum $savebtn = 3000, $newbtn $frmMain = GUICreate("frmMain", 839, 508, 192, 124, BitOR($GUI_SS_DEFAULT_GUI,$WS_MAXIMIZEBOX,$WS_SIZEBOX,$WS_THICKFRAME,$WS_TABSTOP)) $menu_File = GUICtrlCreateMenu("&File") $menu_Exit = GUICtrlCreateMenuItem("E&xit", $menu_File) $ImageList1 = _GUIImageList_Create(32, 32, 5) _GUIImageList_AddIcon($ImageList1, "C:\Windows\System32\shell32.dll", 258, True) _GUIImageList_AddIcon($ImageList1, "C:\Windows\System32\imageres.dll", 2, True) $tbMain = _GUICtrlToolbar_Create($frmMain) GUISetState(@SW_SHOW, $frmMain) ; --> moved here (Zedna) **************************************** $hToolTip = _GUIToolTip_Create($tbMain) ; --> moved here (Zedna) **************************************** _GUICtrlToolbar_SetToolTips($tbMain, $hToolTip) _GUICtrlToolbar_SetExtendedStyle($tbMain, $TBSTYLE_EX_DRAWDDARROWS) _GUICtrlToolbar_SetImageList($tbMain, $ImageList1) _GUICtrlToolbar_AddButton($tbMain, $savebtn, 0, 0) _GUICtrlToolbar_AddButton($tbMain, $newbtn, 1, 0, $BTNS_DROPDOWN) $sbMain = _GUICtrlStatusBar_Create($frmMain) Dim $sbMain_PartsWidth[5] = [125, 325, 525, 650, -1] $ListView1 = GUICtrlCreateListView("COL1|COL2|COL3|", 1, 46, 834, 414) GUICtrlSetResizing(-1, $GUI_DOCKLEFT+$GUI_DOCKRIGHT+$GUI_DOCKTOP+$GUI_DOCKBOTTOM) GUICtrlCreateListViewItem("COL1ROW1|COL2ROW1|COL3ROW1", $ListView1) GUICtrlCreateListViewItem("COL1ROW2|COL2ROW2|COL3ROW2", $ListView1) GUICtrlCreateListViewItem("COL1ROW3|COL2ROW3|COL3ROW3", $ListView1) GUICtrlCreateListViewItem("COL1ROW4|COL2ROW4|COL3ROW4", $ListView1) ; Create ToolTip ;~ $hToolTip = _GUIToolTip_Create($tbMain) ; --> moved up from here (Zedna) **************************************** ;~ _GUICtrlToolbar_SetToolTips($tbMain, $hToolTip) Opt("GUIOnEventMode", 1) ;// Change to OnEvent mode Opt("GUICloseOnEsc", 0) ;//esc key does not close windows OnAutoItExitRegister("OnAutoItExit") ;//on autoit script exit, call this function GUISetOnEvent($GUI_EVENT_CLOSE, "Event_closeApplication",$frmMain) GUIRegisterMsg($WM_SIZE, "WM_SIZE") GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") ;~ GUISetState(@SW_SHOW, $frmMain) ; --> moved up from here (Zedna) **************************************** While 1 Sleep(10) ; Sleep to reduce CPU usage WEnd Func WM_SIZE($hWnd, $iMsg, $iwParam, $ilParam) _GUICtrlStatusBar_Resize($sbMain) ;auto size statusbar _WinAPI_MoveWindow($tbMain, 0, 0 , 0, 0) ;auto size toolbar Return $GUI_RUNDEFMSG EndFunc ;==>MY_WM_SIZE Func Event_closeApplication() Switch @GUI_WinHandle Case $frmMain local $doclose = MsgBox(BitOR($MB_ICONWARNING,$MB_YESNO,$MB_TASKMODAL), "Close Application", "You are about to close this application! Are you sure you want to do this?") Switch $doclose case $IDYES ;clicked yes Exit case $IDNO ;clicked no ;do nothing, the application continues to run. EndSwitch ;Case $frmAsset ; GUISetState(@SW_HIDE,$frmAsset) ; GUISetState(@SW_ENABLE, $frmMain) ; WinActivate($frmMain) EndSwitch EndFunc Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) Local $hWndFrom, $iCode, $tNMHDR, $hWndListView $hWndListView = $ListView1 If Not IsHWnd($ListView1) Then $hWndListView = GUICtrlGetHandle($ListView1) $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndListView Switch $iCode Case $NM_CLICK ;ConsoleWrite("Left click") Case $NM_DBLCLK ConsoleWrite("Double left click" & _GUICtrlListView_GetItemText ( $hWndFrom, _GUICtrlListView_GetSelectedIndices($ListView1),0)) Case $NM_RDBLCLK ;ConsoleWrite("Double right click") Case $NM_RCLICK ConsoleWrite("right click") ;ListView_RClick() Return 0 Case $LVN_COLUMNCLICK ; A column was clicked Local $tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam) ConsoleWrite("Sort LV") EndSwitch ; --> changed/commented (Zedna) **************************************** ;~ Case $tbMain ;~ ;ConsoleWrite("FROM: " & $icode & @CRLF) ;~ Switch $iCode ;~ Case $TBN_DROPDOWN ;~ ConsoleWrite("button drop down") ;~ Case $TTN_GETDISPINFO ;~ $tInfo = DllStructCreate($tagNMTTDISPINFO, $ilParam) ;~ ConsoleWrite("Set Tooltips") ;~ $iID = DllStructGetData($tInfo, "IDFrom") ;~ Switch $iID ;~ Case $savebtn ;~ DllStructSetData($tInfo, "aText", "Save") ;~ Case $newbtn ;~ DllStructSetData($tInfo, "aText", "New") ;~ EndSwitch ;~ EndSwitch EndSwitch ; --> changed (Zedna) **************************************** $tInfo = DllStructCreate($tagNMTTDISPINFO, $ilParam) $iCode = DllStructGetData($tInfo, "Code") ;~ ConsoleWrite("WM_NOTIFY iCode: " & $icode & @CRLF) Switch $iCode Case $TBN_DROPDOWN ConsoleWrite("button drop down") ; Case $TBN_HOTITEMCHANGE ; ConsoleWrite("button TBN_HOTITEMCHANGE"&@CRLF) Case $TTN_GETDISPINFOW $tInfo = DllStructCreate($tagNMTTDISPINFO, $ilParam) ConsoleWrite("Set Tooltips") $iID = DllStructGetData($tInfo, "IDFrom") Switch $iID Case $savebtn DllStructSetData($tInfo, "aText", "Save") Case $newbtn DllStructSetData($tInfo, "aText", "New") EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Func OnAutoItExit() ;function runs when the application is closing. Event_closeApplication() runs first. ;do application cleanup EndFunc ;==>OnAutoItExit1 point
-
AutoIT exe file cannot be deleted
Divya_Jain reacted to ur for a topic
Maybe the process is sill running in the background. From the command prompt, just run below command. taskkill /f /im your_exe_file.exe It will close any running instances of your exe.1 point -
Searching specific content in Text file or AU3
Jangal reacted to marcgforce for a topic
Untouch but adding the new search basic method by restarting script and modifying the $ARRAY_OF_FOLDERS = [@scriptdir, @MyDocumentsDir] Nice work... #include <Constants.au3> #include <GUIConstants.au3> #include <GuiTreeView.au3> #include <File.au3> Opt("MustDeclareVars", 1) Const $ARRAY_OF_FOLDERS = [@scriptdir, @MyDocumentsDir] Const $DEFAULT_FILTER = "*.au3" Local $hGUI = GUICreate("Search Content", 600, 440, 190, 120) GUISetFont(11) Local $idSelect = GUICtrlCreateButton("Select Folder", 25, 20, 135, 30) Local $idFolder = GUICtrlCreateCombo("", 185, 24, 400, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL)) GUICtrlCreateLabel("Filter :", 25, 58, 50, 25) Local $idFilter = GUICtrlCreateInput($DEFAULT_FILTER, 70, 55, 90, 25) GUICtrlCreateLabel("Text to search :", 185, 58, 100, 25) Local $idText = GUICtrlCreateInput("", 285, 55, 300, 25) Local $idTreeFile = GUICtrlCreateTreeView(25, 90, 560, 300) GUICtrlSetFont(-1, 9) Local $idSearch = GUICtrlCreateButton("Search", 100, 400, 100, 25) Local $idOpen = GUICtrlCreateButton("Open", 400, 400, 100, 25) local $idNewSearch = GUICtrlCreateButton("New Search", 230, 400, 150, 25) GUISetState(@SW_SHOW) Local $sFolder, $idTVselect, $aSelect[1], $idParent GUICtrlSetData($idFolder, _ArrayToString($ARRAY_OF_FOLDERS), $ARRAY_OF_FOLDERS[0]) While True Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $idSelect $sFolder = FileSelectFolder("Select root folder", @ScriptDir, 0, @ScriptDir, $hGUI) If @error Then ContinueLoop GUICtrlSetData($idFolder, $sFolder, $sFolder) Case $idSearch If Not GUICtrlRead($idFolder) Or Not GUICtrlRead($idFilter) Then MsgBox($MB_SYSTEMMODAL, "Error", "You must provide folder and filter fields") ContinueLoop EndIf ReDim $aSelect[1] $aSelect[0] = 0 SearchText($idTreeFile, GUICtrlRead($idFolder), GUICtrlRead($idFilter), GUICtrlRead($idText)) Case $idOpen $idTVselect = GUICtrlRead($idTreeFile) If Not $idTVselect Or _GUICtrlTreeView_GetParentHandle($idTreeFile, $idTVselect) Then MsgBox($MB_SYSTEMMODAL, "Error", "Please select file you want to open") ContinueLoop EndIf OpenFile(GUICtrlRead($idTreeFile, $GUI_READ_EXTENDED), GUICtrlRead($idText)) Case $idNewSearch _RestartProgram() EndSwitch $idTVselect = GUICtrlRead($idTreeFile) If $idTVselect Then If _GUICtrlTreeView_GetParentHandle($idTreeFile, $idTVselect) Then ContinueLoop For $i = 1 To $aSelect[0] If $idTVselect = $aSelect[$i] Then ContinueLoop 2 Next _ArrayAdd($aSelect, $idTVselect) $aSelect[0] += 1 DisplayLine($hGUI, $idTreeFile, $idTVselect, ControlTreeView($hGUI, "", $idTreeFile, "GetSelected"), GUICtrlRead($idText)) EndIf WEnd Func SearchText($idTree, $sFolder, $sFilter, $sText) Local Const $CURSOR_WAIT = 15 Local $bFound = False _GUICtrlTreeView_DeleteAll($idTree) Local $aFile = _FileListToArrayRec($sFolder, $sFilter, $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_NOSORT, $FLTAR_FULLPATH) If @error Then Return MsgBox($MB_SYSTEMMODAL, "Error", "No file selected") GUISetCursor($CURSOR_WAIT, $GUI_CURSOR_OVERRIDE) For $i = 1 To $aFile[0] If Not $sText Or StringInStr(FileRead($aFile[$i]), $sText) Then GUICtrlCreateTreeViewItem($aFile[$i], $idTree) $bFound = True EndIf Next GUISetCursor() If Not $bFound Then MsgBox($MB_SYSTEMMODAL, "Error", "Text not found") EndFunc ;==>SearchText Func DisplayLine($hGUI, $idTree, $idItem, $sItem, $sText) If Not $sText Then Return Local $aLine = FileReadToArray($sItem) For $i = 1 To UBound($aLine) - 1 If StringInStr($aLine[$i], $sText) Then GUICtrlCreateTreeViewItem($aLine[$i], $idItem) Next ControlTreeView($hGUI, "", $idTree, "Expand", $sItem) EndFunc ;==>DisplayLine Func OpenFile($sFile, $sText) Local $sDrive, $sDir, $sFileName, $sExtension _PathSplit($sFile, $sDrive, $sDir, $sFileName, $sExtension) ClipPut($sText) ShellExecute($sFile, "", $sDrive & $sDir, "open") EndFunc ;==>OpenFile #Region --- Restart Program --- Func _RestartProgram() If @Compiled = 1 Then Run(FileGetShortName(@ScriptFullPath)) Else Run(FileGetShortName(@AutoItExe) & " " & FileGetShortName(@ScriptFullPath)) EndIf Exit EndFunc; ==> _RestartProgram #EndRegion --- Restart Program ---1 point -
A cross-platform implementation of the AutoIt language
seadoggie01 reacted to RTFC for a topic
Interesting thread, somehow missed it before. For what it's worth, speaking from personal experience, I think it's worth pursuing (regardless of the merits of having a native AutoInux), because nothing ever taught me more about programming design and coherent, consistent language structure than when I had to develop my own programming environment a few years back (now mainly used by other people). If you can spare the time and effort and you think it's worthwhile, make it happen.1 point