<?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=13956</link>
		<atom:link href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=13956&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «AHK, GUI: Как вывести по верх всех окон изображение.».]]></description>
		<lastBuildDate>Sun, 05 Dec 2021 13:47:11 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: AHK, GUI: Как вывести по верх всех окон изображение.]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=150967#p150967</link>
			<description><![CDATA[<p>А можно как-то две картинки сразу вывести?<br />upd: Извините, решил</p>]]></description>
			<author><![CDATA[null@example.com (nonamefromukraine)]]></author>
			<pubDate>Sun, 05 Dec 2021 13:47:11 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=150967#p150967</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK, GUI: Как вывести по верх всех окон изображение.]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=133491#p133491</link>
			<description><![CDATA[<p>Последний вариант отлично работает. Спасибо за хороший пример!</p>]]></description>
			<author><![CDATA[null@example.com (KusochekDobra)]]></author>
			<pubDate>Wed, 10 Apr 2019 15:26:46 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=133491#p133491</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK, GUI: Как вывести по верх всех окон изображение.]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=133488#p133488</link>
			<description><![CDATA[<p>Извиняюсь, без констант, и определения что сообщение - движение мышью.<br /></p><div class="codebox"><pre><code>#SingleInstance, Force
#NoEnv
SetBatchLines, -1
CoordMode, Mouse, Screen 

#Include &lt;GDIP_All&gt;

If !pToken := Gdip_Startup()
{
	MsgBox, 48, gdiplus error!, Gdiplus failed to start. Please ensure you have gdiplus on your system
	ExitApp
}
OnExit, Exit

Width := 20, Height := 20
WS_EX_LAYERED := 0x80000, WS_EX_TRANSPARENT := 0x20
Gui, New, % &quot;-Caption +AlwaysOnTop +ToolWindow +hwndhGui +E&quot; . Format(&quot;{:#x}&quot;, WS_EX_LAYERED|WS_EX_TRANSPARENT)
Gui, Show, NA
hwnd1 := hGui 

hbm := CreateDIBSection(Width, Height)
hdc := CreateCompatibleDC()
obm := SelectObject(hdc, hbm)
G := Gdip_GraphicsFromHDC(hdc)
Gdip_SetSmoothingMode(G, 4)
pBrush := Gdip_BrushCreateSolid(0x70ff0000)
Gdip_FillEllipse(G, pBrush, 0, 0, 20, 20)
Gdip_DeleteBrush(pBrush) 
Gdip_DeleteGraphics(G)
DeleteObject(hbm)  
DeleteObject(obm)  

OnMessage(0x00FF, &quot;InputHandler&quot;)
RegisterRawInputDevices(1, 2) 
Return 

Esc::
Exit: 
	DeleteDC(hdc)
	Gdip_Shutdown(pToken)
	ExitApp
	
InputHandler(wParam, lParam) { 
	Global
	MouseGetPos, xx, yy 
	UpdateLayeredWindow(hwnd1, hdc, xx, yy, Width, Height) 
	; Gui, % hwnd1 &quot;: +AlwaysOnTop&quot;
}

RegisterRawInputDevices(usagePage, usage) {
    static RIDEV_INPUTSINK := 0x00000100
    VarSetCapacity(rawDevice, 8 + A_PtrSize)
    NumPut(usagePage,       rawDevice, 0, &quot;UShort&quot;)
    NumPut(usage,           rawDevice, 2, &quot;UShort&quot;)
    NumPut(RIDEV_INPUTSINK, rawDevice, 4, &quot;UInt&quot;)
    NumPut(A_ScriptHWND,    rawDevice, 8, &quot;UPtr&quot;)

    if !DllCall(&quot;RegisterRawInputDevices&quot;
        , &quot;Ptr&quot;, &amp;rawDevice
        , &quot;UInt&quot;, 1
        , &quot;UInt&quot;, 8 + A_PtrSize)
    {
        throw &quot;Failed to register for HID Device&quot;
    }
}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Wed, 10 Apr 2019 14:26:41 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=133488#p133488</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK, GUI: Как вывести по верх всех окон изображение.]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=133487#p133487</link>
			<description><![CDATA[<div class="quotebox"><cite>serzh82saratov пишет:</cite><blockquote><p>Я бы ещё на HID попробовал отследить,</p></blockquote></div><p>Хотя тут палка о двух концах. С хуком без таймера - гарантия что окно будет всегда рядом с курсором, но просадки повлияют на соответствие движений мышью и курсора. И случается что с хуком (тем более мышиным) происходят затыки, вплоть до блокировки ввода.<br />С HID просадки повлияют на соответствие позиции курсора и окна.</p>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Wed, 10 Apr 2019 13:48:45 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=133487#p133487</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK, GUI: Как вывести по верх всех окон изображение.]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=133486#p133486</link>
			<description><![CDATA[<p>Последний нормально работает?</p>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Wed, 10 Apr 2019 13:41:10 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=133486#p133486</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK, GUI: Как вывести по верх всех окон изображение.]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=133485#p133485</link>
			<description><![CDATA[<div class="quotebox"><cite>serzh82saratov пишет:</cite><blockquote><p>Я бы ещё на HID попробовал отследить</p></blockquote></div><p>Буду Вам благодарен за пример!</p>]]></description>
			<author><![CDATA[null@example.com (KusochekDobra)]]></author>
			<pubDate>Wed, 10 Apr 2019 13:38:11 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=133485#p133485</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK, GUI: Как вывести по верх всех окон изображение.]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=133484#p133484</link>
			<description><![CDATA[<p>Ну и hook тут неправильно использовать. Перехват тут не нужен, ожидание в хуке не есть хорошо, хотя и так &quot;успевает&quot;:<br /></p><div class="codebox"><pre><code>#SingleInstance, Force
#NoEnv
SetBatchLines, -1

#Include &lt;GDIP_All&gt;

If !pToken := Gdip_Startup()
{
	MsgBox, 48, gdiplus error!, Gdiplus failed to start. Please ensure you have gdiplus on your system
	ExitApp
}
OnExit, Exit

Width := 20, Height := 20
WS_EX_LAYERED := 0x80000, WS_EX_TRANSPARENT := 0x20
Gui, New, % &quot;-Caption +AlwaysOnTop +ToolWindow +hwndhGui +E&quot; . Format(&quot;{:#x}&quot;, WS_EX_LAYERED|WS_EX_TRANSPARENT)
Gui, Show, NA
hwnd1 := hGui 

hbm := CreateDIBSection(Width, Height)
hdc := CreateCompatibleDC()
obm := SelectObject(hdc, hbm)
G := Gdip_GraphicsFromHDC(hdc)
Gdip_SetSmoothingMode(G, 4)
pBrush := Gdip_BrushCreateSolid(0x80ff0000)
Gdip_FillEllipse(G, pBrush, 0, 0, 20, 20)
Gdip_DeleteBrush(pBrush) 
Gdip_DeleteGraphics(G)
DeleteObject(hbm)  
DeleteObject(obm)  

CallBack := RegisterCallback(&quot;MouseHook&quot;)
hook := SetWindowsHookEx(14, CallBack)
Return 

Esc::
Exit:
	if hook
		UnhookWindowsHookEx(hook)
	Gdip_Shutdown(pToken)
	DeleteDC(hdc)
	ExitApp

MouseHook(nCode, wParam, lParam) {
    Global hwnd1, hdc, Width, Height
    if (nCode &gt;= 0) {
        xx := NumGet(lParam+0, 0, &quot;Int&quot;)
        yy := NumGet(lParam+0, 4, &quot;Int&quot;)
        UpdateLayeredWindow(hwnd1, hdc, xx, yy, Width, Height) 
		; Gui, % hwnd1 &quot;: +AlwaysOnTop&quot;
    } Return CallNextHookEx(nCode, wParam, lParam)
}

SetWindowsHookEx(idHook, pfn) {
   Return DllCall(&quot;SetWindowsHookEx&quot;, &quot;int&quot;, idHook, &quot;Ptr&quot;, pfn, &quot;Ptr&quot;, DllCall(&quot;GetModuleHandle&quot;, &quot;Ptr&quot;, 0, &quot;Ptr&quot;), &quot;UInt&quot;, 0)
}
CallNextHookEx(nCode, wParam, lParam, hHook = 0) {
   Return DllCall(&quot;CallNextHookEx&quot;, &quot;Ptr&quot;, hHook, &quot;int&quot;, nCode, &quot;Ptr&quot;, wParam, &quot;Ptr&quot;, lParam)
}
UnhookWindowsHookEx(hHook) {
   Return DllCall(&quot;UnhookWindowsHookEx&quot;, &quot;Ptr&quot;, hHook)
}</code></pre></div><p>Таймер в хуке часто сбрасывается, и окно и не двигается до менее интенсивных движений. Я бы ещё на HID попробовал отследить, это всё таки сообщение, ему задержки не страшны.</p>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Wed, 10 Apr 2019 13:15:33 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=133484#p133484</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK, GUI: Как вывести по верх всех окон изображение.]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=133483#p133483</link>
			<description><![CDATA[<p>Для начала так.<br /></p><div class="codebox"><pre><code>#SingleInstance, Force
#NoEnv
SetBatchLines, -1

#Include &lt;GDIP_All&gt;

If !pToken := Gdip_Startup()
{
	MsgBox, 48, gdiplus error!, Gdiplus failed to start. Please ensure you have gdiplus on your system
	ExitApp
}
OnExit, Exit

Width := 20, Height := 20
WS_EX_LAYERED := 0x80000, WS_EX_TRANSPARENT := 0x20
Gui, New, % &quot;-Caption +AlwaysOnTop +ToolWindow +hwndhGui +E&quot; . Format(&quot;{:#x}&quot;, WS_EX_LAYERED|WS_EX_TRANSPARENT)
Gui, Show, NA
hwnd1 := hGui 

hbm := CreateDIBSection(Width, Height)
hdc := CreateCompatibleDC()
obm := SelectObject(hdc, hbm)
G := Gdip_GraphicsFromHDC(hdc)
Gdip_SetSmoothingMode(G, 4)
pBrush := Gdip_BrushCreateSolid(0x80ff0000)
Gdip_FillEllipse(G, pBrush, 0, 0, 20, 20)
Gdip_DeleteBrush(pBrush) 
Gdip_DeleteGraphics(G)
DeleteObject(hbm)  
DeleteObject(obm)  

CallBack := RegisterCallback(&quot;MouseHook&quot;)
hook := SetWindowsHookEx(14, CallBack)
Return

DrawMyPic:
	UpdateLayeredWindow(hwnd1, hdc, xx, yy, Width, Height) 
Return

Esc::
Exit:
	if hook
		UnhookWindowsHookEx(hook)
	Gdip_Shutdown(pToken)
	DeleteDC(hdc)
	ExitApp

MouseHook(nCode, wParam, lParam) {
    Global xx, yy
    Critical 1000
    if (nCode &gt;= 0) {
        xx := NumGet(lParam+0, 0, &quot;Int&quot;)
        yy := NumGet(lParam+0, 4, &quot;Int&quot;)
        SetTimer, DrawMyPic, -1
    } Return CallNextHookEx(nCode, wParam, lParam)
}

SetWindowsHookEx(idHook, pfn) {
   Return DllCall(&quot;SetWindowsHookEx&quot;, &quot;int&quot;, idHook, &quot;Ptr&quot;, pfn, &quot;Ptr&quot;, DllCall(&quot;GetModuleHandle&quot;, &quot;Ptr&quot;, 0, &quot;Ptr&quot;), &quot;UInt&quot;, 0)
}
CallNextHookEx(nCode, wParam, lParam, hHook = 0) {
   Return DllCall(&quot;CallNextHookEx&quot;, &quot;Ptr&quot;, hHook, &quot;int&quot;, nCode, &quot;Ptr&quot;, wParam, &quot;Ptr&quot;, lParam)
}
UnhookWindowsHookEx(hHook) {
   Return DllCall(&quot;UnhookWindowsHookEx&quot;, &quot;Ptr&quot;, hHook)
}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Wed, 10 Apr 2019 13:09:33 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=133483#p133483</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK, GUI: Как вывести по верх всех окон изображение.]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=133482#p133482</link>
			<description><![CDATA[<p>Окно во весь экран заново переписывать, конечно тормозит.</p>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Wed, 10 Apr 2019 12:43:17 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=133482#p133482</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK, GUI: Как вывести по верх всех окон изображение.]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=133481#p133481</link>
			<description><![CDATA[<p>Подскажите пожалуйста, как сделать так, чтобы такое изображение следовало за курсором?<br />Моя попытка сильно жрёт процессор и постоянно дёргается:<br /></p><div class="codebox"><pre><code>
#SingleInstance, Force
#NoEnv
SetBatchLines, -1

#Include &lt;GDIP_All&gt;

If !pToken := Gdip_Startup()
{
	MsgBox, 48, gdiplus error!, Gdiplus failed to start. Please ensure you have gdiplus on your system
	ExitApp
}
OnExit, Exit

Width := A_ScreenWidth, Height := A_ScreenHeight
WS_EX_LAYERED := 0x80000, WS_EX_TRANSPARENT := 0x20
Gui, New, % &quot;-Caption +AlwaysOnTop +ToolWindow +hwndhGui +E&quot; . Format(&quot;{:#x}&quot;, WS_EX_LAYERED|WS_EX_TRANSPARENT)
Gui, Show, NA

hwnd1 := hGui

CallBack := RegisterCallback(&quot;MouseHook&quot;)
hook := SetWindowsHookEx(14, CallBack)
Return

DrawMyPic:
	hbm := CreateDIBSection(Width, Height)
	hdc := CreateCompatibleDC()
	obm := SelectObject(hdc, hbm)
	G := Gdip_GraphicsFromHDC(hdc)
	Gdip_SetSmoothingMode(G, 4)
	pBrush := Gdip_BrushCreateSolid(0x80ff0000)
	Gdip_FillEllipse(G, pBrush, xx-10, yy-10, 20, 20)
	Gdip_DeleteBrush(pBrush)
	UpdateLayeredWindow(hwnd1, hdc, 0, 0, Width, Height)
	SelectObject(hdc, obm)
	DeleteObject(hbm)
	DeleteDC(hdc)
	Gdip_DeleteGraphics(G)
Return

Esc::
Exit:
	if hook
		UnhookWindowsHookEx(hook)
	Gdip_Shutdown(pToken)
	ExitApp

MouseHook(nCode, wParam, lParam) {
    Global xx, yy
    Critical 1000
    if (nCode &gt;= 0) {
        xx := NumGet(lParam+0, 0, &quot;Int&quot;)
        yy := NumGet(lParam+0, 4, &quot;Int&quot;)
        SetTimer, DrawMyPic, -1
    } Return CallNextHookEx(nCode, wParam, lParam)
}

SetWindowsHookEx(idHook, pfn) {
   Return DllCall(&quot;SetWindowsHookEx&quot;, &quot;int&quot;, idHook, &quot;Ptr&quot;, pfn, &quot;Ptr&quot;, DllCall(&quot;GetModuleHandle&quot;, &quot;Ptr&quot;, 0, &quot;Ptr&quot;), &quot;UInt&quot;, 0)
}
CallNextHookEx(nCode, wParam, lParam, hHook = 0) {
   Return DllCall(&quot;CallNextHookEx&quot;, &quot;Ptr&quot;, hHook, &quot;int&quot;, nCode, &quot;Ptr&quot;, wParam, &quot;Ptr&quot;, lParam)
}
UnhookWindowsHookEx(hHook) {
   Return DllCall(&quot;UnhookWindowsHookEx&quot;, &quot;Ptr&quot;, hHook)
}
</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (KusochekDobra)]]></author>
			<pubDate>Wed, 10 Apr 2019 11:27:54 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=133481#p133481</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK, GUI: Как вывести по верх всех окон изображение.]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=127196#p127196</link>
			<description><![CDATA[<p>Возможно у меня был глюк в системе, но в Win10 этого не удалось повторить.<br />На счет Вин7 этот недостаток остался (он есть только при активации окна мышью).</p>]]></description>
			<author><![CDATA[null@example.com (Malcev)]]></author>
			<pubDate>Fri, 20 Jul 2018 13:26:25 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=127196#p127196</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK, GUI: Как вывести по верх всех окон изображение.]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=127190#p127190</link>
			<description><![CDATA[<p>Первое, честно говоря, не понял, у меня всё нормально, да и нужно ли так заморачиваться. В любом случае, если есть окно, которое AlwaysOnTop, такие окна будут конкурировать.<br />На десятке у меня тоже нормально работает, при закрытии пропадает. Там это событие специально обрабатывается — EVENT_OBJECT_DESTROY.</p>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Fri, 20 Jul 2018 12:27:12 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=127190#p127190</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK, GUI: Как вывести по верх всех окон изображение.]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=127189#p127189</link>
			<description><![CDATA[<p><strong>teadrinker</strong>, в твоём коде из 8 поста не всегда соблюдается условие &quot;Нужно вывести изображение по верх всех окон.&quot;<br />1) Сдвигаем окно блокнота так, чтобы картинка &quot;AHK&quot; была над кнопкой Start.<br />2) Нажимаем кнопку&nbsp; Start.<br />3) Активируем окно блокнота.<br />В результате кнопка Start будет поверх картинки &quot;AHK&quot; при активированном блокноте.<br />А на Win10 вообще глючит - при закрытии блокнота картинка остантся.</p>]]></description>
			<author><![CDATA[null@example.com (Malcev)]]></author>
			<pubDate>Fri, 20 Jul 2018 11:42:59 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=127189#p127189</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK, GUI: Как вывести по верх всех окон изображение.]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=127186#p127186</link>
			<description><![CDATA[<p>Нет, просто если делаешь скрипт только для себя, то можно применять эту фичу.</p>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Fri, 20 Jul 2018 10:21:07 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=127186#p127186</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK, GUI: Как вывести по верх всех окон изображение.]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=127185#p127185</link>
			<description><![CDATA[<p>В таких случаях можно делать проверку ОС, хоть у кого то будет работать как должно. <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /></p>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Fri, 20 Jul 2018 10:10:00 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=127185#p127185</guid>
		</item>
	</channel>
</rss>
