<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: Взаимодействие со строками в Listbox.]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=16953&amp;type=atom" />
	<updated>2022-02-12T10:53:26Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=16953</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Взаимодействие со строками в Listbox.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=152154#p152154" />
			<content type="html"><![CDATA[<p>GuiControl.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2022-02-12T10:53:26Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=152154#p152154</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Взаимодействие со строками в Listbox.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=152153#p152153" />
			<content type="html"><![CDATA[<p><strong>teadrinker</strong>, как выделить?</p>]]></content>
			<author>
				<name><![CDATA[Morux2112]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=41251</uri>
			</author>
			<updated>2022-02-12T10:05:03Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=152153#p152153</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Взаимодействие со строками в Listbox.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=152152#p152152" />
			<content type="html"><![CDATA[<p>Что именно?</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2022-02-12T08:09:22Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=152152#p152152</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Взаимодействие со строками в Listbox.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=152151#p152151" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>teadrinker пишет:</cite><blockquote><p>Можно снова выделить её же, номер же есть.</p></blockquote></div><p>Не подскажите?)</p>]]></content>
			<author>
				<name><![CDATA[Morux2112]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=41251</uri>
			</author>
			<updated>2022-02-11T23:00:31Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=152151#p152151</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Взаимодействие со строками в Listbox.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=152148#p152148" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Morux2112 пишет:</cite><blockquote><p>можно ли сделать так, чтобы при изменении строки выделение с неё не убиралось?</p></blockquote></div><p>По-моему, нет. Можно снова выделить её же, номер же есть.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2022-02-11T13:28:09Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=152148#p152148</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Взаимодействие со строками в Listbox.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=152146#p152146" />
			<content type="html"><![CDATA[<p><strong>teadrinker</strong>, огромное спасибо. Ну и последний вопрос: можно ли сделать так, чтобы при изменении строки выделение с неё не убиралось? Либо же как-то считывать содержимое строки по другому? Просто я использую код с кнопки &quot;OnButton&quot; и в качестве переменной с содержанием этой строчки использую text.</p>]]></content>
			<author>
				<name><![CDATA[Morux2112]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=41251</uri>
			</author>
			<updated>2022-02-11T12:52:53Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=152146#p152146</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Взаимодействие со строками в Listbox.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=152139#p152139" />
			<content type="html"><![CDATA[<p>Замените<br /></p><div class="codebox"><pre><code>text := InStr(text, &quot;☐&quot;) ? StrReplace(text, &quot;☐&quot;, &quot;✅&quot;) : StrReplace(text, &quot;✅&quot;, &quot;☐&quot;)</code></pre></div><p>на<br /></p><div class="codebox"><pre><code>text := StrReplace(text, &quot;☐&quot;, &quot;✅&quot;)</code></pre></div>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2022-02-10T22:15:35Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=152139#p152139</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Взаимодействие со строками в Listbox.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=152138#p152138" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>teadrinker пишет:</cite><blockquote><p>В последнем варианте моего кода переменная items не используется для замен, попробуйте его.</p></blockquote></div><p>А не могли бы вы убрать функцию &quot;активации/деактивации&quot; этой галочки на одну кнопку. Просто я не знаю как эта функция работает и поэтому самостоятельно убрать её не могу.</p>]]></content>
			<author>
				<name><![CDATA[Morux2112]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=41251</uri>
			</author>
			<updated>2022-02-10T22:07:34Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=152138#p152138</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Взаимодействие со строками в Listbox.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=152137#p152137" />
			<content type="html"><![CDATA[<p>Я ничего не понял, что откуда удалять.</p><div class="quotebox"><cite>Morux2112 пишет:</cite><blockquote><div class="codebox"><pre><code>SendMessage, 0x188 ...</code></pre></div></blockquote></div><p>Никто не обязан знать, что означает число 0х188 и какому сообщению оно соответствует, поэтому непонятно, что это сообщение делает.<br />В последнем варианте моего кода переменная items не используется для замен, попробуйте его.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2022-02-10T20:19:32Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=152137#p152137</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Взаимодействие со строками в Listbox.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=152136#p152136" />
			<content type="html"><![CDATA[<p><strong>teadrinker</strong>, мне уже не удобно просить, и так много сделали для меня. Как очищать item от строки, которую я удалил?<br /></p><div class="codebox"><pre><code>Delete:  
    SendMessage, 0x188, 0, 0, , ahk_id %hListbox%     ; If (ErrorLevel = 0xffffffff) Not Selected 
    Control, Delete, % ++ErrorLevel, , ahk_id %hListbox%   
    return</code></pre></div><p>Данный скрипт удаляет просто строку из Listbox&#039;a и если попытаться изменить содержимое строки, которое идет после удаленной - оно поменяется на удаленную строку, т.к. в переменной items осталась данная удаленная строка. Так как её можно удалить из Items?</p>]]></content>
			<author>
				<name><![CDATA[Morux2112]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=41251</uri>
			</author>
			<updated>2022-02-10T18:43:50Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=152136#p152136</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Взаимодействие со строками в Listbox.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=152135#p152135" />
			<content type="html"><![CDATA[<p><strong>teadrinker</strong>, огромное спасибо.</p>]]></content>
			<author>
				<name><![CDATA[Morux2112]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=41251</uri>
			</author>
			<updated>2022-02-10T15:00:02Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=152135#p152135</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Взаимодействие со строками в Listbox.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=152133#p152133" />
			<content type="html"><![CDATA[<p>Хотя, если уж использовать сообщения, можно избавиться от переменной items:<br /></p><div class="codebox"><pre><code>global hListbox, squawk := 2000

items =
(Join|
☐ / ILKOK / ULLI / ULLI / A012 / V / —— / RNAV / RVSM / %squawk%
☐ / RYR1TZ / ULLI / UUEE / FL350 / I / —— / RNAV / RVSM / %squawk%
☐ / BRU457 / ULLI / UMMS / FL250 / I / —— / RNAV / RVSM / %squawk%
)
Gui, Add, ListBox, x12 y13 w410 h140 hwndhListbox vMyListBox AltSubmit, % items
Gui, Add, Button, x12 y153 w30 h30 gOnButton, ✅
Gui, Add, Button, x50 y153 w30 h30 gAdd, +
Gui, Show, w435 h220, test
return

OnButton() {
   static LB_INSERTSTRING := 0x0181
        , LB_DELETESTRING := 0x0182
        , LB_GETTEXT      := 0x0189
        , LB_GETTEXTLEN   := 0x018A
   GuiControlGet, selected,, MyListBox
   WinExist(&quot;ahk_id&quot; . hListbox)
   SendMessage, LB_GETTEXTLEN, --selected
   VarSetCapacity(text, ErrorLevel &lt;&lt; !!A_IsUnicode, 0)
   SendMessage, LB_GETTEXT, selected, &amp;text
   text := InStr(text, &quot;☐&quot;) ? StrReplace(text, &quot;☐&quot;, &quot;✅&quot;) : StrReplace(text, &quot;✅&quot;, &quot;☐&quot;)
   SendMessage, LB_DELETESTRING, selected
   SendMessage, LB_INSERTSTRING, selected, &amp;text
}

Add() {
   sost := &quot;☐&quot;
   callsign := &quot;NWS1234&quot;
   dep := &quot;ULLI&quot;
   dest := &quot;URSS&quot;
   fl := &quot;FL350&quot;
   rules := &quot;I&quot;
   sid := &quot;SUGIN 1A&quot;
   rnav := &quot;RNAV&quot;
   rvsm := &quot;RVSM&quot;
   newItem := sost &quot; / &quot; callsign &quot; / &quot; dep &quot; / &quot; dest &quot; / &quot; fl &quot; / &quot; rules &quot; / &quot; sid &quot; / &quot; rnav &quot; / &quot; rvsm &quot; / &quot; squawk
   GuiControl,, MyListBox, % newItem
}

GuiClose() {
   ExitApp
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2022-02-10T14:29:14Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=152133#p152133</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Взаимодействие со строками в Listbox.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=152132#p152132" />
			<content type="html"><![CDATA[<p>Также можно воспользоваться более продвинутым способом, который будет заменять не всё содержимое контрола сразу, а только одну строку:<br /></p><div class="codebox"><pre><code>global items, hListbox, squawk := 2000

items =
(Join|
☐ / ILKOK / ULLI / ULLI / A012 / V / —— / RNAV / RVSM / %squawk%
☐ / RYR1TZ / ULLI / UUEE / FL350 / I / —— / RNAV / RVSM / %squawk%
☐ / BRU457 / ULLI / UMMS / FL250 / I / —— / RNAV / RVSM / %squawk%
)
Gui, Add, ListBox, x12 y13 w410 h140 hwndhListbox vMyListBox AltSubmit, % items
Gui, Add, Button, x12 y153 w30 h30 gOnButton, ✅
Gui, Add, Button, x50 y153 w30 h30 gAdd, +
Gui, Show, w435 h220, test
return

OnButton() {
   static LB_INSERTSTRING := 0x0181
        , LB_DELETESTRING := 0x0182
   GuiControlGet, selected,, MyListBox
   newItems := &quot;&quot;
   Loop, parse, items, |
   {
      item := A_LoopField
      if (A_Index = selected) {
         if InStr(A_LoopField, &quot;☐&quot;)
            item := StrReplace(A_LoopField, &quot;☐&quot;, &quot;✅&quot;)
         else
            item := StrReplace(A_LoopField, &quot;✅&quot;, &quot;☐&quot;)
         SendMessage, LB_DELETESTRING, A_Index - 1,,, ahk_id %hListbox%
         SendMessage, LB_INSERTSTRING, A_Index - 1, &amp;item,, ahk_id %hListbox%
      }
      newItems .= (A_Index = 1 ? &quot;&quot; : &quot;|&quot;) . item
   }
   items := newItems
}

Add() {
   sost := &quot;☐&quot;
   callsign := &quot;NWS1234&quot;
   dep := &quot;ULLI&quot;
   dest := &quot;URSS&quot;
   fl := &quot;FL350&quot;
   rules := &quot;I&quot;
   sid := &quot;SUGIN 1A&quot;
   rnav := &quot;RNAV&quot;
   rvsm := &quot;RVSM&quot;
   newItem := sost &quot; / &quot; callsign &quot; / &quot; dep &quot; / &quot; dest &quot; / &quot; fl &quot; / &quot; rules &quot; / &quot; sid &quot; / &quot; rnav &quot; / &quot; rvsm &quot; / &quot; squawk
   items  .= &quot;|&quot; . newItem
   GuiControl,, MyListBox, % newItem
}

GuiClose() {
   ExitApp
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2022-02-10T13:38:51Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=152132#p152132</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Взаимодействие со строками в Listbox.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=152131#p152131" />
			<content type="html"><![CDATA[<p>Нужно всё время менять содержимое переменной items, чтобы оно соответствовало текущему содержимому контрола:<br /></p><div class="codebox"><pre><code>global items, squawk := 2000

items =
(Join|
☐ / ILKOK / ULLI / ULLI / A012 / V / —— / RNAV / RVSM / %squawk%
☐ / RYR1TZ / ULLI / UUEE / FL350 / I / —— / RNAV / RVSM / %squawk%
☐ / BRU457 / ULLI / UMMS / FL250 / I / —— / RNAV / RVSM / %squawk%
)
Gui, Add, ListBox, x12 y13 w410 h140 hwndhListbox vMyListBox AltSubmit, % items
Gui, Add, Button, x12 y153 w30 h30 gOnButton, ✅
Gui, Add, Button, x50 y153 w30 h30 gAdd, +
Gui, Show, w435 h220, test
return

OnButton() {
   GuiControlGet, selected,, MyListBox
   newItems := &quot;&quot;
   Loop, parse, items, |
   {
      item := A_LoopField
      if (A_Index = selected) {
         if InStr(A_LoopField, &quot;☐&quot;)
            item := StrReplace(A_LoopField, &quot;☐&quot;, &quot;✅&quot;)
         else
            item := StrReplace(A_LoopField, &quot;✅&quot;, &quot;☐&quot;)
      }
      newItems .= (A_Index = 1 ? &quot;&quot; : &quot;|&quot;) . item
   }
   GuiControl,, MyListBox, % &quot;|&quot; . (items := newItems)
}

Add() {
   sost := &quot;☐&quot;
   callsign := &quot;NWS1234&quot;
   dep := &quot;ULLI&quot;
   dest := &quot;URSS&quot;
   fl := &quot;FL350&quot;
   rules := &quot;I&quot;
   sid := &quot;SUGIN 1A&quot;
   rnav := &quot;RNAV&quot;
   rvsm := &quot;RVSM&quot;
   newItem := sost &quot; / &quot; callsign &quot; / &quot; dep &quot; / &quot; dest &quot; / &quot; fl &quot; / &quot; rules &quot; / &quot; sid &quot; / &quot; rnav &quot; / &quot; rvsm &quot; / &quot; squawk
   items  .= &quot;|&quot; . newItem
   GuiControl,, MyListBox, % newItem
}

GuiClose() {
   ExitApp
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2022-02-10T13:00:59Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=152131#p152131</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Взаимодействие со строками в Listbox.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=152130#p152130" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>teadrinker пишет:</cite><blockquote><p>Конечно, всё можно. Если вы поняли принцип, вам не составит труда изменить код.</p></blockquote></div><p>Я не совсем понимаю как оно работает. Точнее понимаю, но не могу сделать так, чтобы оно работало на все строчки. Не поможете?</p><div class="quotebox"><cite>teadrinker пишет:</cite><blockquote><p>И можно ли как-то избежать переменной items такого рода, либо же записывать новые строки туда? Просто новые строки записываются таким родом<br />Я не совсем понял, что вы имеете в виду. Данные всегда находятся в какой-либо переменной, где ж им ещё быть.</p></blockquote></div><p>Строки в ListBox добавляются таким методом, только данные для переменных берутся с файла. После добавления строчки через GuiControl и попытки изменить в ней хоть что-то - она пропадает. Можно ли как-то это исправить?</p><div class="codebox"><pre><code>global squawk := 2000

items =
(Join|
☐ / ILKOK / ULLI / ULLI / A012 / V / —— / RNAV / RVSM / %squawk%
☐ / RYR1TZ / ULLI / UUEE / FL350 / I / —— / RNAV / RVSM / %squawk%
☐ / BRU457 / ULLI / UMMS / FL250 / I / —— / RNAV / RVSM / %squawk%
)
Gui, Add, ListBox, x12 y13 w410 h140 hwndhListbox vMyListBox AltSubmit, % items
Gui, Add, Button, x12 y153 w30 h30 gOnButton, ✅
Gui, Add, Button, x50 y153 w30 h30 gAdd, +
Gui, Show, w435 h220, test
return

OnButton() {
   global items
   GuiControlGet, selected,, MyListBox
   newItems := &quot;&quot;
   Loop, parse, items, |
      newItems .= &quot;|&quot; . (A_Index = selected ? StrReplace(A_LoopField, &quot;☐&quot;, &quot;✅&quot;) : A_LoopField)
   GuiControl,, MyListBox, % newItems
}

Numpad1::
InputBox, sqk
global items
GuiControlGet, selected,, MyListBox
newItems := &quot;&quot;
Loop, parse, items, |
newItems .= &quot;|&quot; . (A_Index = selected ? StrReplace(A_LoopField, squawk, sqk) : A_LoopField)
GuiControl,, MyListBox, % newItems
return

Add() {
   sost := &quot;☐&quot;
   callsign := &quot;NWS1234&quot;
   dep := &quot;ULLI&quot;
   dest := &quot;URSS&quot;
   fl := &quot;FL350&quot;
   rules := &quot;I&quot;
   sid := &quot;SUGIN 1A&quot;
   rnav := &quot;RNAV&quot;
   rvsm := &quot;RVSM&quot;
   GuiControl,, MyListBox, %sost% / %callsign% / %dep% / %dest% / %fl% / %rules% / %sid% / %rnav% / %rvsm% / %squawk%
}

GuiClose() {
   ExitApp
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Morux2112]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=41251</uri>
			</author>
			<updated>2022-02-10T10:54:42Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=152130#p152130</id>
		</entry>
</feed>
