<?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=6472&amp;type=atom" />
	<updated>2011-11-23T16:30:48Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=6472</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Множественные действия правой кнопки мыши]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=53783#p53783" />
			<content type="html"><![CDATA[<p>А перекроить горячую клавишу из<br /></p><div class="codebox"><pre><code>
Hotkey, *%RMShowHotkey%, RMShowHotkey, on/off</code></pre></div><p>в<br /></p><div class="codebox"><pre><code>
$RButton::</code></pre></div><p>можно?</p>]]></content>
			<author>
				<name><![CDATA[DD]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=25263</uri>
			</author>
			<updated>2011-11-23T16:30:48Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=53783#p53783</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: Множественные действия правой кнопки мыши]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=53774#p53774" />
			<content type="html"><![CDATA[<p>Код является слегка непричёсанным (уж извиняйте) фрагментом программы <a href="http://www.autohotkey.com/forum/topic50813.html">RadialMenu</a>.<br />При зажатой правой кнопке доступны следующие жесты:</p><p><strong>вверх/вниз</strong> — блокнот/окно-gui;<br /><strong>вправо/влево</strong> — посылает нажатия клавиш вправо/влево (удобно для перемотки видео);<br /><strong>вправо и вниз</strong> закомментировано.</p><div class="codebox"><pre><code>
#SingleInstance force

RMShowHotkey =		RButton
RMShowMethod =		D
RSMShowHotkey =	LButton

MenuBackgroundWidth =	225	
MenuBackgroundHeight =	225	


Hotkey, IfWinNotActive, ahk_group BlackList
Hotkey, *%RMShowHotkey%, RMShowHotkey, on
Hotkey, IfWinNotActive

Hotkey, IfWinExist, RMItem1     ; at least Item1 in main menu must be shown to enable Radial submenu show Hotkey
Hotkey, %RSMShowHotkey%, RSMShowHotkey
Hotkey, IfWinExist
return



;===Main menu show Hotkey========================================================================
RMShowHotkey:
Hotkey, %RMShowHotkey%, RMShowHotkey, off


; Collect useful informations: OrigWinID, OrigWinTitle, OrigWinClass
MouseGetPos, mx1, my1, OrigWinID
WinGetTitle, OrigWinTitle, ahk_id %OrigWinID%
WinGetClass, OrigWinClass, ahk_id %OrigWinID%

mxInit := mx1
myInit := my1

;===Prepare background postiton===
RMBX := mx1-MenuBackgroundWidth/2, RMBY := my1-MenuBackgroundHeight/2
Gui, 99: Show, hide x%RMBX% y%RMBY%, RMBackground        ; RMBackground


if RMShowMethod is not digit    ; than RMShowMethod is mouse gesture
{
   ;===Recognize gesture===
   Loop
   {
      if !(GetKeyState(RMShowHotkey, &quot;p&quot;))
      {
         if Gesture =
         {
            EmptyGestureVars()
            SendInput, {%RMShowHotkey%}
            Hotkey, *%RMShowHotkey%, RMShowHotkey, on
            Return
         }
         MG_%Gesture%()
         EmptyGestureVars()
         Hotkey, *%RMShowHotkey%, RMShowHotkey, on
         Return
      }
      Sleep, 20   ; prevents high CPU load
      MouseGetPos, EndX, EndY
      Radius := GetRadius(mx1, my1, EndX, EndY)
      if (Radius &lt; 109)
      Continue
      
      Angle := GetAngle(mx1, my1, EndX, EndY)
      MouseGetPos, mx1, my1
      CurGesture := GetGesture(Angle)
      
      if !(CurGesture = LastGesture)
      {
         Gesture .= CurGesture
         LastGesture := CurGesture
         {
            if (StrLen(Gesture) &gt; 3)   ; limit to 3 moves 
            {
               EmptyGestureVars()
               Progress, m2 b fs10 zh0 w80 WMn700, Gesture canceled
               Sleep, 200
               KeyWait, %RMShowHotkey%, u
               Progress, off
               Hotkey, *%RMShowHotkey%, RMShowHotkey, on
               Return
            }
         }
      }
      if Gesture = %RMShowMethod%   ; Call RM to show
      break
   }
   EmptyGestureVars()
}
Else    ; than RMShowMethod is show delay
{
   While (A_TimeSinceThisHotkey &lt; RMShowMethod)       ; ShowDelay sleep...
   {
      Sleep, 20   ; prevents high CPU load
      if not (GetKeyState(RMShowHotkey,&quot;p&quot;))
      {
tooltip ggggggggggggg
sleep 600
tooltip
         SendInput, {%RMShowHotkey%}
         Hotkey, *%RMShowHotkey%, RMShowHotkey, on
         Return
      }
   }
}


Gui, 99: -Caption +LastFound +AlwaysOnTop +ToolWindow +OwnDialogs +Disabled   ; +Disabled suggested by bmn_ (Thanks!)


Gui, 99: Show, NA x%RMBX% y%RMBY% w255 h255,RMBackground      ; RMBackground
Loop, %MMTotalButtons%                            ; RMItem (s)
Gui, %A_Index%: Show, NA    
if RMShowMethod is not digit    ; than RMShowMethod is mouse gesture, therefore return mouse in initial position
{
   Sleep, 30   ; short break before returning mouse
   MouseMove, mxInit, myInit   ; return in initial position
}



KeyWait, %RMShowHotkey%, u      ; waits RMShowHotkey to be released
Hotkey, *%RMShowHotkey%, RMShowHotkey, on

LastRMItemNum = 


; if problems with run occur (if Gui, 98 is still not hidden), put a short sleep here
MouseGetPos, , , WinID
WinGetTitle, WinTitle, ahk_id %WinID%
if WinTitle contains RMItem     ; RMShowHotkey released on item
{
   
   Gosub, RadialMenuClose

}
else                            ; RMShowHotkey not released on item - just close menu
{
   Gosub, RadialMenuClose
}
Return


RSMShowHotkey:

return


RadialMenuClose:
Gui, 99: Hide
Return


GetGesture(Angle)    ; by Learning one
{
   Loop, 4
   {
      if (Angle &lt;= 90*A_Index-45)
      {
         Sector := A_Index
         Break
      }
      Else if (A_Index = 4)
      Sector := 1
   }
   if Sector = 1
   Return &quot;U&quot;
   else if Sector = 2
   Return &quot;R&quot;
   else if Sector = 3
   Return &quot;D&quot;
   else if Sector = 4
   Return &quot;L&quot;
}

GetAngle(ByRef StartX, ByRef StartY, ByRef EndX, ByRef EndY)    ; by Learning one
{
   x := EndX-StartX, y := EndY-StartY
   if x = 0
   {
      if y &gt; 0
      return 180
      Else if y &lt; 0
      return 360
      Else
      return
   }
   Angle := ATan(y/x)*57.295779513
   if x &gt; 0
   return Angle + 90
   Else
   return Angle + 270	
}


GetRadius(ByRef StartX, ByRef StartY, ByRef EndX, ByRef EndY)      ; by Learning one
{
   a := Abs(endX-startX), b := Abs(endY-startY), Radius := Sqrt(a*a+b*b)
   Return Radius    
}


EmptyGestureVars()    ; by Learning one
{
   global
   EndX =
   EndY =
   Gesture =
   LastGesture =
}


;===Mouse gesture definitions=========================================================================

MG_U() {
   Run, notepad	; this is just example to produce &quot;it works&quot; impression when you try Radial menu for the first time.
}
MG_R() {
  send, {right}

}
MG_L() {
  send, {left}

}
;MG_RD() {
;  ActiveWinID := WinExist(&quot;A&quot;)
;  WinClose, ahk_id %ActiveWinID%
;}


^1::exitapp</code></pre></div><p>Во весь свой рост встала необходимость срастить его вот с таким незамысловатым:</p><div class="codebox"><pre><code>
$RButton::
SendInput, {RButton}
Return</code></pre></div><p>Возможно ли (не меняя последний)?</p>]]></content>
			<author>
				<name><![CDATA[DD]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=25263</uri>
			</author>
			<updated>2011-11-22T21:18:55Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=53774#p53774</id>
		</entry>
</feed>
