<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; AHK: Edit(Scrolling)]]></title>
		<link>https://forum.script-coding.com/viewtopic.php?id=13216</link>
		<atom:link href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=13216&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «AHK: Edit(Scrolling)».]]></description>
		<lastBuildDate>Thu, 21 Dec 2017 15:29:03 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: AHK: Edit(Scrolling)]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=122472#p122472</link>
			<description><![CDATA[<p><a href="http://forum.script-coding.com/viewtopic.php?pid=121329#p121329">http://forum.script-coding.com/viewtopi … 29#p121329</a><br /><a href="http://forum.script-coding.com/viewtopic.php?pid=121328#p121328">http://forum.script-coding.com/viewtopi … 28#p121328</a><br /><a href="http://forum.script-coding.com/viewtopic.php?pid=121320#p121320">http://forum.script-coding.com/viewtopi … 20#p121320</a><br /><a href="http://forum.script-coding.com/viewtopic.php?pid=120861#p120861">http://forum.script-coding.com/viewtopi … 61#p120861</a><br /><a href="http://forum.script-coding.com/viewtopic.php?pid=120710#p120710">http://forum.script-coding.com/viewtopi … 10#p120710</a><br /><a href="http://forum.script-coding.com/viewtopic.php?pid=120701#p120701">http://forum.script-coding.com/viewtopi … 01#p120701</a><br /><a href="http://forum.script-coding.com/viewtopic.php?pid=120165#p120165">http://forum.script-coding.com/viewtopi … 65#p120165</a><br /><a href="http://forum.script-coding.com/viewtopic.php?pid=120127#p120127">http://forum.script-coding.com/viewtopi … 27#p120127</a><br /><a href="http://forum.script-coding.com/viewtopic.php?pid=119436#p119436">http://forum.script-coding.com/viewtopi … 36#p119436</a><br /><a href="http://forum.script-coding.com/viewtopic.php?pid=118270#p118270">http://forum.script-coding.com/viewtopi … 70#p118270</a><br /><a href="http://forum.script-coding.com/viewtopic.php?pid=118143#p118143">http://forum.script-coding.com/viewtopi … 43#p118143</a><br /><a href="http://forum.script-coding.com/viewtopic.php?pid=118033#p118033">http://forum.script-coding.com/viewtopi … 33#p118033</a><br /><a href="http://forum.script-coding.com/viewtopic.php?pid=117843#p117843">http://forum.script-coding.com/viewtopi … 43#p117843</a><br /><a href="http://forum.script-coding.com/viewtopic.php?pid=117301#p117301">http://forum.script-coding.com/viewtopi … 01#p117301</a><br /><a href="http://forum.script-coding.com/viewtopic.php?pid=110005#p110005">http://forum.script-coding.com/viewtopi … 05#p110005</a><br /><a href="http://forum.script-coding.com/viewtopic.php?pid=109982#p109982">http://forum.script-coding.com/viewtopi … 82#p109982</a></p>]]></description>
			<author><![CDATA[null@example.com (ypppu)]]></author>
			<pubDate>Thu, 21 Dec 2017 15:29:03 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=122472#p122472</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Edit(Scrolling)]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=121416#p121416</link>
			<description><![CDATA[<p><span style="color: green"><strong>MandarinKa02</strong>, поставьте точки в конце предложений.</span></p>]]></description>
			<author><![CDATA[null@example.com (ypppu)]]></author>
			<pubDate>Sun, 19 Nov 2017 20:57:47 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=121416#p121416</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Edit(Scrolling)]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=121396#p121396</link>
			<description><![CDATA[<div class="quotebox"><cite>MandarinKa02 пишет:</cite><blockquote><p>ООооо.. Ну здесь вы попались <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /> Вам по-любому нужен буфер и Strlen.</p></blockquote></div><p>Обычно мне фиолетово. <br />Но вот в чём смысл радости от того, что один из любезно предложенных вам методов для решения вашей задачи оказался, по вашему скромному мнению, нерабочим.<br />К чему эти &quot;ООооо..&quot;, &quot;попались&quot;, смайлик, если велика вероятность того что вы же сами ошибаетесь, и если в итоге вы ошибетесь, а вы ошиблись, то тогда такое утверждение будет выглядеть ещё глупее.</p>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Sun, 19 Nov 2017 15:41:32 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=121396#p121396</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Edit(Scrolling)]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=121393#p121393</link>
			<description><![CDATA[<p><strong>serzh82saratov</strong>, вижу)</p>]]></description>
			<author><![CDATA[null@example.com (MandarinKa02)]]></author>
			<pubDate>Sun, 19 Nov 2017 15:13:02 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=121393#p121393</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Edit(Scrolling)]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=121373#p121373</link>
			<description><![CDATA[<p>Но тут нет буфера, нет Strlen.</p>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Sun, 19 Nov 2017 12:49:24 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=121373#p121373</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Edit(Scrolling)]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=121367#p121367</link>
			<description><![CDATA[<p>Буфер - всмысле переменная, где хранится весь текст</p>]]></description>
			<author><![CDATA[null@example.com (MandarinKa02)]]></author>
			<pubDate>Sun, 19 Nov 2017 09:59:15 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=121367#p121367</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Edit(Scrolling)]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=121362#p121362</link>
			<description><![CDATA[<div class="quotebox"><cite>MandarinKa02 пишет:</cite><blockquote><p>ООооо.. Ну здесь вы попались <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /> Вам по-любому нужен буфер и Strlen.</p></blockquote></div><p>Так что за буфер такой?<br /></p><div class="codebox"><pre><code>maxlines := 20
VarSetCapacity(start, 4), VarSetCapacity(end, 4)
Gui, Color, 111111
Gui, Font, s12 cFFFFFF, Georgia
Gui, Add, Edit, w400 r18 hwndhEdit ReadOnly, 8`nлд
Gui, Show
Str = ########## ######## #############

AddText:
	Loop {
		Sleep, 200
		GuiControl, -Redraw, %hEdit%
		SendMessage, 0xB0, &amp;start, &amp;end, , ahk_id %hEdit%  ; EM_GETSEL
		ControlGet, Line, CurrentLine,,, ahk_id %hEdit%
		ControlGet, Col, CurrentCol,,, ahk_id %hEdit%
		SendMessage, 0x0E, , , , ahk_id %hEdit%    ;  WM_GETTEXTLENGTH
		random, rand, 0, 33
		msg := (Errorlevel ? &quot;`r`n&quot; : &quot;&quot;) SubStr(Str, 1, rand) 
		SendMessage, 0x00B1, Errorlevel, Errorlevel, , ahk_id %hEdit%    ;  EM_SETSEL
		SendMessage, 0x00C2 , TRUE, &amp;msg,, ahk_id %hEdit%  ;	EM_REPLACESEL
		SendMessage, 0x00BA, 0, 0,, ahk_id %hEdit% ; EM_GETLINECOUNT
		If ((LINECOUNT := Errorlevel) &gt; maxlines)
		{
			SendMessage, 0xBB, 1,,,ahk_id %hEdit%    ;  EM_LINEINDEX
			SendMessage, 0x00B1, 0, Off := Errorlevel, , ahk_id %hEdit%    ;  EM_SETSEL
			SendMessage, 0x00C2 , TRUE, 0,, ahk_id %hEdit%  ;	EM_REPLACESEL
		}
		SendMessage, 0xBB, Line - 1,,,ahk_id %hEdit%    ;  EM_LINEINDEX
		_start := Errorlevel + Col - 1
		SendMessage, 0xBB, Line,,,ahk_id %hEdit%    ;  EM_LINEINDEX
		If (_start &gt; (__start := Errorlevel - 2))
			_start := __start
		SendMessage, 0x0B1, _start, NumGet(end) - NumGet(start) + _start, , ahk_id %hEdit%  ; EM_SETSEL
		GuiControl, +Redraw, %hEdit%
		ToolTip % Line
	}
	Return</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Sun, 19 Nov 2017 05:21:54 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=121362#p121362</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Edit(Scrolling)]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=121349#p121349</link>
			<description><![CDATA[<div class="codebox"><pre><code>ControlGet, Line, CurrentLine,,, ahk_id %hEdit%
ControlGet, Col, CurrentCol,,, ahk_id %hEdit%</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (stealzy)]]></author>
			<pubDate>Sat, 18 Nov 2017 18:02:37 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=121349#p121349</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Edit(Scrolling)]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=121348#p121348</link>
			<description><![CDATA[<p>Не понял какой буфер, вопрос то не про - как, а про - что должно получится. <br />Сейчас остаётся в том же месте от начала текста, а если длинны строк разные, то получится что может визуально смещатся.</p>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Sat, 18 Nov 2017 17:54:16 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=121348#p121348</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Edit(Scrolling)]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=121346#p121346</link>
			<description><![CDATA[<div class="quotebox"><cite>serzh82saratov пишет:</cite><blockquote><p>Тут вопрос, где должен оставатся курсор, если длинны строк разные.</p></blockquote></div><p>ООооо.. Ну здесь вы попались <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /> Вам по-любому нужен буфер и Strlen.</p>]]></description>
			<author><![CDATA[null@example.com (MandarinKa02)]]></author>
			<pubDate>Sat, 18 Nov 2017 17:33:55 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=121346#p121346</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Edit(Scrolling)]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=121343#p121343</link>
			<description><![CDATA[<div class="quotebox"><cite>serzh82saratov пишет:</cite><blockquote><p>Тогда метод stealzy удобнее, можно сразу из msg удалять 1 строку.</p></blockquote></div><p>А может и неудобнее.<br /></p><div class="codebox"><pre><code>
maxlines := 10
VarSetCapacity(start, 4), VarSetCapacity(end, 4)
Gui, Color, 111111
Gui, Font, s7 cFFFFFF, Georgia
Gui, Add, Edit, w200 h100 hwndhEdit ReadOnly
Gui, Show

AddText:
	Loop {
		Sleep, 100
		GuiControl, -Redraw, %hEdit%
		SendMessage, 0xB0, &amp;start, &amp;end, , ahk_id %hEdit%  ; EM_GETSEL
		SendMessage, 0x0E, , , , ahk_id %hEdit%    ;  WM_GETTEXTLENGTH
		msg := (Errorlevel ? &quot;`r`n&quot; : &quot;&quot;) &quot;text #&quot; A_Index
		SendMessage, 0x00B1, Errorlevel, Errorlevel, , ahk_id %hEdit%    ;  EM_SETSEL
		SendMessage, 0x00C2 , TRUE, &amp;msg,, ahk_id %hEdit%  ;	EM_REPLACESEL
		SendMessage, 0x00BA, 0, 0,, ahk_id %hEdit% ; EM_GETLINECOUNT
		If (Errorlevel &gt; maxlines)
		{
			SendMessage, 0xBB, 1,,,ahk_id %hEdit%    ;  EM_LINEINDEX
			SendMessage, 0x00B1, 0, Off := Errorlevel, , ahk_id %hEdit%    ;  EM_SETSEL
			SendMessage, 0x00C2 , TRUE, 0,, ahk_id %hEdit%  ;	EM_REPLACESEL
		}
		SendMessage, 0x0B1, NumGet(start), NumGet(end), , ahk_id %hEdit%  ; EM_SETSEL
		GuiControl, +Redraw, %hEdit%
	}
	Return
</code></pre></div><p>Тут вопрос, где должен оставатся курсор, если длинны строк разные.</p>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Sat, 18 Nov 2017 17:17:25 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=121343#p121343</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Edit(Scrolling)]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=121330#p121330</link>
			<description><![CDATA[<p>Еще в конце можно переделать условие,<br /></p><div class="codebox"><pre><code>
if(line = 50 &amp;&amp; ScrPos != 38)
        PostMessage, WM_VSCROLL := 0x115, SB_LINEUP := 0,,, ahk_id %hConsole%
</code></pre></div><p>Тогда, если строка будет равна последней(38-ая), то LINEUP работать не будет</p>]]></description>
			<author><![CDATA[null@example.com (MandarinKa02)]]></author>
			<pubDate>Sat, 18 Nov 2017 15:47:30 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=121330#p121330</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Edit(Scrolling)]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=121329#p121329</link>
			<description><![CDATA[<p>Сделал вот такое(вроде на костыль не похоже).<br /></p><div class="codebox"><pre><code>
Gui Color, 111111
Gui Font, s7 cFFFFFF, Georgia
Gui Add, Edit, w200 h150 hwndhConsole ReadOnly
Gui Show

i:=0, line := 0
Loop {
	Sleep 100
    value := &quot;text&quot; ++i
    len := 0
    ScrPos := SB_GetPos(hConsole)
    EM_GETSEL(hConsole, start, end)



    if(line = 50) {
        len := GetFirstLineLength(msg)
        msg := RegExReplace(msg, &quot;U).*`n&quot;,,,1), msg .= value &quot;`n&quot;
    }
    else msg .= value &quot;`n&quot;, line++
    GuiControl,, % hConsole, % msg



    EM_SETSEL(hConsole, start-len, end-len)
    SB_SetPos(hConsole,, ScrPos)
    SetScrollPos(hConsole, true, ScrPos)
    if(line = 50)
        PostMessage, WM_VSCROLL := 0x115, SB_LINEUP := 0,,, ahk_id %hConsole%
}

GuiClose:
	ExitApp
f5::reload
GetFirstLineLength(line) {
    return Strlen(RegExReplace(line, &quot;U)`n.*&quot;,,,1))
}
; ======================================================================================================================
; Gets the starting and ending character positions of the current selection in an edit control.
; Start  -  receives the start of the current selection
; End    -  receives the end of the current selection
; ======================================================================================================================
EM_GETSEL(HWND, ByRef Start, ByRef End) {
   ; EM_GETSEL = 0x00B0 -&gt; msdn.microsoft.com/en-us/library/bb761598(v=vs.85).aspx
   Start := End := 0
   DllCall(&quot;User32.dll\SendMessage&quot;, &quot;Ptr&quot;, HWND, &quot;UInt&quot;, 0x00B0, &quot;UIntP&quot;, Start, &quot;UIntP&quot;, End, &quot;Ptr&quot;)
   ++Start, ++End
   Return True
}
; ======================================================================================================================
; Selects a range of characters in an edit control.
; Start  -  the character index of the start of the selection.
; End    -  the character index of the end of the selection.
; ======================================================================================================================
EM_SETSEL(HWND, Start, End) {
   ; EM_SETSEL = 0x00B1 -&gt; msdn.microsoft.com/en-us/library/bb761661(v=vs.85).aspx
   Return DllCall(&quot;User32.dll\SendMessage&quot;, &quot;Ptr&quot;, HWND, &quot;UInt&quot;, 0x00B1, &quot;Ptr&quot;, Start - 1, &quot;Ptr&quot;, End - 1, &quot;Ptr&quot;)
}


SB_GetPos(hwnd, Which:=&quot;V&quot;){
    Which := (Which=&quot;V&quot; || Which=1) ? 1 : (Which=&quot;H&quot; || Which=0) ? 0 : 1
    Return DllCall(&quot;GetScrollPos&quot;, &quot;UInt&quot;, Hwnd, &quot;Int&quot;, Which)                
}

SB_SetPos(hwnd, Which:=&quot;V&quot;, To:=&quot;0&quot;){
    Which := (Which=&quot;V&quot; || Which=1) ? 1 : (Which=&quot;H&quot; || Which=0) ? 0 : 1
    Return DllCall(&quot;SetScrollPos&quot;, &quot;UInt&quot;, Hwnd, &quot;Int&quot;, Which, &quot;Int&quot;, To, &quot;UInt&quot;, 1)
}


SetScrollPos(hwnd, fnBar, nPos)
{
    VarSetCapacity(si, 28, 0) ; SCROLLINFO si
    NumPut(28  , si,  0)    ; si.cbSize := sizeof(SCROLLINFO)
    NumPut(0x4 , si,  4)    ; si.fMask := SIF_POS
    NumPut(nPos, si, 20)    ; si.nPos := nPos
 
    ; Use SetScrollInfo first because it supports 32-bit positions.
    ; If an application supports positions &lt; 0 or &gt; 65535, it most likely
    ; ignores WM_#SCROLL&#039;s wParam and uses GetScrollPos or GetScrollInfo
    ; to get the actual scroll position.
    DllCall(&quot;SetScrollInfo&quot;, &quot;uint&quot;, hwnd, &quot;int&quot;, fnBar, &quot;uint&quot;, &amp;si, &quot;int&quot;, 0)
    
    ; WM_HSCROLL or WM_VSCROLL must be sent for the window to update it&#039;s contents.
    msg := (fnBar=0) ? 0x114 : 0x115
    wParam := 4 ; SB_THUMBPOSITION
        | ((nPos&amp;0xFFFF)&lt;&lt;16)
    SendMessage, msg, wParam,,, ahk_id %hwnd%
    
    return (ErrorLevel != &quot;FAIL&quot;)
}

GetScrollInfo(hwnd, fnBar, ByRef nPos=0, ByRef nTrackPos=0, ByRef nMin=0, ByRef nMax=0, ByRef nPage=0)
{
    WinGet, Style, Style, ahk_id %hwnd%
    if !(Style &amp; (fnBar ? 0x200000 : 0x100000))
        return false ; Fix for some controls which report {min:0,max:100} even though scroll bar doesn&#039;t exist.

    VarSetCapacity(si, 28, 0) ; SCROLLINFO si
    NumPut(28  , si, 0) ; si.cbSize := sizeof(SCROLLINFO)
    NumPut(0x17, si, 4) ; si.fMask := SIF_ALL
    
    if ! DllCall(&quot;GetScrollInfo&quot;, &quot;uint&quot;, hwnd, &quot;int&quot;, fnBar, &quot;uint&quot;, &amp;si)
        return false
    
    nPos        := NumGet(si, 20)
    nTrackPos   := NumGet(si, 24)
    nMin        := NumGet(si,  8)
    nMax        := NumGet(si, 12)
    nPage       := NumGet(si, 16)
    return true
}
</code></pre></div><p>Только, если выделять текст во время добавление строчки то он будет прыгать. Но то не существенно.</p>]]></description>
			<author><![CDATA[null@example.com (MandarinKa02)]]></author>
			<pubDate>Sat, 18 Nov 2017 15:40:40 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=121329#p121329</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Edit(Scrolling)]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=121328#p121328</link>
			<description><![CDATA[<div class="quotebox"><cite>serzh82saratov пишет:</cite><blockquote><p>В вашем случае надо будет ещё позицию каретки пересчитывать исходя из удалённых данных.</p></blockquote></div><p>Уже работаю.</p>]]></description>
			<author><![CDATA[null@example.com (MandarinKa02)]]></author>
			<pubDate>Sat, 18 Nov 2017 15:30:19 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=121328#p121328</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Edit(Scrolling)]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=121327#p121327</link>
			<description><![CDATA[<p>Тогда метод <strong>stealzy</strong> удобнее, можно сразу из msg удалять 1 строку.<br />В вашем случае надо будет ещё позицию каретки пересчитывать исходя из удалённых данных.</p>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Sat, 18 Nov 2017 15:28:07 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=121327#p121327</guid>
		</item>
	</channel>
</rss>
