So I'm needing a (better) way to get the selection in an edit control, while knowing which end of the selection is active vs anchor (ie, if you're holding shift while moving with the arrow keys, which end of the selection is moving and which is not). Since _GUICtrlEdit_GetSel() only returns the start and end positions, in the order of smallest to largest, if you were to pass that back to the _GUICtrlEdit_SetSel(), the user's selection could end up "backwards".
My solution has been this function:
Func _GUICtrlEdit_GetSelByAnchor($hWnd) ; Get selection range with anchor in first index If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd) Local $aActive, $aSelection = _GUICtrlEdit_GetSel($hWnd) ; Get base selection If $aSelection <> $aSelection Then ; Only proceed if actual selection range _GUICtrlEdit_SetSel($hWnd, -1, 0) ; Deselect, leaving only the active point $aActive = _GUICtrlEdit_GetSel($hWnd) ; Record the active point If $aActive = $aSelection Then ; If the active point is equal to the original first index ; Swap the original selection points (putting the anchor in  and active in ) $aSelection = $aSelection $aSelection = $aActive EndIf _GUICtrlEdit_SetSel($hWnd, $aSelection, $aSelection) ; Reset selection to the original points EndIf Return $aSelection EndFunc The problem with this, as you may have already guessed from the two SetSel calls, is that calling it in a tight loop causes a lot of flickering. Is there a better, more reliable way to do what I'm looking for?
I have a GUI with an edit-field and a button.
First I write some text into the edit-field and select a part of it. After that I press the button, and the selection is edited.
How would I do that, though? When the text is selected and I press the button, it's unselected before the button actually raises an event.
I just started recently with AutoIT and I am trying to make two dropdownlists where the selectable values of the second dropdownlist will be depending on what is selected on the first one.
Dropdown 1 Dropdown 2
xxx => 01-15 ("01" , "02" ,"03" , ...)
yyy => a - f ("a" , "b" ,"c" ,"d" ,"e" ,"f" )
zzz => "new", "old", "spare"
I started with this code that I've found in this Forum:
; Here is the array
Global $aArray = ["SORT", "PCM", "UNIF", "KKE", "GMS", "CDY"]
; And here we get the elements into a list
$sList = ""
For $i = 0 To UBound($aArray) - 1
$sList &= "|" & $aArray[$i]
; Create a GUI
$hGUI = GUICreate("DropDown", 500, 500)
; Create the combo
$hCombo = GUICtrlCreateCombo("", 10, 10, 200, 20)
; And fill it
Any idea how to start on this one...
I'm stuck on how to use for range selection .Cells function.
_Excel_RangeSort($oWorkbook, Default, Default, "AD:AD", Default, Default, $xlYes, False, Default, "AE:AE", Default, "L:L", Default) and
$aResult = _Excel_RangeRead($oWorkbook, 1, "S2:AB" & $iRows) which works properly I want to use Cells to select the range.
Why? Because the Excel sheet was modified and an additional row was inserted. I want to create the script more dynamically by selection it with Cells because I can search for the column headers.
Hi I'm struggling to clear the display text of of a GUI control combo selection string.
I would like to clear the selection like it is clear after it is populated, but not remove any items from the list.
Here is a small example.
#include <GuiComboBox.au3> #include <ComboConstants.au3> #include <GUIConstantsEx.au3> ; Create GUI $hgui= guicreate("Clear ComboBox Edit Text", 320, 200) $control_combo= guictrlcreatecombo("", 10, 10, 250, 20, $CBS_DROPDOWNLIST) $control_clear_button= guictrlcreatebutton("Reset Blank Combo Selection String", 10, 40, 200, 20) guisetstate() guictrlsetdata($control_combo, "a|b|c"); Populate Combo while 1 switch guigetmsg() case $control_clear_button guictrlsetdata($control_combo, ""); This clears the entire list frustrating me case $gui_event_close exitloop endswitch;guigetmsg() wend;main loopDoes anyone one know how I can reset the selection to "", clear, empty set?I've tried SetEditText but doesn't work CBS_DROPDOWNLIST.
Sorry I thought I had tried this: _GUICtrlComboBox_SetCurSel($control_combo, -1) is the solution.