Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 11/22/2020 in all areas

  1. This example is about implementing Rectangular Selection in a listview with mouse and keyboard. By default, listviews only supports selection of entire rows. Either a single row or multiple rows. The purpose of this UDF is also to support selection of a rectangular group of cells. Either a single rectangular group of cells or multiple rectangular groups of cells. The UDF supports all four types of listviews: The conventional (all examples in the help file), virtual (includes the $LVS_OWNERDATA style), ownerdrawn (includes the $LVS_OWNERDRAWFIXED style) and ownerdrawn+virtual listview. The examples are all about virtual listviews to verify that the code still works with a large number of additional WM_NOTIFY messages needed to populate a virtual listview. One additional message per cell for all cells visible on a listview page. If a page shows 40 rows and 15 columns, this means 600 additional messages to fill the page with data. The first post here is about selecting a single rectangular group of cells. The next post is about selecting multiple rectangular groups of cells. Single selectionSelecting a single rectangular group of cells forming a rectangular selection can be performed by selecting the first corner cell of the rectangle as a fixed starting cell and then selecting the opposite corner cell of the rectangle based on the Single Cell Navigation technique. The technique of creating a single rectangular selection in this post and of creating multiple rectangular selections in the next post is heavily based on the Single Cell Navigation (SCN) UDF. The ideas in code to implement resizable GUIs and listviews and the use of multiple listviews are exactly the same in terms of Rectangular Selections as they are in terms of Single Cell Navigation. And the requirements for a listview to implement Rectangular Selections are the same as the requirements for implementing Single Cell Navigation: The $LVS_EX_HEADERDRAGDROP style (drag/drop reordering of columns) is not supported. Zero-width columns are not supported. In the code it's checked that columns are not narrower than 10 pixels. ExampleThis is the Virtual-SRS.au3 example. The example demonstrates the use of the pure UDF. The rectangle selection is not used in user code. Run the example in SciTE with F5. Right-click listview and select "Single rectangle selection". You should try to create a selection using all four methods described below: The yellow cell is the active cell that is subject of keyboard navigation. There are four ways to create a rectangle selection. Click and drag a selection with the mouse. Releasing the mouse button completes the selection. The advantage of this method is that it's simple, fast and intuitive. The disadvantage is that it can only be used to make a selection on the current visible page in the listview. When using the mouse to create the selection, you cannot use the mouse on the scrollbars at the same time. The other three ways uses the Shift key to create the selection. This allows you to continue a selection by pressing the Shift key and performing single cell navigation on the yellow active cell in one of the corners of the current selection. You can also continue a selection started with the Click and drag method above. The ability to continue a selection allows you to create large selections that span multiple listview pages and navigate the listview with the scrollbars in between each subselection. The three methods with the Shift key are fully integrated. You can start a selection with one method and continue with another method. The yellow active cell is the fixed start cell in the selection rectangle. Press the Shift key and Use keyboard navigation to create the selection rectangle. Click the opposite corner of the selection rectangle with the mouse. Using the scrollbars, you can navigate around the listview before clicking the opposite corner. Click and drag a selection with the mouse. Releasing Shift key and mouse button temporarily completes the selection. Since only a single rectangle selection is supported, a click of the mouse, a movement of the yellow active cell with the keyboard or starting a new selection will immediately delete the current selection. The codeSingle Rectangle Selection (SRS) is implemented as a UDF in Includes\GuiListViewSRS.au3. GuiListViewSRS.au3 was started as a direct copy of GuiListViewSCN.au3. The UDF contains two functions to enable and disable SRS functionality. The functions starts and stops two message handlers implemented through the subclassing technique that takes care of the actual Single Rectangle Selection. One message handler, SRS_GuiHandler(), takes care of WM_NOTIFY messages (listview and header notifications and messages) sent to the main GUI. The other message handler, SRS_ListViewHandler(), takes care of mouse and keyboard messages sent directly to the listview. ExamplesRun examples in SciTE with F5. There are only two examples of single rectangle selections. Virtual-SRS.au3 is the example shown above. Virtual-SRS-Ex.au3 is a very simple example of using the rectangle selection in the user code. It's used to draw a corresponding rectangle in the user code. Right-click listview and select "Single rectangle selection" to switch to UDF code. Create a rectangle selection. Right-click listview and select "Default row selection" to switch back to user code. Because the UDF only supports single selections, the rectangle is passed to the user code as item/subitem (row/column) coordinates (indexes) of two opposite corner cells in the rectangle. This means that even a very large rectangle is passed instantly. You should see the rectangel in the user code. 7z-fileThe 7z-file contains source code for UDFs and examples. You need AutoIt 3.3.12 or later. Tested on Windows 7 and Windows 10. Comments are welcome. Let me know if there are any issues. RectangularSelection.7z
    1 point
  2. @Siwa Not sure why the javascript worked where the standard click didn't, but glad you found a solution. FWIW, the control is being found successfully, but the click attempt is failing with "element not interactable". From the webdriver specs --
    1 point
  3. @Siwa The link you sent me via PM won't load for me. Not sure why... maybe limited access geographically. <shrug> Maybe this will help you -- #include <wd_core.au3> Local $sDesiredCapabilities SetupChrome() _WD_Startup() Local $sSession = _WD_CreateSession($sDesiredCapabilities) _WD_Navigate($sSession, "https://cdn.rawgit.com/salmanarshad2000/demos/v1.0.4/jquery-ui-dialog/modal-dialog-with-buttons.html") Local $oElement1 = _WD_FindElement($sSession,$_WD_LOCATOR_ByXPath,"//div[@class='ui-dialog-buttonset']/button[1]") Local $oElement2 = _WD_FindElement($sSession,$_WD_LOCATOR_ByXPath,"//div[@class='ui-dialog-buttonset']/button[2]") _WD_ElementAction($sSession, $oElement1, 'click') Func SetupChrome() _WD_Option('Driver', 'chromedriver.exe') _WD_Option('Port', 9515) _WD_Option('DriverParams', '--verbose --log-path="' & @ScriptDir & '\chrome.log"') $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "excludeSwitches": [ "enable-automation"], "useAutomationExtension": false }}}}' EndFunc
    1 point
  4. @Siwa Can you provide a link to the website? If not, then how about finding another site with the same type of dialog? FWIW, I suspect that you are dealing with a jQuery Dialog like this, but can't tell for sure based on info provided.
    1 point
  5. Here what I do : _WD_WINDOW($sSession, "rect", '{"x":-1000,"y":-1000,"width":500,"height":500}')
    1 point
  6. is a small variation that saves 2 bytes allowed on my previous post? Local $dog = "shorty\wp-content\plugins\IDXSEO\css\colors.php" MsgBox(0, '', StringTrimLeft($dog, StringInStr($dog, '\', 0, -1))) p.s. in versions that uses an array, if you want to save some bytes you can avoid using the $cat variable like this: Local $dog = "shorty\wp-content\plugins\IDXSEO\css\colors.php" Msgbox(0,"", StringRegExp($dog, "[^\\]+$", 1)[0])
    1 point
  7. @Siwa Have you checked out the ChroPath extension?
    1 point
  8. Hello pixelsearch, I have added your changes to "ArrayDisplayInternals.au3". The sort context menu is very useful. Thanks again.
    1 point
  9. Second post above has been completed. 7z-file at bottom of first post has been updated.
    1 point
  10. This example is about Single Cell Navigation in a listview with mouse and keyboard. By default, listviews only supports navigation through the rows. The purpose of this UDF is also to support navigation through the cells. The UDF supports all four types of listviews: The conventional (all examples in the help file), virtual (includes the $LVS_OWNERDATA style), ownerdrawn (includes the $LVS_OWNERDRAWFIXED style) and ownerdrawn+virtual listview. However, the 7z-file at bottom of post only contains examples for conventional and virtual listviews. ExampleThis is the Virtual\Resizable2.au3 example. Run the example in SciTE with F5. Right-click listview and select "Single cell navigation": The yellow cell is the active cell that is subject of keyboard navigation. Mouse navigation: Click a listview cell. Vertical keyboard navigation: Up, Down, PageUp, PageDown, Home and End. Horizontal keyboard navigation: Left, Right, CapsLock + PageUp, PageDown, Home or End. If the yellow active cell is located outside the visible page in the listview (if eg. a scrollbar has been used), using a navigation key will again place the active cell on the visible page. CapsLock is used for horizontal navigation because both Shift and Ctrl are used for standard multiple row selection. CapsLock + PageUp, PageDown, Home or End is especially interesting for ownerdrawn+virtual listviews that supports many columns. Horizontal or vertical navigation one page at a time can generate a lot of flicker. To prevent excessive flicker, automatic repeat of the PageUp/PageDown keys is disabled. A large amount of code is used to ensure that when a cell in a only partially visible (or not visible at all) column along a listview edge becomes the active cell, then the entire column and thus the cell becomes fully visible. Both in the UDF and in the examples, a large amount of code has also been used on the topic of GUI and listview resizing. ResizingFor a large control like a listview, it's usually valuable that both the GUI and the listview are resizable. And for a listview, it's nice if the height always fits an integer number of rows. If a column is made wider or narrower by dragging the header divider so that the horizontal scrollbar appears or disappears, then the height of the listview must be adjusted a little so that it again corresponds to an integer number of rows. The UDF to some extent support resizing in relation to these assumptions. But only for a single listview. If you need multiple listviews in the same GUI that all offers single cell navigation, then disable resizing in single cell navigation mode (remove resizing in GUI style and remove column resizing in listview header style (Virtual\Resizable4.au3)). Then you can handle resizing completely in your own code. RequirementsImplementing the functionality described above already requires quite a lot of code. In order not to use too much code, the following requirements for a listview must be met in order to use the UDF: The $LVS_EX_HEADERDRAGDROP style (drag/drop reordering of columns) is not supported. Zero-width columns are not supported. In the code it's checked that columns are not narrower than 10 pixels. The codeThe code is based on the KeyboardNavigation and MarkCurrentCell examples in the multi-column listviews thread. And these examples are again based on this old example of cell editing. In the new thread here, the Single Cell Navigation (SCN) functionality is implemented as a UDF in Includes\GuiListViewSCN.au3. The UDF contains two functions to enable and disable SCN functionality. In addition to the usual housekeeping code, the functions starts and stops two message handlers implemented through the subclassing technique that takes care of the actual Single Cell Navigation. One message handler, SCN_GuiHandler(), takes care of WM_NOTIFY messages (listview and header notifications and messages) sent to the main GUI. The other message handler, SCN_ListViewHandler(), takes care of mouse and keyboard messages sent directly to the listview. Because the code is very much about message handling, Windows Message Monitor has been an important tool for developing the UDF. ExamplesRun all examples in SciTE with F5. Virtual listviews FirstTest.au3, Incompatible.au3, MultipleLists.au3 and Non-Resizable.au3 are all non-resizable. And it's not possible to change column widths. FirstTest.au3 is a very simple example that immediately starts up in single cell navigation mode. Non-Resizable.au3 is similar to FirstTest.au3, but single cell navigation can be enabled/disabled dynamically through the listview context menu. Incompatible.au3 is incompatible with single cell navigation due to the $LVS_EX_HEADERDRAGDROP style. An error is generated when you right-click to enable single cell navigation. MultipleLists.au3 demonstrates how to use single cell navigation in multiple listviews. Right-click listviews to enable/disable single cell navigation. In Resizable1.au3, the width of GUI and listview corresponds to the width of the columns. If you increase/decrease the width of a column or the width of the GUI a little bit, the horizontal scrollbar will appear/disappear. Resizable2.au3 is the example shown above. It's used to test horizontal navigation. Resizable3.au3 demonstrates how to handle resizing when the GUI contains more controls than just the listview. Resizable4.au3 shows how to disable resizing in single cell navigation mode. Then you can handle all resizing in your own code. Conventional listviews The examples for conventional listviews are similar to the examples for virtual listviews with the same names. UsageSingle cell navigation can be used for many different purposes. Here it'll be used to implement Rectangular Selection in ListView. 7z-fileThe 7z-file contains source code for UDFs and examples. You need AutoIt 3.3.12 or later. Tested on Windows 7 and Windows 10. Comments are welcome. Let me know if there are any issues. CellNavigation.7z
    1 point
  11. Paul, you're welcome I just tried a little context menu inside _ArrayDisplay to choose the way of sorting, it seems to give good results. Lets have a look at the results first, then the personal modifications made to ArrayDisplayInternals.au3 code. Test script : #include <Array.au3> Global $aSortTest[12][1] = [["0x0B"], ["0x020"], ["0x0C"], ["0x03"], ["0x01"], ["0x0A"], _ ["0x0FF"], ["0x030"], ["0x04"], ["0x0E"], ["0x0D"], ["0x02"]] _ArrayDisplay($aSortTest) The pic above is your case : you need to choose the Numeric sort to be able to sort correctly a column of handles, pointers or any hex number starting with 0x In the pic above, we see it's very different if we want to sort the "Row" column. It needs a Natural sort to be correctly sorted because it is composed of letters ("Row ") and numbers. I suppose this is the main reason why Dev's forced the Natural sort in ArrayDisplay (when the default way of sorting in GuiListView.au3 is a Numeric sort +++) . Maybe if this Row column had only been composed of numeric elements (like the Excel column numerotation) then Dev's would have kept the original default Numeric sort found in GuiListView.au3... maybe Here is the code change in _ArrayDisplay, it's certainly optimizable but it may give ideas to users who want to tweak their own version of ArrayDisplayInternals.au3 1) Creation of a context menu associated to the listview (lines to be inserted after the listview has been created) ; Create ListView context menu (so user can choose the kind of sort he wants) Local $idContext_Menu = GUICtrlCreateContextMenu($idListView) Local $idContext_0 = GUICtrlCreateMenuItem("String sort", $idContext_Menu) Local $idContext_1 = GUICtrlCreateMenuItem("Numeric sort", $idContext_Menu) Local $idContext_2 = GUICtrlCreateMenuItem("Natural sort <<<", $idContext_Menu) ; default (keeps compatibility with old scripts) Local $iSort_Desired = 2, $iSort_Actual = -1 ; 0 = String sort, 1 = Numeric Sort, 2 = Natural sort 2) Inside the While... Wend loop, 3 Case added (Case $idContext_0 ... Case $idContext_1 ... Case $idContext_2) Case $idContext_0 ; String sort (chosen by user in context menu) $iSort_Desired = 0 GUICtrlSetData($idContext_0, "String sort <<<") GUICtrlSetData($idContext_1, "Numeric sort") GUICtrlSetData($idContext_2, "Natural sort") Case $idContext_1 ; Numeric sort (chosen by user in context menu) $iSort_Desired = 1 GUICtrlSetData($idContext_0, "String sort") GUICtrlSetData($idContext_1, "Numeric sort <<<") GUICtrlSetData($idContext_2, "Natural sort") Case $idContext_2 ; Natural sort (chosen by user in context menu) $iSort_Desired = 2 GUICtrlSetData($idContext_0, "String sort") GUICtrlSetData($idContext_1, "Numeric sort") GUICtrlSetData($idContext_2, "Natural sort <<<") 3) Inside the While... Wend loop, modifications made in Case $idListView code : Case $idListView ; left click on listview column header => sort If $iSort_Desired <> $iSort_Actual Then ; note that $iSort_Actual = -1 at 1st passage DllCallbackFree($__g_aArrayDisplay_SortInfo[2]) __ArrayDisplay_RegisterSortCallBack($idListView, $iSort_Desired, True, "__ArrayDisplay_SortCallBack") $iSort_Actual = $iSort_Desired EndIf ; Kick off the sort callback __ArrayDisplay_SortItems($idListView, GUICtrlGetState($idListView)) 4) Original line #448 to be deleted because it was placed outside the While... Wend loop (eventual sorts are now registered / unregistered within the While... Wend loop, inside the Case $idListView as shown just above) #448 __ArrayDisplay_RegisterSortCallBack($idListView, 2, True, "__ArrayDisplay_SortCallBack") 5) Original lines #598 et #599 amended to convert strings to numbers when "0x" is found at the beginning of the string. These 2 lines are originally already included inside a test where the user choosed voluntarily a Numeric sort. In case you're afraid that a string starting with "0x" is not a valid hex number, then you can use guinness _IsHex() function, found in this link, where he checks the string with a Regex expression '^0x[[:xdigit:]]+$' If StringIsInt($sVal1) Or StringIsFloat($sVal1) Or StringLeft($sVal1, 2) = "0x" Then $sVal1 = Number($sVal1) If StringIsInt($sVal2) Or StringIsFloat($sVal2) Or StringLeft($sVal2, 2) = "0x" Then $sVal2 = Number($sVal2) 6) As discussed in this link , original line #560 has to be moved "just below" the 2 lines below it. This will make the sort arrow visible when you click on a column header in ArrayDisplay It will also correct the value found in the variable $hHeader and in the array element $__g_aArrayDisplay_SortInfo[10] This is fixed in trac ticket #3791 ;~ Local Const $LVM_GETHEADER = (0x1000 + 31) ; 0x101F Local $hHeader = HWnd(GUICtrlSendMsg($hWnd, 0x101F, 0, 0)) If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd) 7) Finally, DllCallbackFree should be added before both GuiDelete($hGUI) as discussed in this link : DllCallbackFree($__g_aArrayDisplay_SortInfo[2]) GUIDelete($hGUI) Hope I didn't miss something important. If Mods think it's better to upload (or not) the complete amended ArrayDisplayInternals.au3 somewhere (for test or whatever) I'll do it. I just thought it could be a bit dangerous to share it fully here, because all these tweaks are very new. Dinner time Edit : 11/21/2020 Parts 1) and 2) in the code above can be scripted differently, to get a shorter code based on menu radioitems. 1) Creation of a context menu associated to the listview (lines to be inserted after the listview has been created) ; Create ListView context menu (so user can choose the kind of sort he wants) Local $idContext_Menu = GUICtrlCreateContextMenu($idListView) Local $idContext_0 = GUICtrlCreateMenuItem("String sort", $idContext_Menu, -1, 1) ; menuradioitem Local $idContext_1 = GUICtrlCreateMenuItem("Numeric sort", $idContext_Menu, -1, 1) ; menuradioitem Local $idContext_2 = GUICtrlCreateMenuItem("Natural sort", $idContext_Menu, -1, 1) ; menuradioitem GUICtrlSetState(-1, 1) ; $GUI_CHECKED = 1 (Natural sort is the default, to keep compatibility) Local $iSort_Desired = 2, $iSort_Actual = -1 ; 0 = String sort, 1 = Numeric Sort, 2 = Natural sort 2) Inside the While... Wend loop, 3 Case added (Case $idContext_0 ... Case $idContext_1 ... Case $idContext_2) Case $idContext_0 ; String sort (chosen by user in context menu) $iSort_Desired = 0 Case $idContext_1 ; Numeric sort (chosen by user in context menu) $iSort_Desired = 1 Case $idContext_2 ; Natural sort (chosen by user in context menu) $iSort_Desired = 2 This will display a context menu based on menu radio items : Thanks to lemony & Malkey in this post from 2008 (I discovered it right now !)
    1 point
  12. Got it! #include <WindowsConstants.au3> #include <GUIConstants.au3> Opt("GUIOnEventMode", 1) Local $hGui, $ContextMenu, $menu1,$menu2,$subMenu1,$separator1,$MenuItemExit $hGui = GUICreate("GDI1",200, 200, -1,-1) $ContextMenu = GUICtrlCreateContextMenu() $menu1 = GUICtrlCreateMenuItem("Toggle on/off", $ContextMenu) GUICtrlSetState($menu1, $GUI_UNCHECKED) GUICtrlSetOnEvent($menu1, "menu1Func") $menu2 = GUICtrlCreateMenu("To Submenu", $ContextMenu) $subMenu1 = GUICtrlCreateMenuItem("Submenu1)", $menu2) GUICtrlSetOnEvent($subMenu1, "Submenu1Func") $separator1 = GUICtrlCreateMenuItem("", $ContextMenu) ; create a separator line $radiotest = GUICtrlCreateMenu("Radio Test", $ContextMenu) $radio1 = GUICtrlCreateMenuItem("Radio Option1", $radiotest, -1, 1) GUICtrlSetState(-1, $GUI_CHECKED) $radio2 = GUICtrlCreateMenuItem("Radio Option2", $radiotest, -1, 1) $radio3 = GUICtrlCreateMenuItem("Radio Option3", $radiotest, -1, 1) $radio4 = GUICtrlCreateMenuItem("Radio Option4", $radiotest, -1, 1) GUICtrlCreateMenuItem("", $radiotest) $radioa = GUICtrlCreateMenuItem("Radio OptionA", $radiotest, -1, 1) $radiob = GUICtrlCreateMenuItem("Radio OptionB", $radiotest, -1, 1) GUICtrlSetState(-1, $GUI_CHECKED) $radioc = GUICtrlCreateMenuItem("Radio OptionC", $radiotest, -1, 1) GUICtrlCreateMenuItem("", $ContextMenu) $MenuItemExit = GUICtrlCreateMenuItem("Exit", $ContextMenu) GUICtrlSetOnEvent($MenuItemExit, "Quit") GUISetState() While 1 sleep(10) Wend Func menu1func() If BitAND(GUICtrlRead($menu1), $GUI_CHECKED) = $GUI_CHECKED Then GUICtrlSetState($menu1, $GUI_UNCHECKED) ;Extra Commands here, if needed.... Else GUICtrlSetState($menu1, $GUI_CHECKED) GUISetState(@SW_SHOW, $hGui) ;Extra Commands here, if needed.... EndIf Return 1 EndFunc ;==>ShowaOrig Func Submenu1Func() MsgBox(0,"","Submenu function here") EndFunc Func Quit() Local $e $e = MsgBox(1, "Exit", "Press OK to Exit") If $e = 1 Then Exit Return 1 EndFunc ;==>Quit
    1 point
  13. @Danp2 No, it did not work.
    0 points
×
×
  • Create New...