<?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=10537&amp;type=atom" />
	<updated>2015-03-31T19:52:28Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=10537</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Активация программ из трея]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=92884#p92884" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>yalanne пишет:</cite><blockquote><p>Я на просторах инэта нашел</p></blockquote></div><p><a href="http://forum.script-coding.com/viewtopic.php?id=10480">Я тоже</a>. <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /></p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2015-03-31T19:52:28Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=92884#p92884</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Активация программ из трея]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=92882#p92882" />
			<content type="html"><![CDATA[<p>Я на просторах инэта нашел скрипт который может считывать информацию о иконках,скрывать и удалять их а также на них кликать левой, правой или средней кнопкой.<br />Вот скрипт:<br /></p><div class="fancy_spoiler_switcher"><div class="fancy_spoiler_switcher_header" data-lang-open="открыть спойлер" data-lang-close="скрыть спойлер"><strong>+</strong>&nbsp;открыть спойлер</div><div class="fancy_spoiler"><div class="codebox"><pre><code>; ----------------------------------------------------------------------------------------------------------------------
; Name .........: TrayIcon library
; Description ..: Provide some useful functions to deal with Tray icons.
; AHK Version ..: AHK_L 1.1.13.01 x32/64 Unicode
; Author .......: Sean (http://goo.gl/dh0xIX) &amp; Cyruz (http://ciroprincipe.info)
; Thanks .......: FanaticGuru
; License ......: WTFPL - http://www.wtfpl.net/txt/copying/
; Changelog ....: Dic. 31, 2013 - v0.1 - First revision.
; ..............: Jan. 16, 2014 - v0.2 - Added NotifyIconOverflowWindow icon parsing and DetectHiddenWindows management.
; ----------------------------------------------------------------------------------------------------------------------

; ----------------------------------------------------------------------------------------------------------------------
; Function .....: TrayIcon_GetInfo
; Description ..: Get a series of useful information about tray icons.
; Parameters ...: sExeName  - The exe for which we are searching the tray icon data. Leave it empty to receive data for 
; ..............:             all tray icons.
; Return .......: oTrayInfo - An array of objects containing tray icons data. Any entry is structured like this:
; ..............:             oTrayInfo[A_Index].idx     - 0 based tray icon index.
; ..............:             oTrayInfo[A_Index].idcmd   - Command identifier associated with the button.
; ..............:             oTrayInfo[A_Index].pid     - Process ID.
; ..............:             oTrayInfo[A_Index].uid     - Application defined identifier for the icon.
; ..............:             oTrayInfo[A_Index].msgid   - Application defined callback message.
; ..............:             oTrayInfo[A_Index].hicon   - Handle to the tray icon.
; ..............:             oTrayInfo[A_Index].hwnd    - Window handle.
; ..............:             oTrayInfo[A_Index].class   - Window class.
; ..............:             oTrayInfo[A_Index].process - Process executable.
; ..............:             oTrayInfo[A_Index].tooltip - Tray icon tooltip.
; ..............:             oTrayInfo[A_Index].place   - Place where to find the icon.
; Info .........: TB_BUTTONCOUNT message - http://goo.gl/DVxpsg
; ..............: TB_GETBUTTON message   - http://goo.gl/2oiOsl
; ..............: TBBUTTON structure     - http://goo.gl/EIE21Z
; ----------------------------------------------------------------------------------------------------------------------
TrayIcon_GetInfo(sExeName:=&quot;&quot;) {
    d := A_DetectHiddenWindows
    DetectHiddenWindows, On   

    oTrayInfo := Object()
    For key, sTrayP in [&quot;Shell_TrayWnd&quot;, &quot;NotifyIconOverflowWindow&quot;]
    {   
        idxTB := TrayIcon_GetTrayBar()
        WinGet, pidTaskbar, PID, ahk_class %sTrayP%

        hProc := DllCall( &quot;OpenProcess&quot;,    UInt,0x38, Int,0, UInt,pidTaskbar                       )
        pRB   := DllCall( &quot;VirtualAllocEx&quot;, Ptr,hProc, Ptr,0, UInt,20,        UInt,0x1000, UInt,0x4 )

        szBtn := VarSetCapacity( btn, (A_Is64bitOS) ? 32 : 24, 0 )
        szNfo := VarSetCapacity( nfo, (A_Is64bitOS) ? 32 : 24, 0 )
        szTip := VarSetCapacity( tip, 128 * 2,                 0 )

        SendMessage, 0x418, 0, 0, ToolbarWindow32%idxTB%, ahk_class %sTrayP% ; TB_BUTTONCOUNT
        Loop, %ErrorLevel%
        {
            SendMessage, 0x417, A_Index - 1, pRB, ToolbarWindow32%idxTB%, ahk_class %sTrayP% ; TB_GETBUTTON

            DllCall( &quot;ReadProcessMemory&quot;, Ptr,hProc, Ptr,pRB, Ptr,&amp;btn, UInt,szBtn, UInt,0 )

            iBitmap := NumGet( btn, 0                       )
            idCmd   := NumGet( btn, 4                       )
            Statyle := NumGet( btn, 8                       )
            dwData  := NumGet( btn, (A_Is64bitOS) ? 16 : 12 )
            iString := NumGet( btn, (A_Is64bitOS) ? 24 : 16 )

            DllCall( &quot;ReadProcessMemory&quot;, Ptr,hProc, Ptr,dwData, Ptr,&amp;nfo, UInt,szNfo, UInt,0 )

            hWnd  := NumGet( nfo, 0                       )
            uID   := NumGet( nfo, (A_Is64bitOS) ? 8  : 4  )
            nMsg  := NumGet( nfo, (A_Is64bitOS) ? 12 : 8  )
            hIcon := NumGet( nfo, (A_Is64bitOS) ? 24 : 20 )

            WinGet,      pid,      PID,         ahk_id %hWnd%
            WinGet,      sProcess, ProcessName, ahk_id %hWnd%
            WinGetClass, sClass,                ahk_id %hWnd%

            If ( !sExeName || (sExeName == sProcess) || (sExeName == pid) )
                DllCall( &quot;ReadProcessMemory&quot;, Ptr,hProc, Ptr,iString, Ptr,&amp;tip, UInt,szTip, UInt,0 )
              , oTrayInfo.Insert({ &quot;idx&quot;: A_Index-1, &quot;idcmd&quot;: idCmd, &quot;pid&quot;: pid, &quot;uid&quot;: uID, &quot;msgid&quot;: nMsg
                                 , &quot;hicon&quot;: hIcon, &quot;hwnd&quot;: hWnd, &quot;class&quot;: sClass, &quot;process&quot;: sProcess
                                 , &quot;tooltip&quot;: StrGet(&amp;tip, &quot;UTF-16&quot;), &quot;place&quot;: sTrayP })
        }
        
        DllCall( &quot;VirtualFreeEx&quot;, Ptr,hProc, Ptr,pRB, UInt,0, UInt,0x8000 )
        DllCall( &quot;CloseHandle&quot;,   Ptr,hProc                               )
    }
    DetectHiddenWindows, %d%
    Return oTrayInfo
}

; ----------------------------------------------------------------------------------------------------------------------
; Function .....: TrayIcon_Hide
; Description ..: Hide or unhide a tray icon.
; Parameters ...: idCmd  - Command identifier associated with the button.
; ..............: sTrayP - Place where to find the icon (&quot;Shell_TrayWnd&quot; or &quot;NotifyIconOverflowWindow&quot;).
; ..............: bHide  - True for hide, False for unhide.
; Info .........: TB_HIDEBUTTON message - http://goo.gl/oelsAa
; ----------------------------------------------------------------------------------------------------------------------
TrayIcon_Hide(idCmd, sTrayP:=&quot;Shell_TrayWnd&quot;, bHide:=True) {
    d := A_DetectHiddenWindows
    DetectHiddenWindows, On
    idxTB := TrayIcon_GetTrayBar()
    SendMessage, 0x404, idCmd, bHide, ToolbarWindow32%idxTB%, ahk_class %sTrayP% ; TB_HIDEBUTTON
    SendMessage, 0x1A, 0, 0, , ahk_class %sTrayP%
    DetectHiddenWindows, %d%
}

; ----------------------------------------------------------------------------------------------------------------------
; Function .....: TrayIcon_Remove
; Description ..: Remove a Tray icon. It should be more reliable than TrayIcon_Delete.
; Parameters ...: hWnd - Window handle.
; ..............: uID  - Application defined identifier for the icon.
; ----------------------------------------------------------------------------------------------------------------------
TrayIcon_Remove(hWnd, uID) {
    sz := VarSetCapacity( NID, (A_PtrSize == 4) ? 832 : 848, 0 )
    NumPut( sz, NID, 0 ), NumPut( hWnd, NID, A_PtrSize ), NumPut( uID, NID, A_PtrSize*2 )
    DllCall( &quot;Shell32.dll\Shell_NotifyIcon&quot;, UInt,2, Ptr,&amp;NID )
}

; ----------------------------------------------------------------------------------------------------------------------
; Function .....: TrayIcon_Delete
; Description ..: Delete a tray icon.
; Parameters ...: idx - 0 based tray icon index.
; ..............: sTrayP - Place where to find the icon (&quot;Shell_TrayWnd&quot; or &quot;NotifyIconOverflowWindow&quot;).
; Info .........: TB_DELETEBUTTON message - http://goo.gl/L0pY4R
; ----------------------------------------------------------------------------------------------------------------------
TrayIcon_Delete(idx, sTrayP:=&quot;Shell_TrayWnd&quot;) {
    d := A_DetectHiddenWindows
    DetectHiddenWindows, On
    idxTB := TrayIcon_GetTrayBar()
    SendMessage, 0x416, idx, 0, ToolbarWindow32%idxTB%, ahk_class %sTrayP% ; TB_DELETEBUTTON
    SendMessage, 0x1A, 0, 0, , ahk_class %sTrayP%
    DetectHiddenWindows, %d%
}

; ----------------------------------------------------------------------------------------------------------------------
; Function .....: TrayIcon_Move
; Description ..: Move a tray icon.
; Parameters ...: idxOld - 0 based index of the tray icon to move.
; ..............: idxNew - 0 based index where to move the tray icon.
; ..............: sTrayP - Place where to find the icon (&quot;Shell_TrayWnd&quot; or &quot;NotifyIconOverflowWindow&quot;).
; Info .........: TB_MOVEBUTTON message - http://goo.gl/1F6wPw
; ----------------------------------------------------------------------------------------------------------------------
TrayIcon_Move(idxOld, idxNew, sTrayP:=&quot;Shell_TrayWnd&quot;) {
    d := A_DetectHiddenWindows
    DetectHiddenWindows, On
    idxTB := TrayIcon_GetTrayBar()
    SendMessage, 0x452, idxOld, idxNew, ToolbarWindow32%idxTB%, ahk_class %sTrayP% ; TB_MOVEBUTTON
    DetectHiddenWindows, %d%
}

; ----------------------------------------------------------------------------------------------------------------------
; Function .....: TrayIcon_GetTrayBar
; Description ..: Get the tray icon handle.
; ----------------------------------------------------------------------------------------------------------------------
TrayIcon_GetTrayBar() {
    d := A_DetectHiddenWindows
    DetectHiddenWindows, On
    WinGet, ControlList, ControlList, ahk_class Shell_TrayWnd
    RegExMatch(ControlList, &quot;(?&lt;=ToolbarWindow32)\d+(?!.*ToolbarWindow32)&quot;, nTB)

    Loop, %nTB%
    {
        ControlGet, hWnd, hWnd,, ToolbarWindow32%A_Index%, ahk_class Shell_TrayWnd
        hParent := DllCall( &quot;GetParent&quot;, Ptr,hWnd )
        WinGetClass, sClass, ahk_id %hParent%
        If (sClass &lt;&gt; &quot;SysPager&quot;)
            Continue
        idxTB := A_Index
            Break
    }
    
    DetectHiddenWindows, %d%
    Return  idxTB
}

; ----------------------------------------------------------------------------------------------------------------------
; Function .....: TrayIcon_GetHotItem
; Description ..: Get the index of tray&#039;s hot item.
; Info .........: TB_GETHOTITEM message - http://goo.gl/g70qO2
; ----------------------------------------------------------------------------------------------------------------------
TrayIcon_GetHotItem() {
   idxTB := TrayIcon_GetTrayBar()
   SendMessage, 0x447, 0, 0, ToolbarWindow32%idxTB%, ahk_class Shell_TrayWnd ; TB_GETHOTITEM
   Return ErrorLevel &lt;&lt; 32 &gt;&gt; 32
}
 

; ----------------------------------------------------------------------------------------------------------------------
; Function .....: TrayIcon_Button
; Description ..: Simulate mouse button click on a tray icon.
; Parameters ...: sExeName - Executable Process Name of tray icon.
; ..............: sButton  - Mouse button to simulate (L, M, R).
; ..............: bDouble  - True to double click, false to single click.
; ..............: index    - Index of tray icon to click if more than one match.
; ----------------------------------------------------------------------------------------------------------------------
TrayIcon_Button(sExeName, sButton := &quot;L&quot;, bDouble := false, index := 1)
{
    Setting_A_DetectHiddenWindows := A_DetectHiddenWindows
    DetectHiddenWindows, On
    WM_MOUSEMOVE      = 0x0200
    WM_LBUTTONDOWN    = 0x0201
    WM_LBUTTONUP      = 0x0202
    WM_LBUTTONDBLCLK = 0x0203
    WM_RBUTTONDOWN    = 0x0204
    WM_RBUTTONUP      = 0x0205
    WM_RBUTTONDBLCLK = 0x0206
    WM_MBUTTONDOWN    = 0x0207
    WM_MBUTTONUP      = 0x0208
    WM_MBUTTONDBLCLK = 0x0209
    sButton := &quot;WM_&quot; sButton &quot;BUTTON&quot;
    oIcons := {}
    oIcons := TrayIcon_GetInfo(sExeName)
    msgID  := oIcons[index].msgID
    uID    := oIcons[index].uID
    hWnd   := oIcons[index].hWnd
    if bDouble
        PostMessage, msgID, uID, %sButton%DBLCLK, , ahk_id %hWnd%
    else
    {
        PostMessage, msgID, uID, %sButton%DOWN, , ahk_id %hWnd%
        PostMessage, msgID, uID, %sButton%UP, , ahk_id %hWnd%
    }
    DetectHiddenWindows, %Setting_A_DetectHiddenWindows%
    return
}</code></pre></div></div></div><p>этот скрипт работает с теми иконками, которые есть на панели задач, то бишь вот тут:<br /><span class="postimg"><img src="http://i.imgur.com/87GHFUH.png" alt="http://i.imgur.com/87GHFUH.png" /></span><br />Пример использования покажу на иконке от NVIDIA:<br /></p><div class="codebox"><pre><code>TrayIcon_Button(&quot;nvtray.exe&quot;, &quot;L&quot;)  </code></pre></div><p> <br />Эта функция сделает клик на иконку.<br />1)nvtray.exe - exe файл который находится в трее.<br />2)L - тык левой кнопкой мыши.<br />2)R -&nbsp; тык правой кнопкой мыши.<br />2)M -&nbsp; тык средней кнопкой мыши.</p><p>Так же что бы вывести информацию о иконках в трее:<br /></p><div class="codebox"><pre><code>oIcons := {}
oIcons := TrayIcon_GetInfo()

for index, element in oIcons
    sInfoDisplay .= &quot;idx: &quot; element.idx &quot; | cmdID: &quot; element.cmdID &quot; | pID: &quot; element.pID &quot; | uID: &quot; element.uID &quot; | msgID: &quot; element.msgID &quot; | hIcon: &quot; element.hIcon &quot; | hWnd: &quot; element.hWnd &quot; | Class: &quot; element.Class &quot; | Process: &quot; element.Process &quot; | Tray: &quot; element.Tray &quot; | Tooltip: &quot; element.Tooltip &quot;`n`n&quot;

MsgBox % sInfoDisplay</code></pre></div><p>Ответ будет таким: (это в моем в случае)<br /><span class="postimg"><img src="http://i.imgur.com/EYGVr31.png" alt="http://i.imgur.com/EYGVr31.png" /></span><br />нет 4й иконки <span class="postimg"><img src="http://i.imgur.com/85iDWOL.png?1" alt="http://i.imgur.com/85iDWOL.png?1" /></span> потому что она уже не из трея, а новая кнопка настроек\уведомлений из win10.<br />вроде все:)</p>]]></content>
			<author>
				<name><![CDATA[yalanne]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=32850</uri>
			</author>
			<updated>2015-03-31T19:26:02Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=92882#p92882</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Активация программ из трея]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=92862#p92862" />
			<content type="html"><![CDATA[<div class="quotebox"><blockquote><p>Что, и прокомментировать ссылку нельзя? Например - восстанавливает ли команда окна(судя по названию), которых нет?<br />Программа висит в трее и окна пока ее не активируешь нет (хотя для этого есть WinActivate). Хорошо, активирует ли команда окно, которое еще не открывалось, т.е. будет ли работать скрипт сразу после запуска системы?</p></blockquote></div><p>А тут уже от окна зависит. С некоторыми прокатывает, с некоторыми нет.<br />В начале надо прописать:<br /></p><div class="codebox"><pre><code>SetTitleMatchMode, 2
DetectHiddenWindows, On</code></pre></div><p>Если же таким способом не прокатит, то тогда так:<br /><a href="http://forum.script-coding.com/viewtopic.php?pid=65987#p65987">http://forum.script-coding.com/viewtopi … 987#p65987</a><br /></p><div class="quotebox"><blockquote><p>Клавиша &quot;Б&quot; имеет плавающий сканкод в зависимости от раскладки клавиатуры, как сделать изменение сканкода в зависимости от раскладки?</p></blockquote></div><p>Сканкод как и виртуальный код у клавиш всегда один, вне зависимости от раскладки.<br /></p><div class="codebox"><pre><code>vkBC:: msgbox, нажата &quot;б&quot; или &quot;,&quot;</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2015-03-30T09:05:20Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=92862#p92862</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Активация программ из трея]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=92861#p92861" />
			<content type="html"><![CDATA[<div class="codebox"><pre><code>^SC033::msgbox 1</code></pre></div><p> Вот так будет нажиматься на рус. и англ. раскладке.</p>]]></content>
			<author>
				<name><![CDATA[yalanne]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=32850</uri>
			</author>
			<updated>2015-03-30T09:04:59Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=92861#p92861</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Активация программ из трея]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=92858#p92858" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Malcev пишет:</cite><blockquote><p><a href="http://www.script-coding.com/AutoHotkey/WinRestore.html">http://www.script-coding.com/AutoHotkey/WinRestore.html</a></p></blockquote></div><p>Что, и прокомментировать ссылку нельзя? Например - восстанавливает ли команда окна(судя по названию), которых нет?<br />Программа висит в трее и окна пока ее не активируешь нет (хотя для этого есть WinActivate). Хорошо, активирует ли команда окно, которое еще не открывалось, т.е. будет ли работать скрипт сразу после запуска системы?<br />К тому же хотелось бы знать что делать с языковой раскладкой, пока я ковырялся по форуму, я понял что это для меня довольно трудно а в статьях я там такого не нашел.<br />Клавиша &quot;Б&quot; имеет плавающий сканкод в зависимости от раскладки клавиатуры, как сделать изменение сканкода в зависимости от раскладки?<br />P.S. проверил, действует только когда окно свернуто, по крайней мере в скрипте ( во время русской раскладки)<br /></p><div class="codebox"><pre><code>^Б::WinRestore, - Блокнот для записей - ; это заголовок разворачиваемого окна</code></pre></div>]]></content>
			<author>
				<name><![CDATA[HepoH]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=32964</uri>
			</author>
			<updated>2015-03-30T03:55:35Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=92858#p92858</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Активация программ из трея]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=92854#p92854" />
			<content type="html"><![CDATA[<p><a href="http://www.script-coding.com/AutoHotkey/WinRestore.html">http://www.script-coding.com/AutoHotkey/WinRestore.html</a></p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2015-03-29T20:27:11Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=92854#p92854</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: Активация программ из трея]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=92852#p92852" />
			<content type="html"><![CDATA[<p>Народ, сам я новичок, помогите написать скрипт для активации программы из трея по нажатию на комбинацию клавиш Ctrl+Б для русской и английской раскладки (как я понимаю, фиксированого vk-кода клавиши для обоих раскладок нет)<br />программа в трее зафиксирована, имеет координаты 1170, 755.<br />имя программы в трее PENGUI |DVD-ROM|Звук|Блокнот|<br /><a href="https://www.mjtnet.com/blog/2006/07/13/activating-system-tray-icons/">https://www.mjtnet.com/blog/2006/07/13/ … ray-icons/</a> Здесь дан примерный код для реализации на macrosheluder, не знаю, поможет ли.</p>]]></content>
			<author>
				<name><![CDATA[HepoH]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=32964</uri>
			</author>
			<updated>2015-03-29T17:40:51Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=92852#p92852</id>
		</entry>
</feed>
