Leaderboard
Popular Content
Showing content with the highest reputation on 10/04/2020 in all areas
-
thank you @mLipok I just completed the header and posted the updated file.1 point
-
Here is a commented version that will hopefully help you further : #include <Color.au3> #include <GUIConstantsEx.au3> #include <GuiRichEdit.au3> #include <WindowsConstants.au3> #include <Array.au3> HotKeySet("{Escape}", "_Exit") ; Shift-Alt-E to Exit the script Global $g_hRichEdit , $g_aRichEditFields[0][3], $g_sSearchPattern, $g_iIndex = 1, $g_bMatchesFound = False ; Description : ; 1. $g_hRichEdit : the text(string) you want to analyze, using a regular expression. ; 2. $g_sSearchPattern : the regular expression to match (pattern). ; 3. $g_aRichEditFields[0][3] : ; a two dimensional "one-based"-array, which means that the data starts in Row 1. ; Row 0 [0][0] contains the number of 'data-rows' ; Row 1, Element 1 (Index 0) ==> [1][0] = Match 1 ; Row 1, Element 2 (Index 1) ==> [1][1] = Startposition in text ; Row 1, Element 3 (Index 2) ==> [1][2] = Endposition in text ; Row 2 ... ; The function _GenerateRichEditFields() populates this array with data. ; 4. $g_iIndex : global helper index for accessing the desired row. ; 5. $g_bMatchesFound : False, if no matches were found, otherwise True. $g_sSearchPattern = "\d\d[-.\s]\d\d[-.\s]\d\d[-.\s]\d\d[-.\s]\d\d|\d\d\d\d[-.\s]\d\d\d[-.\s]\d\d\d" ; Un numéro de tél FR (A revoir) Example() Func Example() Local $hGui, $idBtnNext, $iStep = 0 $hGui = GUICreate(StringTrimRight(@ScriptName, StringLen(".exe")), 420, 350, -1, -1) $g_hRichEdit = _GUICtrlRichEdit_Create( $hGui, 'Bonjour mon numéro de téléphone est le 06.12.34.56.78 06.12.34.56.78 ou 07.12.34.56.78 08.12.34.56.78 06.12.34.56.78 09.12.34.56.78', _ 10, 10, 400, 220, _ BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL)) $idBtnNext = GUICtrlCreateButton("Next", 270, 310, 40, 30) GUISetState(@SW_SHOW) If _GenerateRichEditFields() Then $g_bMatchesFound = True While True Switch GUIGetMsg() Case $GUI_EVENT_CLOSE _GUICtrlRichEdit_Destroy($g_hRichEdit) ; needed unless script crashes GUIDelete() Exit Case $idBtnNext If $g_bMatchesFound Then ; Variation 1 : ; ------------- ; The matches will be colored STEP by STEP if the Next button is pushed. ;If $g_iIndex <= $g_aRichEditFields[0][0] Then ; _GUICtrlRichEdit_SetSel($g_hRichEdit, $g_aRichEditFields[$g_iIndex][1] , $g_aRichEditFields[$g_iIndex][2]) ; _GUICtrlRichEdit_SetCharBkColor($g_hRichEdit, Dec('00FF00')) ; Red ; _GUICtrlRichEdit_Deselect($g_hRichEdit) ; $g_iIndex += 1 ;Else ; $g_iIndex = 1 ;EndIf ; Variation 2 : ; ------------- ; ALL matches will be colored if the Next button is pushed. While $g_iIndex <= $g_aRichEditFields[0][0] _GUICtrlRichEdit_SetSel($g_hRichEdit, $g_aRichEditFields[$g_iIndex][1] , $g_aRichEditFields[$g_iIndex][2]) _GUICtrlRichEdit_SetCharBkColor($g_hRichEdit, Dec('00FF00')) ; Red _GUICtrlRichEdit_Deselect($g_hRichEdit) $g_iIndex += 1 WEnd $g_iIndex = 1 EndIf EndSwitch WEnd EndFunc ;==>Example Func _GenerateRichEditFields() Local $aMatches, $iStringStart, $iStringEnd, $iOffset = 1 ; Check if the search pattern ($g_sSearchPattern) was found. Matches are stored in an array. ; If there are no matches, the function will be exited with the return value 0. $aMatches = StringRegExp(_GUICtrlRichEdit_GetText($g_hRichEdit), $g_sSearchPattern , 3) If @error Then Return 0 ; Redimension of the array $g_aRichEditFields (the size is now known) ReDim $g_aRichEditFields[UBound($aMatches) + 1][3] $g_aRichEditFields[0][0] = UBound($aMatches) ; To find multiple (identical) matches, the starting position (offset) within StringInStr ; is increased. Parts of the already searched string are thereby skipped. For $i = 0 To UBound($aMatches) - 1 $iStringStart = StringInStr( _GUICtrlRichEdit_GetText($g_hRichEdit), $aMatches[$i], 0 , 1, $iOffset) - 1 $iStringEnd = $iStringStart + StringLen($aMatches[$i]) $iOffset = $iStringEnd $g_aRichEditFields[$i+1][0] = $aMatches[$i] $g_aRichEditFields[$i+1][1] = $iStringStart $g_aRichEditFields[$i+1][2] = $iStringEnd Next Return 1 EndFunc ;==>_GenerateRichEditFields Func _Exit() Exit EndFunc ;==>_Exit If you have further questions, you are welcome to write me a PM, as already mentioned .1 point
-
Any thoughts on using Eval on Enums with IniFiles?
JockoDundee reacted to Nine for a topic
I like your approach, although I would use Eval instead of Execute and remove all $ signs in the ini file. Would make it more elegant IMO.1 point -
IDK. Could you try to minimize the window and restore it ? See if that helps.1 point
-
Does autoit have a reflection mechanism to return variable names as strings?
Subz reacted to JockoDundee for a topic
So it is! Thx and apologies. btw, my delayed upvote has apparently pushed you out of your sinister, if cool, reputational tally1 point -
maniootek, Look at the _GUICtrlListView_SetColumnWidth function - and the use of the $LVSCW_AUTOSIZE width parameter. This is what _ArrayDisplay does to make the GUI auto-size. M231 point
-
AU3Check ended.rc:-1073740791 : many #include
Professor_Bernd reacted to Jos for a topic
I don't get easily pissed off at people as that doesn't help much and simply state how I feel about it all to the person involved, not making it my problem. Guess that also happened in this case... People perceive the directness of those replies as impolite/offensive, while all they are is a very exact statement of what I need to help.1 point -
I too have a great appreciation for enums, especially when they add to the overall readability and maintainability of the code. However, I wouldn't consider the ini example you gave as adding to either the readability or maintainability. Of course it's just my opinion, but it seems to add levels of complexity and obfuscation that are totally unnecessary. If you are the only one that needs to maintain the scripts, then all of the complexity and obfuscation really doesn't matter. But if anyone else has to pick up your code and try to maintain it...well let it suffice to say that I'm glad it wouldn't be me.1 point
-
maniootek, But of course! #include <GUIConstantsEx.au3> #include <GuiListViewEx.au3> #include <Array.au3> #include "StringSize.au3" Global $iWidth = 200, $iTextSize = 10 Example() Func Example() $hGUI = GUICreate("listview items", $iWidth + 20, 250, 100, 200, -1) Local $idListview = GUICtrlCreateListView("col1|col2|col3 ", 10, 10, $iWidth, 150) Local $iExListViewStyle = BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES, $LVS_EX_GRIDLINES, $LVS_EX_DOUBLEBUFFER) _GUICtrlListView_SetExtendedListViewStyle($idListview, $iExListViewStyle) GUICtrlSetFont($idListview, $iTextSize, 0, 0) Local $aArray[6] For $i = 0 To 5 $aArray[$i] = $i & "|name|1" GUICtrlCreateListViewItem($i & "|name|1", $idListview) Next $cButton = GUICtrlCreateButton("Read ListView", 10, 200, 80, 30) GUISetState(@SW_SHOW) $iLV_Index = _GUIListViewEx_Init($idListview, $aArray, 0, 0, True, 2) _GUIListViewEx_SetEditStatus($iLV_Index, "2") _GUIListViewEx_MsgRegister(True, False, False) ; Resize column to match input (not necessasry in this case but colud be if you were entering more varied data) _ColumnResizer($hGUI, $idListview, $iLV_Index) ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $cButton $aRead = _GUIListViewEx_ReturnArray($iLV_Index) _ArrayDisplay($aRead, "Content", Default, 8) $aRead = _GUIListViewEx_ReturnArray($iLV_Index, 1) _ArrayDisplay($aRead, "Checkboxes", Default, 8) EndSwitch $vRet = _GUIListViewEx_EventMonitor() ; Check there was a valid edit return If @extended = 1 And IsArray($vRet) Then ; Resize column to fit new data _ColumnResizer($hGUI, $idListview, $iLV_Index) EndIf WEnd EndFunc ;==>Example Func _ColumnResizer($hGUI, $idListview, $iLV_Index) Local $iMaxWidth = 50 ; Read content $aRead = _GUIListViewEx_ReturnArray($iLV_Index, 3) ; Loop through elements to find longest For $i = 0 To UBound($aRead) - 1 ; Get the size of the string $aRet = _StringSize($aRead[$i][2], $iTextSize) ; And check to see if it is the biggest yet If $aRet[2] + 15 > $iMaxWidth Then ; Reset max width $iMaxWidth = $aRet[2] + 15 EndIf Next ; Now get current column width $iColWidth = _GUICtrlListView_GetColumnWidth($idListview, 2) ; And reset it _GUICtrlListView_SetColumnWidth($idListview, 2, $iMaxWidth) ; Now check on the change we just made $iDiff = $iMaxWidth - $iColWidth ; And adjust GUI to fit $aWinPos = WinGetPos($hGUI) WinMove($hGUI, "", Default, Default, $aWinPos[2] + $iDiff) EndFunc ;==>_ColumnResizer How is that? M231 point
-
That worked! at least in Chrome. I did have to update the _WD_ElementAction() Function to include 'displayed' as a valid command Switch $sCommand Case 'name', 'rect', 'text', 'selected', 'enabled', 'displayed' ; #FUNCTION# ==================================================================================================================== ; Name ..........: _WD_WaitElementVisible ; Description ...: Wait for a element to be found in the current tab and that its visible before returning ; Syntax ........: _WD_WaitElementVisible($sSession, $sElement, $sStrategy, $sSelector[, $iDelay = 0[, $iTimeout = -1]]) ; Parameters ....: $sSession - Session ID from _WDCreateSession ; $sStrategy - Locator strategy. See defined constant $_WD_LOCATOR_* for allowed values ; $sSelector - Value to find ; $iDelay - [optional] Milliseconds to wait before checking status ; $iTimeout - [optional] Period of time to wait before exiting function ; Return values .: Success - 1 ; Failure - 0 and sets the @error flag to non-zero ; @error - $_WD_ERROR_Success ; - $_WD_ERROR_Timeout ; Author ........: Dan Pollak ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _WD_WaitElementVisible($sSession, $sStrategy, $sSelector, $iDelay = 0, $iTimeout = -1) Local Const $sFuncName = "_WD_WaitElementVisible" Local $bAbort = False, $iErr, $iResult, $isVisible If $iTimeout = -1 Then $iTimeout = $_WD_DefaultTimeout Sleep($iDelay) Local $hWaitTimer = TimerInit() While 1 $FindRet = _WD_FindElement($sSession, $sStrategy, $sSelector) $iErr = @error If $iErr = $_WD_ERROR_Success Then $isVisible = _WD_ElementAction($sSession, $FindRet, 'displayed') if $isVisible = True Then $iResult = 1 ExitLoop EndIf ElseIf $iErr = $_WD_ERROR_NoMatch Then If (TimerDiff($hWaitTimer) > $iTimeout) Then $iErr = $_WD_ERROR_Timeout ExitLoop EndIf Else ExitLoop EndIf Sleep(1000) WEnd Return SetError(__WD_Error($sFuncName, $iErr), $iResult) EndFunc1 point
-
Here's a helper function for creating a new tab and optionally switching to it -- Func _WD_NewTab($sSession, $lSwitch = True) _WDExecuteScript($sSession, 'window.open()', '{}') Local $aHandles = _WDWindow($sSession, 'handles', '') If $lSwitch Then _WDWindow($sSession, 'Switch', '{"handle":"' & $aHandles[UBound($aHandles) - 1] & '"}') EndIf EndFunc1 point
-
supersonic, Would Sir like fries with this? #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <ListViewConstants.au3> #Include <GuiListView.au3> Global $iColumns = 3, $sHeader = "This header is longer than the items| | ", $iScroll_Allowance = 0 Global $aData[5] = ["1|1|1", "2|2222222222222|2", "33333333|3333|33333333333333", "4|444444444444444444444444444|4", "5|5|5"] Global $iGUI_Width = 500, $iGUI_Height = 200 ; Create GUI at initial size Global $hGUI = GUICreate("Test", $iGUI_Width, $iGUI_Height) ; Create List View at initial size Global $hListView = GUICtrlCreateListView($sHeader, 10, 10, $iGUI_Width - 20, $iGUI_Height - 20, $LVS_SHOWSELALWAYS, BitOR($LVS_EX_FULLROWSELECT, $WS_EX_CLIENTEDGE)) ; Add data For $i = 0 To UBound($aData) - 1 GUICtrlCreateListViewItem($aData[$i], $hListView) Next ; Scroll down to ensure final item visible _GUICtrlListView_EnsureVisible($hListView, UBound($aData) - 1) ; Check top index - if not 0 then we have a scroll bar so increase ListView width If _GUICtrlListView_GetTopIndex($hListView) > 0 Then $iScroll_Allowance = 17 EndIf ; Scroll to top again _GUICtrlListView_EnsureVisible($hListView, 0) ; Determine ListView width $iLV_Width = $iScroll_Allowance For $i = 0 To $iColumns - 1 ; Size column to fit header _GUICtrlListView_SetColumnWidth($hListView, $i, $LVSCW_AUTOSIZE_USEHEADER) $iHeader_Width = _GUICtrlListView_GetColumnWidth($hListView, $i) ; Now size column to fit data _GUICtrlListView_SetColumnWidth($hListView, $i, $LVSCW_AUTOSIZE) $iData_Width = _GUICtrlListView_GetColumnWidth($hListView, $i) ; If header is wider, reset width If $iHeader_Width > $iData_Width Then _GUICtrlListView_SetColumnWidth($hListView, $i, $iHeader_Width) $iLV_Width += $iHeader_Width Else $iLV_Width += $iData_Width EndIf Next ; Resize ListView and GUI to fit data ControlMove($hGUI, "", $hListView, 10, 10, $iLV_Width + 10, $iGUI_Height - 20) ; Add 10 for internal ListView borders WinMove($hGUI, "", Default, Default, $iLV_Width + 30) ; Add 30 for internal ListView and external GUI borders GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEndI have used _GUICtrlListView functions when we set the column width to make it easier to follow - all they do is wrap the GUICtrlSendMsg commands we used before. M231 point
-
SoulA modified helpfile example without any checking for menu handles. use the GuiMenu.au3 UDF to make menus you can check for the handles of using wparam in _WM_CONTEXTMENU(). see helpfile GuiMenu UDF section example for _GUICtrlMenu_CreatePopup () Edit: added comment on helpfile example #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Opt('MustDeclareVars', 1) Local $contextmenu, $button, $buttoncontext, $buttonitem, $msg, $iFlag = 0 Local $newsubmenu, $textitem, $fileitem, $saveitem, $infoitem ;right click on gui to bring up context Menu. ;right click on the "ok" button to bring up a control specific context menu. ;click on the "ok" button to disable contextmenus GUICreate("My GUI Context Menu", 300, 200) $button = GUICtrlCreateButton("Context Menu Enabled", 75, 100, 150, 20) $buttoncontext = GUICtrlCreateContextMenu($button) $buttonitem = GUICtrlCreateMenuItem("About button", $buttoncontext) $contextmenu = GUICtrlCreateContextMenu() $newsubmenu = GUICtrlCreateMenu("new", $contextmenu) $textitem = GUICtrlCreateMenuItem("text", $newsubmenu) $fileitem = GUICtrlCreateMenuItem("Open", $contextmenu) $saveitem = GUICtrlCreateMenuItem("Save", $contextmenu) GUICtrlCreateMenuItem("", $contextmenu) ; separator $infoitem = GUICtrlCreateMenuItem("Info", $contextmenu) GUIRegisterMsg($WM_CONTEXTMENU, "_WM_CONTEXTMENU") GUISetState() While 1 Switch GUIGetMsg() Case $button $iFlag = Not $iFlag If $iFlag Then GUICtrlSetData($button, "Context Menu Disabled") Else GUICtrlSetData($button, "Context Menu Enabled") EndIf Case $GUI_EVENT_CLOSE GUIDelete() Exit EndSwitch WEnd Func _WM_CONTEXTMENU($hwnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam, $lParam If $iFlag Then Return 0 Return $GUI_RUNDEFMSG EndFunc1 point
-
The solution is for me to fix that mod I made a couple of weeks ago.... which is done now and uploaded. ... and don't try to reason with @FrancoDM as somehow he is pissed off at me for pushing him to provide a replicator script. When he did the issue was clear and we could fix it. Anyway ... it is what it is, and "just let him stew in his own juice".0 points
-
@Jemboy Perhaps you can explain why you have to keep making these changes. FWIW, most of the examples that you will find online are geared towards Selenium so not sure will meet your needs. Sounds like we need another "helper" function that assists in this task.0 points