<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; AHK: Прозрачность элементов GUI]]></title>
		<link>https://forum.script-coding.com/viewtopic.php?id=16243</link>
		<atom:link href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=16243&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «AHK: Прозрачность элементов GUI».]]></description>
		<lastBuildDate>Wed, 07 Apr 2021 20:05:41 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: AHK: Прозрачность элементов GUI]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=147211#p147211</link>
			<description><![CDATA[<div class="quotebox"><cite>__Михаил__ пишет:</cite><blockquote><p>Проверял прозрачность</p></blockquote></div><p>Прозрачность чего именно?</p>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Wed, 07 Apr 2021 20:05:41 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=147211#p147211</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Прозрачность элементов GUI]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=147208#p147208</link>
			<description><![CDATA[<p>На работе win7 x64. Проверял прозрачность и всё работало исправно.<br />Нужно будет этот код проверить завтра.</p>]]></description>
			<author><![CDATA[null@example.com (__Михаил__)]]></author>
			<pubDate>Wed, 07 Apr 2021 19:17:03 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=147208#p147208</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Прозрачность элементов GUI]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=147207#p147207</link>
			<description><![CDATA[<p>Чтобы сделать окно частично прозрачным, к нему нужно <a href="https://www.experts-exchange.com/articles/1783/Win32-Semi-Transparent-Window.html">применить</a> стиль WS_EX_LAYERED (что и делает WinSet, Transparent). Окна, о которых идёт речь, в обоих примерах дочерние, а со стилем WS_EX_LAYERED окна могут быть дочерними только <a href="https://docs.microsoft.com/en-us/windows/win32/winmsg/window-features#layered-windows">начиная с Windows 8</a>:<br /></p><div class="quotebox"><blockquote><p>Beginning with Windows 8, WS_EX_LAYERED can be used with child windows and top-level windows. Previous Windows versions support WS_EX_LAYERED only for top-level windows.</p></blockquote></div>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Wed, 07 Apr 2021 18:43:52 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=147207#p147207</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Прозрачность элементов GUI]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=147197#p147197</link>
			<description><![CDATA[<p>А где можно узнать, что именно на win10 только будет работать код?</p>]]></description>
			<author><![CDATA[null@example.com (__Михаил__)]]></author>
			<pubDate>Wed, 07 Apr 2021 17:06:55 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=147197#p147197</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Прозрачность элементов GUI]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=147194#p147194</link>
			<description><![CDATA[<p>Изменять прозрачность можно так же и у контролов, например:<br /></p><div class="codebox"><pre><code>Gui, Margin, 0, 0
Gui, Font, s15 bold, Segoe UI
Gui, Add, Text, y50 w400 Center hwndhText1, Элемент №1
Gui, Font, s10
Gui, Add, Text, y+10 wp Center hwndhText2, Элемент №2
Gui, Show, h300
trans := 0
Elems := [hText1, hText2]
SetTrans(Elems, trans)
incr := 8
delay := 0
count := 3, counter := 0
SetTimer, Timer, 10
Return

GuiClose:
   ExitApp

Timer() {
   global
   if (trans &lt;= 0)
      k := ++delay &lt; 0 ? 0 : 1
   if (trans &gt;= 255)
      k := -1, delay := -30, counter++
   if (counter = count)
      SetTimer,, Off
   SetTrans(Elems, trans += incr*k)
}

SetTrans(Elems, trans) {
   for k, v in Elems
      WinSet, Transparent, % trans, ahk_id %v%
}</code></pre></div><p>Одна проблема — такой код будет работать только на десятке.</p>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Wed, 07 Apr 2021 15:29:27 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=147194#p147194</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Прозрачность элементов GUI]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=147188#p147188</link>
			<description><![CDATA[<p>Идея думаю хорошая, один недостаток - при перемещении окна анимация зависает.</p>]]></description>
			<author><![CDATA[null@example.com (__Михаил__)]]></author>
			<pubDate>Wed, 07 Apr 2021 11:45:29 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=147188#p147188</guid>
		</item>
		<item>
			<title><![CDATA[AHK: Прозрачность элементов GUI]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=147187#p147187</link>
			<description><![CDATA[<p>Всем привет <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /></p><p>Однажды, когда мне нужно было сделать красивую анимацию в окне, я задумался: как мне изменить прозрачность элементов у GUI. Не прозрачность окна, а именно прозрачность элементов.</p><p>До меня дошло, что можно поэкспериментировать с WinSet. Зная, что с помощью Transparent&#039;а можно менять прозрачность окна, я решил через параметр <em>+Parent</em> &quot;присоединить&quot; окно в другое окно. Чтобы не было заголовка, добавил параметр <em>-Caption</em>.</p><p>Получился такой код:<br /></p><div class="codebox"><pre><code>; Создаем основное окно, где будут расположены элементы.
; Color должен быть идентичный в обоих окнах, во избежание артефактов. Допустим, будет White.
title := &quot;Transparent Window&quot;

; Добавляем hwnd для упрощения работы.
Gui, main:-MinimizeBox +hwndmainwid
Gui, main:Color, White
Gui, main:Show, w479 h379, % title

; Теперь создаем пустое окошко и применяем к нему параметры (это окно будет отвечать за показ элементов).
; Именно пустое. Потому что если туда что-то добавить, то элементы этого окна будут в приоритете и могут создать артефакты.
Gui, secondary:+ParentMain -Caption +hwndsecondwid
Gui, secondary:Show, x0 y0 w479 h379, % title

; Ставим нулевую прозрачность с целью незаметного создания элементов окна и анимацией &quot;проявления&quot; в будущем.
WinSet, Transparent, 0, ahk_id %secondwid%
sleep, 1000 ; хотя бы одну мс. Потому что если убрать эту задержку появятся артефакты. Будут видны серые границы элементов.

; Создаем элементы, которые будут отображаться в будущем.
Gui, secondary:Color, White
Gui, secondary:Font, S15 CDefault bold, Segoe UI
Gui, secondary:Add, Text, x12 y59 w450 h30 +Center, Элемент №1
Gui, secondary:Font, S10 CDefault norm, Segoe UI
Gui, secondary:Add, Text, x12 y94 w450 h20 +Center, Элемент №2

moment_transparent = 0 ; значение, которое будет использоваться в цикле (в WinSet, Transparent).
delay = 1 ; значение, которое будет использоваться в цикле (задержка перед повтором цикла).
speed = 10 ; значение, которое будет использоваться в цикле (число которое будет добавляться в новом круге цикла к переменной moment_transparent).

loop, 5 ; для демонстрации
{
	; Сама &quot;анимация&quot;
	loop {
		if moment_transparent &gt; 255
			break

		moment_transparent+=%speed%
		WinSet, Transparent, % moment_transparent, ahk_id %secondwid%
		sleep, %delay%
	}

	; Теперь та же анимация, но наоборот
	loop {
		if moment_transparent &lt; 0
			break

		moment_transparent-=%speed%
		WinSet, Transparent, % moment_transparent, ahk_id %secondwid%
		sleep, %delay%
	}
}

sleep, 500

MainGuiClose:
ExitApp</code></pre></div><p>Ранее создавал тему с вопросом &quot;как это сделать?&quot;, но никто так и не дал дельного совета. Нашел решение самостоятельно. Пользуйтесь <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /></p>]]></description>
			<author><![CDATA[null@example.com (streleck1y433)]]></author>
			<pubDate>Wed, 07 Apr 2021 10:18:05 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=147187#p147187</guid>
		</item>
	</channel>
</rss>
