<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; AHK: Деактивация окон сторонних процессов]]></title>
		<link>https://forum.script-coding.com/viewtopic.php?id=15393</link>
		<atom:link href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=15393&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «AHK: Деактивация окон сторонних процессов».]]></description>
		<lastBuildDate>Fri, 29 May 2020 18:14:15 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: AHK: Деактивация окон сторонних процессов]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=139795#p139795</link>
			<description><![CDATA[<p>Похоже, с SetParent лучше.<br />Если не использовать инжект, то для попап-меню этого достаточно, но у меня модифицируется оконное меню. Тоже можно, конечно, попап-меню присобачить, но придётся как-то отслеживать клик по оконному меню.</p>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Fri, 29 May 2020 18:14:15 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=139795#p139795</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Деактивация окон сторонних процессов]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=139792#p139792</link>
			<description><![CDATA[<p>То есть правильнее и универсальнее с SetParent?<br />И TrackPopupMenu может отменить так сказать &quot;необходимость инжекта&quot; в твоём случае со сторонним меню?</p>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Fri, 29 May 2020 17:42:26 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=139792#p139792</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Деактивация окон сторонних процессов]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=139787#p139787</link>
			<description><![CDATA[<p>Попробовал со SciTE, ошибки не возникает, но и окно не показывается.</p>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Fri, 29 May 2020 11:17:51 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=139787#p139787</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Деактивация окон сторонних процессов]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=139785#p139785</link>
			<description><![CDATA[<div class="quotebox"><blockquote><p>WS_CLIPCHILDREN</p></blockquote></div><p>Понял, спасибо.</p><p>А с SciTE у тебя не так?<br /></p><div class="quotebox"><blockquote><p>+Parent&quot; . WinExist()</p></blockquote></div><p> <br /></p><div class="quotebox"><blockquote><p>Invalid or nonexistent owner or parent window</p></blockquote></div>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Fri, 29 May 2020 02:39:59 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=139785#p139785</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Деактивация окон сторонних процессов]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=139745#p139745</link>
			<description><![CDATA[<p>Надо так:<br /></p><div class="codebox"><pre><code>
#SingleInstance Off
#Persistent
#NoEnv

p = %1%
if p = 
{  
   Gui, Show, w444 h444, ______#######______
   Run %A_ScriptFullPath% 1
   Return
}
WinWait, ______#######______
WinSet, Style, +0x2000000 ; WS_CLIPCHILDREN

Gui, New, % &quot;+hwndhGui -Caption +ToolWindow +Parent&quot; . WinExist()
Gui, Color, 00ff00
Gui, Show, NA x5 y5 w111 h111
OnMessage(0x204, &quot;WM_RBUTTONDOWN&quot;)  
Menu, TestMenu, Add, Item 1, Label
Menu, TestMenu, Add, Item 2, Label
Return

Label() {
   ToolTip % A_ThisMenuItem
}

WM_RBUTTONDOWN(wp, lp, msg, hwnd) {  
   hMenu := MenuGetHandle(&quot;TestMenu&quot;) 
   CoordMode, Mouse 
   MouseGetPos, mX, mY
   DllCall(&quot;TrackPopupMenu&quot;, &quot;ptr&quot;, hMenu, &quot;uint&quot;, 0, &quot;int&quot;, mx, &quot;int&quot;, my
                        , &quot;int&quot;, 0, &quot;ptr&quot;, A_ScriptHwnd, &quot;ptr&quot;, 0)
                  
   ; Menu, TestMenu, Show 
}

~Esc:: ExitApp</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Wed, 27 May 2020 01:07:58 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=139745#p139745</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Деактивация окон сторонних процессов]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=139744#p139744</link>
			<description><![CDATA[<p>Значит это было исправлено в AutoHotkey.<br /></p><div class="quotebox"><cite>teadrinker пишет:</cite><blockquote><p>только иногда дочернее окно не появляется</p></blockquote></div><p>У меня такого не было, баг AutoHotkey?<br />Может с WinExist(&quot;______#######______&quot;) что то.<br />Так тоже?<br /></p><div class="codebox"><pre><code>Gui, +HwndhGui -Caption +AlwaysOnTop</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Tue, 26 May 2020 22:29:14 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=139744#p139744</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Деактивация окон сторонних процессов]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=139743#p139743</link>
			<description><![CDATA[<p>У меня на семёрке вроде нормально работает, только иногда дочернее окно не появляется.</p>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Tue, 26 May 2020 22:24:46 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=139743#p139743</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Деактивация окон сторонних процессов]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=139742#p139742</link>
			<description><![CDATA[<div class="quotebox"><cite>teadrinker пишет:</cite><blockquote><p>Потом постараюсь какой-нибудь простой пример выложить.</p></blockquote></div><p>Интересно посмотреть, так как в моём тесте, в рабочем скрипте, заменён только код анк для инжекта.</p><p>TrackPopupMenu даже не стал пробовать:<br /></p><div class="quotebox"><blockquote><p>There are three problems:</p><p>Clicking a menu item will still temporarily deactivate the active window.<br />The menu does not automatically disappear if you click elsewhere.<br />You cannot use the keyboard to select an item or cancel the menu, as it does not have keyboard focus.</p></blockquote></div><p>Но оказалось что на Win10 это работает без отличий от обычным образом показанного, на семёрке насколько я помню всё так как пишет <strong>Lexikos</strong>.</p><p>В общем на Win10 это работает как надо.<br /></p><div class="codebox"><pre><code>
#SingleInstance Off
#Persistent
#NoEnv

p = %1%
if p = 
{  
	Gui, Show, w444 h444, ______#######______
	Run %A_ScriptFullPath% 1
	Return
}

; Gui, +HwndhGui1
; Gui, Show, w444 h444, ______#######______
Gui, New

WS_EX_NOACTIVATE := 0x8000000
WS_POPUP := 0x80000000
WS_CHILD := 0x40000000

; Gui, +E%WS_EX_NOACTIVATE%  
Gui, +%WS_CHILD% -%WS_POPUP%
Gui, +HwndhGui -Caption
Gui, Color, 00ff00 
DllCall(&quot;SetParent&quot;, &quot;Ptr&quot;, hGui, &quot;Ptr&quot;, WinExist(&quot;______#######______&quot;))
Gui, Show, x5 y5 w111 h111
OnMessage(0x204, &quot;WM_RBUTTONDOWN&quot;)  
Menu, TestMenu, Add, Item 1, Return
Menu, TestMenu, Add, Item 2, Return
Return:
	ToolTip % A_ThisMenuItem
	Return

WM_RBUTTONDOWN(wp, lp, msg, hwnd) {  
	hMenu := MenuGetHandle(&quot;TestMenu&quot;) 
	CoordMode, Mouse 
	MouseGetPos, mX, mY
	DllCall(&quot;TrackPopupMenu&quot;, &quot;ptr&quot;, hMenu, &quot;uint&quot;, 0, &quot;int&quot;, mx, &quot;int&quot;, my
                        , &quot;int&quot;, 0, &quot;ptr&quot;, A_ScriptHwnd, &quot;ptr&quot;, 0)
						
	; Menu, TestMenu, Show 
}

~Esc:: ExitApp
</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Tue, 26 May 2020 22:15:34 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=139742#p139742</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Деактивация окон сторонних процессов]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=139741#p139741</link>
			<description><![CDATA[<div class="quotebox"><cite>serzh82saratov пишет:</cite><blockquote><p>А ты как инжектил</p></blockquote></div><p>У меня это часть большого кода, я делал своё меню для SciTE:</p><p> <span class="postimg"><img src="https://i.imgur.com/uL77CEf.png" alt="https://i.imgur.com/uL77CEf.png" /></span></p><p>Даже с иконками вышло.<br />Потом постараюсь какой-нибудь простой пример выложить.<br /></p><div class="quotebox"><cite>serzh82saratov пишет:</cite><blockquote><p>Ты это по памяти?</p></blockquote></div><p>Теперь уже да, приходилось использовать.</p>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Tue, 26 May 2020 21:57:05 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=139741#p139741</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Деактивация окон сторонних процессов]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=139738#p139738</link>
			<description><![CDATA[<div class="quotebox"><cite>teadrinker пишет:</cite><blockquote><p>SetMenu — это для оконного меню, в меню-баре.</p></blockquote></div><p>Ты это по памяти? У меня ощущение что функции всех меню смешаны в одно описание.<br /><a href="https://docs.microsoft.com/ru-ru/windows/win32/menurc/about-menus#menu-bars-and-menus">https://docs.microsoft.com/ru-ru/window … -and-menus</a></p>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Tue, 26 May 2020 20:59:09 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=139738#p139738</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Деактивация окон сторонних процессов]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=139737#p139737</link>
			<description><![CDATA[<p>А ты как инжектил, у меня всё равно деактивирует, но процесс меню от блокнота.<br /></p><div class="codebox"><pre><code>
SetWorkingDir %A_ScriptDir%
#SingleInstance Force
#NoEnv
#Persistent  

code =
(LTrim

#NoEnv
#Persistent 
Menu, TestMenu, Add, 1, Return
Menu, TestMenu, Add, 2, Return
Return

f1::
Menu, TestMenu, Show 
Return

Return:
	Return
	
	
)

if (A_Is64bitOS &amp;&amp; A_PtrSize = 4)
{
	Run, %A_AhkPath%\..\AutoHotkeyU64.exe &quot;%A_ScriptFullPath%&quot;, %A_ScriptDir%
	ExitApp
}

Run, notepad,,, pid
WinWait, ahk_pid %pid%

dllFile := FileExist(&quot;AutoHotkey.dll&quot;) ? A_ScriptDir &quot;\AutoHotkey.dll&quot;
          : (A_PtrSize = 8)                  ? A_ScriptDir &quot;\ahkDll\x64\AutoHotkey.dll&quot;
          : A_ScriptDir &quot;\ahkDll\x32\AutoHotkey.dll&quot;
rThread := InjectAhkDll(pid, dllFile, &quot;&quot;)
rThread.Exec(code)   
return



InjectAhkDll(PID,dll:=&quot;AutoHotkey64.dll&quot;,script:=0, deleteThread := false)
{
   static PROCESS_ALL_ACCESS:=0x1F0FFF,MEM_COMMIT := 0x1000,MEM_RELEASE:=0x8000,PAGE_EXECUTE_READWRITE:=64
   ,hKernel32:=DllCall(&quot;LoadLibrary&quot;,&quot;Str&quot;,&quot;kernel32.dll&quot;,&quot;PTR&quot;),LoadLibraryA:=DllCall(&quot;GetProcAddress&quot;,&quot;PTR&quot;,hKernel32,&quot;AStr&quot;,&quot;LoadLibraryA&quot;,&quot;PTR&quot;)
   ,FreeLibrary:=DllCall(&quot;GetProcAddress&quot;,&quot;PTR&quot;,hKernel32,&quot;AStr&quot;,&quot;FreeLibrary&quot;,&quot;PTR&quot;)
   ,TH32CS_SNAPMODULE:=0x00000008,INVALID_HANDLE_VALUE:=-1
   ,MAX_PATH:=260,MAX_MODULE_NAME32:=255,ModuleName:=&quot;&quot;,init:=VarSetCapacity(ModuleName,MAX_PATH*(A_IsUnicode?2:1))
   base:= deleteThread ? {__Call:&quot;InjectAhkDll&quot;,__Delete:&quot;InjectAhkDll&quot;} : {__Call:&quot;InjectAhkDll&quot;}

   if IsObject(PID)
   {
      if (dll!=&quot;Exec&quot; &amp;&amp; script)
         return &quot;Only Exec method can be used here!&quot;

      hProc := DllCall(&quot;OpenProcess&quot;, &quot;UInt&quot;, PROCESS_ALL_ACCESS, &quot;Int&quot;,0, &quot;UInt&quot;, PID.PID,&quot;PTR&quot;)
      if !hProc
         return &quot;Could not open process for PID: &quot; PID.PID

      if (!script) ; Free Library in remote process (object is being deleted)
      {
         ; Terminate the thread in ahkdll
         hThread := DllCall(&quot;CreateRemoteThread&quot;, &quot;PTR&quot;, hProc, &quot;PTR&quot;, 0, &quot;PTR&quot;, 0, &quot;PTR&quot;, PID.ahkTerminate, &quot;PTR&quot;, 0, &quot;UInt&quot;, 0, &quot;PTR&quot;, 0,&quot;PTR&quot;)
         DllCall(&quot;WaitForSingleObject&quot;, &quot;PTR&quot;, hThread, &quot;UInt&quot;, 0xFFFFFFFF)
         ,DllCall(&quot;CloseHandle&quot;, &quot;PTR&quot;, hThread)

         ; Free library in remote process
         hThread := DllCall(&quot;CreateRemoteThread&quot;, &quot;PTR&quot;, hProc, &quot;UInt&quot;, 0, &quot;UInt&quot;, 0, &quot;PTR&quot;, FreeLibrary, &quot;PTR&quot;, PID.hModule, &quot;UInt&quot;, 0, &quot;UInt&quot;, 0,&quot;PTR&quot;)
         DllCall(&quot;WaitForSingleObject&quot;, &quot;PTR&quot;, hThread, &quot;UInt&quot;, 0xFFFFFFFF)
         ,DllCall(&quot;CloseHandle&quot;, &quot;PTR&quot;, hThread),DllCall(&quot;CloseHandle&quot;, &quot;PTR&quot;, hProc)
         return
      }

      nScriptLength := VarSetCapacity(nScript, (StrLen(script)+1)*(A_IsUnicode?2:1), 0)
      ,StrPut(script,&amp;nScript)

      ; Reserve memory in remote process where our script will be saved
      if !pBufferRemote := DllCall(&quot;VirtualAllocEx&quot;, &quot;Ptr&quot;, hProc, &quot;Ptr&quot;, 0, &quot;PTR&quot;, nScriptLength, &quot;UInt&quot;, MEM_COMMIT, &quot;UInt&quot;, PAGE_EXECUTE_READWRITE, &quot;Ptr&quot;)
         return &quot;Could not reseve memory for process&quot;
      ,DllCall(&quot;CloseHandle&quot;, &quot;PTR&quot;, hProc)

      ; Write script to remote process memory
      DllCall(&quot;WriteProcessMemory&quot;, &quot;Ptr&quot;, hProc, &quot;Ptr&quot;, pBufferRemote, &quot;Ptr&quot;, &amp;nScript, &quot;PTR&quot;, nScriptLength, &quot;Ptr&quot;, 0)

      ; Start execution of code
      hThread := DllCall(&quot;CreateRemoteThread&quot;, &quot;PTR&quot;, hProc, &quot;PTR&quot;, 0, &quot;PTR&quot;, 0, &quot;PTR&quot;, PID.ahkExec, &quot;PTR&quot;, pBufferRemote, &quot;UInt&quot;, 0, &quot;PTR&quot;, 0,&quot;PTR&quot;)
      if !hThread
      {
         DllCall(&quot;VirtualFreeEx&quot;,&quot;PTR&quot;,hProc,&quot;PTR&quot;,pBufferRemote,&quot;PTR&quot;,nScriptLength,MEM_RELEASE)
         ,DllCall(&quot;CloseHandle&quot;, &quot;PTR&quot;, hProc)
         return &quot;Could not execute script in remote process&quot;
      }

      ; Wait for thread to finish
      DllCall(&quot;WaitForSingleObject&quot;, &quot;PTR&quot;, hThread, &quot;UInt&quot;, 0xFFFFFFFF)

      ; Get Exit code returned by ahkExec (1 = script could be executed / 0 = script could not be executed)
      DllCall(&quot;GetExitCodeThread&quot;, &quot;PTR&quot;, hThread, &quot;UIntP&quot;, lpExitCode)
      if !lpExitCode
         return &quot;Could not execute script in remote process&quot;

      DllCall(&quot;CloseHandle&quot;, &quot;PTR&quot;, hThread)
      ,DllCall(&quot;VirtualFreeEx&quot;,&quot;PTR&quot;,hProc,&quot;PTR&quot;,pBufferRemote,&quot;PTR&quot;,nScriptLength,MEM_RELEASE)
      ,DllCall(&quot;CloseHandle&quot;, &quot;PTR&quot;, hProc)
      return
   }
   else if !hDll:=DllCall(&quot;LoadLibrary&quot;,&quot;Str&quot;,dll,&quot;PTR&quot;)
      return &quot;Could not find &quot; dll &quot; library&quot;, DllCall(&quot;CloseHandle&quot;, &quot;PTR&quot;, hProc)
   else
   {
      hProc := DllCall(&quot;OpenProcess&quot;,&quot;UInt&quot;, PROCESS_ALL_ACCESS, &quot;Int&quot;,0,&quot;UInt&quot;, DllCall(&quot;GetCurrentProcessId&quot;),&quot;PTR&quot;)
      DllCall(&quot;GetModuleFileName&quot;,&quot;PTR&quot;,hDll,&quot;PTR&quot;,&amp;ModuleName,&quot;UInt&quot;,MAX_PATH)
      DllCall(&quot;CloseHandle&quot;,&quot;PTR&quot;,hProc)
   }
   ; Open Process to PID
   hProc := DllCall(&quot;OpenProcess&quot;, &quot;UInt&quot;, PROCESS_ALL_ACCESS, &quot;Int&quot;,0, &quot;UInt&quot;, PID,&quot;PTR&quot;)
   if !hProc
      return &quot;Could not open process for PID: &quot; PID
   
   Loop, Files, %dll%, F
      dll := A_LoopFileLongPath
   ; Reserve some memory and write dll path (ANSI)
   nDirLength := VarSetCapacity(nDir, StrLen(dll)+1, 0)
   ,StrPut(dll,&amp;nDir,&quot;CP0&quot;)

   ; Reserve memory in remote process
   if !pBufferRemote := DllCall(&quot;VirtualAllocEx&quot;, &quot;Ptr&quot;, hProc, &quot;Ptr&quot;, 0, &quot;PTR&quot;, nDirLength, &quot;UInt&quot;, MEM_COMMIT, &quot;UInt&quot;, PAGE_EXECUTE_READWRITE, &quot;Ptr&quot;)
      return &quot;Could not reseve memory for process&quot;, DllCall(&quot;CloseHandle&quot;, &quot;PTR&quot;, hProc)

   ; Write dll path to remote process memory
   DllCall(&quot;WriteProcessMemory&quot;, &quot;Ptr&quot;, hProc, &quot;Ptr&quot;, pBufferRemote, &quot;Ptr&quot;, &amp;nDir, &quot;PTR&quot;, nDirLength, &quot;Ptr&quot;, 0)

   ; Start new thread loading our dll

   hThread:=DllCall(&quot;CreateRemoteThread&quot;,&quot;PTR&quot;,hProc,&quot;PTR&quot;,0,&quot;PTR&quot;,0,&quot;PTR&quot;,LoadLibraryA,&quot;PTR&quot;,pBufferRemote,&quot;UInt&quot;,0,&quot;PTR&quot;,0,&quot;PTR&quot;)
   if !hThread
   {
      DllCall(&quot;VirtualFreeEx&quot;,&quot;PTR&quot;,hProc,&quot;PTR&quot;,pBufferRemote,&quot;PTR&quot;,nDirLength,&quot;Uint&quot;,MEM_RELEASE)
      ,DllCall(&quot;CloseHandle&quot;, &quot;PTR&quot;, hProc)
      return &quot;Could not load &quot; dll &quot; in remote process&quot;
   }
   ; Wait for thread to finish
   DllCall(&quot;WaitForSingleObject&quot;, &quot;PTR&quot;, hThread, &quot;UInt&quot;, 0xFFFFFFFF)

   ; Get Exit code returned by thread (HMODULE for our dll)
   DllCall(&quot;GetExitCodeThread&quot;, &quot;PTR&quot;, hThread, &quot;UInt*&quot;, hModule)

   ; Close Thread
   DllCall(&quot;CloseHandle&quot;, &quot;PTR&quot;, hThread)

   if (A_PtrSize=8)
   { ; use different method to retrieve base address because GetExitCodeThread returns DWORD only
      hModule:=0,VarSetCapacity(me32, (A_PtrSize=8?48:32)+(A_IsUnicode?1032:516), 0) ;W:1080:1064, A:564:548
      ;  Take a snapshot of all modules in the specified process.
      hModuleSnap := DllCall(&quot;CreateToolhelp32Snapshot&quot;,&quot;UInt&quot;, TH32CS_SNAPMODULE,&quot;UInt&quot;, PID, &quot;PTR&quot; )
      if ( hModuleSnap != INVALID_HANDLE_VALUE )
      {
         ; reset hModule and set the size of the structure before using it.
         NumPut((A_PtrSize=8?48:32)+(A_IsUnicode?1032:516), &amp;me32, 0, &quot;UInt&quot;) ;dwSize  ;W:1080:1064, A:564:548
         ;  Retrieve information about the first module,
         ;  and exit if unsuccessful
         if ( !DllCall(&quot;Module32First&quot; (A_IsUnicode?&quot;W&quot;:&quot;&quot;),&quot;PTR&quot;, hModuleSnap,&quot;PTR&quot;, &amp;me32 ) )
         {
            ; Free memory used for passing dll path to remote thread
            DllCall(&quot;VirtualFreeEx&quot;,&quot;PTR&quot;,hProc,&quot;PTR&quot;,pBufferRemote,&quot;PTR&quot;,nDirLength,MEM_RELEASE)
            ,DllCall(&quot;CloseHandle&quot;,&quot;PTR&quot;, hModuleSnap ) ; Must clean up the snapshot object!
            return false
         }
         ;  Now walk the module list of the process,and display information about each module
         while(A_Index=1 || DllCall(&quot;Module32Next&quot; (A_IsUnicode?&quot;W&quot;:&quot;&quot;),&quot;PTR&quot;,hModuleSnap,&quot;PTR&quot;, &amp;me32 ) )
            if (StrGet(&amp;me32+(A_PtrSize=8?48:32)+(A_IsUnicode?512:256))=dll) ;szExePath ;W:560:544, A:304:288
            {
               hModule := NumGet(me32, A_PtrSize=8?40:28, &quot;Ptr&quot;) ;hModule
               break
            }
         DllCall(&quot;CloseHandle&quot;,&quot;PTR&quot;,hModuleSnap) ; clean up
      }
   }

   hDll:=DllCall(&quot;LoadLibrary&quot;,&quot;Str&quot;,dll,&quot;PTR&quot;)

   ; Calculate pointer to ahkdll and ahkExec functions
   ahktextdll:=hModule+DllCall(&quot;GetProcAddress&quot;,&quot;PTR&quot;,hDll,&quot;AStr&quot;,&quot;ahktextdll&quot;,&quot;PTR&quot;)-hDll
   ahkExec:=hModule+DllCall(&quot;GetProcAddress&quot;,&quot;PTR&quot;,hDll,&quot;AStr&quot;,&quot;ahkExec&quot;,&quot;PTR&quot;)-hDll
   ahkTerminate:=hModule+DllCall(&quot;GetProcAddress&quot;,&quot;PTR&quot;,hDll,&quot;AStr&quot;,&quot;ahkTerminate&quot;,&quot;PTR&quot;)-hDll

   if script
   {
      nScriptLength := VarSetCapacity(nScript, (StrLen(script)+1)*(A_IsUnicode?2:1), 0)
      ,StrPut(script,&amp;nScript)
      ; Reserve memory in remote process where our script will be saved
      if !pBufferScript := DllCall(&quot;VirtualAllocEx&quot;, &quot;Ptr&quot;, hProc, &quot;Ptr&quot;, 0, &quot;PTR&quot;, nScriptLength, &quot;UInt&quot;, MEM_COMMIT, &quot;UInt&quot;, PAGE_EXECUTE_READWRITE, &quot;Ptr&quot;)
         return &quot;Could not reseve memory for process&quot;
      ,DllCall(&quot;CloseHandle&quot;, &quot;PTR&quot;, hProc)

      ; Write script to remote process memory
      DllCall(&quot;WriteProcessMemory&quot;, &quot;Ptr&quot;, hProc, &quot;Ptr&quot;, pBufferScript, &quot;Ptr&quot;, &amp;nScript, &quot;PTR&quot;, nScriptLength, &quot;Ptr&quot;, 0)
   }
   else
      pBufferScript:=0

   ; Run ahkdll function in remote thread
   hThread := DllCall(&quot;CreateRemoteThread&quot;,&quot;PTR&quot;,hProc,&quot;PTR&quot;,0,&quot;PTR&quot;,0,&quot;PTR&quot;,ahktextdll,&quot;PTR&quot;,pBufferScript,&quot;PTR&quot;,0,&quot;UInt&quot;,0,&quot;PTR&quot;)
   if !hThread
   { ; could not start ahkdll in remote process
      ; Free memory used for passing dll path to remote thread
      DllCall(&quot;VirtualFreeEx&quot;,&quot;PTR&quot;,hProc,&quot;PTR&quot;,pBufferRemote,&quot;PTR&quot;,nDirLength,MEM_RELEASE)
      DllCall(&quot;CloseHandle&quot;, &quot;PTR&quot;, hProc)
      return &quot;Could not start ahkdll in remote process&quot;
   }
   DllCall(&quot;WaitForSingleObject&quot;, &quot;PTR&quot;, hThread, &quot;UInt&quot;, 0xFFFFFFFF)
   DllCall(&quot;GetExitCodeThread&quot;, &quot;PTR&quot;, hThread, &quot;UIntP&quot;, lpExitCode)

   ; Release memory and handles
   DllCall(&quot;VirtualFreeEx&quot;,&quot;PTR&quot;,hProc,&quot;PTR&quot;,pBufferRemote,&quot;PTR&quot;,nDirLength,MEM_RELEASE)
   DllCall(&quot;CloseHandle&quot;, &quot;PTR&quot;, hThread)
   DllCall(&quot;CloseHandle&quot;, &quot;PTR&quot;, hProc)

   if !lpExitCode ; thread could not be created.
      return &quot;Could not create a thread in remote process&quot;

   return {PID:PID,hModule:hModule,ahkExec:ahkExec,ahkTerminate:ahkTerminate,base:base}
}
</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Tue, 26 May 2020 20:51:11 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=139737#p139737</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Деактивация окон сторонних процессов]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=139736#p139736</link>
			<description><![CDATA[<p>SetMenu — это для оконного меню, в меню-баре.</p>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Tue, 26 May 2020 20:32:02 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=139736#p139736</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Деактивация окон сторонних процессов]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=139735#p139735</link>
			<description><![CDATA[<p>Так не работает.<br /></p><div class="codebox"><pre><code>WM_RBUTTONDOWN(wp, lp, msg, hwnd) {  
	hMenu := MenuGetHandle(&quot;TestMenu&quot;)
	DllCall(&quot;SetMenu&quot;, &quot;Ptr&quot;, WinActive(&quot;A&quot;), &quot;Ptr&quot;, hMenu)
	Menu, TestMenu, Show 
}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Tue, 26 May 2020 20:21:57 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=139735#p139735</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Деактивация окон сторонних процессов]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=139734#p139734</link>
			<description><![CDATA[<div class="quotebox"><cite>teadrinker пишет:</cite><blockquote><p>Это уже обсуждали когда-то.</p></blockquote></div><p>Да, я про это уже раз третий забываю.<br /></p><div class="quotebox"><cite>teadrinker пишет:</cite><blockquote><p>по-другому не знаю как.</p></blockquote></div><p>Это <a href="https://docs.microsoft.com/ru-ru/windows/win32/api/winuser/nf-winuser-setmenu">https://docs.microsoft.com/ru-ru/window … er-setmenu</a> по твоему может как то относится к вопросу?</p>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Tue, 26 May 2020 20:17:16 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=139734#p139734</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Деактивация окон сторонних процессов]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=139733#p139733</link>
			<description><![CDATA[<p>Это уже обсуждали когда-то.<br /></p><div class="quotebox"><cite>SetParent пишет:</cite><blockquote><p>For compatibility reasons, SetParent does not modify the WS_CHILD or WS_POPUP window styles of the window whose parent is being changed. ... if hWndNewParent is not NULL and the window was previously a child of the desktop, you should clear the WS_POPUP style and set the WS_CHILD style before calling SetParent.</p></blockquote></div><p>Это всё автоматически делает GUI-опция <em>+Parent%hwnd%</em>.<br />По поводу меню — я лично просто создал меню изнутри другого процесса через инжект AutoHotkey.dll, по-другому не знаю как.</p>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Tue, 26 May 2020 19:39:42 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=139733#p139733</guid>
		</item>
	</channel>
</rss>
