Editable class available on GitHub
Overview
Editable class can be used to interact with editable elements such as textboxes and manipulate their content. It requires UIA.ahk to be used.
Editable() returns an UIA element, which in addition to regular UIA properties and methods has some additional text-related ones:
Code: Select all
Editable().Value => gets or sets the current text
Editable().Selection => returns an object {start, end, text} with the current selection text, and start and end offsets
Editable().CaretOffset => returns the position of the caret relative to the beginning of the text
Editable().Select(from, to) => selects text from offsets (starting from beginning of the element)
Editable().Insert(text, offset?) => inserts text, by default to the current caret position
Calling the class with an UIA textual element ( Editable(element) ) returns an Editable for the provided element.
Editable static method GetCaretPos can be used to get the current screen coordinates for the caret: Editable.GetCaretPos(&x:=0, &y:=0)
Examples
Provided in the Editables.ahk file in GitHub.
Known limitations
1. Doesn't work in Chrome or Edge URL bar when autosuggestions are shown
2. Doesn't work in Steam
3. In some Qt apps (eg qBittorrent), when inserting text to the end of the editable, then the caret is positioned incorrectly
4. Discord doesn't handle inserted text properly, ending up with undeletable text (at least in some elements)
5. Cannot access windows ran as administrators, unless the script is also ran as admin or with UIAccess
6. Probably many more limitations...