<?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=11884&amp;type=atom" />
	<updated>2018-03-16T00:51:46Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=11884</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Отклонение мыши джойстиком]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=124078#p124078" />
			<content type="html"><![CDATA[<p>Оказалось, что в игре не срабатывает MouseMove. Можно это исправить?</p>]]></content>
			<author>
				<name><![CDATA[Kurskador]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=33207</uri>
			</author>
			<updated>2018-03-16T00:51:46Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=124078#p124078</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Отклонение мыши джойстиком]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=124064#p124064" />
			<content type="html"><![CDATA[<p>В игре курсор двигается джойстиком, а при переключении на персонаж(от первого лица) наклоны рукоятки джойстика игрой игнорируются. При этом имитация колёсика и назначенных кнопок проходит нормально.<br />&nbsp; Можно как-то доработать этот скрипт, чтобы и прицел джойстиком двигался?</p>]]></content>
			<author>
				<name><![CDATA[Kurskador]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=33207</uri>
			</author>
			<updated>2018-03-14T20:50:11Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=124064#p124064</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Отклонение мыши джойстиком]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=108294#p108294" />
			<content type="html"><![CDATA[<p><strong>Kurskador</strong>,<br />Допустим, некоторая программа принимает отклонение мыши от центра экрана (или же любой другой точки) за величину силы. Очевидно, что для возвращения значения силы к нулю нужно вернуть курсор в начальную позицию. В случае с джойстиком всё логично -- его рукоятка также возвращается в исходное положение.</p>]]></content>
			<author>
				<name><![CDATA[Gector]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=34109</uri>
			</author>
			<updated>2016-10-09T20:22:29Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=108294#p108294</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Отклонение мыши джойстиком]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=108290#p108290" />
			<content type="html"><![CDATA[<p>Наверное вопрос в том, зачем нужно возвращать назад?</p>]]></content>
			<author>
				<name><![CDATA[Kurskador]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=33207</uri>
			</author>
			<updated>2016-10-09T15:24:33Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=108290#p108290</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Отклонение мыши джойстиком]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=108289#p108289" />
			<content type="html"><![CDATA[<p><strong>Alectric</strong>,<br />То есть конфигурация?</p>]]></content>
			<author>
				<name><![CDATA[Gector]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=34109</uri>
			</author>
			<updated>2016-10-09T15:04:50Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=108289#p108289</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Отклонение мыши джойстиком]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=106639#p106639" />
			<content type="html"><![CDATA[<p>Если не секрет, зачем такая странная конфигурация?</p>]]></content>
			<author>
				<name><![CDATA[Alectric]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26027</uri>
			</author>
			<updated>2016-08-07T03:35:29Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=106639#p106639</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Отклонение мыши джойстиком]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=106638#p106638" />
			<content type="html"><![CDATA[<p><strong>Alectric</strong><br />Благодарю</p>]]></content>
			<author>
				<name><![CDATA[Gector]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=34109</uri>
			</author>
			<updated>2016-08-06T19:41:55Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=106638#p106638</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Отклонение мыши джойстиком]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=106634#p106634" />
			<content type="html"><![CDATA[<div class="codebox"><pre><code>CoordMode,Mouse,Screen

startx=800 ; центр - куда будет возвращаться курсор
starty=800
x:=300 ; как далеко курсор будет перемещатся от центра
y:=300
;x:=a_screenwidth//2
;y:=a_screenheight//2

loop
{
  if aintwork
  {
    sleep,100
    continue
  }
  sleep,10

  GetKeyState,Bstate,joy1
  if (Bstate=&quot;U&quot; and joy1=1)
  {
    joy1=
    send {lbutton Up}
  }

  GetKeyState,JoyX,%JoystickNumber%JoyX
  GetKeyState,JoyY,%JoystickNumber%JoyY

  JoyX:=(JoyX-50)*0.02
  JoyY:=(JoyY-50)*0.02

  mx:=round(startx+x*JoyX)
  my:=round(starty+y*JoyY)

;  tooltip,% a_tickcount &quot;`n&quot; mx &quot;`n&quot; my,mx,my
  if (oldmx!=mx or oldmy!=my)
    mousemove,mx,my,0

  oldmx:=mx
  oldmy:=my
}
return

joy1::
joy1=1
send,{lbutton down}
return

f1::
aintwork:=!aintwork
return
</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Alectric]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26027</uri>
			</author>
			<updated>2016-08-06T17:13:21Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=106634#p106634</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Отклонение мыши джойстиком]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=106631#p106631" />
			<content type="html"><![CDATA[<p><strong>Alectric</strong><br />То есть центр, куда будет возвращаться курсор. Переменные x и y?</p>]]></content>
			<author>
				<name><![CDATA[Gector]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=34109</uri>
			</author>
			<updated>2016-08-06T16:48:19Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=106631#p106631</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Отклонение мыши джойстиком]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=106630#p106630" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Gector пишет:</cite><blockquote><p>как изменить точку курсора?</p></blockquote></div><p>Что это значит?</p>]]></content>
			<author>
				<name><![CDATA[Alectric]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26027</uri>
			</author>
			<updated>2016-08-06T16:46:00Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=106630#p106630</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Отклонение мыши джойстиком]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=106628#p106628" />
			<content type="html"><![CDATA[<p><strong>Alectric</strong><br />Огромное спасибо, то что нужно! Только вот как изменить точку курсора и поставить ЛКМ на 1 кнопку джойстика?</p>]]></content>
			<author>
				<name><![CDATA[Gector]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=34109</uri>
			</author>
			<updated>2016-08-06T16:44:30Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=106628#p106628</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Отклонение мыши джойстиком]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=106627#p106627" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Gector пишет:</cite><blockquote><p>Помогите изменить скрипт,</p></blockquote></div><p>Проще новый написать...<br /></p><div class="codebox"><pre><code>CoordMode,Mouse,Screen

;x:=a_screenwidth//2
;y:=a_screenheight//2
x:=65535//2
y:=65535//2

loop
{
  if aintwork
  {
    sleep,100
    continue
  }
  sleep,10

  GetKeyState,JoyX,%JoystickNumber%JoyX
  GetKeyState,JoyY,%JoystickNumber%JoyY

  JoyX:=(JoyX-50)*0.02
  JoyY:=(JoyY-50)*0.02

  mx:=round(x+x*JoyX)
  my:=round(y+y*JoyY)

;  tooltip,% a_tickcount &quot;`n&quot; mx &quot;`n&quot; my,mx,my
  if (oldmx!=mx or oldmy!=my)
    DllCall(&quot;mouse_event&quot;, uint, 0x8001, int, mx, int, my, uint, 0, int, 0)
;    mousemove,mx,my,0

  oldmx:=mx
  oldmy:=my
}
return

f1::
aintwork:=!aintwork
return
</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Alectric]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26027</uri>
			</author>
			<updated>2016-08-06T15:16:04Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=106627#p106627</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: Отклонение мыши джойстиком]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=106620#p106620" />
			<content type="html"><![CDATA[<p>Приветствую всех. Помогите изменить скрипт, позволяющий двигать курсором с помощью джойстика. Требуется сдвигать курсор от центра экрана (или любой другой точки) в зависимости от отклонения ручки, а потом возвращать курсор назад.<br />Ниже приведен работающий скрипт, взятый из <a href="http://forum.script-coding.com/viewtopic.php?id=759">этой темы.</a><br /></p><div class="codebox"><pre><code>; Увеличьте это значение, чтобы курсор двигался быстрее.
JoyMultiplier = 0.30

; Уменьшите это значение, чтобы курсор начинал двигаться при меньшем отклонении
; осей джойстика. Однако, может понадобиться калибровка джойстика, чтобы добиться
; его хорошей центровки и избежать дрейфа курсора. С хорошо отцентрованным
; джойстиком может использоваться значение 1.
JoyThreshold = 3

; Измените значение на true, чтобы инвертировать ось Y и заставить мышь
; двигаться вертикально в направлении, обратном движению рукоятки (или как там
; эта штука называется - YMP).
InvertYAxis := false

; Измените эти значения, чтобы использовать для кнопок мыши другие кнопки 
; джойстика, а не 1, 2 и 3. Возможные значения от 1 до 32.
ButtonLeft = 1
ButtonRight = 2
ButtonMiddle = 3

; Если ваш джойстик имеет POV control (понятия не имею, что за фигня - YMP),
; вы можете использовать его как колесо мыши. Значение ниже означает количество
; миллисекунд между поворотами колеса. Уменьшите, чтобы ускорить колесо.
WheelDelay = 250

; Если в системе больше одного джойстика, укажите здесь номер того, который
; нужно использовать.
JoystickNumber = 1

; КОНЕЦ РАЗДЕЛА НАСТРОЕК -- не изменяйте то, что ниже, если только вы не
; хотите изменить базовый функционал скрипта.

#SingleInstance

JoystickPrefix = %JoystickNumber%Joy
Hotkey, %JoystickPrefix%%ButtonLeft%, ButtonLeft
Hotkey, %JoystickPrefix%%ButtonRight%, ButtonRight
Hotkey, %JoystickPrefix%%ButtonMiddle%, ButtonMiddle

; Calculate the axis displacements that are needed to start moving the cursor:
JoyThresholdUpper := 50 + JoyThreshold
JoyThresholdLower := 50 - JoyThreshold
if InvertYAxis
    YAxisMultiplier = -1
else
    YAxisMultiplier = 1

SetTimer, WatchJoystick, 10  ; Monitor the movement of the joystick.

GetKeyState, JoyInfo, %JoystickNumber%JoyInfo
IfInString, JoyInfo, P  ; Joystick has POV control, so use it as a mouse wheel.
    SetTimer, MouseWheel, %WheelDelay%

return  ; End of auto-execute section.


; The subroutines below do not use KeyWait because that would sometimes trap the
; WatchJoystick quasi-thread beneath the wait-for-button-up thread, which would
; effectively prevent mouse-dragging with the joystick.

ButtonLeft:
SetMouseDelay, -1  ; Makes movement smoother.
MouseClick, left,,, 1, 0, D  ; Hold down the left mouse button.
SetTimer, WaitForLeftButtonUp, 10
return

ButtonRight:
SetMouseDelay, -1  ; Makes movement smoother.
MouseClick, right,,, 1, 0, D  ; Hold down the right mouse button.
SetTimer, WaitForRightButtonUp, 10
return

ButtonMiddle:
SetMouseDelay, -1  ; Makes movement smoother.
MouseClick, middle,,, 1, 0, D  ; Hold down the right mouse button.
SetTimer, WaitForMiddleButtonUp, 10
return

WaitForLeftButtonUp:
if GetKeyState(JoystickPrefix . ButtonLeft)
    return  ; The button is still, down, so keep waiting.
; Otherwise, the button has been released.
SetTimer, WaitForLeftButtonUp, off
SetMouseDelay, -1  ; Makes movement smoother.
MouseClick, left,,, 1, 0, U  ; Release the mouse button.
return

WaitForRightButtonUp:
if GetKeyState(JoystickPrefix . ButtonRight)
    return  ; The button is still, down, so keep waiting.
; Otherwise, the button has been released.
SetTimer, WaitForRightButtonUp, off
MouseClick, right,,, 1, 0, U  ; Release the mouse button.
return

WaitForMiddleButtonUp:
if GetKeyState(JoystickPrefix . ButtonMiddle)
    return  ; The button is still, down, so keep waiting.
; Otherwise, the button has been released.
SetTimer, WaitForMiddleButtonUp, off
MouseClick, middle,,, 1, 0, U  ; Release the mouse button.
return

WatchJoystick:
MouseNeedsToBeMoved := false  ; Set default.
SetFormat, float, 03
GetKeyState, joyx, %JoystickNumber%JoyX
GetKeyState, joyy, %JoystickNumber%JoyY
if joyx &gt; %JoyThresholdUpper%
{
    MouseNeedsToBeMoved := true
    DeltaX := joyx - JoyThresholdUpper
}
else if joyx &lt; %JoyThresholdLower%
{
    MouseNeedsToBeMoved := true
    DeltaX := joyx - JoyThresholdLower
}
else
    DeltaX = 0
if joyy &gt; %JoyThresholdUpper%
{
    MouseNeedsToBeMoved := true
    DeltaY := joyy - JoyThresholdUpper
}
else if joyy &lt; %JoyThresholdLower%
{
    MouseNeedsToBeMoved := true
    DeltaY := joyy - JoyThresholdLower
}
else
    DeltaY = 0
if MouseNeedsToBeMoved
{
    SetMouseDelay, -1  ; Makes movement smoother.
    MouseMove, DeltaX * JoyMultiplier, DeltaY * JoyMultiplier * YAxisMultiplier, 0, R
}
return

MouseWheel:
GetKeyState, JoyPOV, %JoystickNumber%JoyPOV
if JoyPOV = -1  ; No angle.
    return
if (JoyPOV &gt; 31500 or JoyPOV &lt; 4500)  ; Forward
    Send {WheelUp}
else if JoyPOV between 13500 and 22500  ; Back
    Send {WheelDown}
return</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Gector]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=34109</uri>
			</author>
			<updated>2016-08-06T14:17:48Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=106620#p106620</id>
		</entry>
</feed>
