<?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=13017&amp;type=atom" />
	<updated>2017-10-18T20:55:19Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=13017</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Управление клавиатурными стрелочками с помощью мыши]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=120175#p120175" />
			<content type="html"><![CDATA[<p>Доброго времени суток. Уважаемый <strong>Alectric</strong> скрипт который вы предоставили работает как то неправильно картинка крутится как вертолёт в разные стороны. Всего лишь нужно сделать, при<br />движении мыши влево, нажать стрелку влево на клавиатуре и соответственно при<br />движении мыши вправо, нажать стрелку вправо с задержкой 500 (мс). Помогите пожалуйста .<br />Вот нашёл на буржуйском сайте. Всё вроде бы работает но не так плавно как хотелось бы. Задержки пробовал менять не помогло, может что нибудь добавить или наоборот . Да кстати разобрался насчёт кручения картинки (вертолётом) это происходит из за параметра (-1) в этой строке &quot;SetMouseDelay, -1&quot; достаточно поменять значение на (1) и всё кручения прекращаются.<br /></p><div class="codebox"><pre><code>Hover = ~F1

; Select Hotkey to active StickMode:
Stick = ~F2

; Select Hotkey show Zones Guidelines:
ShowZones = CapsLock

; Select optional Hotkey reset mouse to Center:
Center = MButton

; Set Horizontal &amp; Vertical Dead Zone Ranges in pixels:
DeadZoneRangeX := 600
DeadZoneRangeY := 500

KeySet =
( ; Set the keys that will be sent for each of the eight zones of the screen:
Up = Up
Down = Down
Left = Left
Right = Right
UpLeft = Up &amp; Left
UpRight = Up &amp; Right
DownLeft = Down &amp; Left
DownRight = Down &amp; Right
)

; ########## End of configurations! ##########

; Parse KeySet and assign variables to the keys:
Loop, Parse, KeySet, `n
{
	Loop, Parse, A_LoopField, =, %A_Space%
		If Mod(A_Index, 2)
			Key := A_LoopField
		Else
		{
			%Key% := A_LoopField
			StringSplit, %Key%, A_LoopField, &amp;, %A_Space%
		}
}

#SingleInstance, Force
SendMode, Input
SetKeyDelay, -1
SetMouseDelay, 1
SetBatchLines, -1 ; How often the script should sleep (how fast it will run)
CoordMode, Mouse, Screen

; Get coordinates for the center of the screen to create a Dead Zone:
DeadZoneX := A_ScreenWidth / 2
DeadZoneY := A_ScreenHeight / 2

; Activate Hotkeys:
Hotkey, %Hover%, Hover, On
Hotkey, %Stick%, Stick, On
Hotkey, %ShowZones%, ShowZones, On
Try Hotkey, %Center%, CenterMouse, On

; Create a rectangle to show Dead Zone:
A := DeadZoneRangeX*2, B := DeadZoneRangeY*2, C := A-2, D := B-2

Gui, -Caption +ToolWindow +LastFound +AlwaysOnTop
Gui, Color, Red
Gui, +LastFound
WinSet, Region, 0-0 %A%-0 %A%-%B% 0-%B% 0-0  2-2 %C%-2 %C%-%D% 2-%D% 2-2
GoSub, ShowZones
Display := !Display
SetTimer, RemoveTip, -1500
return

Hover:
StickMode := False
SetTimer, WatchMouse, % (HoverMode := !HoverMode) ? 0 : &quot;Off&quot;
Loop, % %hKeys%0
	Send, %  (hKeys = &quot;DeadZone&quot;) ? &quot;&quot; : &quot;{&quot; %hKeys%%A_Index% &quot; up}&quot;
TrayTip,, % (HoverMode) ? &quot;HoverMode On&quot; : &quot;HoverMode Off&quot;
return

Stick:
HoverMode := False
SetTimer, WatchMouse, % (StickMode := !StickMode) ? 0 : &quot;Off&quot;
Loop, % %hKeys%0
	Send, %  (hKeys = &quot;DeadZone&quot;) ? &quot;&quot; : &quot;{&quot; %hKeys%%A_Index% &quot; up}&quot;
TrayTip,, % (StickMode) ? &quot;StickMode On&quot; : &quot;StickMode Off&quot;
return

ShowZones:
If (Display := !Display)
{
	Gui, Show, % &quot;NA x&quot; DeadZoneX - DeadZoneRangeX &quot;y&quot; DeadZoneY - DeadZoneRangeY &quot;w&quot; DeadZoneRangeX * 2 &quot;h&quot; DeadZoneRangeY * 2
	Tooltip, Dead Zone, % DeadZoneX-25, % DeadZoneY-25, 1
	Tooltip, % Up, % DeadZoneX-25, % 0, 2
	Tooltip, % Down, % DeadZoneX-25, % A_ScreenHeight, 3
	Tooltip, % Left, % 0, % DeadZoneY-25, 4
	Tooltip, % Right, % A_ScreenWidth, % DeadZoneY-25, 5
	Tooltip, % UpLeft, % 0, % 0, 6
	Tooltip, % UpRight, % A_ScreenWidth, % 0, 7
	Tooltip, % DownLeft, % 0, % A_ScreenHeight, 8
	Tooltip, % DownRight, % A_ScreenWidth, % A_ScreenHeight, 9
}
Else
	GoSub, RemoveTip
return

RemoveTip:
Gui, Cancel
Tooltip,,,,1
Tooltip,,,,2
Tooltip,,,,3
Tooltip,,,,4
Tooltip,,,,5
Tooltip,,,,6
Tooltip,,,,7
Tooltip,,,,8
Tooltip,,,,9
return

CenterMouse:
Click, %DeadZoneX%, %DeadZoneY%, 0
return

WatchMouse:
MouseGetPos, pX, pY
If StickMode
{
	If ((pX = 0) || (pX = A_ScreenWidth-1))
		|| ((pY = 0) || (pY = A_ScreenHeight-1))
		GoSub, CenterMouse
	Sleep, 250
	MouseGetPos, cX, cY
	zKeys := MoveZone(pX, pY, cX, cY)
}
Else
	zKeys := GetZone(pX, pY, DeadZoneX, DeadZoneY, DeadZoneRangeX, DeadZoneRangeY)
If (hKeys &lt;&gt; zKeys)
{
	Loop, % %hKeys%0
		Send, %  (hKeys = &quot;DeadZone&quot;) ? &quot;&quot; : &quot;{&quot; %hKeys%%A_Index% &quot; up}&quot;
	Loop, % %zKeys%0
		Send, % (zKeys = &quot;DeadZone&quot;) ? &quot;&quot; : &quot;{&quot; %zKeys%%A_Index% &quot;  down}&quot;
	hKeys := zKeys
}
return

GetZone(X, Y, DX, DY, RX, RY)
{
	If (Y &lt; (DY - RY))
		Zone .= &quot;Up&quot;
	If (Y &gt; (DY + RY))
		Zone .= &quot;Down&quot;
	If (X &lt; (DX - RX))
		Zone .= &quot;Left&quot;
	If (X &gt; (DX + RX))
		Zone .= &quot;Right&quot;
	return Zone = &quot;&quot; ? &quot;DeadZone&quot; : Zone
}

MoveZone(pX, pY, cX, cY)
{
	If (cY &lt; pY)
		Zone .= &quot;Up&quot;
	If (cY &gt; pY)
		Zone .= &quot;Down&quot;
	If (cX &lt; pX)
		Zone .= &quot;Left&quot;
	If (cX &gt; pX)
		Zone .= &quot;Right&quot;
	return Zone = &quot;&quot; ? &quot;DeadZone&quot; : Zone
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Ядрён]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=30092</uri>
			</author>
			<updated>2017-10-18T20:55:19Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=120175#p120175</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Управление клавиатурными стрелочками с помощью мыши]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=119499#p119499" />
			<content type="html"><![CDATA[<p>Вот держи, переделай под свои нужды:<br /></p><div class="codebox"><pre><code>#NoEnv
#SingleInstance,Force
SetTitleMatchMode,2
SetBatchLines,-1
CoordMode,Mouse,Screen
CoordMode,ToolTip
SetKeyDelay,0
SendMode,Input



; Настройки:
class=EPSX     ; класс окна.

; клавиши.
Mouse_Up=up
Mouse_Down=down
Mouse_left=left
Mouse_Right=right
Mouse_LB=vk58 ; X
Mouse_RB=vk59 ; Y
Mouse_MB=vk5a ; Z

Delay=20       ; чувствительность.
coeffx=1.5     ; коэффициенты для мыши.
coeffy=1.5

Gui=0          ; прицел - требуется файл &quot;xros.png&quot;, содержащий изображение прицела с прозрачным фоном.
Xoffset=-10    ; смещение прицела относительно центра экрана.
Yoffset=5
w=32           ; Размеры прицела.
h=32


; Начало.
if gui
{
  x:=(a_screenwidth/2-1-w/2)+Xoffset
  y:=(a_screenheight/2-1-h/2)+Yoffset

  Gui,-Caption +AlwaysOnTop +E0x08000020 +Lastfound
  Gui,Margin,0,0
  Gui,Add,Picture,w%w% h%h%,%a_scriptdir%\xros.png
  Gui,Show,NA x%x% y%y% w%w% h%h%
  ID:=WinExist()
  WinSet,ExStyle,+0x20,ahk_id %ID%
  WinSet,TransColor,0xF0F0F0,ahk_id %ID%
  Gui,hide
}

loop ; ШИМ мышь-клавиши
{
  if !WinActive(&quot;ahk_class &quot; . class)
  {
    if gui
      gui,hide
    sleep,1000
    continue
  }

  mousemove,a_screenwidth/2,a_screenheight/2,0
  DllCall(&quot;Sleep&quot;,UInt,Delay)
  mousegetpos,x1,y1
  x:=a_screenwidth/2-x1, y:=a_screenheight/2-y1
 ; ------------------------------- право лево ----------------------------------
  if (x!=0 and !dooncex)
  {
    dooncex=1
    pressx:=abs(x)          ; x&gt;0 = left; x&lt;0 = right
    xx:=x
    send,% &quot;{&quot; Mouse_left &quot; &quot; (x&lt;0 ? &quot;Up&quot; : &quot;Down&quot;) &quot;}{&quot; Mouse_right &quot; &quot; (x&gt;0 ? &quot;Up&quot; : &quot;Down&quot;) &quot;}&quot;
  }
  else if (x=0 and dooncex)
  {
    dooncex=
    send,% &quot;{&quot; Mouse_left &quot; up}{&quot; Mouse_right &quot; up}&quot;
  }
  if ((pressx:=pressx-coeffx)&lt;0 and pressx&gt;-coeffx-1)
  {
    dooncex=
    send,% &quot;{&quot; (xx&gt;0 ? Mouse_left : Mouse_right) &quot; up}&quot;
  }
 ; ------------------------------- верх низ ----------------------------------
  if (y!=0 and !dooncey)
  {
    dooncey=1
    pressy:=abs(y)            ; y&gt;0 = up; y&lt;0 = Down
    yy:=y
    send,% &quot;{&quot; Mouse_Up &quot; &quot; (y&lt;0 ? &quot;Up&quot; : &quot;Down&quot;) &quot;}{&quot; Mouse_Down &quot; &quot; (y&gt;0 ? &quot;Up&quot; : &quot;Down&quot;) &quot;}&quot;
  }
  else if (y=0 and dooncey)
  {
    dooncey=
    send,% &quot;{&quot; Mouse_Up &quot; up}{&quot; Mouse_Down &quot; up}&quot;
  }
  if ((pressy:=pressy-coeffy)&lt;0 and pressy&gt;-coeffy-1)
  {
    dooncey=
    send,% &quot;{&quot; (yy&gt;0 ? Mouse_Up : Mouse_Down) &quot; up}&quot;
  }
 ; ------------------------------- gui update ----------------------------------
  if (gui and !showw:=showw&gt;50 ? 0 : showw=&quot;&quot; ? 1 : showw+1)
  {
    Gui, Show, na
    WinSet, AlwaysOnTop, On,ahk_id %ID%
  }
}
return


#if WinActive(&quot;ahk_class &quot; . class)

lbutton::
send,{%Mouse_LB% down}
return
lbutton up::
send,{%Mouse_LB% up}
return

rbutton::
send,{%Mouse_RB% down}
return
rbutton up::
send,{%Mouse_RB% up}
return

mbutton::
send,{%Mouse_MB% down}
return
mbutton up::
send,{%Mouse_MB% up}
return

#if

!esc:: ; Alt+Esc
exitapp
</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Alectric]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26027</uri>
			</author>
			<updated>2017-09-22T16:09:06Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=119499#p119499</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Управление клавиатурными стрелочками с помощью мыши]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=119449#p119449" />
			<content type="html"><![CDATA[<p>MouseGetPos.</p>]]></content>
			<author>
				<name><![CDATA[svoboden]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=34280</uri>
			</author>
			<updated>2017-09-21T00:11:05Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=119449#p119449</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: Управление клавиатурными стрелочками с помощью мыши]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=119447#p119447" />
			<content type="html"><![CDATA[<p>Доброго времени суток. Подскажите пожалуйста как можно реализовать управление клавиатурными стрелочками с помощью движений мыши в соответствующем направлении .</p>]]></content>
			<author>
				<name><![CDATA[Ядрён]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=30092</uri>
			</author>
			<updated>2017-09-21T00:02:15Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=119447#p119447</id>
		</entry>
</feed>
