<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; ALT+F4]]></title>
		<link>http://forum.script-coding.com/viewtopic.php?id=14616</link>
		<atom:link href="http://forum.script-coding.com/extern.php?action=feed&amp;tid=14616&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «ALT+F4».]]></description>
		<lastBuildDate>Sun, 03 Mar 2019 21:38:02 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: ALT+F4]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=132759#p132759</link>
			<description><![CDATA[<p>Воспользуйтесь данным скриптом. Он определит название нажатой вами клавиши и выдаст его имя и виртуальный код. Геймпад не тестировал, однако джойстик (штурвал-манипулятор) вполне определяется программой:<br /></p><div class="codebox"><pre><code>   Menu, Tray, Icon, Shell32.dll, 45

; клавиши дополнительной клавиатуры и Pause, sc которых ф-ция MapVirtualKey не определяет
   ScVk := &quot;45,13|11D,A3|135,6F|136,A1|137,2C|138,A5|145,90|147,24|148,26|149,21|&quot;
         . &quot;14B,25|14D,27|14F,23|150,28|151,22|152,2D|153,2E|15B,5B|15C,5C|15D,5D&quot;

; клавиши мыши и их vk, а также Ctrl+Break и Clear
   KeysVK := &quot;LButton,1|RButton,2|Ctrl+Break,3|MButton,4|XButton1,5|XButton2,6|&quot;
           . &quot;Clear,c|Shift,10|Ctrl,11|Alt,12&quot;

   Height := 165  ; высота клиентской области, не включая заголовки вкладок

   Gui, Color, DAD6CA
   Gui, Add, Tab2, vTab gTab x0 y0 w200 h185 AltSubmit hwndhTab, Получить код|Клавиша по коду
   Tab = 2
   VarSetCapacity(RECT, 16)
   SendMessage, TCM_GETITEMRECT := 0x130A, 1, &amp;RECT,, ahk_id %hTab%
   TabH := NumGet(RECT, 12)
   GuiControl, Move, Tab, % &quot;x0 y0 w200 h&quot; TabH + Height
   Gui, Add, Text, % &quot;x8 y&quot; TabH + 8 &quot; w183 +&quot; SS_GRAYFRAME := 0x8 &quot; h&quot; Height - 16

   Gui, Font, q5 s12, Verdana
   Gui, Add, Text, vAction x15 yp+7 w170 Center c0033BB, Нажмите клавишу
   Gui, Add, Text, vKey xp yp+35 wp Center Hidden

   Gui, Font, q5 c333333
   Gui, Add, Text, vTextVK xp+8 yp+37 Hidden, vk =
   Gui, Add, Text, vVK xp+35 yp w62 h23 Center Hidden
   Gui, Add, Text, vTextSC xp-35 yp+35 Hidden, sc =
   Gui, Add, Text, vSC xp+35 yp w62 h23 Center Hidden

   Gui, Font, s8
   Gui, Add, Button, vCopyVK gCopy xp+70 yp-35 w50 h22 Hidden, Copy
   Gui, Add, Button, vCopySC gCopy xp yp+33 wp hp Hidden, Copy

   Gui, Tab, 2
   Gui, Add, Text, % &quot;x8 y&quot; TabH + 8 &quot; w183 +&quot; SS_GRAYFRAME &quot; h&quot; Height - 16
   Gui, Add, Text, x15 yp+7 w170 c0033BB
      , Введите код`nв шестнадцатеричном формате без префикса &quot;0x&quot;

   Gui, Font, q5 s11
   Gui, Add, Text, xp yp+58, vk
   Gui, Add, Edit, vEditVK gGetKey xp+25 yp-2 w45 h23 Limit3 Uppercase Center
   Gui, Add, Text, vKeyVK xp+45 yp+2 w105 Center

   Gui, Add, Text, x15 yp+43, sc
   Gui, Add, Edit, vEditSC gGetKey xp+25 yp-2 w45 h23 Limit3 Uppercase Center
   Gui, Add, Text, vKeySC xp+45 yp+2 w105 Center
   Gui, Show, % &quot;w199 h&quot; TabH + Height - 1, Коды клавиш

   hHookKeybd := SetWindowsHookEx()
   OnExit, Exit
   OnMessage(0x6, &quot;WM_ACTIVATE&quot;)
   OnMessage(0x102, &quot;WM_CHAR&quot;)
   Return

Tab:                            ; whenever the user switches to a new tab, the output variable will
   If (Tab = 2 &amp;&amp; !hHookKeybd)  ; be set to the previously selected tab number in the case of AltSubmit.
      hHookKeybd := SetWindowsHookEx()
   Else if (Tab = 1 &amp;&amp; hHookKeybd)
      DllCall(&quot;UnhookWindowsHookEx&quot;, UInt, hHookKeybd), hHookKeybd := &quot;&quot;
   Return

Copy:
   GuiControlGet, Code,, % SubStr(A_GuiControl, -1)
   StringLower, GuiControl, A_GuiControl
   Clipboard := SubStr(GuiControl, -1) . SubStr(Code, 3)
   Return

GetKey:
   GuiControlGet, Code,, % A_GuiControl
   Code := RegExReplace(Code, &quot;^0+&quot;)
   Code := &quot;0x&quot; . Code
   SetFormat, IntegerFast, H
   if A_GuiControl = EditVK
   {
      if (Code &gt; 0xA5 &amp;&amp; Code &lt; 0xBA)
         Key := &quot;&quot;, IsKey := 1

      Loop, parse, KeysVK, |
      {
         if (Substr(Code, 3) = RegExReplace(A_LoopField, &quot;.*,(.*)&quot;, &quot;$1&quot;))
         {
            Key := RegExReplace(A_LoopField, &quot;(.*),.*&quot;, &quot;$1&quot;)
            IsKey = 1
            Break
         }
      }

      if !IsKey
      {
         Loop, parse, ScVk, |
         {
            if (Code = &quot;0x&quot; . RegExReplace(A_LoopField, &quot;.*,(.*)&quot;, &quot;$1&quot;))
            {
               Code := RegExReplace(A_LoopField, &quot;(.*),.*&quot;, &quot;0x$1&quot;)
               IsCode = 1
               Break
            }
         }
         if !IsCode
            Code := DllCall(&quot;MapVirtualKey&quot;, UInt, Code, UInt, MAPVK_VK_TO_VSC := 0)
      }
   }
   else if (Code = 0x56 || Code &gt; 0x1FF)
      Key := &quot;&quot;, IsKey := 1

   if !IsKey
      Key := GetKeyNameText(Code)

   Key := RegExReplace(Key, &quot;(.*)Windows&quot;, &quot;$1Win&quot;)
   GuiControl,, % &quot;Key&quot; SubStr(A_GuiControl, -1), % Key
   Key := IsKey := IsCode := &quot;&quot;
   Return

GuiClose:
   ExitApp

Exit:
   if hHookKeybd
      DllCall(&quot;UnhookWindowsHookEx&quot;, UInt, hHookKeybd)
   ExitApp

WM_ACTIVATE(wp)
{
   global
   if (wp &amp; 0xFFFF = 0 &amp;&amp; hHookKeybd)
      DllCall(&quot;UnhookWindowsHookEx&quot;, UInt, hHookKeybd), hHookKeybd := &quot;&quot;
   if (wp &amp; 0xFFFF &amp;&amp; Tab = 2 &amp;&amp; !hHookKeybd)
      hHookKeybd := SetWindowsHookEx()
   GuiControl,, Action, % wp &amp; 0xFFFF = 0 ? &quot;Активируйте окно&quot; : &quot;Нажмите клавишу&quot;
}

SetWindowsHookEx()
{
   Return DllCall(&quot;SetWindowsHookEx&quot;
            , Int, WH_KEYBOARD_LL := 13
            , UInt, RegisterCallback(&quot;LowLevelKeyboardProc&quot;, &quot;Fast&quot;)
            , UInt, DllCall(&quot;GetModuleHandle&quot;, UInt, 0)
            , UInt, 0)
}

LowLevelKeyboardProc(nCode, wParam, lParam)
{
   static once, WM_KEYDOWN = 0x100, WM_SYSKEYDOWN = 0x104

   Critical
   SetFormat, IntegerFast, H
   vk := NumGet(lParam+0)
   Extended := NumGet(lParam+0, 8) &amp; 1
   sc := (Extended&lt;&lt;8)|NumGet(lParam+0, 4)
   sc := sc = 0x136 ? 0x36 : sc
   Key := GetKeyNameText(sc)

   if (wParam = WM_SYSKEYDOWN || wParam = WM_KEYDOWN)
   {
      GuiControl,, Key, % Key
      GuiControl,, VK, % vk
      GuiControl,, SC, % sc
   }

   if !once
   {
      Controls := &quot;Key|TextVK|VK|TextSC|SC|CopyVK|CopySC&quot;
      Loop, parse, Controls, |
         GuiControl, Show, % A_LoopField
      once = 1
   }

   if Key Contains Ctrl,Alt,Shift,Tab
      Return CallNextHookEx(nCode, wParam, lParam)

   if (Key = &quot;F4&quot; &amp;&amp; GetKeyState(&quot;Alt&quot;, &quot;P&quot;))  ; закрытие окна и выход по Alt + F4
      Return CallNextHookEx(nCode, wParam, lParam)

   Return nCode &lt; 0 ? CallNextHookEx(nCode, wParam, lParam) : 1
}

CallNextHookEx(nCode, wp, lp)
{
   Return DllCall(&quot;CallNextHookEx&quot;, UInt, 0, Int, nCode, UInt, wp, UInt, lp)
}

GetKeyNameText(sc)
{
   VarSetCapacity(Key, A_IsUnicode ? 32 : 16)
   DllCall(&quot;GetKeyNameText&quot;, UInt, sc&lt;&lt;16, Str, Key, UInt, 16)
   if Key in Shift,Ctrl,Alt
      Key := &quot;Left &quot; . Key
   Return Key
}

WM_CHAR(wp, lp)
{
   global hBall
   SetWinDelay, 0
   CoordMode, Caret
   WinClose, ahk_id %hBall%
   GuiControlGet, Focus, Focus
   if !InStr(Focus, &quot;Edit&quot;)
      Return

   if wp in 3,8,24,26   ; обработка Ctrl + C, BackSpace, Ctrl + X, Ctrl + Z
      Return

   if wp = 22   ; обработка Ctrl + V
   {
      GuiControlGet, Content,, % Focus
      if !StrLen(String := SubStr(Clipboard, 1, 3 - StrLen(Content)))
      {
         ShowBall(&quot;Буфер обмена не содержит текста.&quot;, &quot;Ошибка!&quot;)
         Return 0
      }
      Loop, parse, String
      {
         Text .= A_LoopField
         if A_LoopField not in 0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f,A,B,C,D,E,F
         {
            ShowBall(&quot;Буфер обмена содержит недопустимые символы.&quot;
               . &quot;`nДопустимые символы:`n0123456789ABCDEF&quot;, &quot;Ошибка!&quot;)
            Return 0
         }
      }
      Control, EditPaste, % Text, % Focus, Коды клавиш
      Return 0
   }

   Char := Chr(wp)
   if Char not in 0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f,A,B,C,D,E,F
   {
      ShowBall(&quot;Допустимые символы:`n0123456789ABCDEF&quot;, Char &quot; — недопустимый символ&quot;)
      Return 0
   }
   Return
}

ShowBall(Text, Title=&quot;&quot;)
{
   global
   WinClose, ahk_id %hBall%
   hBall := BalloonTip(A_CaretX+1, A_CaretY+15, Text, Title)
   SetTimer, BallDestroy, -2000
   Return

BallDestroy:
   WinClose, ahk_id %hBall%
   Return
}

BalloonTip(x, y, sText, sTitle = &quot;&quot;, h_icon = 0)
{
   ; BalloonTip — это ToolTip с хвостиком
   ; h_icon — 1:Info, 2: Warning, 3: Error, n &gt; 3: предполагается hIcon.

   TTS_NOPREFIX := 2, TTS_ALWAYSTIP := 1, TTS_BALLOON := 0x40, TTS_CLOSE := 0x80

   hWnd := DllCall(&quot;CreateWindowEx&quot;, UInt, WS_EX_TOPMOST := 8
                                   , Str, &quot;tooltips_class32&quot;, Str, &quot;&quot;
                                   , UInt, TTS_NOPREFIX|TTS_ALWAYSTIP|TTS_BALLOON|TTS_CLOSE
                                   , Int, 0, Int, 0, Int, 0, Int, 0
                                   , UInt, 0, UInt, 0, UInt, 0, UInt, 0)
   VarSetCapacity(TOOLINFO, 40)
   NumPut(40, TOOLINFO)
   NumPut(0x20, TOOLINFO, 4)       ; TTF_TRACK = 0x20
   NumPut(&amp;sText, TOOLINFO, 36)

   A_DHW := A_DetectHiddenWindows
   DetectHiddenWindows, On
   WinWait, ahk_id %hWnd%

   SendMessage, 1048,, 500         ; TTM_SETMAXTIPWIDTH
   SendMessage, 1028,, &amp;TOOLINFO   ; TTM_ADDTOOL
   SendMessage, 1042,, x|(y&lt;&lt;16)   ; TTM_TRACKPOSITION
   SendMessage, 1041, 1, &amp;TOOLINFO ; TTM_TRACKACTIVATE
   SendMessage, 1056 + (A_IsUnicode ? 1 : 0), h_icon, &amp;sTitle      ; TTM_SETTITLEA и TTM_SETTITLEW
   SendMessage, 1036 + (A_IsUnicode ? 45 : 0),, &amp;TOOLINFO     ; TTM_UPDATETIPTEXTA и TTM_UPDATETIPTEXTW

   DetectHiddenWindows, % A_DHW
   Return hWnd
}</code></pre></div><p>Кроме того можно узнавать названия всех нажатых ранее клавиш через KeyHistory, при условии установленного клавиатурного хука, почитайте справку по этой команде.</p>]]></description>
			<author><![CDATA[null@example.com (belyankin12)]]></author>
			<pubDate>Sun, 03 Mar 2019 21:38:02 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=132759#p132759</guid>
		</item>
		<item>
			<title><![CDATA[Re: ALT+F4]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=132758#p132758</link>
			<description><![CDATA[<p>В любом случае спасибо за помощь . А нет ли где конкретного рисунка для кнопок геймпада , как какая кнопка называется?А то в инструкции , честно говоря , не очень понятно название кнопок</p>]]></description>
			<author><![CDATA[null@example.com (nfortochkin)]]></author>
			<pubDate>Sun, 03 Mar 2019 21:28:28 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=132758#p132758</guid>
		</item>
		<item>
			<title><![CDATA[Re: ALT+F4]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=132747#p132747</link>
			<description><![CDATA[<p>Вот, ваши старания не пропали зря. Добавьте третьей строчкой ещё команду return - она вернет скрипт в так называемый &quot;режим ожидания&quot;. Это полезно, когда у вас будет несколько назначенных подпрограмм в одном скрипте, чтобы не выполнялись все они поочередно.</p>]]></description>
			<author><![CDATA[null@example.com (belyankin12)]]></author>
			<pubDate>Sun, 03 Mar 2019 18:16:24 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=132747#p132747</guid>
		</item>
		<item>
			<title><![CDATA[Re: ALT+F4]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=132745#p132745</link>
			<description><![CDATA[<p>NumPad5::<br />Send,{alt down}{F4}{alt up}</p><p>Вроде работает</p>]]></description>
			<author><![CDATA[null@example.com (nfortochkin)]]></author>
			<pubDate>Sun, 03 Mar 2019 17:52:27 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=132745#p132745</guid>
		</item>
		<item>
			<title><![CDATA[Re: ALT+F4]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=132565#p132565</link>
			<description><![CDATA[<p>Просто прочитайте справку, товарищи старались когда переводили английские инструкции, там все внятно объяснено (доступным языком), с примечаниями и примерами. Подсказка: вам нужна тема об основах AHK (чтобы понять общий принцип работы скриптов и базовый синтаксис) и справка по команде send.</p>]]></description>
			<author><![CDATA[null@example.com (belyankin12)]]></author>
			<pubDate>Thu, 28 Feb 2019 13:06:10 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=132565#p132565</guid>
		</item>
		<item>
			<title><![CDATA[ALT+F4]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=132563#p132563</link>
			<description><![CDATA[<p>Только что наткнулся на эту программу . Не могу разобраться как забиндить на NumPad5 сочетание клавиш ALT+F4 , окна не закрываются</p>]]></description>
			<author><![CDATA[null@example.com (nfortochkin)]]></author>
			<pubDate>Thu, 28 Feb 2019 10:03:12 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=132563#p132563</guid>
		</item>
	</channel>
</rss>
