<?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=875&amp;type=atom" />
	<updated>2014-05-29T14:48:16Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=875</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: отслеживание подключения дисков]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=83492#p83492" />
			<content type="html"><![CDATA[<p>Отслеживание события подключения/отключения диска и получение его буквы:<br /></p><div class="codebox"><pre><code>OnMessage(0x219, &quot;WM_DEVICECHANGE&quot;)
return

EventHandling(drive, event)
{
   TrayTip, Диск %drive%:, %event%,, 1
}

WM_DEVICECHANGE(wp, lp)
{
   static DBT_DEVICEARRIVAL := 0x8000, DBT_DEVICEREMOVECOMPLETE := 0x8004, DBT_DEVTYP_VOLUME := 2
   
   if ((wp = DBT_DEVICEARRIVAL || wp = DBT_DEVICEREMOVECOMPLETE) &amp;&amp; NumGet(lp+4, &quot;UInt&quot;) = DBT_DEVTYP_VOLUME)
   {
      dbcv_unitmask := NumGet(lp+12, &quot;UInt&quot;)
   
      Loop
         Letter := Chr(Asc(&quot;A&quot;) + A_Index - 1)
      until (dbcv_unitmask &gt;&gt; (A_Index - 1))&amp;1
      
      EventHandling(Letter, wp = DBT_DEVICEARRIVAL ? &quot;подключен&quot; : &quot;отключен&quot;)
   }
}</code></pre></div><p>Информация:<br /><a href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa363480%28v=vs.85%29.aspx">WM_DEVICECHANGE</a><br /><a href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa363249%28v=vs.85%29.aspx">DEV_BROADCAST_VOLUME structure</a><br /><a href="http://forum.script-coding.com/viewtopic.php?id=8785">Связанная тема</a></p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2014-05-29T14:48:16Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=83492#p83492</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: отслеживание подключения дисков]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=6314#p6314" />
			<content type="html"><![CDATA[<p>Скрипт отслеживает момент подключения/отключения диска:<br /></p><div class="codebox"><pre><code>OnMessage(0x219, &quot;notify_change&quot;) ; WM_DEVICECHANGE
Return

notify_change(wParam, lParam, msg, hwnd)
{
    MsgBox, %wParam% %lParam% %msg% %hwnd%
}</code></pre></div><p>Вывод подключенных съёмных дисков:<br /></p><div class="codebox"><pre><code>SetFormat, Integer, H
DriveGet, DrvList, List, Removable
Loop, Parse, DrvList
{
   DriveGet, DrvSerial, Serial, %A_Loopfield%:
   StringTrimLeft, DrvSerial, DrvSerial, 2
   StringUpper, DrvSerial, DrvSerial
   MsgBox, Serial Number of  %A_Loopfield%: is %DrvSerial%
}</code></pre></div><p>Примеры опубликовал <strong>Wlad</strong>.</p>]]></content>
			<author>
				<name><![CDATA[The gray Cardinal]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=2</uri>
			</author>
			<updated>2007-11-22T20:27:38Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=6314#p6314</id>
		</entry>
</feed>
