<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: Размещение картинки поверх конкретного окна]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=15578&amp;type=atom" />
	<updated>2020-08-07T03:43:28Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=15578</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Размещение картинки поверх конкретного окна]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=141517#p141517" />
			<content type="html"><![CDATA[<p>Вот я немного изменил скрипт - и теперь один скрипт размещает картинку - справа сверху окна.<br />А другой скрипт размещает картинку - справа снизу окна.</p><p>Но вопрос в том - как объединить эти два скрипта в один и как привязать эти картинки не к Class, а к Title ?</p><div class="codebox"><pre><code>#NoEnv
SetBatchLines, -1

sFile := A_ScriptDir . &quot;\рисунок 1.jpg&quot;

pictureWidth := 150

hGui := CreatePicture(sFile, pictureWidth)
BindToWindow(hGui, &quot;Notepad&quot;)

CreatePicture(sFile, winWidth)  {
   static 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, Hide

   pToken := GDIp.Gdip_Startup()

   pBitmap := GDIp.Gdip_CreateBitmapFromFile(sFile)
   width := GDIp.Gdip_GetImageWidth(pBitmap)
   height := GDIp.Gdip_GetImageHeight(pBitmap)
   hbm := GDIp.CreateDIBSection(winWidth, winHeight := winWidth/width*height)
   hdc := GDIp.CreateCompatibleDC()
   obm := GDIp.SelectObject(hdc, hbm)

   G := GDIp.Gdip_GraphicsFromHDC(hdc)
   GDIp.Gdip_SetInterpolationMode(G, 7)
   GDIp.Gdip_DrawImage(G, pBitmap, 0, 0, winWidth, winHeight, 0, 0, width, height)

   GDIp.UpdateLayeredWindow(hGui, hdc, 0, 0, winWidth, winHeight)

   GDIp.SelectObject(hdc, obm), GDIp.DeleteObject(hbm), GDIp.DeleteDC(hdc)
   GDIp.Gdip_DeleteGraphics(G), GDIp.Gdip_DisposeImage(pBitmap)
   GDIp.Gdip_Shutdown(pToken)
   
   Return hGui
}

BindToWindow(bound, winClass)  { ;------------------------------------------------------------------------------------------------------------------------------------
   static EVENT_OBJECT_LOCATIONCHANGE := 0x800B, hHook, oInfo := {}
   
   DllCall(&quot;RegisterShellHookWindow&quot;, Ptr, A_ScriptHwnd) 
   OnMessage( DllCall(&quot;RegisterWindowMessage&quot;, Str, &quot;SHELLHOOK&quot;), Func(&quot;ShellProc&quot;).Bind(bound, winClass) )
   
   oInfo.bound := bound, oInfo.parentWinClass := winClass
   pInfo := Object(oInfo)
   hHook := SetWinEventHook( EVENT_OBJECT_LOCATIONCHANGE, EVENT_OBJECT_LOCATIONCHANGE, 0
                           , RegisterCallback(&quot;HookProc&quot;, &quot;F&quot;, 3, pInfo), 0, 0, 0 )
   ObjRelease(pInfo)
   OnExit( Func(&quot;Exit&quot;).Bind(A_ScriptHwnd, hHook) )
}

ShellProc(bound, parentWinClass, nCode, wParam)  {
   if (nCode = 4)  {  ; HSHELL_WINDOWACTIVATED := 4
      hwnd := wParam
      WinGetClass, winClass, ahk_id %hwnd%
      if (winClass != parentWinClass)
         Gui, %bound%:Show, Hide
      else  {
         VarSetCapacity(WINDOWPLACEMENT, size := 4*11, 0)
         NumPut(size, WINDOWPLACEMENT)
         DllCall(&quot;GetWindowPlacement&quot;, Ptr, hwnd, Ptr, &amp;WINDOWPLACEMENT)
         for k, v in [&quot;x&quot;, &quot;y&quot;]
            %v% := NumGet(WINDOWPLACEMENT, 4*(k + 6), &quot;Int&quot;)
         WinGetPos,,,W,H, A,
         Gui, %bound%:Show, % &quot;NA x&quot; . (x + W-170) . &quot; y&quot; (y + 5+20)
      }
   }
}

SetWinEventHook(eventMin, eventMax, hmodWinEventProc, lpfnWinEventProc, idProcess, idThread, dwFlags)  {
   return DllCall(&quot;SetWinEventHook&quot;, UInt, eventMin, UInt, eventMax
                                   , Ptr, hmodWinEventProc, Ptr, lpfnWinEventProc
                                   , UInt, idProcess , UInt, idThread, UInt, dwFlags, Ptr)
}

HookProc(hWinEventHook, event, hwnd)  {
   oInfo := Object(A_EventInfo)
   parentWinClass := oInfo.parentWinClass, bound := oInfo.bound
   WinGetClass, winClass, ahk_id %hwnd%
   if (winClass != parentWinClass)
      Return
   
   WinGetPos, x, y,,, ahk_id %hwnd%;--------------------------------------------------------------------------------------------------------------------------------------------------
   WinGetPos,,,W,H, A,   
Gui, %bound%:Show, % &quot;NA x&quot; . (x + W-170) . &quot; y&quot; (y + 5+20)
}

Exit(shellHookWindow, winEventHook)  {
   DllCall(&quot;DeregisterShellHookWindow&quot;, Ptr, shellHookWindow)
   DllCall(&quot;UnhookWinEvent&quot;, Ptr, winEventHook)
}

class GDIp   {
   Gdip_Startup()  {
      if !DllCall(&quot;GetModuleHandle&quot;, Str, &quot;gdiplus&quot;, Ptr)
         DllCall(&quot;LoadLibrary&quot;, Str, &quot;gdiplus&quot;)
      VarSetCapacity(si, A_PtrSize = 8 ? 24 : 16, 0), si := Chr(1)
      DllCall(&quot;gdiplus\GdiplusStartup&quot;, PtrP, pToken, Ptr, &amp;si, Ptr, 0)
      return pToken
   }

   Gdip_CreateBitmapFromFile(sFile)  {
      DllCall(&quot;gdiplus\GdipCreateBitmapFromFile&quot;, WStr, sFile, PtrP, pBitmap)
      return pBitmap
   }

   Gdip_GetImageWidth(pBitmap)  {
      DllCall(&quot;gdiplus\GdipGetImageWidth&quot;, Ptr, pBitmap, UIntP, Width)
      return Width
   }
   
   Gdip_GetImageHeight(pBitmap)  {
      DllCall(&quot;gdiplus\GdipGetImageHeight&quot;, Ptr, pBitmap, UIntP, Height)
      return Height
   }

   CreateDIBSection(w, h, hdc=&quot;&quot;, bpp=32, ByRef ppvBits=0)  {
      hdc2 := hdc ? hdc : this.GetDC()
      VarSetCapacity(bi, 40, 0)
      
      NumPut(w, bi, 4, &quot;UInt&quot;), NumPut(h, bi, 8, &quot;UInt&quot;), NumPut(40, bi, 0, &quot;UInt&quot;)
      NumPut(1, bi, 12, &quot;ushort&quot;), NumPut(0, bi, 16, &quot;uInt&quot;), NumPut(bpp, bi, 14, &quot;ushort&quot;)
      
      hbm := DllCall(&quot;CreateDIBSection&quot;, Ptr, hdc2, Ptr, &amp;bi, UInt, 0, PtrP, ppvBits, Ptr, 0, UInt, 0, Ptr)

      if !hdc
         this.ReleaseDC(hdc2)
      return hbm
   }

   GetDC(hwnd=0)  {
      return DllCall(&quot;GetDC&quot;, Ptr, hwnd)
   }
   
   CreateCompatibleDC(hdc=0)  {
      return DllCall(&quot;CreateCompatibleDC&quot;, Ptr, hdc)
   }

   SelectObject(hdc, hgdiobj)  {
      return DllCall(&quot;SelectObject&quot;, Ptr, hdc, Ptr, hgdiobj)
   }

   Gdip_GraphicsFromHDC(hdc)  {
       DllCall(&quot;gdiplus\GdipCreateFromHDC&quot;, Ptr, hdc, PtrP, pGraphics)
       return pGraphics
   }

   Gdip_SetInterpolationMode(pGraphics, InterpolationMode)  {
      return DllCall(&quot;gdiplus\GdipSetInterpolationMode&quot;, Ptr, pGraphics, Int, InterpolationMode)
   }
   
   Gdip_DrawImage(pGraphics, pBitmap, dx, dy, dw, dh, sx, sy, sw, sh)  {
      Return DllCall(&quot;gdiplus\GdipDrawImageRectRect&quot;, Ptr, pGraphics, Ptr, pBitmap
                                                    , Float, dx, Float, dy, Float, dw, Float, dh
                                                    , Float, sx, Float, sy, Float, sw, Float, sh
                                                    , Int, 2, Ptr, 0, Ptr, 0, Ptr, 0)
   }
   
   UpdateLayeredWindow(hwnd, hdc, x=&quot;&quot;, y=&quot;&quot;, w=&quot;&quot;, h=&quot;&quot;, Alpha=255)  {
      if ((x != &quot;&quot;) &amp;&amp; (y != &quot;&quot;))
         VarSetCapacity(pt, 8), NumPut(x, pt, 0, &quot;UInt&quot;), NumPut(y, pt, 4, &quot;UInt&quot;)

      if (w = &quot;&quot;) ||(h = &quot;&quot;)
         WinGetPos,,, w, h, ahk_id %hwnd% ;---------------------------------------------------------------------------------------------------------------------
      
      return DllCall(&quot;UpdateLayeredWindow&quot;, Ptr, hwnd, Ptr, 0, Ptr, ((x = &quot;&quot;) &amp;&amp; (y = &quot;&quot;)) ? 0 : &amp;pt
                                          , Int64P, w|h&lt;&lt;32, Ptr, hdc, Int64P, 0, UInt, 0
                                          , &quot;UInt*&quot;, Alpha&lt;&lt;16|1&lt;&lt;24, UInt, 2)
   }

   ReleaseDC(hdc, hwnd=0)  {
      return DllCall(&quot;ReleaseDC&quot;, Ptr, hwnd, Ptr, hdc)
   }

   DeleteDC(hdc)  {
      return DllCall(&quot;DeleteDC&quot;, Ptr, hdc)
   }

   DeleteObject(hObject)  {
      return DllCall(&quot;DeleteObject&quot;, Ptr, hObject)
   }

   Gdip_DeleteGraphics(pGraphics)  {
      return DllCall(&quot;gdiplus\GdipDeleteGraphics&quot;, Ptr, pGraphics)
   }

   Gdip_DisposeImage(pBitmap)  {
      return DllCall(&quot;gdiplus\GdipDisposeImage&quot;, Ptr, pBitmap)
   }
   
   Gdip_Shutdown(pToken)  {
      DllCall(&quot;gdiplus\GdiplusShutdown&quot;, Ptr, pToken)
      if hModule := DllCall(&quot;GetModuleHandle&quot;, Str, &quot;gdiplus&quot;, Ptr)
         DllCall(&quot;FreeLibrary&quot;, Ptr, hModule)
   }
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[ttt480]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=39556</uri>
			</author>
			<updated>2020-08-07T03:43:28Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=141517#p141517</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Размещение картинки поверх конкретного окна]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=141516#p141516" />
			<content type="html"><![CDATA[<p>__Михаил__, ее не надо ниоткуда качать.<br />Любой фотофайл на своем компьютере назовите &quot;рисунок 1.jpg&quot; и киньте в папку со скрипом.</p>]]></content>
			<author>
				<name><![CDATA[ttt480]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=39556</uri>
			</author>
			<updated>2020-08-06T21:00:51Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=141516#p141516</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Размещение картинки поверх конкретного окна]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=141515#p141515" />
			<content type="html"><![CDATA[<p><strong>ttt480</strong></p><p>Я про эту картинку и&nbsp; говорю - она у меня с 0 байт появляется, т.е. не может быть скачана с сайта посредством скрипта.<br />Далее проблема в работоспособности в целом - нет реакции на окно блокнота, возможно на win10 не работает, либо пример имеет ошибки.</p>]]></content>
			<author>
				<name><![CDATA[__Михаил__]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=40928</uri>
			</author>
			<updated>2020-08-06T20:52:04Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=141515#p141515</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Размещение картинки поверх конкретного окна]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=141514#p141514" />
			<content type="html"><![CDATA[<p>__Михаил__, скачивать там ничего не надо.<br />Нужна только вот эта картинка <br /></p><div class="codebox"><pre><code>sFile := A_ScriptDir . &quot;\рисунок 1.jpg&quot;</code></pre></div><p>И еще любая другая картинка (с другом названием).</p>]]></content>
			<author>
				<name><![CDATA[ttt480]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=39556</uri>
			</author>
			<updated>2020-08-06T20:39:49Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=141514#p141514</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Размещение картинки поверх конкретного окна]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=141513#p141513" />
			<content type="html"><![CDATA[<p>BindToWindow - это функция, поэтому по ней нет документации.<br />Пробую править скрипт...</p><p>Картинка скриптом не скачалась - интересно как так...<br />И даже с ней скрипт не реагирует на окно блокнота.</p>]]></content>
			<author>
				<name><![CDATA[__Михаил__]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=40928</uri>
			</author>
			<updated>2020-08-06T20:18:47Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=141513#p141513</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Размещение картинки поверх конкретного окна]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=141512#p141512" />
			<content type="html"><![CDATA[<p>Понятно.<br />А как привязать к title ?</p><p>Сейчас стоит строка привязки к классу.<br /></p><div class="codebox"><pre><code>BindToWindow(hGui, &quot;Notepad&quot;)</code></pre></div><p>Как в этой команде - поставить привязку к Title ?</p>]]></content>
			<author>
				<name><![CDATA[ttt480]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=39556</uri>
			</author>
			<updated>2020-08-06T19:46:02Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=141512#p141512</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Размещение картинки поверх конкретного окна]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=141511#p141511" />
			<content type="html"><![CDATA[<p><strong>ttt480</strong></p><div class="codebox"><pre><code>; Получаем размеры текущего окна в переменные W,H (ширина, высота)
WinGetPos,,,W,H, A</code></pre></div>]]></content>
			<author>
				<name><![CDATA[__Михаил__]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=40928</uri>
			</author>
			<updated>2020-08-06T19:01:05Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=141511#p141511</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: Размещение картинки поверх конкретного окна]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=141503#p141503" />
			<content type="html"><![CDATA[<p>Здравствуйте.<br />Нашел на форуме давнюю тему вот с таким кодом:<br /><a href="http://forum.script-coding.com/viewtopic.php?id=13956">http://forum.script-coding.com/viewtopic.php?id=13956</a></p><div class="codebox"><pre><code>
#NoEnv
SetBatchLines, -1

sFile := A_ScriptDir . &quot;\рисунок 1.jpg&quot;
if !FileExist(sFile)
   URLDownloadToFile, https://i.imgur.com/SUIJf6w.png, % sFile

pictureWidth := 150

hGui := CreatePicture(sFile, pictureWidth)
BindToWindow(hGui, &quot;Notepad&quot;)

CreatePicture(sFile, winWidth)  {
   static 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, Hide

   pToken := GDIp.Gdip_Startup()

   pBitmap := GDIp.Gdip_CreateBitmapFromFile(sFile)
   width := GDIp.Gdip_GetImageWidth(pBitmap)
   height := GDIp.Gdip_GetImageHeight(pBitmap)
   hbm := GDIp.CreateDIBSection(winWidth, winHeight := winWidth/width*height)
   hdc := GDIp.CreateCompatibleDC()
   obm := GDIp.SelectObject(hdc, hbm)

   G := GDIp.Gdip_GraphicsFromHDC(hdc)
   GDIp.Gdip_SetInterpolationMode(G, 7)
   GDIp.Gdip_DrawImage(G, pBitmap, 0, 0, winWidth, winHeight, 0, 0, width, height)

   GDIp.UpdateLayeredWindow(hGui, hdc, 0, 0, winWidth, winHeight)

   GDIp.SelectObject(hdc, obm), GDIp.DeleteObject(hbm), GDIp.DeleteDC(hdc)
   GDIp.Gdip_DeleteGraphics(G), GDIp.Gdip_DisposeImage(pBitmap)
   GDIp.Gdip_Shutdown(pToken)
   
   Return hGui
}

BindToWindow(bound, winClass)  {
   static EVENT_OBJECT_LOCATIONCHANGE := 0x800B, hHook, oInfo := {}
   
   DllCall(&quot;RegisterShellHookWindow&quot;, Ptr, A_ScriptHwnd) 
   OnMessage( DllCall(&quot;RegisterWindowMessage&quot;, Str, &quot;SHELLHOOK&quot;), Func(&quot;ShellProc&quot;).Bind(bound, winClass) )
   
   oInfo.bound := bound, oInfo.parentWinClass := winClass
   pInfo := Object(oInfo)
   hHook := SetWinEventHook( EVENT_OBJECT_LOCATIONCHANGE, EVENT_OBJECT_LOCATIONCHANGE, 0
                           , RegisterCallback(&quot;HookProc&quot;, &quot;F&quot;, 3, pInfo), 0, 0, 0 )
   ObjRelease(pInfo)
   OnExit( Func(&quot;Exit&quot;).Bind(A_ScriptHwnd, hHook) )
}

ShellProc(bound, parentWinClass, nCode, wParam)  {
   if (nCode = 4)  {  ; HSHELL_WINDOWACTIVATED := 4
      hwnd := wParam
      WinGetClass, winClass, ahk_id %hwnd%
      if (winClass != parentWinClass)
         Gui, %bound%:Show, Hide
      else  {
         VarSetCapacity(WINDOWPLACEMENT, size := 4*11, 0)
         NumPut(size, WINDOWPLACEMENT)
         DllCall(&quot;GetWindowPlacement&quot;, Ptr, hwnd, Ptr, &amp;WINDOWPLACEMENT)
         for k, v in [&quot;x&quot;, &quot;y&quot;]
            %v% := NumGet(WINDOWPLACEMENT, 4*(k + 6), &quot;Int&quot;)
         Gui, %bound%:Show, % &quot;NA x&quot; . (x + 5) . &quot; y&quot; (y + 5)
      }
   }
}

SetWinEventHook(eventMin, eventMax, hmodWinEventProc, lpfnWinEventProc, idProcess, idThread, dwFlags)  {
   return DllCall(&quot;SetWinEventHook&quot;, UInt, eventMin, UInt, eventMax
                                   , Ptr, hmodWinEventProc, Ptr, lpfnWinEventProc
                                   , UInt, idProcess , UInt, idThread, UInt, dwFlags, Ptr)
}

HookProc(hWinEventHook, event, hwnd)  {
   oInfo := Object(A_EventInfo)
   parentWinClass := oInfo.parentWinClass, bound := oInfo.bound
   WinGetClass, winClass, ahk_id %hwnd%
   if (winClass != parentWinClass)
      Return
   
   WinGetPos, x, y,,, ahk_id %hwnd%
   Gui, %bound%:Show, % &quot;NA x&quot; . (x + 5) . &quot; y&quot; (y + 5)
}

Exit(shellHookWindow, winEventHook)  {
   DllCall(&quot;DeregisterShellHookWindow&quot;, Ptr, shellHookWindow)
   DllCall(&quot;UnhookWinEvent&quot;, Ptr, winEventHook)
}

class GDIp   {
   Gdip_Startup()  {
      if !DllCall(&quot;GetModuleHandle&quot;, Str, &quot;gdiplus&quot;, Ptr)
         DllCall(&quot;LoadLibrary&quot;, Str, &quot;gdiplus&quot;)
      VarSetCapacity(si, A_PtrSize = 8 ? 24 : 16, 0), si := Chr(1)
      DllCall(&quot;gdiplus\GdiplusStartup&quot;, PtrP, pToken, Ptr, &amp;si, Ptr, 0)
      return pToken
   }

   Gdip_CreateBitmapFromFile(sFile)  {
      DllCall(&quot;gdiplus\GdipCreateBitmapFromFile&quot;, WStr, sFile, PtrP, pBitmap)
      return pBitmap
   }

   Gdip_GetImageWidth(pBitmap)  {
      DllCall(&quot;gdiplus\GdipGetImageWidth&quot;, Ptr, pBitmap, UIntP, Width)
      return Width
   }
   
   Gdip_GetImageHeight(pBitmap)  {
      DllCall(&quot;gdiplus\GdipGetImageHeight&quot;, Ptr, pBitmap, UIntP, Height)
      return Height
   }

   CreateDIBSection(w, h, hdc=&quot;&quot;, bpp=32, ByRef ppvBits=0)  {
      hdc2 := hdc ? hdc : this.GetDC()
      VarSetCapacity(bi, 40, 0)
      
      NumPut(w, bi, 4, &quot;UInt&quot;), NumPut(h, bi, 8, &quot;UInt&quot;), NumPut(40, bi, 0, &quot;UInt&quot;)
      NumPut(1, bi, 12, &quot;ushort&quot;), NumPut(0, bi, 16, &quot;uInt&quot;), NumPut(bpp, bi, 14, &quot;ushort&quot;)
      
      hbm := DllCall(&quot;CreateDIBSection&quot;, Ptr, hdc2, Ptr, &amp;bi, UInt, 0, PtrP, ppvBits, Ptr, 0, UInt, 0, Ptr)

      if !hdc
         this.ReleaseDC(hdc2)
      return hbm
   }

   GetDC(hwnd=0)  {
      return DllCall(&quot;GetDC&quot;, Ptr, hwnd)
   }
   
   CreateCompatibleDC(hdc=0)  {
      return DllCall(&quot;CreateCompatibleDC&quot;, Ptr, hdc)
   }

   SelectObject(hdc, hgdiobj)  {
      return DllCall(&quot;SelectObject&quot;, Ptr, hdc, Ptr, hgdiobj)
   }

   Gdip_GraphicsFromHDC(hdc)  {
       DllCall(&quot;gdiplus\GdipCreateFromHDC&quot;, Ptr, hdc, PtrP, pGraphics)
       return pGraphics
   }

   Gdip_SetInterpolationMode(pGraphics, InterpolationMode)  {
      return DllCall(&quot;gdiplus\GdipSetInterpolationMode&quot;, Ptr, pGraphics, Int, InterpolationMode)
   }
   
   Gdip_DrawImage(pGraphics, pBitmap, dx, dy, dw, dh, sx, sy, sw, sh)  {
      Return DllCall(&quot;gdiplus\GdipDrawImageRectRect&quot;, Ptr, pGraphics, Ptr, pBitmap
                                                    , Float, dx, Float, dy, Float, dw, Float, dh
                                                    , Float, sx, Float, sy, Float, sw, Float, sh
                                                    , Int, 2, Ptr, 0, Ptr, 0, Ptr, 0)
   }
   
   UpdateLayeredWindow(hwnd, hdc, x=&quot;&quot;, y=&quot;&quot;, w=&quot;&quot;, h=&quot;&quot;, Alpha=255)  {
      if ((x != &quot;&quot;) &amp;&amp; (y != &quot;&quot;))
         VarSetCapacity(pt, 8), NumPut(x, pt, 0, &quot;UInt&quot;), NumPut(y, pt, 4, &quot;UInt&quot;)

      if (w = &quot;&quot;) ||(h = &quot;&quot;)
         WinGetPos,,, w, h, ahk_id %hwnd%
      
      return DllCall(&quot;UpdateLayeredWindow&quot;, Ptr, hwnd, Ptr, 0, Ptr, ((x = &quot;&quot;) &amp;&amp; (y = &quot;&quot;)) ? 0 : &amp;pt
                                          , Int64P, w|h&lt;&lt;32, Ptr, hdc, Int64P, 0, UInt, 0
                                          , &quot;UInt*&quot;, Alpha&lt;&lt;16|1&lt;&lt;24, UInt, 2)
   }

   ReleaseDC(hdc, hwnd=0)  {
      return DllCall(&quot;ReleaseDC&quot;, Ptr, hwnd, Ptr, hdc)
   }

   DeleteDC(hdc)  {
      return DllCall(&quot;DeleteDC&quot;, Ptr, hdc)
   }

   DeleteObject(hObject)  {
      return DllCall(&quot;DeleteObject&quot;, Ptr, hObject)
   }

   Gdip_DeleteGraphics(pGraphics)  {
      return DllCall(&quot;gdiplus\GdipDeleteGraphics&quot;, Ptr, pGraphics)
   }

   Gdip_DisposeImage(pBitmap)  {
      return DllCall(&quot;gdiplus\GdipDisposeImage&quot;, Ptr, pBitmap)
   }
   
   Gdip_Shutdown(pToken)  {
      DllCall(&quot;gdiplus\GdiplusShutdown&quot;, Ptr, pToken)
      if hModule := DllCall(&quot;GetModuleHandle&quot;, Str, &quot;gdiplus&quot;, Ptr)
         DllCall(&quot;FreeLibrary&quot;, Ptr, hModule)
   }
}
</code></pre></div><p>Он размещает картинку в левом углу программы Блокнот. И таскает эту картинку за блокнотом, если перемещать окно этой программы.</p><p>Скажите, пожалуйста - как разместить две картинки с разными адресами - в правом нижнем углу и правом верхнем - у программы с Title: &quot;Блокнот - Безымянный&quot;?</p><p>Я сам пытался поменять, догадался только что вот в этой строчке <br /></p><div class="codebox"><pre><code>            %v% := NumGet(WINDOWPLACEMENT, 4*(k + 6), &quot;Int&quot;)
         Gui, %bound%:Show, % &quot;NA x&quot; . (x + 500) . &quot; y&quot; (y + 5)</code></pre></div><p>Можно прибавляя к x числа - двигать картинку по горизонтали - и соответственно к y - по вертикали.<br />Но размер окна может быть разный. Так что тут не подгадаешь с точным числом.</p><p> Насчет BindToWindow(hGui, &quot;Notepad&quot;) - тоже непонятно как задать Title. Не нашел в интернете команды BindToWindow.</p>]]></content>
			<author>
				<name><![CDATA[ttt480]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=39556</uri>
			</author>
			<updated>2020-08-06T16:47:16Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=141503#p141503</id>
		</entry>
</feed>
