ControlGet Line

Report problems with documented functionality
zorg
Posts: 8
Joined: 01 Feb 2019, 10:09

ControlGet Line

02 Feb 2019, 05:50

AutoHotkey version 1.1.30.01

Code: Select all

WinActivate, ahk_class Notepad++
ControlGetFocus, Scintilla, ahk_class Notepad++
ControlGet, count, CurrentLine,, %Scintilla%
Works.

Code: Select all

WinActivate, ahk_class Notepad++
ControlGetFocus, Scintilla, ahk_class Notepad++
ControlGet, count, CurrentCol,, %Scintilla%
Works.

Code: Select all

WinActivate, ahk_class Notepad++
ControlGetFocus, Scintilla, ahk_class Notepad++
ControlGetText, text, %Scintilla%
Works.

Code: Select all

WinActivate, ahk_class Notepad++
ControlGetFocus, Scintilla, ahk_class Notepad++
ControlGet, ln, Line, 10, %Scintilla%
Throws an error (but ErrorLevel = 0).

So, workaround:

Code: Select all

WinActivate, ahk_class Notepad++
ControlGetFocus, Scintilla, ahk_class Notepad++
ControlGetText, text, %Scintilla%
lines := StrSplit(text, "`r`n")
ln := lines[10]
just me
Posts: 9457
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: ControlGet Line

02 Feb 2019, 06:15

Where's the bug?
Line

Retrieves the text of line N in an Edit control.

Code: Select all

ControlGet, OutputVar, Line, N , Control, WinTitle, WinText, ExcludeTitle, ExcludeText
Line 1 is the first line. Depending on the nature of the control, OutputVar might end in a carriage return (`r) or a carriage return + linefeed (`r`n). If the specified line number is blank or does not exist, ErrorLevel is set to 1 and OutputVar is made blank.
The Notepad++ main control is not an Edit control.
zorg
Posts: 8
Joined: 01 Feb 2019, 10:09

Re: ControlGet Line

02 Feb 2019, 06:45

Code: Select all

WinActivate, ahk_class Notepad++
ControlGetFocus, Scintilla, ahk_class Notepad++
Does retrieve an Edit control: ControlGet CurrentLine, ControlGet CurrentCol and ControlGetText work that way.
But not ControlGet Line.
just me
Posts: 9457
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: ControlGet Line

03 Feb 2019, 03:39

Every control may respond to (some) common Edit messages, or not.
zorg
Posts: 8
Joined: 01 Feb 2019, 10:09

Re: ControlGet Line

03 Feb 2019, 05:40

It may be an explanation.
Now I suspect the Notepad++ Scintilla control is a Rich Edit Control, that comes with Unsupported Edit Control Functionalities indeed, but EM_GETLINE is not part of them. So it should be usable by AutoHotkey.
just me
Posts: 9457
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: ControlGet Line

03 Feb 2019, 07:40

The Windows version of Scintilla is a Windows Control. As such, its primary programming interface is through Windows messages. Early versions of Scintilla emulated much of the API defined by the standard Windows Edit and RichEdit controls but those APIs are now deprecated in favour of Scintilla's own, more consistent API. In addition to messages performing the actions of a normal Edit control, Scintilla allows control of syntax styling, folding, markers, autocompletion and call tips.

Scintilla Documentation - Introduction
zorg
Posts: 8
Joined: 01 Feb 2019, 10:09

Re: ControlGet Line

03 Feb 2019, 08:28

That's it. Scintilla is "messages performing the actions of a normal Edit control". Well, maybe not all of them... But it would be surprising if it missed GETLINE.
User avatar
nnnik
Posts: 4500
Joined: 30 Sep 2013, 01:01
Location: Germany

Re: ControlGet Line

03 Feb 2019, 09:14

Well to me it seems that GETLINE is missing.
You might be better off to use the messages for the Scintilla Control directly than using AHK code.
Recommends AHK Studio
zorg
Posts: 8
Joined: 01 Feb 2019, 10:09

Re: ControlGet Line

03 Feb 2019, 10:18

Yes it would be great to use the messages for the Scintilla Control directly. But I don't know how to do that in my ahk script :?
User avatar
nnnik
Posts: 4500
Joined: 30 Sep 2013, 01:01
Location: Germany

Re: ControlGet Line

03 Feb 2019, 11:08

There is a wonderful forum thats just about helping people achieve goals like those ->
See: https://www.autohotkey.com/boards/viewforum.php?f=76
Recommends AHK Studio
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: ControlGet Line

03 Feb 2019, 11:26

I've added 2 functions, JEE_SciGetTextLine and JEE_SciGetTextSel, here. Cheers.
GUIs via DllCall: text functions (get/set internal/external control text) - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=40514
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
zorg
Posts: 8
Joined: 01 Feb 2019, 10:09

Re: ControlGet Line

03 Feb 2019, 15:23

jeeswg your work is impressive. It is far more advanced than my little workaround of 3 lines.
Thank you guys.

Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 46 guests