<?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=13723&amp;type=atom" />
	<updated>2018-05-25T21:36:48Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=13723</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Настройка автозамены на геймпаде для джойстика]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=125610#p125610" />
			<content type="html"><![CDATA[<p>Да, я геймпад имел ввиду, ок, но мне надо больше.</p>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2018-05-25T21:36:48Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=125610#p125610</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Настройка автозамены на геймпаде для джойстика]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=125604#p125604" />
			<content type="html"><![CDATA[<p><strong>serzh82saratov</strong><br />один геймпад с двумя джойстиками</p>]]></content>
			<author>
				<name><![CDATA[al-biruni]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=39275</uri>
			</author>
			<updated>2018-05-25T18:12:19Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=125604#p125604</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Настройка автозамены на геймпаде для джойстика]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=125597#p125597" />
			<content type="html"><![CDATA[<p>Мне надо кое что потестить, у вас один джойстик?</p>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2018-05-25T16:23:46Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=125597#p125597</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Настройка автозамены на геймпаде для джойстика]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=125592#p125592" />
			<content type="html"><![CDATA[<p><strong>serzh82saratov</strong><br />Крайне благодарен за помощь! То что надо!</p>]]></content>
			<author>
				<name><![CDATA[al-biruni]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=39275</uri>
			</author>
			<updated>2018-05-25T14:49:10Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=125592#p125592</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Настройка автозамены на геймпаде для джойстика]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=125555#p125555" />
			<content type="html"><![CDATA[<p>Тут скорее не с таймером, а с условиями и переменными надо работать.<br /></p><div class="codebox"><pre><code>#Persistent  
SetTimer, DoubleAxis, 5
return

MyFunc(key) {
	Static Arr := {&quot;LR&quot;:&quot;{ENTER}&quot;,&quot;RL&quot;:&quot;{ESC}&quot;,&quot;LL&quot;:&quot;{BACKSPASE}&quot;}
	ToolTip % key &quot;`n&quot; Arr[key]
	; SendInput % Arr[key]
}
DoubleAxis() {
	Static Tick := 0, Prev, Birth, Dev := 30  ; отклонение от центра, от 0 до 50.
	, min := 50 - Dev, max := 50 + Dev, Delay := 500  ;	задержка между отклонениями  
	X := GetKeyState(&quot;JoyU&quot;), Y := GetKeyState(&quot;JoyR&quot;)
	Key := X &gt; max ? &quot;R&quot; : X &lt; min ? &quot;L&quot; : Y &gt; max ? &quot;D&quot; : Y &lt; min ? &quot;U&quot; : 0
	if Birth
		return !Key &amp;&amp; (Birth := 0)
	if !Prev
		return Key &amp;&amp; (Tick := A_TickCount, Prev := Key, Birth := 1) 
	if (A_TickCount - Delay &gt; Tick)
		return (Prev := Birth := 0)
	if Key 
		MyFunc(Prev Key), Prev := Tick := 0, Birth := 1
}
</code></pre></div>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2018-05-22T23:09:03Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=125555#p125555</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Настройка автозамены на геймпаде для джойстика]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=125549#p125549" />
			<content type="html"><![CDATA[<p><strong>serzh82saratov</strong><br />В идеале хочу сделать так чтобы на двойное отклонение джойстика&nbsp; в любую сторону можно было бы назначить какую либо клавишу с клавиатуры. Например при отклонении: <br /></p><div class="codebox"><pre><code>&quot;влево&quot;+&quot;вправо&quot; = {ENTER},  
&quot;вправо&quot;+&quot;влево&quot;={ESC} 
&quot;влево&quot;+&quot;влево&quot; = {BACKSPASE}
</code></pre></div><p>Но сейчас уперся в проблему что никак не могу понять как работать с таймером</p>]]></content>
			<author>
				<name><![CDATA[al-biruni]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=39275</uri>
			</author>
			<updated>2018-05-22T18:56:30Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=125549#p125549</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Настройка автозамены на геймпаде для джойстика]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=125548#p125548" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>al-biruni пишет:</cite><blockquote><p>хоть так</p></blockquote></div><p>А как в идеале?</p>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2018-05-22T18:35:50Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=125548#p125548</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Настройка автозамены на геймпаде для джойстика]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=125547#p125547" />
			<content type="html"><![CDATA[<p><strong>serzh82saratov</strong><br />Да хоть так, допустим отклонение в ту же сторону.</p>]]></content>
			<author>
				<name><![CDATA[al-biruni]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=39275</uri>
			</author>
			<updated>2018-05-22T18:34:26Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=125547#p125547</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Настройка автозамены на геймпаде для джойстика]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=125546#p125546" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>al-biruni пишет:</cite><blockquote><p>двойного отклонения</p></blockquote></div><p>Это - отклонение в сторону - возврат в центр, не &quot;задевая&quot; в другую сторону - отклонение в ту же сторону в диапазоне задержки?</p>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2018-05-22T18:19:28Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=125546#p125546</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Настройка автозамены на геймпаде для джойстика]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=125542#p125542" />
			<content type="html"><![CDATA[<p><strong>serzh82saratov</strong></p><p>Спасибо, так работает!</p><p>Но хотелось бы как то модифицировать скрипт так что бы работало без автозамен. Иными словами при двойном отклонении джойстика нажималась определенная клавиша на клавиатуре. Я никак не соображу каков должен быть алгоритм и как задать таймаут двойного отклонения... Если таймер запускает скрипт с заданным промежутком времени который считывает состояние джойстика, то как и где при этом нужно задавать задержку между изменениями состояния джойстика... в таймере? или нужно создать еще один таймер? подкиньте идей, плиз</p>]]></content>
			<author>
				<name><![CDATA[al-biruni]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=39275</uri>
			</author>
			<updated>2018-05-22T16:58:27Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=125542#p125542</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Настройка автозамены на геймпаде для джойстика]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=125489#p125489" />
			<content type="html"><![CDATA[<div class="codebox"><pre><code>SendLevel, 1</code></pre></div>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2018-05-20T20:17:15Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=125489#p125489</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: Настройка автозамены на геймпаде для джойстика]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=125486#p125486" />
			<content type="html"><![CDATA[<p>Передо мной стоит такая задача. Необходимо сделать так чтобы при двойном отклонении джойстика нажималась на клавиатуре определённая клавиша. Получился такой скрипт (см. ниже), но не все работает и не совсем так как хотелось бы. <br />При вводе с клавиатуры </p><div class="quotebox"><blockquote><p>00</p></blockquote></div><p>&nbsp; автозамена срабатывает на </p><div class="quotebox"><blockquote><p>airline</p></blockquote></div><p>, но при вводе с геймпада автозамена не работает. Нужна помощь, подскажите где копать, или может какой то другой подход к данной задаче кто то предложит?<br /></p><div class="codebox"><pre><code>#Persistent  ; Keep this script running until the user explicitly exits it.
SetTimer, WatchAxis, 5
return

WatchAxis:
GetKeyState, JoyU, JoyU  ; Get position of X axis.
GetKeyState, JoyR, JoyR  ; Get position of Y axis.
KeyToHoldDownPrev = %KeyToHoldDown%  ; Prev now holds the key that was down before (if any).

if JoyU &gt; 80
    KeyToHoldDown = 0
else if JoyU &lt; 20
    KeyToHoldDown = Numpad1
else if JoyR &gt; 80
    KeyToHoldDown = VK32
else if JoyR &lt; 20
    KeyToHoldDown = VK33
else
    KeyToHoldDown =

if KeyToHoldDown = %KeyToHoldDownPrev%  ; The correct key is already down (or no key is needed).
    return  ; Do nothing.

; Otherwise, release the previous key and press down the new key:

;SetKeyDelay -1  ; Avoid delays between keystrokes.
;if KeyToHoldDownPrev   ; There is a previous key to release.
;    SendInput, {%KeyToHoldDownPrev% up}  ; Release it.
;if KeyToHoldDown   ; There is a key to press down.
;    SendInput, {%KeyToHoldDown% down}  ;
SendInput %KeyToHoldDown%

return

:b*?:00::airline</code></pre></div>]]></content>
			<author>
				<name><![CDATA[al-biruni]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=39275</uri>
			</author>
			<updated>2018-05-20T18:13:59Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=125486#p125486</id>
		</entry>
</feed>
