Leaderboard
Popular Content
Showing content with the highest reputation on 04/23/2016 in all areas
-
meomeo192, You need to use a ListView to display the data - you can set certain column widths to zero so that they do not display and add checkboxes to the first column. The other controls you have there are standard. This should get you started: #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <File.au3> #include <Array.au3> #include <GuiListView.au3> ; Create file $sFileName = "Data.txt" FileDelete($sFileName) $sString = "Checked|Column 1|Column 2|Column 3|Column 4|Column 5|Column 6|Column 7|Column 8" & @CRLF & _ "×|50.01.0001|160404134631346000|Other value|T3|alphachymotrypsin|Other value|C|alpha choay 4000IU" & @CRLF & _ "×|50.01.0003|160407154252435000|Other value|T2|Paracetamol|Other value|C|Acepron 250mg" & @CRLF & _ "|50.01.0005|160415135700860000|Other value|T3|Acenocoumarol|Other value|D|Acenocumarol WPW 4mg" & @CRLF & _ "|50.01.0006|160423064434487000|Other value|T3|Acetylcystein|Other value|D|Aceblue 100mg" & @CRLF & _ "×|50.01.0007|160430993168114000|Other value|T1|Acetylcystein|Other value|C|Aceblue 200mg" FileWrite($sFileName, $sString) ; Read file into a 2D array Local $aData _FileReadToArray($sFileName, $aData, $FRTA_NOCOUNT, "|") ; Create GUI $hGUI = GUICreate("Test", 800, 500) ; Create controls GUICtrlCreateLabel("Find:", 10, 30, 100, 20) $cInput = GUICtrlCreateInput("", 120, 30, 300, 20) $cSave = GUICtrlCreateButton("Save Check", 480, 10, 80, 20) $cFind = GUICtrlCreateButton("Find", 480, 30, 80, 20) $cFind8Only = GUICtrlCreateCheckbox(" Column 8 only", 600, 30, 200, 20) ; Create ListView $cListView = GUICtrlCreateListView("", 10, 100, 780, 300) _GUICtrlListView_SetExtendedListViewStyle($cListView, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES, $LVS_EX_CHECKBOXES)) ; Add columns For $i = 0 To 8 _GUICtrlListView_AddColumn($cListView, $aData[0][$i], 100) Next ; Hide columns 3 & 6 _GUICtrlListView_HideColumn($cListView, 3) _GUICtrlListView_HideColumn($cListView, 6) ; Remove the header _ArrayDelete($aData, 0) ; Load the ListView with the data _GUICtrlListView_AddArray($cListView, $aData) ; Check the checkboxes to match the data For $i = 0 To _GUICtrlListView_GetItemCount($cListView) - 1 If $aData[$i][0] = "×" Then _GUICtrlListView_SetItemChecked($cListView, $i) _GUICtrlListView_SetItemText($cListView, $i, "") EndIf Next GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Please ask if you have any questions. M232 points
-
[New Release] - 06 April 2019 Added: Error-checking for sensible column numbers in the $aSortData array, with an additional error status. ------------------------------------------------------------------------------------------------------------------------ While answering a recent question about sorting a ListView on several columns, I developed this function to sort a 2D array on several columns and I though I might give it a wider audience. Here is the function: #include-once ;#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7 ; #INCLUDES# ========================================================================================================= #include <Array.au3> ; =============================================================================================================================== ; #INDEX# ======================================================================================================================= ; Title .........: ArrayMultiColSort ; AutoIt Version : v3.3.8.1 or higher ; Language ......: English ; Description ...: Sorts 2D arrays on several columns ; Note ..........: ; Author(s) .....: Melba23 ; Remarks .......: ; =============================================================================================================================== ; #CURRENT# ===================================================================================================================== ; _ArrayMultiColSort : Sort 2D arrays on several columns ; =============================================================================================================================== ; #INTERNAL_USE_ONLY#================================================================================================= ; __AMCS_SortChunk : Sorts array section ; =============================================================================================================================== ; #FUNCTION# ==================================================================================================================== ; Name...........: _ArrayMultiColSort ; Description ...: Sort 2D arrays on several columns ; Syntax.........: _ArrayMultiColSort(ByRef $aArray, $aSortData[, $iStart = 0[, $iEnd = 0]]) ; Parameters ....: $aArray - The 2D array to be sorted ; $aSortData - 2D array holding details of the sort format ; Format: [Column to be sorted, Sort order] ; Sort order can be either numeric (0/1 = ascending/descending) or a ordered string of items ; Any elements not matched in string are left unsorted after all sorted elements ; $iStart - Element of array at which sort starts (default = 0) ; $iEnd - Element of array at which sort endd (default = 0 - converted to end of array) ; Requirement(s).: v3.3.8.1 or higher ; Return values .: Success: No error ; Failure: @error set as follows ; @error = 1 with @extended set as follows (all refer to $sIn_Date): ; 1 = Array to be sorted not 2D ; 2 = Sort data array not 2D ; 3 = More data rows in $aSortData than columns in $aArray ; 4 = Start beyond end of array ; 5 = Start beyond End ; @error = 2 with @extended set as follows: ; 1 = Invalid string parameter in $aSortData ; 2 = Invalid sort direction parameter in $aSortData ; 3 = Invalid column index in $aSortData ; Author ........: Melba23 ; Remarks .......: Columns can be sorted in any order ; Example .......; Yes ; =============================================================================================================================== Func _ArrayMultiColSort(ByRef $aArray, $aSortData, $iStart = 0, $iEnd = 0) ; Errorchecking ; 2D array to be sorted If UBound($aArray, 2) = 0 Then Return SetError(1, 1, "") EndIf ; 2D sort data If UBound($aSortData, 2) <> 2 Then Return SetError(1, 2, "") EndIf If UBound($aSortData) > UBound($aArray) Then Return SetError(1, 3) EndIf For $i = 0 To UBound($aSortData) - 1 If $aSortData[$i][0] < 0 Or $aSortData[$i][0] > UBound($aArray, 2) -1 Then Return SetError(2, 3, "") EndIf Next ; Start element If $iStart < 0 Then $iStart = 0 EndIf If $iStart >= UBound($aArray) - 1 Then Return SetError(1, 4, "") EndIf ; End element If $iEnd <= 0 Or $iEnd >= UBound($aArray) - 1 Then $iEnd = UBound($aArray) - 1 EndIf ; Sanity check If $iEnd <= $iStart Then Return SetError(1, 5, "") EndIf Local $iCurrCol, $iChunk_Start, $iMatchCol ; Sort first column __AMCS_SortChunk($aArray, $aSortData, 0, $aSortData[0][0], $iStart, $iEnd) If @error Then Return SetError(2, @extended, "") EndIf ; Now sort within other columns For $iSortData_Row = 1 To UBound($aSortData) - 1 ; Determine column to sort $iCurrCol = $aSortData[$iSortData_Row][0] ; Create arrays to hold data from previous columns Local $aBaseValue[$iSortData_Row] ; Set base values For $i = 0 To $iSortData_Row - 1 $aBaseValue[$i] = $aArray[$iStart][$aSortData[$i][0]] Next ; Set start of this chunk $iChunk_Start = $iStart ; Now work down through array For $iRow = $iStart + 1 To $iEnd ; Match each column For $k = 0 To $iSortData_Row - 1 $iMatchCol = $aSortData[$k][0] ; See if value in each has changed If $aArray[$iRow][$iMatchCol] <> $aBaseValue[$k] Then ; If so and row has advanced If $iChunk_Start < $iRow - 1 Then ; Sort this chunk __AMCS_SortChunk($aArray, $aSortData, $iSortData_Row, $iCurrCol, $iChunk_Start, $iRow - 1) If @error Then Return SetError(2, @extended, "") EndIf EndIf ; Set new base value $aBaseValue[$k] = $aArray[$iRow][$iMatchCol] ; Set new chunk start $iChunk_Start = $iRow EndIf Next Next ; Sort final section If $iChunk_Start < $iRow - 1 Then __AMCS_SortChunk($aArray, $aSortData, $iSortData_Row, $iCurrCol, $iChunk_Start, $iRow - 1) If @error Then Return SetError(2, @extended, "") EndIf EndIf Next EndFunc ;==>_ArrayMultiColSort ; #INTERNAL_USE_ONLY# =========================================================================================================== ; Name...........: __AMCS_SortChunk ; Description ...: Sorts array section ; Author ........: Melba23 ; Remarks .......: ; =============================================================================================================================== Func __AMCS_SortChunk(ByRef $aArray, $aSortData, $iRow, $iColumn, $iChunkStart, $iChunkEnd) Local $aSortOrder ; Set default sort direction Local $iSortDirn = 1 ; Need to prefix elements? If IsString($aSortData[$iRow][1]) Then ; Split elements $aSortOrder = StringSplit($aSortData[$iRow][1], ",") If @error Then Return SetError(1, 1, "") EndIf ; Add prefix to each element For $i = $iChunkStart To $iChunkEnd For $j = 1 To $aSortOrder[0] If $aArray[$i][$iColumn] = $aSortOrder[$j] Then $aArray[$i][$iColumn] = StringFormat("%02i-", $j) & $aArray[$i][$iColumn] ExitLoop EndIf Next ; Deal with anything that does not match If $j > $aSortOrder[0] Then $aArray[$i][$iColumn] = StringFormat("%02i-", $j) & $aArray[$i][$iColumn] EndIf Next Else Switch $aSortData[$iRow][1] Case 0, 1 ; Set required sort direction if no list If $aSortData[$iRow][1] Then $iSortDirn = -1 Else $iSortDirn = 1 EndIf Case Else Return SetError(1, 2, "") EndSwitch EndIf ; Sort the chunk Local $iSubMax = UBound($aArray, 2) - 1 __ArrayQuickSort2D($aArray, $iSortDirn, $iChunkStart, $iChunkEnd, $iColumn, $iSubMax) ; Remove any prefixes If IsString($aSortData[$iRow][1]) Then For $i = $iChunkStart To $iChunkEnd $aArray[$i][$iColumn] = StringTrimLeft($aArray[$i][$iColumn], 3) Next EndIf EndFunc ;==>__AMCS_SortChunk And here is an example to show it working: #include "ArrayMultiColSort.au3" #include <String.au3> ; Only used to fill array ; Create and display array Global $aArray[100][4] For $i = 0 To 99 $aArray[$i][0] = _StringRepeat(Chr(Random(65, 68, 1)), 5) $aArray[$i][1] = _StringRepeat(Chr(Random(74, 77, 1)), 5) $aArray[$i][2] = _StringRepeat(Chr(Random(80, 83, 1)), 5) $aArray[$i][3] = _StringRepeat(Chr(Random(87, 90, 1)), 5) Next _ArrayDisplay($aArray, "Unsorted") ; Copy arrays for separate examples below $aArray_1 = $aArray $aArray_2 = $aArray ; This sorts columns in ascending order - probably the most common requirement ; Sort requirement: ; Col 0 = Decending ; Col 1 = Ascending ; Col 2 = Required order of elements (note not alphabetic PQRS nor reverse SRQP) ; Col 3 = Ascending Global $aSortData[][] = [ _ [0, 1], _ [1, 0], _ [2, "SSSSS,QQQQQ,PPPPP,RRRRR"], _ [3, 0]] ; Sort and display array _ArrayMultiColSort($aArray_1, $aSortData) ; Display any errors encountered If @error Then ConsoleWrite("Oops: " & @error & " - " & @extended & @CRLF) _ArrayDisplay($aArray_1, "Sorted in order 0-1-2-3") ; But the UDF can sort columns in any order ; Sort requirement: ; Col 2 = Decending ; Col 0 = Ascending Global $aSortData[][] = [ _ [2, 1], _ [0, 0]] ; Sort and display array _ArrayMultiColSort($aArray_2, $aSortData) ; Display any errors encountered If @error Then ConsoleWrite("Oops: " & @error & " - " & @extended & @CRLF) _ArrayDisplay($aArray_2, "Sorted in order 2-0") And here are both in zip form: ArrayMultiColSort.zip As usual all comments welcome. M231 point
-
Hello. DllCall("UxTheme.dll","LONG","HWND",$YourHWND,"INT",$YourWINDOWTHEMEATTRIBUTETYPE,"ptr",$yourpvAttribute,"dword",$yourcbAttribute) Saludos1 point
-
May I add ;.... _GUICtrlListView_SetColumnOrder ($cListView, "0|1|2|7|4|5|8|3|6") ; GUISetState()1 point
-
$workingdir1 = FileSelectFolder("Select folder", "") ; Shows desktop as root $workingdir2 = FileSelectFolder("Select folder", $workingdir1) ; shows $workingdir1 return folder as root if you have any other function that points to different(last) directory between those 2 lines, use their value instead of $workingdir11 point
-
Check out my CodeCrypter (link in my sig), it supports user password (key ID 1) plus additional concurrent environment checks (use the multiple encryption keys option, user-defined in MCFinclude.au3, in array $CCkey). Allowing a subset of IPs will probably require you to write a little lookup function (producing versions that each validate a single IP directly would be more secure though).1 point
-
Oops, sorry I missed the notification for your previous post. Yet you're lucky: I never answer question related to games (see forum rules why), but I considered your script isn't actually "interacting with one". Glad to see you finally got it working. It's now up to you to decide which codepage constant has to be used with each file.1 point
-
That was easy. Check the code. Weekdays and months are in danish on my PC. Nice. #include <GUIConstantsEx.au3> #include <date.au3> #include ".\UDFs\ListViewColorsFonts.au3" #include ".\UDFs\GuiListViewEx.au3" Example() Func Example() Local $bISO = True ; if True = 1° Day week Moonday ; if False = 1° Day week Sunday Local $aDaysOfWeek, $sDaysOfWeekISO, $iDayLen = 3 For $i = 1 To 7 $sDaysOfWeekISO &= StringLeft(_DateDayOfWeek($i, $DMW_LOCALE_LONGNAME), $iDayLen) & "|" Next $sDaysOfWeekISO = ($bISO) ? StringMid($sDaysOfWeekISO, $iDayLen + 2) & StringLeft($sDaysOfWeekISO, $iDayLen) : StringLeft($sDaysOfWeekISO, $iDayLen * 7 + 6) ; $aDaysOfWeek = StringSplit($sDaysOfWeekISO, '|') ; _ArrayDisplay($aDaysOfWeek,$sDaysOfWeekISO) Local $hGui = GUICreate("ListView test", 1300, 500) ; Create the "skeleton" of the ListView (an empty ListView) Local $iColumns = 32 ; desired columns in the ListView (0 to 31) Local $iRows = 12 ; nr. of rows (in addition to the header) Local $sColumns = StringReplace(StringFormat('%' & $iColumns & 's', ""), " ", '|') ; as many separators as desired nr. of columns Local $idListview = GUICtrlCreateListView($sColumns, 2, 2, 1296, 496, Default, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_DOUBLEBUFFER, $LVS_EX_GRIDLINES)) For $i = 1 To 12 ; create the rows (in addition to the header) GUICtrlCreateListViewItem($sColumns, $idListview) Next ; Initialize ListView to support alternating row colors ListViewColorsFonts_Init( $idListView, 7 ) ; 7 = Back and fore colors <--- this alone works OK ; Set columns (headers) _GUICtrlListView_SetColumn($idListview, 0, @YEAR, 140, 0) ; First column header (Year) For $i = 1 To 31 ; Days of month _GUICtrlListView_SetColumn($idListview, $i, $i, 37) Next ; Set items Text Local $iYear = @YEAR, $iDayOfWeek For $iMonth = 1 To 12 _GUICtrlListView_SetItemText($idListview, $iMonth - 1, _DateToMonth($iMonth, $DMW_LOCALE_LONGNAME)) ; Month name If Not Mod( $iMonth, 2 ) Then ListViewColorsFonts_SetItemColors($idListview, $iMonth - 1, -1, 0xCCFFFF ) ; Cyan <<<<<<<<<<<< ;If Mod( $iMonth, 6 ) > 2 Then ListViewColorsFonts_SetItemColors($idListview, $iMonth, -1, 0xCCFFFF ) ; Cyan, quarters for $iDay = 1 To _DateDaysInMonth($iYear, $iMonth) $iDayOfWeek = ($bISO) ? _DateToDayOfWeekISO($iYear, $iMonth, $iDay) : _DateToDayOfWeek($iYear, $iMonth, $iDay) _GUICtrlListView_SetItemText($idListview, $iMonth - 1, $aDaysOfWeek[$iDayOfWeek], $iDay) If _DateToDayOfWeekISO($iYear, $iMonth, $iDay) = 7 Then ListViewColorsFonts_SetItemColors($idListview, $iMonth - 1, $iDay, 0xCCCCFF, 0xFF0000) ; Blue, Red EndIf Next ; Next day Next; Next Month ; Set Today Green ListViewColorsFonts_SetItemColors($idListview, Int(@MON)-1, Int(@MDAY), 0x00FF00, 0xFF0000) ; Blue, Green ; Adjust height of GUI and ListView to fit ten rows Local $iLvHeight = _GUICtrlListView_GetHeightToFitRows($idListview, $iRows) WinMove($hGui, "", Default, Default, Default, WinGetPos($hGui)[3] - WinGetClientSize($hGui)[1] + $iLvHeight + 4 ) WinMove(GUICtrlGetHandle($idListview), "", Default, Default, Default, $iLvHeight + 4 ) ; 4 additional pixels to account for gridlines ; Redraw listview ListViewColorsFonts_Redraw($idListview) GUISetState(@SW_SHOW) ; Loop until the user exits. Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>Example1 point
-
I vote this to replace 'resistance is obligatory'1 point
-
Look at _GetIP() on help file and base on Result do your needed check. Regards Alien.1 point
-
@Imbuter2000, If you meant that regex_one (note: not regex_test_one) alone doesn't match, this is no surprise since the final \r\n in the expression can never match. Hence this part of the alternation is pointless. Your regexps are terrible and imply a whole lot of useless backtracking. Besides, it is unclear what you actually intend to capture, how the various fields are formatted and whether they are mandatory or not.1 point
-
Hi I'm palyng with this UDF and I have a dobut: Can "Item colors" and "Alternating row colors" functions be combined together? Here is a listing for testing where I'm trying to use both functionalities at the same time without success. If I use Line 33 as this it works (sunday is red): ;(setting 7 alone as second parameter it works) ListViewColorsFonts_Init( $idListView, 7 ) ; 7 = Back and fore colors If I use Line 34 as this it works (Alternating rows colors): ; (setting 16 alone as second parameter it works) ListViewColorsFonts_Init( $idListView, 16 ) ; 16 = Alternating row colors (for entire listview) If I try to combine both of above In Line 35, it doesn't work. ; Combining both together it doesn't work ListViewColorsFonts_Init($idListview, BitOR(7, 16)) ; 7 and 16 combined What am I doing wrong? any help is welcome Thanks #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <date.au3> #include ".\UDFs\ListViewColorsFonts.au3" #include ".\UDFs\GuiListViewEx.au3" Example() Func Example() Local $bISO = True ; if True = 1° Day week Moonday ; if False = 1° Day week Sunday Local $aDaysOfWeek, $sDaysOfWeekISO, $iDayLen = 3 For $i = 1 To 7 $sDaysOfWeekISO &= StringLeft(_DateDayOfWeek($i, $DMW_LOCALE_LONGNAME), $iDayLen) & "|" Next $sDaysOfWeekISO = ($bISO) ? StringMid($sDaysOfWeekISO, $iDayLen + 2) & StringLeft($sDaysOfWeekISO, $iDayLen) : StringLeft($sDaysOfWeekISO, $iDayLen * 7 + 6) ; $aDaysOfWeek = StringSplit($sDaysOfWeekISO, '|') ; _ArrayDisplay($aDaysOfWeek,$sDaysOfWeekISO) Local $hGui = GUICreate("ListView test", 1300, 500) ; Create the "skeleton" of the ListView (an empty ListView) Local $iColumns = 32 ; desired columns in the ListView (0 to 31) Local $iRows = 12 ; nr. of rows (in addition to the header) Local $sColumns = StringReplace(StringFormat('%' & $iColumns & 's', ""), " ", '|') ; as many separators as desired nr. of columns Local $idListview = GUICtrlCreateListView($sColumns, 2, 2, 1296, 496, Default, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_DOUBLEBUFFER, $LVS_EX_GRIDLINES)) For $i = 1 To 12 ; create the rows (in addition to the header) GUICtrlCreateListViewItem($sColumns, $idListview) Next ; Initialize ListView to support alternating row colors ListViewColorsFonts_Init( $idListView, 7 ) ; 7 = Back and fore colors <--- this alone works OK ;~ ListViewColorsFonts_Init( $idListView, 16 ) ; 16 = Alternating row colors (for entire listview) <--- this alone works OK ;~ ListViewColorsFonts_Init($idListview, BitOR(7, 16)) ; 7 and 16 combined <--- above combined together doesn't work ??? ListViewColorsFonts_SetAlternatingColors($idListview, _ 1, 1, _ ; $iRows = 1, $iCols = 1 0xCCFFFF, -1) ; $iBackColor = Cyan, $iForeColor = Default (black) GUISetState(@SW_SHOW) ; Fill all rows and columns with wanted data _GUICtrlListView_BeginUpdate($idListview) ; Set columns (headers) _GUICtrlListView_SetColumn($idListview, 0, @YEAR, 140, 0) ; First column header (Year) For $i = 1 To 31 ; Days of month _GUICtrlListView_SetColumn($idListview, $i, $i, 37) Next ; Set items Text Local $iYear = @YEAR, $iDayOfWeek For $iMonth = 1 To 12 _GUICtrlListView_SetItemText($idListview, $iMonth - 1, _DateToMonth($iMonth, $DMW_LOCALE_LONGNAME)) ; Month name for $iDay = 1 To _DateDaysInMonth($iYear, $iMonth) $iDayOfWeek = ($bISO) ? _DateToDayOfWeekISO($iYear, $iMonth, $iDay) : _DateToDayOfWeek($iYear, $iMonth, $iDay) _GUICtrlListView_SetItemText($idListview, $iMonth - 1, $aDaysOfWeek[$iDayOfWeek], $iDay) If _DateToDayOfWeekISO($iYear, $iMonth, $iDay) = 7 Then ListViewColorsFonts_SetItemColors($idListview, $iMonth - 1, $iDay, 0xCCCCFF, 0xFF0000) ; Blue, Red EndIf Next ; Next day Next; Next Month ; Set Today Green ListViewColorsFonts_SetItemColors($idListview, @MON - 1, @MDAY, 0x00FF00, 0xFF0000) ; Blue, Green ; Adjust height of GUI and ListView to fit ten rows Local $iLvHeight = _GUICtrlListView_GetHeightToFitRows($idListview, $iRows) WinMove($hGui, "", Default, Default, Default, WinGetPos($hGui)[3] - WinGetClientSize($hGui)[1] + $iLvHeight + 20) WinMove($idListview, "", Default, Default, Default, $iLvHeight) ; Redraw listview ListViewColorsFonts_Redraw($idListview) _GUICtrlListView_EndUpdate($idListview) ; Loop until the user exits. Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>Example1 point
-
Even better, this solution which is not a workaround #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <IE.au3> HotKeySet("{ESC}", "myExit") ;GUI setup $GUI_main = GUICreate("Menu", 800, 800, -1, -1) Global $oIE =_IECreateEmbedded() $ObjectIE = GUICtrlCreateObj($oIE, 0, 30, 800, 770) $cButton1 = GUICtrlCreateButton("Start test inside GUI window", 0, 0, 400, 30) GUISetState(@SW_SHOW, $GUI_main) ;GUI While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $cButton1 fTestFunction1() EndSwitch WEnd ;function inside GUI Func fTestFunction1() Local $sURL = "http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/onbeforeunload.htm" $oIE.Navigate($sURL) _IELoadWait($oIE) _IEHeadInsertEventScript($oIE, "window", "onbeforeunload", "return;") Sleep(2000) $oIE.Navigate("https://www.google.com") MsgBox($MB_TOPMOST, "", "done", 2) EndFunc ;shortcut to exit Func myExit() GUIDelete($GUI_main) Exit EndFunc1 point
-
another simpler workaround could be like this: change this code in your listing $oIE.Navigate("https://www.google.com") with this: $dummy = $oIE.Navigate("https://www.google.com") + Send("!o") and remove the Send("!o") located after the Sleep(2500) statement.1 point
-
You can do some tests with this code #include "CUIAutomation2.au3" Opt( "MustDeclareVars", 1 ) Opt( "WinTitleMatchMode", 2 ) Example() Func Example() ; Mozilla Thunderbird window Local $hWindow = WinGetHandle( " - Mozilla Thunderbird" ) If Not $hWindow Then Return ConsoleWrite( "Window handle ERR" & @CRLF ) ConsoleWrite( "Window handle OK" & @CRLF ) ; Create UI Automation object Local $oUIAutomation = ObjCreateInterface( $sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtagIUIAutomation ) If Not IsObj( $oUIAutomation ) Then Return ConsoleWrite( "UI Automation object ERR" & @CRLF ) ConsoleWrite( "UI Automation object OK" & @CRLF ) ; Get UI Automation element from window handle Local $pWindow, $oWindow $oUIAutomation.ElementFromHandle( $hWindow, $pWindow ) $oWindow = ObjCreateInterface( $pWindow, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) ; Note that $oWindow is an AutomationElement object ; Search for $dtagIUIAutomationElement in CUIAutomation2.au3 to see which methods can be used If Not IsObj( $oWindow ) Then Return ConsoleWrite( "Automation element from window ERR" & @CRLF ) ConsoleWrite( "Automation element from window OK" & @CRLF ) #cs ; Condition to find text controls Local $pCondition $oUIAutomation.CreatePropertyCondition( $UIA_ControlTypePropertyId, $UIA_TextControlTypeId, $pCondition ) If Not $pCondition Then Return ConsoleWrite( "Property condition ERR" & @CRLF ) ConsoleWrite( "Property condition OK" & @CRLF ) #ce ; Condition to find custom controls Local $pCondition $oUIAutomation.CreatePropertyCondition( $UIA_ControlTypePropertyId, $UIA_CustomControlTypeId, $pCondition ) ; You can use any of the ControlTypeIds in CUIAutomation2.au3 (search for ControlTypeId) If Not $pCondition Then Return ConsoleWrite( "Property condition ERR" & @CRLF ) ConsoleWrite( "Property condition OK" & @CRLF ) ; Find custom controls Local $pUIElementArray, $oUIElementArray, $iElements $oWindow.FindAll( $TreeScope_Descendants, $pCondition, $pUIElementArray ) ; You can use any of the TreeScope constants in CUIAutomation2.au3 (search for TreeScope) $oUIElementArray = ObjCreateInterface( $pUIElementArray, $sIID_IUIAutomationElementArray, $dtagIUIAutomationElementArray ) $oUIElementArray.Length( $iElements ) If Not $iElements Then Return ConsoleWrite( "Find controls ERR" & @CRLF ) ConsoleWrite( "Find controls OK" & @CRLF ) ; Print custom control info Local $pUIElement, $oUIElement For $i = 0 To $iElements - 1 ConsoleWrite( @CRLF ) $oUIElementArray.GetElement( $i, $pUIElement ) $oUIElement = ObjCreateInterface( $pUIElement, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) ConsoleWrite( "Index = " & $i & @CRLF & _ "Name = " & GetCurrentPropertyValue( $oUIElement, $UIA_NamePropertyId ) & @CRLF & _ "Class = " & GetCurrentPropertyValue( $oUIElement, $UIA_ClassNamePropertyId ) & @CRLF & _ "Ctrl type = " & GetCurrentPropertyValue( $oUIElement, $UIA_ControlTypePropertyId ) & @CRLF & _ "Ctrl name = " & GetCurrentPropertyValue( $oUIElement, $UIA_LocalizedControlTypePropertyId ) & @CRLF & _ "Value = " & GetCurrentPropertyValue( $oUIElement, $UIA_LegacyIAccessibleValuePropertyId ) & @CRLF & _ "Rectangle = " & GetCurrentPropertyValue( $oUIElement, $UIA_BoundingRectanglePropertyId ) & @CRLF & _ "Handle = " & Hex( GetCurrentPropertyValue( $oUIElement, $UIA_NativeWindowHandlePropertyId ) ) & @CRLF ) ; You can add any of the PropertyIdIds in CUIAutomation2.au3 (search for PropertyId) Next EndFunc Func GetCurrentPropertyValue( $obj, $id ) Local $tVal $obj.GetCurrentPropertyValue( $id, $tVal ) If Not IsArray( $tVal ) Then Return $tVal Local $tStr = $tVal[0] For $i = 1 To UBound( $tVal ) - 1 $tStr &= "; " & $tVal[$i] Next Return $tStr EndFunc1 point