Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 02/14/2020 in all areas

  1. Trong

    ImageSearchUDF

    Version 2025.5.25.1

    10,988 downloads

    UDF comes with the source code of the DLL!
    1 point
  2. [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. M23
    1 point
  3. #include <File.au3> $array = _FileListToArray (@UserProfileDir & "\AppData\Roaming\Microsoft\Windows\Recent") _ArrayDisplay ($array)
    1 point
  4. Hence my suggestion for the consolewrite with the "||" so you can see them. It happens often that Space/Tab or CR, LF character is part of the string making the test fail. Jos
    1 point
  5. Just post a script that replicates your issue we can run to test with, as this looks ok so far. one other thing you could do is change the msgbox to: ConsoleWrite ("|" & $line & "|" & @crlf) Run it with SciTE and show us the exact console output. Jos
    1 point
  6. I would suggest asking directly about the applications you want to try to automate and give a brief description of what you want to do inside them. Otherwise a simple "yes" is going to be the most accurate answer here. I can move my mouse around to automate anything with MouseMove, MouseClick, and Sleep, but that's generally not the best way to do something
    1 point
  7. TheAutomator, As promised I have been playing around with this problem again over the past few days and have not changed my original conclusion (see my earlier post) that the problem seems to arise after clearing the edit using GUICtrlSetData and then trying to use _GUICtrlEdit_AppendText to add text which includes @CR characters. if you do this the script freezes at some indeterminate (as far as I can see) instance of a @CR within the new text being appended - although the freeze is repeatable at the same point for a given text. This appears only to be a problem when using Win 10 - so like Nine I suspect that a subtle change within the editbox implementation has caused this, but I have no idea just what. I have played about with various ways of emptying the editbox before appending the new text - such as not mixing native and UDF functions (often a recipe for disaster) and using _GUICtrlEdit_SetSel and _GUICtrlEdit_ReplaceSel to clear the edit - but the only reliable way to avoid the problem seems to be to delete and recreate the entire control - which might appear a bit of an overkill but does at least seem to resolve the problem: #include <guiconstantsex.au3> #include <buttonconstants.au3> #include <windowsconstants.au3> #include <guiedit.au3> Opt("TrayIconDebug", 1) HotKeySet('{esc}', 'quit') Const $form = GUICreate('TypingError', 600, 400) ;, Default, Default, BitOR($gui_ss_default_gui, $ws_maximizebox, $ws_sizebox, $ws_thickframe, $ws_tabstop)) $console = GUICtrlCreateEdit('loading...', 10, 10, 581, 341, BitOR($es_autovscroll, $es_readonly, $es_wantreturn, $ws_vscroll)) ;, 0) Const $user = GUICtrlCreateInput('', 10, 360, 521, 30) ; , Default, 0) Const $send = GUICtrlCreateButton('send', 540, 360, 51, 31, BitOR($es_uppercase, $bs_defpushbutton, $ws_disabled)) GUISetState(@SW_SHOW) Global $clear = False write(FileRead(@ScriptDir & '\a.txt')) $clear = True write(FileRead(@ScriptDir & '\a.txt')) read() write('[[[done]]]') Func WRITE($message) If $clear Then ; Delete existing edit control and recreate a new empty one <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< GUICtrlDelete($console) $console = GUICtrlCreateEdit('', 10, 10, 581, 341, BitOR($es_autovscroll, $es_readonly, $es_wantreturn, $ws_vscroll)) $clear = False Else _GUICtrlEdit_AppendText($console, @CRLF) EndIf ADD($message) EndFunc ;==>WRITE Func ADD($message) For $i = 1 To StringLen($message) Sleep(50) _GUICtrlEdit_AppendText($console, StringMid($message, $i, 1)) Next EndFunc ;==>ADD Func READ() GUICtrlSetState($send, $gui_enable) While 1 Switch GUIGetMsg() Case $gui_event_close Exit Case $send GUICtrlSetState($send, $gui_disable) Local $answer = GUICtrlRead($user) GUICtrlSetData($user, '') Return $answer EndSwitch WEnd EndFunc ;==>READ Func QUIT() WRITE("goodbye...") Exit EndFunc ;==>QUIT Sorry that I cannot yet pin the problem down any closer - and that we need to use such an inelegant workaround. I will keep poking away at the problem and see if anything new comes up. M23 Edit: Just to add that amending the _AppendText function did not work for me at all.
    1 point
  8. Here are a couple of RE patterns that appear to work. $CSVString = '1,Enabled,"Mr,Test",Test,Location' & @CRLF & _ '2,Enabled,"Mr,Test",Location,Test' ;$Result1 = StringRegExpReplace($CSVString, '(?m)^(("[^"]+",)|([^,]*,)){3}(Location).*(*SKIP)(*F)|^.*\R?', "") $Result1 = StringRegExpReplace($CSVString, '(?m)^(("[^"]+",)|([^,]*,)){3}+(Location).*(*SKIP)(*F)|^.*\R?', "") ; Updated to overcome "unique trait", 2 posts down. ConsoleWrite($Result1 & @CRLF & @CRLF) ;$Result2 = StringRegExpReplace($CSVString, '(?m)^(?!(("[^"]+",)|([^,]*,)){3}(Location).*)^.*\R?', "") $Result2 = StringRegExpReplace($CSVString, '(?m)^(?!(("[^"]+",)|([^,]*,)){3}+(Location).*)^.*\R?', "") ; Updated to overcome "unique trait", 2 posts down. ConsoleWrite($Result2 & @CRLF & @CRLF)
    1 point
  9. trancexx

    WinHTTP functions

    I prefer leaving last three parameters undocumented for forward compatibility reasons. They're used internally.
    1 point
  10. I'm seeing a weird issue where if the application I'm automating freezes and goes into (Not Responding) then the UIA code seems to freeze up the AutoIt script. If a screen doesn't open within the 120 second timeout, it calls a function that resets the program back to the main screen. Part of that is to reset a tree view, that code below. That seems to be the part that freezes up the script but as it's very random I can't seem to figure out a more specific line to look at. Any ideas on which of these could get stuck in an infinite loop? Local $oP4 = _UIA_getObjectByFindAll($UIA_oDesktop, "processid:=" & $iPID & ";controltype:=UIA_WindowControlTypeId;class:=Afx", $treescope_children) _UIA_Action($oP4, "setfocus") Local $oP3 = _UIA_getObjectByFindAll($oP4, "Title:=Applications;controltype:=UIA_PaneControlTypeId;class:=Afx:ControlBar", $treescope_children) _UIA_Action($oP3, "setfocus") Local $oP2 = _UIA_getObjectByFindAll($oP3, "Title:=;controltype:=UIA_TabControlTypeId;class:=Afx:TabWnd", $treescope_children) _UIA_Action($oP2, "setfocus") Local $oP1 = _UIA_getObjectByFindAll($oP2, "Title:=Applications;controltype:=UIA_PaneControlTypeId;class:=Afx:ControlBar", $treescope_children) _UIA_Action($oP1, "setfocus") Local $oP0 = _UIA_getObjectByFindAll($oP1, "Title:=;controltype:=UIA_TreeControlTypeId;class:=SysTreeView32", $treescope_children) _UIA_Action($oP0, "setfocus") Dim $pTrueCondition, $pElements, $iLength ;Create the variables that will be populated by the functions below $UIA_oUIAutomation.CreateTrueCondition($pTrueCondition) Local $oCondition = ObjCreateInterface($pTrueCondition, $sIID_IUIAutomationCondition, $dtagIUIAutomationCondition) $oP0.FindAll($treescope_subtree, $oCondition, $pElements) ;Find all objects under the $oP5 and populate the variables with them Local $oAutomationElementArray = ObjCreateInterface($pElements, $sIID_IUIAutomationElementArray, $dtagIUIAutomationElementArray) ;Create a UIA Array Element $oAutomationElementArray.Length($iLength) ;Get the count of items in the UIA Array For $U = $iLength - 1 To 0 Step -1 ; it's zero based Loop through the Array in reverse looking for each item in the Tree view, End at first as we want focus set to the top when done $oAutomationElementArray.GetElement($U, $UIA_pUIElement) ;Get the element of Array Item $i Local $oUIElement = ObjCreateInterface($UIA_pUIElement, $sIID_IUIAutomationElement, $dtagIUIAutomationElement) $sItemText = _UIA_action($oUIElement, "property", $UIA_NamePropertyId) ;This Can be used to identify the item to select by Visible Text for opening/closing specific items $iState = _UIA_action($oUIElement, "property", $UIA_ExpandCollapseExpandCollapseStatePropertyId) ;Identify if this is expanded If $iState = 1 Then _UIA_Action($oUIElement, "setfocus") ;Select the item ControlSend($hFacets, "Applications", "SysTreeView323", "{Left}") ;Now that the item is selected, send the Left key to the containing Control to collapse it. EndIf If $sItemText = "Accounting " Then ;Since we moved through the list in reverse, the item 0 should be the first item in the list. _UIA_Action($oUIElement, "setfocus") ;Select the item EndIf Next Update: Got a bit more info from COM error trapping We intercepted a COM Error at line: 1079! Number: 0x00000003 Description: NULL Pointer assignment In my UIAWrapper.au3 file it is for the Func _UIA_getObjectByFindAll on this line $oAutomationElementArray = ObjCreateInterface($pElements, $sIID_IUIAutomationElementArray, $dtagIUIAutomationElementArray) Thanks
    1 point
  11. Hi Mbee, good addition 👍, added to the Beta. Next release will also contain a context menu entry to directly "Update" existing save file, as well as dealing with negative offsets in multi-monitor environments.
    1 point
  12. This function is used to find a control that is at a specified position from a known control (Anchor). This is loosely based on the UFT Object Repository feature called Visual Relation Identifier edit: 12/19 added option 4 to search for a control that is contained within the area of the Anchor control itself. I needed this to find a fake scrollbar inside a fake edit box for an ancient app I'm automating. Example: I want to find the first Button to the Right of the Label that says "To Continue, Click Here >" ;Get the handle to that label which will be our Anchor point.     $hAnchor = ControlGetHandle("My Application", "", "[TEXT:To Continue, Click Here >]") ;Find the first button to the right of our Anchor point     $hwnd = _ControlFind_VisualRelation(1, "Button", 3, $hAnchor) ;Now click on that control     ControlClick("My Application", "", $hwnd) Below is a much larger example that I used when building the function to assist with the more advanced features such as Padding, Visibility, and Debugging along with the function #include <GUIConstantsEx.au3> #include <GuiEdit.au3> #include <StaticConstants.au3> #include "_VisualRelationIdentifier.au3" $hGUI = GUICreate("Visual Relation TestApp", 600, 400) $hInfo = GUICtrlCreateLabel("F1 = find Left, F2 = Find Top, F3 = Find Right, F4 = find Bottom", 5, 3, 590, 17, $SS_CENTER) $Edit = GUICtrlCreateEdit("This is the Anchor Control", 200, 150, 200, 100) $hContained = GUICtrlCreateInput("Contained", 220, 210, 100, 20) GUICtrlCreateLabel("Search Padding: ", 350, 23, 200, 17, $SS_RIGHT) $hPadding = GUICtrlCreateInput("0", 550, 20, 40, 20) GUICtrlCreateUpdown(-1) GUICtrlCreateLabel("Instance: ", 350, 48, 200, 17, $SS_RIGHT) $hInstance = GUICtrlCreateInput("1", 550, 45, 40, 20) GUICtrlCreateUpdown(-1) GUICtrlSetLimit(-1, 999, 1) ;Controls on the left of the Anchor, not created in the order they are displayed GUICtrlCreateLabel("Label", 10, 133, 80, 17) GUICtrlCreateButton("btn1", 10, 155, 80, 20) GUICtrlCreateButton("btn2", 95, 130, 100, 20) ;Technically Above, but adding padding should catch this on left GUICtrlCreateButton("btn3", 95, 155, 100, 20) GUICtrlCreateButton("btn4", 95, 230, 100, 20) GUICtrlCreateButton("btn5", 95, 180, 100, 20) GUICtrlCreateButton("btn6", 10, 255, 80, 20) ;Technically below, but adding padding should catch this on left GUICtrlCreateButton("btn7", 95, 255, 100, 20) ;Technically below, but adding padding should catch this on left GUICtrlCreateButton("btn8", 95, 205, 100, 20) ;Controls on the Top of the Anchor GUICtrlCreateLabel("Label", 10, 30, 100, 17) GUICtrlCreateButton("btn9", 10, 50, 100, 20) ;Could be Above, or Left with enough padding GUICtrlCreateButton("btn10", 120, 50, 100, 20) ;Could be Above, or Left with enough padding GUICtrlCreateButton("btn11", 450, 75, 100, 20) ;Could be Above, or Right with enough padding GUICtrlCreateButton("btn12", 120, 75, 100, 20) ;Could be Above, or Left with enough padding GUICtrlCreateButton("btn13", 230, 50, 100, 20) GUICtrlCreateButton("btn14", 230, 75, 100, 20) GUICtrlCreateButton("btn15", 10, 75, 100, 20) ;Could be Above, or Left with enough padding GUICtrlCreateButton("btn16", 230, 125, 100, 20) GUICtrlCreateButton("btn17", 340, 100, 100, 20) ;Could be Above, or Right with enough padding GUICtrlCreateButton("btn18", 340, 125, 100, 20) ;Could be Above, or Right with enough padding GUICtrlCreateButton("btn19", 230, 100, 100, 20) GUICtrlCreateButton("btn20", 450, 100, 100, 20) ;Could be Above, or Right with enough padding ;Controls on the Right of the Anchor GUICtrlCreateLabel("Label", 410, 153, 80, 17) GUICtrlCreateButton("btn21", 410, 175, 80, 20) GUICtrlCreateButton("btn22", 500, 225, 80, 20) GUICtrlCreateButton("btn23", 500, 175, 80, 20) GUICtrlCreateButton("btn24", 500, 200, 80, 20) GUICtrlCreateButton("btn25", 500, 150, 80, 20) GUICtrlCreateButton("btn26", 410, 200, 80, 20) GUICtrlCreateButton("btn27", 410, 225, 80, 20) ;Controls on the Bottom of the Anchor GUICtrlCreateLabel("Label", 205, 253, 80, 17) GUICtrlCreateButton("btn28", 500, 251, 80, 20) GUICtrlCreateButton("btn29", 440, 280, 100, 20) GUICtrlCreateButton("btn30", 10, 280, 100, 20) GUICtrlCreateButton("btn31", 220, 280, 100, 20) GUICtrlCreateButton("btn32", 110, 280, 100, 20) GUICtrlCreateButton("btn33", 330, 280, 100, 20) GUICtrlCreateButton("btn34", 10, 310, 100, 20) GUICtrlCreateButton("btn35", 410, 251, 80, 20) GUICtrlCreateButton("btn36", 110, 305, 100, 20) GUICtrlCreateButton("btn37", 440, 350, 100, 20) GUISetState(@SW_SHOW, $hGUI) $hEdit = ControlGetHandle($hGUI, "", $Edit) HotKeySet("{F1}", "_GetLeft") ;Adjust Padding and Instance within the GUI HotKeySet("{F2}", "_GetAbove") ;Adjust Padding and Instance within the GUI HotKeySet("{F3}", "_GetRight") ;Adjust Padding and Instance within the GUI HotKeySet("{F4}", "_GetBelow") ;Adjust Padding and Instance within the GUI HotKeySet("{F5}", "_GetContained") ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd ;Get the control that is contained within the area of the Anchor control Func _GetContained() _GUICtrlEdit_AppendText($hEdit, @CRLF & "F5 (Get Contained Within)") ;Update the Edit to show what was selected $Foundhwnd = _ControlFind_VisualRelation(GUICtrlRead($hInstance), "Edit", 4, $hEdit, 0, True, True) ;Find the first button to the left of Anchor where Vertical padding is +- Specified If @error Then MsgBox(0, "Error " & @error, "Failed to find the specified control Button" & GUICtrlRead($hInstance)) Return EndIf ControlSetText($hGUI, "", $Foundhwnd, "FOUND!") ;Update the text for the control it identified ConsoleWrite("Handle returned = (" & $Foundhwnd & ")" & @CRLF) GUICtrlSetData($hInfo, "Buttons renamed to order they were found. The requested control changed to FOUND!") EndFunc Func _GetLeft() _GUICtrlEdit_AppendText($hEdit, @CRLF & "F1 [Get Button" & GUICtrlRead($hInstance) & " to Left, " & GUICtrlRead($hPadding) & " padding]") ;Update the Edit to show what was selected $Foundhwnd = _ControlFind_VisualRelation(GUICtrlRead($hInstance), "Button", 2, $hEdit, GUICtrlRead($hPadding), True, True) ;Find the first button to the left of Anchor where Vertical padding is +- Specified If @error Then MsgBox(0, "Error " & @error, "Failed to find the specified control Button" & GUICtrlRead($hInstance)) Return EndIf ControlSetText($hGUI, "", $Foundhwnd, "FOUND!") ;Update the text for the control it identified ConsoleWrite("Handle returned = (" & $Foundhwnd & ")" & @CRLF) GUICtrlSetData($hInfo, "Buttons renamed to order they were found. The requested control changed to FOUND!") EndFunc Func _GetAbove() _GUICtrlEdit_AppendText($hEdit, @CRLF & "F2 (Get Above selected)") ;Update the Edit to show what was selected $Foundhwnd = _ControlFind_VisualRelation(GUICtrlRead($hInstance), "Button", 0, $hEdit, GUICtrlRead($hPadding), True, True) ;Find the first button above the anchor where Horizontal padding is +- specified If @error Then MsgBox(0, "Error " & @error, "Failed to find the specified control Button" & GUICtrlRead($hInstance)) Return EndIf ControlSetText($hGUI, "", $Foundhwnd, "FOUND!") ;Update the text for the control it identified ConsoleWrite("Handle returned = (" & $Foundhwnd & ")" & @CRLF) GUICtrlSetData($hInfo, "Buttons renamed to order they were found. The requested control changed to FOUND!") EndFunc Func _GetRight() _GUICtrlEdit_AppendText($hEdit, @CRLF & "F3 (Get Right selected)") ;Update the Edit to show what was selected $Foundhwnd = _ControlFind_VisualRelation(GUICtrlRead($hInstance), "Button", 3, $hEdit, GUICtrlRead($hPadding), True, True) ;Find the first button to the left of Anchor where Vertical padding is +- Specified If @error Then MsgBox(0, "Error " & @error, "Failed to find the specified control Button" & GUICtrlRead($hInstance)) Return EndIf ControlSetText($hGUI, "", $Foundhwnd, "FOUND!") ;Update the text for the control it identified ConsoleWrite("Handle returned = (" & $Foundhwnd & ")" & @CRLF) GUICtrlSetData($hInfo, "Buttons renamed to order they were found. The requested control changed to FOUND!") EndFunc Func _GetBelow() _GUICtrlEdit_AppendText($hEdit, @CRLF & "F4 (Get Below selected)") ;Update the Edit to show what was selected $Foundhwnd = _ControlFind_VisualRelation(GUICtrlRead($hInstance), "Button", 1, $hEdit, GUICtrlRead($hPadding), True, True) If @error Then MsgBox(0, "Error " & @error, "Failed to find the specified control Button" & GUICtrlRead($hInstance)) Return EndIf ControlSetText($hGUI, "", $Foundhwnd, "FOUND!") ;Update the text for the control it identified ConsoleWrite("Handle returned = (" & $Foundhwnd & ")" & @CRLF) GUICtrlSetData($hInfo, "Buttons renamed to order they were found. The requested control changed to FOUND!") EndFunc The Function which needs Melba23's _ArrayMultiColSort : #include-once #include <WinAPI.au3> #include <WindowsConstants.au3> #include <GDIPlus.au3> #include "ArrayMultiColSort.au3" ;----------------------------------------------------------------------------------------------------- ; Name........... _ControlFind_VisualRelation ; Description.... Find a specific control depending on its location to a known control (Anchor point) ; Control search order is closest to the control and cascade out in direction specified ; Syntax......... _ControlFind_VisualRelation($iInstance, $sClass, $sDirection, $hAnchor) ; Parameters .... $iInstance = which instance found from the Anchor ; 1 = First control found in direction specified from Anchor ; 2 = Second control found in the direction specified from Anchor ; etc... ; $sClass = Class name of the control, do not use ClassnameNN or any other type ; $sDirection = 0 = Above Anchor, 1 = Below Anchor, 2 = Left of Anchor, 3 = Right of Anchor, 4 = Fully contained within Anchor (Padding is ignored) ; $hAnchor = hwnd of the known control we are identifying from ; $iPadding = amount to + or - from each side of Anchor size to match control within, Default = 0 ; ex: 10, Above: find the control above the Anchor where x between (Anchor X - 10 and Anchor X + Anchor W + 10) ; ex: 5, Right: find the control to the right of the Anchor where Y between (Anchor Y - 5 and Anchor Y + Anchor H + 5) ; $bIsVisible = True = Only identify those controls that are visible (Default). False will return any control visible or not. ; $bDebug = True will draw lines on the screen where its searching, Default = False ; Return values.. Success = Returns the hwnd ; Failure = Sets @error ; 1 = The Anchor was not passed as a hwnd ; 2 = Failed to find the parent window of the Anchor ; 3 = Unable to identify the position of the Anchor control ; 4 = Could not find any of the specified Classes within the Anchor window ; 5 = Could not find the Instance specified in the position specified ; Author ........ BigDaddyO ; Modified by.... ; Remarks ....... requires Include: WinAPI.au3, WindowsConstants.au3, Melba23's _ArrayMultiColSort (https://www.autoitscript.com/forum/topic/155442-arraymulticolsort-new-release-06-april-2019/) ; Example........ $sClassnameNN = _ControlFind_VisualRelation(1, "Button", 2, $hEdit, 0) ;----------------------------------------------------------------------------------------------------- Func _ControlFind_VisualRelation($iInstance, $sClass, $sDirection, $hAnchor, $iPadding = 0, $bIsVisible = True, $bDebug = False) ;Ensure the $hAnchor is a handle If IsHWnd($hAnchor) = 0 Then Return SetError(1) ;Get the handle for the window the $hAnchor control is in $hAnchorWin = _WinAPI_GetAncestor($hAnchor, $GA_ROOT) If IsHWnd($hAnchorWin) = 0 Then Return SetError(2) If $bDebug Then ConsoleWrite("Anchor Window Handle = (" & $hAnchorWin & ")" & @CRLF) ;Get the current position of the Anchor control $aAnchorPos = ControlGetPos($hAnchorWin, "", $hAnchor) If @error Then Return SetError(3) If $bDebug Then ConsoleWrite("Anchor Window position: x=" & $aAnchorPos[0] & ", y=" & $aAnchorPos[1] & @CRLF) Local $iInstanceFound = 0 Local $inst = 0 ;The control instance that we are looking at Local $v = 0 ;The control count we are adding to the search array Local $aFound[9999][5] ;[][0] = hwnd, [][1] = X coord, [][2] = Y coord, [][3] = x + w, [][4] = y + h ;Find every Control with the specified $sClass THAT IS CURRENTLY VISIBLE ;Need to keep the Control Find loop # seperate from the Array Storage to ignore the hidden controls! While 1 $inst += 1 $hCtrl = ControlGetHandle($hAnchorWin, "", "[CLASS:" & $sClass & "; INSTANCE:" & $inst & "]") If @error Then If $inst = 1 Then Return SetError(4) ;Did not find any of the Class type in the window Else ExitLoop ;No more of this Class were found stop looking and start trying to match the requested area EndIf EndIf If $bIsVisible Then ;Do we only want the visible controls? If ControlCommand($hAnchorWin, "", $hCtrl, "IsVisible", "") = 0 Then ContinueLoop EndIf $v += 1 ;If we got this far, we need to add this control to our array $aCtrlPos = ControlGetPos($hAnchorWin, "", $hCtrl) If $bDebug = True Then ConsoleWrite($sClass & $v & " - hwnd(" & $hCtrl & ") found at " & $aCtrlPos[0] & ", " & $aCtrlPos[1] & @CRLF) ControlSetText($hAnchorWin, "", $hCtrl, $sClass & $v) EndIf ;Save this control: Handle, X1, Y1, X2, Y2 $aFound[$v - 1][0] = $hCtrl ;Save the Instance # so we can find again $aFound[$v - 1][1] = $aCtrlPos[0] ;X coord of left side $aFound[$v - 1][2] = $aCtrlPos[1] ;Y coord of top $aFound[$v - 1][3] = $aCtrlPos[0] + $aCtrlPos[2] ;X coord of right side $aFound[$v - 1][4] = $aCtrlPos[1] + $aCtrlPos[3] ;Y coord of bottom WEnd ;~ ;Resize and rearrange the found controls so they cascase out from the Anchor control ReDim $aFound[$v][5] ;Now to get the control at the location we were looking for Local $iFoundInstance = 0 Switch $sDirection Case 0 ;Above Anchor control and within the X padding ;0 = TOP: SORT BY Y DESCENDING, THEN BY X ASCENDING Local $aSortData[][] = [[2, 1],[1,0]] _ArrayMultiColSort($aFound, $aSortData) If $bDebug = True Then ;Draw lines to show where it was looking $hVRIgdi = _GDIPlus_Startup(Default, True) $hVRIgraphic = _GDIPlus_GraphicsCreateFromHWND($hAnchorWin) $hVRIpen = _GDIPlus_PenCreate(0xFFFF0000) _GDIPlus_GraphicsDrawLine($hVRIgraphic, $aAnchorPos[0] - $iPadding, $aAnchorPos[1], $aAnchorPos[0] - $iPadding, 0, $hVRIpen) _GDIPlus_GraphicsDrawLine($hVRIgraphic, $aAnchorPos[0] + $aAnchorPos[2] + $iPadding, $aAnchorPos[1], $aAnchorPos[0] + $aAnchorPos[2] + $iPadding, 0, $hVRIpen) EndIf ;Loop through the control found array For $d = 0 to UBound($aFound) - 1 If $aFound[$d][0] = $hAnchor Then ContinueLoop ;Possible that we will see the anchor if looking for the same class type ;If the right of the control is greater than the left of the Anchor minus the padding, AND the left of the control is less than the Anchor plus the padding If ( $aFound[$d][3] >= ($aAnchorPos[0] - $iPadding) ) and ( $aFound[$d][1] <= ($aAnchorPos[0] + $aAnchorPos[2] + $iPadding) ) Then ;if the top of the control is less than the top of the Anchor If $aFound[$d][2] <= $aAnchorPos[1] Then $iFoundInstance += 1 If $iFoundInstance = $iInstance Then If $bDebug = True Then ;Move the mouse to the center of the control we will be returning $aWinPos = WinGetPos($hAnchorWin, "") $aClient = WinGetClientSize($hAnchorWin, "") $iAddX = ($aWinPos[2] - $aClient[0] - 2) ;Generate the X Coord that the ControlGetPos will reference from $iAddY = ($aWinPos[3] - $aClient[1] - 2) ;Generate the Y Coord that the ControlGetPos will reference from $x = $aWinPos[0] + $aFound[$d][1] + (($aFound[$d][3] - $aFound[$d][1]) / 2) + $iAddX $y = $aWinPos[1] + $aFound[$d][2] + (($aFound[$d][4] - $aFound[$d][2]) / 2) + $iAddY MouseMove($x, $y, 0) EndIf Return $aFound[$d][0] Else ContinueLoop EndIf Else ContinueLoop ;This control is not within the Vertical limits of the Anchor and Padding EndIf Else ContinueLoop ;This control is not within the Horizontal limits of the Anchor and Padding EndIf Next Case 1 ;Below Anchor control and within the X padding ;1 = BOTTOM: SORT BY Y ASCENDING, THEN BY X ASCENDING Local $aSortData[][] = [[2, 0],[1,0]] _ArrayMultiColSort($aFound, $aSortData) If $bDebug = True Then ;Draw lines to show where it was looking $hVRIgdi = _GDIPlus_Startup(Default, True) $hVRIgraphic = _GDIPlus_GraphicsCreateFromHWND($hAnchorWin) $hVRIpen = _GDIPlus_PenCreate(0xFFFF0000) _GDIPlus_GraphicsDrawLine($hVRIgraphic, $aAnchorPos[0] - $iPadding, $aAnchorPos[1] + $aAnchorPos[3], $aAnchorPos[0] - $iPadding, $aAnchorPos[1] + 1000, $hVRIpen) _GDIPlus_GraphicsDrawLine($hVRIgraphic, $aAnchorPos[0] + $aAnchorPos[2] + $iPadding, $aAnchorPos[1] + $aAnchorPos[3], $aAnchorPos[0] + $aAnchorPos[2] + $iPadding, $aAnchorPos[1] + 1000, $hVRIpen) EndIf ;Loop through the control found array For $d = 0 to UBound($aFound) - 1 If $aFound[$d][0] = $hAnchor Then ContinueLoop ;Possible that we will see the anchor if looking for the same class type ;If the right of the control is greater than the left of the Anchor minus the padding, AND the left of the control is less than the Anchor plus the padding If ( $aFound[$d][3] >= ($aAnchorPos[0] - $iPadding) ) and ( $aFound[$d][1] <= ($aAnchorPos[0] + $aAnchorPos[2] + $iPadding) ) Then ;if the top of the control is greater than the bottom of the Anchor If $aFound[$d][2] >= ($aAnchorPos[1] + $aAnchorPos[3]) Then $iFoundInstance += 1 If $iFoundInstance = $iInstance Then If $bDebug = True Then ;Move the mouse to the center of the control we will be returning $aWinPos = WinGetPos($hAnchorWin, "") $aClient = WinGetClientSize($hAnchorWin, "") $iAddX = ($aWinPos[2] - $aClient[0] - 2) ;Generate the X Coord that the ControlGetPos will reference from $iAddY = ($aWinPos[3] - $aClient[1] - 2) ;Generate the Y Coord that the ControlGetPos will reference from $x = $aWinPos[0] + $aFound[$d][1] + (($aFound[$d][3] - $aFound[$d][1]) / 2) + $iAddX $y = $aWinPos[1] + $aFound[$d][2] + (($aFound[$d][4] - $aFound[$d][2]) / 2) + $iAddY MouseMove($x, $y, 0) EndIf Return $aFound[$d][0] Else ContinueLoop EndIf Else ContinueLoop ;This control is not within the Vertical limits of the Anchor and Padding EndIf Else ContinueLoop ;This control is not within the Horizontal limits of the Anchor and Padding EndIf Next Case 2 ;Left of Anchor control and within the Y padding ;2 = LEFT: SORT BY Y ASCENDING, THEN BY X DESCENDING SO CLOSEST CONTROL WOULD BE 1 Local $aSortData[][] = [[1, 1],[2,0]] _ArrayMultiColSort($aFound, $aSortData) If $bDebug = True Then ;Draw lines to show where it was looking $hVRIgdi = _GDIPlus_Startup(Default, True) $hVRIgraphic = _GDIPlus_GraphicsCreateFromHWND($hAnchorWin) $hVRIpen = _GDIPlus_PenCreate(0xFFFF0000) _GDIPlus_GraphicsDrawLine($hVRIgraphic, $aAnchorPos[0], $aAnchorPos[1] - $iPadding, 0, $aAnchorPos[1] - $iPadding, $hVRIpen) _GDIPlus_GraphicsDrawLine($hVRIgraphic, $aAnchorPos[0], $aAnchorPos[1] + $aAnchorPos[3] + $iPadding, 0, $aAnchorPos[1] + $aAnchorPos[3] + $iPadding, $hVRIpen) EndIf ;Loop through the control found array For $d = 0 to UBound($aFound) - 1 If $aFound[$d][0] = $hAnchor Then ContinueLoop ;Possible that we will see the anchor if looking for the same class type If $bDebug Then ConsoleWrite("Is " & ControlGetText($hAnchorWin, "", $aFound[$d][0]) & " bottom (" & $aFound[$d][4] & ") located vertically below " & ($aAnchorPos[1] - $iPadding) & " and top (" & $aFound[$d][2] & ") is above " & ($aAnchorPos[1] + $aAnchorPos[3] + $iPadding) ) ;If the top of the control is above the bottom of the anchor plus the padding AND the bottom of the control is below the top of the Anchor minus the padding If ( $aFound[$d][2] <= ($aAnchorPos[1] + $aAnchorPos[3] + $iPadding) ) and ( $aFound[$d][4] > ($aAnchorPos[1] - $iPadding) ) Then If $bDebug Then ConsoleWrite(@TAB & "YES" & @CRLF) If $bDebug Then ConsoleWrite(@TAB & "Is the controls Left (" & $aFound[$d][1] & ") located horizontally left of " & $aAnchorPos[0] ) ;If the left of the control is < the left of the Anchor If $aFound[$d][1] < $aAnchorPos[0] Then If $bDebug Then ConsoleWrite(@TAB & "YES" & @CRLF) $iFoundInstance += 1 If $iFoundInstance = $iInstance Then If $bDebug = True Then ;Move the mouse to the center of the control we will be returning $aWinPos = WinGetPos($hAnchorWin, "") $aClient = WinGetClientSize($hAnchorWin, "") $iAddX = ($aWinPos[2] - $aClient[0] - 2) ;Generate the X Coord that the ControlGetPos will reference from $iAddY = ($aWinPos[3] - $aClient[1] - 2) ;Generate the Y Coord that the ControlGetPos will reference from $x = $aWinPos[0] + $aFound[$d][1] + (($aFound[$d][3] - $aFound[$d][1]) / 2) + $iAddX $y = $aWinPos[1] + $aFound[$d][2] + (($aFound[$d][4] - $aFound[$d][2]) / 2) + $iAddY MouseMove($x, $y, 0) EndIf Return $aFound[$d][0] Else ContinueLoop EndIf Else If $bDebug Then ConsoleWrite(@TAB & "NO" & @CRLF) ContinueLoop ;This control is not within the Horizontal limits Left of the Anchor EndIf Else If $bDebug Then ConsoleWrite(@TAB & "NO" & @CRLF) ContinueLoop ;This control is not within the Vertical limits of the Anchor and Padding EndIf Next Case 3 ;Right of Anchor control ;3 = RIGHT: SORT BY Y ASCENDING, THEN BY X ASCENDING Local $aSortData[][] = [[1, 0],[2,0]] _ArrayMultiColSort($aFound, $aSortData) If $bDebug = True Then ;Draw lines to show where it was looking $hVRIgdi = _GDIPlus_Startup(Default, True) $hVRIgraphic = _GDIPlus_GraphicsCreateFromHWND($hAnchorWin) $hVRIpen = _GDIPlus_PenCreate(0xFFFF0000) _GDIPlus_GraphicsDrawLine($hVRIgraphic, $aAnchorPos[0] + $aAnchorPos[2], $aAnchorPos[1] - $iPadding, $aAnchorPos[0] + 1000, $aAnchorPos[1] - $iPadding, $hVRIpen) _GDIPlus_GraphicsDrawLine($hVRIgraphic, $aAnchorPos[0] + $aAnchorPos[2], $aAnchorPos[1] + $aAnchorPos[3] + $iPadding, $aAnchorPos[0] + 1000, $aAnchorPos[1] + $aAnchorPos[3] + $iPadding, $hVRIpen) EndIf ;Loop through the control found array For $d = 0 to UBound($aFound) - 1 If $aFound[$d][0] = $hAnchor Then ContinueLoop ;Possible that we will see the anchor if looking for the same class type ;If the top of the control is above the bottom of the anchor plus the padding AND the bottom of the control is below the top of the Anchor minus the padding If ( $aFound[$d][2] <= ($aAnchorPos[1] + $aAnchorPos[3] + $iPadding) ) and ( $aFound[$d][4] > ($aAnchorPos[1] - $iPadding) ) Then ;If the Right of the control is > the Right of the Anchor If $aFound[$d][3] > ($aAnchorPos[0] + $aAnchorPos[2]) Then $iFoundInstance += 1 If $iFoundInstance = $iInstance Then If $bDebug = True Then ;Move the mouse to the center of the control we will be returning $aWinPos = WinGetPos($hAnchorWin, "") $aClient = WinGetClientSize($hAnchorWin, "") $iAddX = ($aWinPos[2] - $aClient[0] - 2) ;Generate the X Coord that the ControlGetPos will reference from $iAddY = ($aWinPos[3] - $aClient[1] - 2) ;Generate the Y Coord that the ControlGetPos will reference from $x = $aWinPos[0] + $aFound[$d][1] + (($aFound[$d][3] - $aFound[$d][1]) / 2) + $iAddX $y = $aWinPos[1] + $aFound[$d][2] + (($aFound[$d][4] - $aFound[$d][2]) / 2) + $iAddY MouseMove($x, $y, 0) EndIf Return $aFound[$d][0] Else ContinueLoop EndIf Else ContinueLoop ;This control is not within the Horizontal limits Right of the Anchor EndIf Else ContinueLoop ;This control is not within the Vertical limits of the Anchor and Padding EndIf Next Case 4 ;Contained within the Anchor controls area ;4 = Contained Within: SORT BY Y ASCENDING, THEN BY X ASCENDING Local $aSortData[][] = [[1, 0],[2,0]] _ArrayMultiColSort($aFound, $aSortData) If $bDebug = True Then ;Draw lines to show where it was looking $hVRIgdi = _GDIPlus_Startup(Default, True) $hVRIgraphic = _GDIPlus_GraphicsCreateFromHWND($hAnchorWin) $hVRIpen = _GDIPlus_PenCreate(0xFFFF0000) _GDIPlus_GraphicsDrawLine($hVRIgraphic, $aAnchorPos[0] - 1, $aAnchorPos[1] - 1, $aAnchorPos[0] + $aAnchorPos[2] + 1, $aAnchorPos[1] - 1, $hVRIpen) ;Draw across the tope _GDIPlus_GraphicsDrawLine($hVRIgraphic, $aAnchorPos[0] + $aAnchorPos[2] + 1, $aAnchorPos[1] - 1, $aAnchorPos[0] + $aAnchorPos[2] + 1, $aAnchorPos[1] + $aAnchorPos[3] + 1, $hVRIpen) ;Draw down right side _GDIPlus_GraphicsDrawLine($hVRIgraphic, $aAnchorPos[0] + $aAnchorPos[2] + 1, $aAnchorPos[1] + $aAnchorPos[3] + 1, $aAnchorPos[0] - 1, $aAnchorPos[1] + $aAnchorPos[3] + 1, $hVRIpen) ;Draw across bottom _GDIPlus_GraphicsDrawLine($hVRIgraphic, $aAnchorPos[0] - 1, $aAnchorPos[1] + $aAnchorPos[3] + 1, $aAnchorPos[0] - 1, $aAnchorPos[1] - 1, $hVRIpen) ;Draw up left side EndIf ;Loop through the control found array For $d = 0 to UBound($aFound) - 1 If $aFound[$d][0] = $hAnchor Then ContinueLoop ;Possible that we will see the anchor if looking for the same class type ;Move through them to ensure they are completely contained within the area of the Known Control If $aFound[$d][1] >= $aAnchorPos[0] and $aFound[$d][3] <= $aAnchorPos[0] + $aAnchorPos[2] and $aFound[$d][2] >= $aAnchorPos[1] and $aFound[$d][4] <= $aAnchorPos[1] + $aAnchorPos[3] Then $iFoundInstance += 1 If $iFoundInstance = $iInstance Then If $bDebug = True Then ;Move the mouse to the center of the control we will be returning $aWinPos = WinGetPos($hAnchorWin, "") $aClient = WinGetClientSize($hAnchorWin, "") $iAddX = ($aWinPos[2] - $aClient[0] - 2) ;Generate the X Coord that the ControlGetPos will reference from $iAddY = ($aWinPos[3] - $aClient[1] - 2) ;Generate the Y Coord that the ControlGetPos will reference from $x = $aWinPos[0] + $aFound[$d][1] + (($aFound[$d][3] - $aFound[$d][1]) / 2) + $iAddX $y = $aWinPos[1] + $aFound[$d][2] + (($aFound[$d][4] - $aFound[$d][2]) / 2) + $iAddY MouseMove($x, $y, 0) EndIf Return $aFound[$d][0] Else ContinueLoop EndIf Else ContinueLoop ;This control is not within the Vertical limits of the Anchor and Padding EndIf Next ;~ $aFound[$v - 1][0] = $hCtrl ;Save the Instance # so we can find again ;~ $aFound[$v - 1][1] = $aCtrlPos[0] ;X coord of left side ;~ $aFound[$v - 1][2] = $aCtrlPos[1] ;Y coord of top ;~ $aFound[$v - 1][3] = $aCtrlPos[0] + $aCtrlPos[2] ;X coord of right side ;~ $aFound[$v - 1][4] = $aCtrlPos[1] + $aCtrlPos[3] ;Y coord of bottom EndSwitch Return SetError(5) ;If we got this far, then we found something but not the instance we wanted. EndFunc Any feedback you could offer would be appreciated as aside from my test gui and my one app I needed this for I haven't done a lot of testing. Thanks
    1 point
  13. Here a other example I also think it is from UEZ #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> _GDIPlus_Startup() $hSplashlogo = _GDIPlus_ImageLoadFromFile("C:\Program Files (x86)\AutoIt3\Examples\GUI\Torus.png") $logoheight = (@DesktopHeight/2) - (_GDIPlus_ImageGetHeight($hSplashlogo)/2) - 50 $logowidth = (@DesktopWidth /2) - (_GDIPlus_ImageGetWidth($hSplashlogo)/2) $SplashGUIlogo = GUICreate("", _GDIPlus_ImageGetWidth($hSplashlogo), _GDIPlus_ImageGetHeight($hSplashlogo), $logowidth, $logoheight, $WS_POPUP, BitOR($WS_EX_LAYERED,$WS_EX_TOOLWINDOW)) _SetBitmap($SplashGUIlogo, $hSplashlogo, 255, _GDIPlus_ImageGetWidth($hSplashlogo), _GDIPlus_ImageGetHeight($hSplashlogo)) GUISetState(@SW_SHOWNA, $SplashGUIlogo) While 1 Sleep(20) WEnd _GDIPlus_Shutdown() Func _SetBitmap($hGUI, $hImage, $iOpacity, $n_width = 200, $n_height = 200) Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend $hScrDC = _WinAPI_GetDC(0) $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC) $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap) $tSize = DllStructCreate($tagSIZE) $pSize = DllStructGetPtr($tSize) DllStructSetData($tSize, "X", $n_width) DllStructSetData($tSize, "Y", $n_height) $tSource = DllStructCreate($tagPOINT) $pSource = DllStructGetPtr($tSource) $tBlend = DllStructCreate($tagBLENDFUNCTION) $pBlend = DllStructGetPtr($tBlend) DllStructSetData($tBlend, "Alpha", $iOpacity) DllStructSetData($tBlend, "Format", 1) _WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA) _WinAPI_ReleaseDC(0, $hScrDC) _WinAPI_SelectObject($hMemDC, $hOld) _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteDC($hMemDC) EndFunc ;==>_SetBitmap
    1 point
×
×
  • Create New...