<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; AHK: Взаимодействие со строками в Listbox.]]></title>
		<link>https://forum.script-coding.com/viewtopic.php?id=16953</link>
		<atom:link href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=16953&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «AHK: Взаимодействие со строками в Listbox.».]]></description>
		<lastBuildDate>Sat, 12 Feb 2022 10:53:26 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: AHK: Взаимодействие со строками в Listbox.]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=152154#p152154</link>
			<description><![CDATA[<p>GuiControl.</p>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Sat, 12 Feb 2022 10:53:26 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=152154#p152154</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Взаимодействие со строками в Listbox.]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=152153#p152153</link>
			<description><![CDATA[<p><strong>teadrinker</strong>, как выделить?</p>]]></description>
			<author><![CDATA[null@example.com (Morux2112)]]></author>
			<pubDate>Sat, 12 Feb 2022 10:05:03 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=152153#p152153</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Взаимодействие со строками в Listbox.]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=152152#p152152</link>
			<description><![CDATA[<p>Что именно?</p>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Sat, 12 Feb 2022 08:09:22 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=152152#p152152</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Взаимодействие со строками в Listbox.]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=152151#p152151</link>
			<description><![CDATA[<div class="quotebox"><cite>teadrinker пишет:</cite><blockquote><p>Можно снова выделить её же, номер же есть.</p></blockquote></div><p>Не подскажите?)</p>]]></description>
			<author><![CDATA[null@example.com (Morux2112)]]></author>
			<pubDate>Fri, 11 Feb 2022 23:00:31 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=152151#p152151</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Взаимодействие со строками в Listbox.]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=152148#p152148</link>
			<description><![CDATA[<div class="quotebox"><cite>Morux2112 пишет:</cite><blockquote><p>можно ли сделать так, чтобы при изменении строки выделение с неё не убиралось?</p></blockquote></div><p>По-моему, нет. Можно снова выделить её же, номер же есть.</p>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Fri, 11 Feb 2022 13:28:09 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=152148#p152148</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Взаимодействие со строками в Listbox.]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=152146#p152146</link>
			<description><![CDATA[<p><strong>teadrinker</strong>, огромное спасибо. Ну и последний вопрос: можно ли сделать так, чтобы при изменении строки выделение с неё не убиралось? Либо же как-то считывать содержимое строки по другому? Просто я использую код с кнопки &quot;OnButton&quot; и в качестве переменной с содержанием этой строчки использую text.</p>]]></description>
			<author><![CDATA[null@example.com (Morux2112)]]></author>
			<pubDate>Fri, 11 Feb 2022 12:52:53 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=152146#p152146</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Взаимодействие со строками в Listbox.]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=152139#p152139</link>
			<description><![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>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Thu, 10 Feb 2022 22:15:35 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=152139#p152139</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Взаимодействие со строками в Listbox.]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=152138#p152138</link>
			<description><![CDATA[<div class="quotebox"><cite>teadrinker пишет:</cite><blockquote><p>В последнем варианте моего кода переменная items не используется для замен, попробуйте его.</p></blockquote></div><p>А не могли бы вы убрать функцию &quot;активации/деактивации&quot; этой галочки на одну кнопку. Просто я не знаю как эта функция работает и поэтому самостоятельно убрать её не могу.</p>]]></description>
			<author><![CDATA[null@example.com (Morux2112)]]></author>
			<pubDate>Thu, 10 Feb 2022 22:07:34 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=152138#p152138</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Взаимодействие со строками в Listbox.]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=152137#p152137</link>
			<description><![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>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Thu, 10 Feb 2022 20:19:32 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=152137#p152137</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Взаимодействие со строками в Listbox.]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=152136#p152136</link>
			<description><![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>]]></description>
			<author><![CDATA[null@example.com (Morux2112)]]></author>
			<pubDate>Thu, 10 Feb 2022 18:43:50 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=152136#p152136</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Взаимодействие со строками в Listbox.]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=152135#p152135</link>
			<description><![CDATA[<p><strong>teadrinker</strong>, огромное спасибо.</p>]]></description>
			<author><![CDATA[null@example.com (Morux2112)]]></author>
			<pubDate>Thu, 10 Feb 2022 15:00:02 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=152135#p152135</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Взаимодействие со строками в Listbox.]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=152133#p152133</link>
			<description><![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>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Thu, 10 Feb 2022 14:29:14 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=152133#p152133</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Взаимодействие со строками в Listbox.]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=152132#p152132</link>
			<description><![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>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Thu, 10 Feb 2022 13:38:51 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=152132#p152132</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Взаимодействие со строками в Listbox.]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=152131#p152131</link>
			<description><![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>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Thu, 10 Feb 2022 13:00:59 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=152131#p152131</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Взаимодействие со строками в Listbox.]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=152130#p152130</link>
			<description><![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>]]></description>
			<author><![CDATA[null@example.com (Morux2112)]]></author>
			<pubDate>Thu, 10 Feb 2022 10:54:42 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=152130#p152130</guid>
		</item>
	</channel>
</rss>
