<?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=13956&amp;type=atom" />
	<updated>2021-12-05T13:47:11Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=13956</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK, GUI: Как вывести по верх всех окон изображение.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=150967#p150967" />
			<content type="html"><![CDATA[<p>А можно как-то две картинки сразу вывести?<br />upd: Извините, решил</p>]]></content>
			<author>
				<name><![CDATA[nonamefromukraine]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=42143</uri>
			</author>
			<updated>2021-12-05T13:47:11Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=150967#p150967</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK, GUI: Как вывести по верх всех окон изображение.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=133491#p133491" />
			<content type="html"><![CDATA[<p>Последний вариант отлично работает. Спасибо за хороший пример!</p>]]></content>
			<author>
				<name><![CDATA[KusochekDobra]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=33846</uri>
			</author>
			<updated>2019-04-10T15:26:46Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=133491#p133491</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK, GUI: Как вывести по верх всех окон изображение.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=133488#p133488" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2019-04-10T14:26:41Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=133488#p133488</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK, GUI: Как вывести по верх всех окон изображение.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=133487#p133487" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>serzh82saratov пишет:</cite><blockquote><p>Я бы ещё на HID попробовал отследить,</p></blockquote></div><p>Хотя тут палка о двух концах. С хуком без таймера - гарантия что окно будет всегда рядом с курсором, но просадки повлияют на соответствие движений мышью и курсора. И случается что с хуком (тем более мышиным) происходят затыки, вплоть до блокировки ввода.<br />С HID просадки повлияют на соответствие позиции курсора и окна.</p>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2019-04-10T13:48:45Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=133487#p133487</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK, GUI: Как вывести по верх всех окон изображение.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=133486#p133486" />
			<content type="html"><![CDATA[<p>Последний нормально работает?</p>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2019-04-10T13:41:10Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=133486#p133486</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK, GUI: Как вывести по верх всех окон изображение.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=133485#p133485" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>serzh82saratov пишет:</cite><blockquote><p>Я бы ещё на HID попробовал отследить</p></blockquote></div><p>Буду Вам благодарен за пример!</p>]]></content>
			<author>
				<name><![CDATA[KusochekDobra]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=33846</uri>
			</author>
			<updated>2019-04-10T13:38:11Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=133485#p133485</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK, GUI: Как вывести по верх всех окон изображение.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=133484#p133484" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2019-04-10T13:15:33Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=133484#p133484</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK, GUI: Как вывести по верх всех окон изображение.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=133483#p133483" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2019-04-10T13:09:33Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=133483#p133483</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK, GUI: Как вывести по верх всех окон изображение.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=133482#p133482" />
			<content type="html"><![CDATA[<p>Окно во весь экран заново переписывать, конечно тормозит.</p>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2019-04-10T12:43:17Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=133482#p133482</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK, GUI: Как вывести по верх всех окон изображение.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=133481#p133481" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[KusochekDobra]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=33846</uri>
			</author>
			<updated>2019-04-10T11:27:54Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=133481#p133481</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK, GUI: Как вывести по верх всех окон изображение.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=127196#p127196" />
			<content type="html"><![CDATA[<p>Возможно у меня был глюк в системе, но в Win10 этого не удалось повторить.<br />На счет Вин7 этот недостаток остался (он есть только при активации окна мышью).</p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2018-07-20T13:26:25Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=127196#p127196</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK, GUI: Как вывести по верх всех окон изображение.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=127190#p127190" />
			<content type="html"><![CDATA[<p>Первое, честно говоря, не понял, у меня всё нормально, да и нужно ли так заморачиваться. В любом случае, если есть окно, которое AlwaysOnTop, такие окна будут конкурировать.<br />На десятке у меня тоже нормально работает, при закрытии пропадает. Там это событие специально обрабатывается — EVENT_OBJECT_DESTROY.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2018-07-20T12:27:12Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=127190#p127190</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK, GUI: Как вывести по верх всех окон изображение.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=127189#p127189" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2018-07-20T11:42:59Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=127189#p127189</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK, GUI: Как вывести по верх всех окон изображение.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=127186#p127186" />
			<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>2018-07-20T10:21:07Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=127186#p127186</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK, GUI: Как вывести по верх всех окон изображение.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=127185#p127185" />
			<content type="html"><![CDATA[<p>В таких случаях можно делать проверку ОС, хоть у кого то будет работать как должно. <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /></p>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2018-07-20T10:10:00Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=127185#p127185</id>
		</entry>
</feed>
