<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: Прозрачность элементов GUI]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=16243&amp;type=atom" />
	<updated>2021-04-07T20:05:41Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=16243</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Прозрачность элементов GUI]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=147211#p147211" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>__Михаил__ пишет:</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>2021-04-07T20:05:41Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=147211#p147211</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Прозрачность элементов GUI]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=147208#p147208" />
			<content type="html"><![CDATA[<p>На работе win7 x64. Проверял прозрачность и всё работало исправно.<br />Нужно будет этот код проверить завтра.</p>]]></content>
			<author>
				<name><![CDATA[__Михаил__]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=40928</uri>
			</author>
			<updated>2021-04-07T19:17:03Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=147208#p147208</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Прозрачность элементов GUI]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=147207#p147207" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2021-04-07T18:43:52Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=147207#p147207</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Прозрачность элементов GUI]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=147197#p147197" />
			<content type="html"><![CDATA[<p>А где можно узнать, что именно на win10 только будет работать код?</p>]]></content>
			<author>
				<name><![CDATA[__Михаил__]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=40928</uri>
			</author>
			<updated>2021-04-07T17:06:55Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=147197#p147197</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Прозрачность элементов GUI]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=147194#p147194" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2021-04-07T15:29:27Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=147194#p147194</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Прозрачность элементов GUI]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=147188#p147188" />
			<content type="html"><![CDATA[<p>Идея думаю хорошая, один недостаток - при перемещении окна анимация зависает.</p>]]></content>
			<author>
				<name><![CDATA[__Михаил__]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=40928</uri>
			</author>
			<updated>2021-04-07T11:45:29Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=147188#p147188</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: Прозрачность элементов GUI]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=147187#p147187" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[streleck1y433]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=41624</uri>
			</author>
			<updated>2021-04-07T10:18:05Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=147187#p147187</id>
		</entry>
</feed>
