<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: Функция Opera 50, везде. (свое меню) [Решено]]]></title>
	<link rel="self" href="http://forum.script-coding.com/extern.php?action=feed&amp;tid=13484&amp;type=atom" />
	<updated>2018-02-23T10:43:06Z</updated>
	<generator>PunBB</generator>
	<id>http://forum.script-coding.com/viewtopic.php?id=13484</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Функция Opera 50, везде. (свое меню) [Решено]]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=123815#p123815" />
			<content type="html"><![CDATA[<div class="codebox"><pre><code>~LButton Up::
	CoordMode Mouse, Screen
	CoordMode Caret, Screen

	KeyWait LButton, DT0.5
	If !ErrorLevel
		Return

	ClipSaved := Clipboard, Clipboard := &quot;&quot;
	Send ^{vk43}
	ClipWait 0.1
	
	if ErrorLevel
		Menu2.Hide()
	Else {
		If (A_CaretX &gt; 0)
			x :=A_CaretX, y := A_CaretY+15
		Else
			MouseGetPos x, y

		Menu2.Show(x, y, &quot;S&quot;,, 1)
	}

	Clipboard := ClipSaved
Return</code></pre></div>]]></content>
			<author>
				<name><![CDATA[stealzy]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=31937</uri>
			</author>
			<updated>2018-02-23T10:43:06Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=123815#p123815</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: Функция Opera 50, везде. (свое меню) [Решено]]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=123813#p123813" />
			<content type="html"><![CDATA[<p>Здравствуйте.<br />Есть браузер Opera 50, там при выделении текста, появляется возможность его скопировать, это кажется удобным..<br />Нашел этот скрипт.. чуть изменил получилось это.</p><div class="codebox"><pre><code>#SingleInstance Force
#NoEnv

List2 := [[&quot;Копировать&quot;,&quot;Копировать&quot;],[&quot;Вставить&quot;,&quot;Вставить&quot;],[&quot;Вырезатьр&quot;,&quot;Вырезать&quot;]]

Menu2 := New Menu(List2, &quot;DBDBDB&quot;, &quot;2EC001&quot;, &quot;000000&quot;, , 22)

~vkC0::Menu2.Show(&quot;Center&quot;, 100, &quot;S&quot;,, 1) ;` или Ё

Копировать:
     send, ^{vk43} ;C
     Return
Вставить:
     send, ^{vk56} ;V
     Return
     
Вырезать:
     send, ^{vk58} ;X
     Return

Class Menu {
     Static View, Selection, AllReady, Obj, PrCtrl, WaitX, WaitY, Name, Label
     __New(List, bcgColor, hiColor, textColor, Transparent = 255, FontSize = 0, XMargin = 1, YMargin = 1) {
          If !Menu.AllReady
               Menu.SetHotkeys(), OnMessage(0x202, this[&quot;WM_LBUTTONUP&quot;].Bind(this)), Menu.AllReady := 1
          Gui, New
          Gui, +AlwaysOnTop -DPIScale +hwndhGui +LabelMenuOn -Caption +Border +Owner +E0x08000000
          this.hwnd := hGui, this.List := List
          Gui, Font, % &quot;q1&quot; . (FontSize ? &quot; s&quot; FontSize : &quot;&quot;)
          Gui, Margin, 0, 0
          Gui, Color, %bcgColor%
          S_AutoTrim := A_AutoTrim
          AutoTrim, Off
          Loop % XMargin
               XMarginStr .= &quot; &quot;
          this.XMarginStr := XMarginStr 
          AutoTrim, %S_AutoTrim%
          this.GetMaxSize(List, maxW, maxH)
          Gui, Show, Hide w0 h0
          For k, v in List
          {
               _bcgColor := v[3].B != &quot;&quot; ? v[3].B : bcgColor, _textColor := v[3].T != &quot;&quot; ? v[3].T : textColor, _hiColor := v[3].H != &quot;&quot; ? v[3].H : hiColor 
               Gui, Add, Progress, % (k = 1 ? &quot;x0 y0&quot; : &quot;y+0&quot;) &quot; hwndhBack w&quot; maxW &quot; h&quot; maxH + (maxH / 100 * YMargin) &quot; Background&quot; _bcgColor, 0
               Gui, Add, Text, % &quot;xp yp wp hp hwndhText +0x200 BackgroundTrans c&quot; _textColor, % XMarginStr v[1] XMarginStr
               this.Items[hText] := {back:hBack,key:k,Label:v[2],name:v[1],bcgColor:_bcgColor,hiColor:_hiColor,textColor:_textColor}
               this.Items[hBack] := {text:hText,key:k,Label:v[2],name:v[1],bcgColor:_bcgColor,hiColor:_hiColor,textColor:_textColor}
               this.ItemPos[k] := {text:hText,back:hBack}
          }
          Gui, Show, Hide AutoSize, #32768
          S_DetectHiddenWindows := A_DetectHiddenWindows
          DetectHiddenWindows, On
          If (Transparent &lt; 255)
               WinSet, Transparent, %Transparent%, ahk_id %hGui%
          WinGetPos, , , Width, Height, ahk_id %hGui%
          this.Width := Width, this.Height := Height
          DetectHiddenWindows, %S_DetectHiddenWindows%
          Return this
     }
     Show(x = 0, y = 0, Relative = &quot;M&quot;, hWin = 0, SaveMouse = 0) {
          Menu.Close()
          Hwnd := Menu.View := this.hwnd
          If SaveMouse
               DllCall(&quot;GetCursorPos&quot;, &quot;int64P&quot;, pt), this.SaveMouseX := pt &lt;&lt; 32 &gt;&gt; 32, this.SaveMouseY := pt &gt;&gt; 32
          this.SaveMouse := SaveMouse
          Menu.Name := Menu.Label := Menu.PrCtrl := &quot;&quot;
          If Relative = S
               sx := x, sy := y
          Else
          {
               If Relative = W
               {
                    WinGetPos, wx, wy, ww, wh, % (hWin ? &quot;ahk_id&quot; hWin : &quot;A&quot;)
                    ix := wx + (x = &quot;Center&quot; ? ((ww // 2) - (this.Width // 2)) : x) 
                    iy := wy + (y = &quot;Center&quot; ? ((wh // 2) - (this.Height // 2)) : y)
               }
               Else If Relative = M
               {
                    DllCall(&quot;GetCursorPos&quot;, &quot;int64P&quot;, pt), ix := pt &lt;&lt; 32 &gt;&gt; 32, iy := pt &gt;&gt; 32 
                    ix += (x = &quot;Center&quot; ? -(this.Width // 2) : x)
                    iy += (y = &quot;Center&quot; ? -(this.Height // 2) : y)
               }          
               Menu.GetClientSize(Hwnd, w, h) 
               Menu.CalculatePopupWindowPosition(sx, sy, w, h, ix, iy)  
          }
          Gui, %Hwnd%:Show, NA AutoSize x%sx% y%sy% 
          hFunc := ObjBindMethod(this, &quot;MouseGet&quot;)
          SetTimer, % hFunc, 10
          Menu.Obj := this
     }
     Hide(Select = 0) { 
          hFunc := ObjBindMethod(this, &quot;MouseGet&quot;)
          SetTimer, % hFunc, Off
          Hwnd := Menu.View
          this := Menu.Obj
          item := this.Items[Menu.Selection]
          Menu.Color(item.bcgColor, item.back)
          If this.SaveMouse
               DllCall(&quot;SetCursorPos&quot;, &quot;Uint&quot;, this.SaveMouseX, &quot;Uint&quot;, this.SaveMouseY)
          If this.SaveMouse = 2
               Click
          Menu.View := Menu.Selection := 0, Menu.WaitX := Menu.WaitY := Menu.Obj := &quot;&quot;
          Try Gui, %Hwnd%:Show, Hide
          If Select
               Try GoSub, % Menu.Label
     }
     GetMaxSize(Items, ByRef maxW, ByRef maxH) {  
          For k, v in Items
          {
               Gui, Add, Text, hwndhDummy hidden, % this.XMarginStr v[1] this.XMarginStr
               GuiControlGet, Pos, Pos, %hDummy%
               maxW := !maxW || PosW &gt; maxW ? PosW : maxW
               maxH := !maxH || PosH &gt; maxH ? PosH : maxH
               DllCall(&quot;DestroyWindow&quot;, &quot;Ptr&quot;, hDummy)
          }
     }
     NewText(Index, Text) {  
          hText := this.ItemPos[Index].text
          GuiControl, , %hText%, % this.XMarginStr Text this.XMarginStr
          this.Items[hText].name := Text
          this.Items[this.ItemPos[Index].back].name := Text
     }
     Select() {
          Menu.Hide(1)
     }
     Close() {
          this := Menu.Obj, this.SaveMouse := 0
          Menu.Label := Menu.Name := &quot;&quot;, Menu.Hide()
     }
     MouseGet() {
          MouseGetPos, , , win, ctrl, 2
          If (Menu.WaitX != &quot;&quot;)
          {
               If (win != Menu.View)
                    Return
               DllCall(&quot;GetCursorPos&quot;, &quot;int64P&quot;, pt), X := pt &lt;&lt; 32 &gt;&gt; 32, Y := pt &gt;&gt; 32
               If (Abs(X - Menu.WaitX) &gt; 1 || Abs(Y - Menu.WaitY) &gt; 1)
                    Menu.WaitX := Menu.WaitY := &quot;&quot;
               Else
                    Return
          }
          If (win = Menu.View)
          {
               If (ctrl &amp;&amp; ctrl != Menu.PrCtrl)
               {
                    this := Menu.Obj
                    item := this.Items[Menu.Selection]
                    Menu.Color(item.bcgColor, item.back)
                    Menu.Selection := ctrl
                    item := this.Items[Menu.Selection]
                    Menu.Color(item.hiColor, item.back)
                    Menu.Label := item.Label
                    Menu.Name := item.Name
                    Menu.PrCtrl := ctrl
               }
          }
          Else If Menu.Selection
          {
               this := Menu.Obj
               item := this.Items[Menu.Selection]
               Menu.Color(item.bcgColor, item.back)
               Menu.Name := Menu.Label := Menu.PrCtrl := Menu.Selection := &quot;&quot;
          }
          Hwnd := Menu.View
          Try Gui, %Hwnd%:+AlwaysOnTop
    }
     Up_Down() {
          this := Menu.Obj
          mi := this.List.MaxIndex()
          sel := this.Items[Menu.Selection].key
          new := InStr(A_ThisHotkey, &quot;Up&quot;)
          ? (!sel || sel = 1 ? mi : sel - 1)
          : (!sel || sel = mi ? 1 : sel + 1)
          item := this.Items[Menu.Selection]
          Menu.Color(item.bcgColor, item.back)
          Menu.Selection := this.ItemPos[new].text
          item := this.Items[Menu.Selection]
          Menu.Color(item.hiColor, item.back)
          Menu.Label := item.Label
          Menu.Name := item.Name
          Menu.PrCtrl := 0
          DllCall(&quot;GetCursorPos&quot;, &quot;int64P&quot;, pt), Menu.WaitX := pt &lt;&lt; 32 &gt;&gt; 32, Menu.WaitY := pt &gt;&gt; 32
    }
     SetHotkeys() {
          #If Menu.View
          #If Menu.View &amp;&amp; Menu.Selection
          #If
          Hotkey, IF, Menu.View
          hFunc := ObjBindMethod(this, &quot;Up_Down&quot;)
          If !Menu.NotWheel
          {
               Hotkey, *$WheelUp, % hFunc
               Hotkey, *$WheelDown, % hFunc
          }
          Hotkey, *$Up, % hFunc
          Hotkey, *$Down, % hFunc
          hFunc := ObjBindMethod(this, &quot;MenuIsUnderMouse&quot;)
          Hotkey, ~*$LButton, % hFunc
          Hotkey, ~*$RButton, % hFunc
          Hotkey, ~*$MButton, % hFunc
          hFunc := ObjBindMethod(this, &quot;Close&quot;)
          Hotkey, *$Escape, % hFunc
          Hotkey, $Escape, % hFunc
          Hotkey, *$LAlt, % hFunc
          Hotkey, *$LWin, % hFunc
          Hotkey, IF, Menu.View &amp;&amp; Menu.Selection
          hFunc := ObjBindMethod(this, &quot;Select&quot;)
          Hotkey, *$Space, % hFunc
          Hotkey, *$Enter, % hFunc
          Hotkey, IF
    }
     MenuIsUnderMouse() {
          MouseGetPos, , , win
          If (win != Menu.View)
               Menu.Close()
    }
     Color(color, hwndback)  {
          GuiControl, +Background%color%, %hwndback%
          GuiControl, +Redraw, %hwndback%
          GuiControl, +Redraw, % Menu.Selection
     }
     WM_LBUTTONUP(w, l, m, h)  {
          If (A_Gui = Menu.View)
               Menu.Select()
     }
     GetClientSize(hwnd, ByRef W, ByRef H)  {
          VarSetCapacity(pwi, 60, 0), NumPut(60, pwi, 0, &quot;UInt&quot;)
          DllCall(&quot;GetWindowInfo&quot;, &quot;Ptr&quot;, hwnd, &quot;UInt&quot;, &amp;pwi)
          W := NumGet(pwi, 28, &quot;Int&quot;) - NumGet(pwi, 20, &quot;Int&quot;)
          H := NumGet(pwi, 32, &quot;Int&quot;) - NumGet(pwi, 24, &quot;Int&quot;)
     }
     CalculatePopupWindowPosition(byref left, byref top, w, h, x, y, offsetx = 0, offsety = 0)  {
          VarSetCapacity(point, 8, 0), VarSetCapacity(structs, 24, 0)
          NumPut(x, point, 0, &quot;int&quot;), NumPut(y, point, 4, &quot;int&quot;)
          NumPut(w + offsetx, structs, 0, &quot;int&quot;), NumPut(h + offsety, structs, 4, &quot;int&quot;)
          If !DllCall(&quot;CalculatePopupWindowPosition&quot;
               , &quot;ptr&quot;, &amp;point
               , &quot;ptr&quot;, &amp;structs
               , &quot;int&quot;, 0
               , &quot;ptr&quot;, 0
               , &quot;ptr&quot;, &amp;structs + 8)
               Return 0
          left  := NumGet(structs, 8, &quot;int&quot;) + offsetx
          top := NumGet(structs, 12, &quot;int&quot;) + offsety
          Return
     }
} 
F1::Reload
Return</code></pre></div><p>Помогите пожалуйста, чтоб скрипт вызывался при выделении текста везде.</p>]]></content>
			<author>
				<name><![CDATA[terra-4]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=31073</uri>
			</author>
			<updated>2018-02-23T09:53:25Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=123813#p123813</id>
		</entry>
</feed>
