<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; AHK: Запуск горячей кнопки через сторонний класс]]></title>
		<link>https://forum.script-coding.com/viewtopic.php?id=16427</link>
		<atom:link href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=16427&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «AHK: Запуск горячей кнопки через сторонний класс».]]></description>
		<lastBuildDate>Sun, 13 Jun 2021 09:45:51 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: AHK: Запуск горячей кнопки через сторонний класс]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=148432#p148432</link>
			<description><![CDATA[<div class="quotebox"><blockquote><p>В конкретном случае - XignCode3. Не считаю что глобально вопрос относится конкретно к игре, т.к. похожее было и в покерных клиентах</p></blockquote></div><p>А покер это не игра?<br />И что еще можно ожидать от античитовой программы?<br />Наверняка она проверяет какие глобальные хуки установлены в системе и блокирует их.<br />Как устанавливает их автохотки вы можете почитать в исходниках программы.<br />Ну а заменить GetKeyState можно, наверное, на KeyWait, как работают эти функции можно опять же почитать в исходниках.</p>]]></description>
			<author><![CDATA[null@example.com (Malcev)]]></author>
			<pubDate>Sun, 13 Jun 2021 09:45:51 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=148432#p148432</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Запуск горячей кнопки через сторонний класс]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=148431#p148431</link>
			<description><![CDATA[<p><strong>Malcev</strong> В конкретном случае - XignCode3. Не считаю что глобально вопрос относится конкретно к игре, т.к. похожее было и в покерных клиентах, правда там работали горячие клавиши. </p><p>С точки лаунчера, я понимаю если бы дело касалось только эмуляции, но при чем тут горячие клавиши? Грубо говоря, надо всего лишь активировать запуск подпрограммы. Т.е. это действие даже не имеет ничего общего с лаунчером и никак на него не влияет, более того, запуск с мышки работает.<br /></p><div class="codebox"><pre><code>
XButton1::
msgbox, t
return
</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (Botsy)]]></author>
			<pubDate>Sun, 13 Jun 2021 09:35:23 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=148431#p148431</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Запуск горячей кнопки через сторонний класс]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=148430#p148430</link>
			<description><![CDATA[<div class="codebox"><pre><code>#IfWinActive Launcher
1::
msgbox, t
return
#IfWinActive</code></pre></div><p>Тут у вас через хук.<br />В моем коде через reg.<br />Ваш ланчер всё это блокирует.<br />Что за ланчер такой?<br />Может тему надо в игры перенести?</p>]]></description>
			<author><![CDATA[null@example.com (Malcev)]]></author>
			<pubDate>Sun, 13 Jun 2021 09:15:06 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=148430#p148430</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Запуск горячей кнопки через сторонний класс]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=148429#p148429</link>
			<description><![CDATA[<p><strong>Malcev</strong> Так reg не подходит, т.к. лаунчер просто игнорирует их. Я писал это в 1-ом посте. <br />Допустим в лаунчере вызвать msgbox. <br /></p><div class="codebox"><pre><code>
#IfWinActive Launcher
1::
msgbox, t
return
#IfWinActive
</code></pre></div><p>Или любым из ваших способов - ничего не произойдет. Лаунчер просто проигнорирует вызов msgbox. Пока работает только с командой GetKeyState:<br /></p><div class="codebox"><pre><code>
loop, 
{
	If GetKeyState(&quot;1&quot;, P)
	{
		msgbox, t
		return
	}
}
</code></pre></div><p>Это вариант, правда не сильно удобный, мне кажется есть альтернативное решение.</p>]]></description>
			<author><![CDATA[null@example.com (Botsy)]]></author>
			<pubDate>Sun, 13 Jun 2021 09:04:44 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=148429#p148429</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Запуск горячей кнопки через сторонний класс]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=148428#p148428</link>
			<description><![CDATA[<p>Чтобы хотки регистрировались через reg.<br /></p><div class="codebox"><pre><code>loop
{
   Hotkey, 1, off
   WinWaitActive, Calculator
   Hotkey, 1, on
   WinWaitNotActive, Calculator
}

1::msgbox</code></pre></div><p>Еще можно так<br /></p><div class="codebox"><pre><code>1::
if WinActive(&quot;Calculator&quot;)
   msgbox
else
{
   Hotkey, 1, off
   send 1
   Hotkey, 1, on
}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (Malcev)]]></author>
			<pubDate>Sun, 13 Jun 2021 08:45:21 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=148428#p148428</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Запуск горячей кнопки через сторонний класс]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=148427#p148427</link>
			<description><![CDATA[<p><strong>Malcev</strong> Не понял, а зачем это?</p>]]></description>
			<author><![CDATA[null@example.com (Botsy)]]></author>
			<pubDate>Sun, 13 Jun 2021 08:35:30 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=148427#p148427</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Запуск горячей кнопки через сторонний класс]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=148426#p148426</link>
			<description><![CDATA[<p>Ждете в цикле либо через хук активации нужного вам окна, после чего активируете нужную вам хотки.<br />После чего ждёте деактивации окна и деактивируете нужную вам хотки.</p>]]></description>
			<author><![CDATA[null@example.com (Malcev)]]></author>
			<pubDate>Sun, 13 Jun 2021 08:30:16 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=148426#p148426</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Запуск горячей кнопки через сторонний класс]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=148425#p148425</link>
			<description><![CDATA[<p><strong>teadrinker</strong> С тильдой пробовал, работало только в сочетании с SendMode, Input. Но в целом не подходит - т.к. используется хук и лаунчер ругался.<br />А по какому принципу ahk посылает нажатия? Лаунчер отслеживает и эмуляцию и горячие клавиши, может быть в них есть что-то общее? Например эти хуки.<br />GetKeyState же тоже перехватывает нажатия, но на эту команду не ругается и с ней работает.</p>]]></description>
			<author><![CDATA[null@example.com (Botsy)]]></author>
			<pubDate>Sun, 13 Jun 2021 07:55:48 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=148425#p148425</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Запуск горячей кнопки через сторонний класс]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=148424#p148424</link>
			<description><![CDATA[<div class="quotebox"><cite>Botsy пишет:</cite><blockquote><p>Не отправляет, но использует горячие клавиши. Не знаю можно ли так сказать, но они по своему характеру схожи с эмуляцией</p></blockquote></div><p>Нет, тут у вас путаница. Эмуляция клавиш — это когда AHK-скрипт посылает нажатия (например, командой Send), а горячие клавиши — это когда скрипт перехватывает нажатия, посланные извне. Это две совершенно разные вещи.<br />Не уверен, что получится, но можно попробовать использовать горячие клавиши с тильдой:<br /></p><div class="codebox"><pre><code>~F1:: MsgBox % A_ThisHotkey</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Sun, 13 Jun 2021 05:08:43 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=148424#p148424</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Запуск горячей кнопки через сторонний класс]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=148423#p148423</link>
			<description><![CDATA[<p><strong>teadrinker</strong></p><p>&quot;<em>Что за сторонний класс эмуляции? Что значит «стандартные нажатия из ahk»?</em>&quot;<br />- Это класс который эмулирует клавиатуру и мышь, похожий на AutoHotInterseption. Т.е. методы эмуляции отличные от &quot;стандартных&quot; Send, Click и т.д. </p><p>&quot;<em>Код, вроде, никаких нажатий не отправляет.</em>&quot;<br />- Не отправляет, но использует горячие клавиши. Не знаю можно ли так сказать, но они по своему характеру схожи с эмуляцией. Т.е. используют какие-то стандартные &quot;способы&quot; или &quot;методы&quot;.</p><p>&quot;<em>Имеете в виду, определённое окно реагирует нежелательным образом, когда AHK пытается перехватить нажатия клавиш?</em>&quot;<br />- да. И если непосредственно Send и Click я смог заменить другим классом, то горячие клавиши не смог. Вот и пытаюсь запускать подпрограмму не стандартной горячей клавишей, эмулированной ahk, а со стороннего класса.</p><p><strong>__Михаил__</strong><br />Это класс для эмуляции клавиатуры и мышки на уровне железа. Тут <a href="https://github.com/ddxoft">https://github.com/ddxoft</a> бесплатная демо версия на разных языках, из архива &quot;drivers&quot; нужны .dll. Для бесплатной версии ahk класс:</p><div class="fancy_spoiler_switcher"><div class="fancy_spoiler_switcher_header" data-lang-open="открыть спойлер" data-lang-close="скрыть спойлер"><strong>+</strong>&nbsp;открыть спойлер</div><div class="fancy_spoiler"><div class="codebox"><pre><code>
class DD extends DD_Helper
{
	; Simulate mouse button press
	; param:   1 = LButton Down,    2 = LButton Up
	;          4 = RButton Down,    8 = RButton Up
	;         16 = MButton Down,   32 = MButton Up
	;         64 = Button 4 Down, 128 = Button 4 Up
	;        256 = Button 5 Down, 512 = Button 5 Up
	btn(param) {
		return DllCall(this.dllFile &quot;\DD_btn&quot;, &quot;int&quot;, param)
	}

	; Simulate mouse move
	mov(x, y) {
		return DllCall(this.dllFile &quot;\DD_mov&quot;, &quot;int&quot;, x, &quot;int&quot;, y)
	}

	; Simulate mouse move (relatively)
	movR(dx, dy) {
		return DllCall(this.dllFile &quot;\DD_movR&quot;, &quot;int&quot;, dx, &quot;int&quot;, dy)
	}

	; Simulate mouse wheel
	; param: 1=upward 2=downward
	whl(param) {
		return DllCall(this.dllFile &quot;\DD_whl&quot;, &quot;int&quot;, param)
	}

	; Simulate keyboard
	; param1: DD code
	; param2: 1=Down 2=Up
	key(param1, param2) {
		return DllCall(this.dllFile &quot;\DD_key&quot;, &quot;int&quot;, param1, &quot;int&quot;, param2)
	}

	; VKCode to DD code
	todc(VKCode) {
		return DllCall(this.dllFile &quot;\DD_todc&quot;, &quot;int&quot;, VKCode)
	}

	; Send string
	str(string) {
		return DllCall(this.dllFile &quot;\DD_str&quot;, &quot;astr&quot;, string)
	}

	; Get hwnd of active window
	GetActiveWindow() {
		; return DllCall(this.dllFile &quot;\DD_GetActiveWindow&quot;, &quot;ptr&quot;) ; seems not working
		return WinExist(&quot;A&quot;)
	}

	MouseMove(hwnd, x, y) {
		return DllCall(this.dllFile &quot;\DD_MouseMove&quot;, &quot;ptr&quot;, hwnd, &quot;int&quot;, x, &quot;int&quot;, y)
	}

	; The picture is saved to &quot;C:\DD Snap\&quot; folder
	SnapPic(hwnd, x, y, w, h) {
		return DllCall(this.dllFile &quot;\DD_SnapPic&quot;, &quot;ptr&quot;, hwnd, &quot;int&quot;, x, &quot;int&quot;, y, &quot;int&quot;, w, &quot;int&quot;, h)
	}

	PickColor(hwnd, x, y, mode=2) {
		return DllCall(this.dllFile &quot;\DD_PickColor&quot;, &quot;ptr&quot;, hwnd, &quot;int&quot;, x, &quot;int&quot;, y, &quot;int&quot;, mode)
	}
}

class DD_Helper
{
	static _ := DD_Helper.InitClass()

	InitClass() {
		this.RunAsAdmin()
		this.LoadDll()
	}

	; https://www.autohotkey.com/docs/commands/Run.htm#RunAs
	RunAsAdmin() {
		full_command_line := DllCall(&quot;GetCommandLine&quot;, &quot;str&quot;)

		if not (A_IsAdmin or RegExMatch(full_command_line, &quot; /restart(?!\S)&quot;))
		{
			try
			{
				if A_IsCompiled
					Run *RunAs &quot;%A_ScriptFullPath%&quot; /restart
				else
					Run *RunAs &quot;%A_AhkPath%&quot; /restart &quot;%A_ScriptFullPath%&quot;
			}
			ExitApp
		}
	}

	LoadDll() {
		dllFile := (A_PtrSize=8) ? &quot;DD64.dll&quot; : &quot;DD32.dll&quot;

		if !this.hModule := DllCall(&quot;LoadLibrary&quot;, &quot;Str&quot;, dllFile, &quot;Ptr&quot;) {
			if !FileExist(dllFile) {
				throw, dllFile &quot; not found.&quot;
			}
			throw, &quot;LoadLibrary failed. DllFile is &quot; dllFile
		}
		this.dllFile := dllFile
	}

	UnloadDll() {
		DllCall(&quot;FreeLibrary&quot;, &quot;Ptr&quot;, this.hModule)
	}
	
	; Example: _btn(&quot;RButtonDown&quot;)
	_btn(sNick, x:=&quot;&quot;, y:=&quot;&quot;) {
		static oNick := { LButtonDown: 1, LButtonUp: 2
		                , RButtonDown: 4, RButtonUp: 8
		                , MButtonDown: 16, MButtonUp: 32
		                , 4ButtonDown: 64, 4ButtonUp: 128
		                , 5ButtonDown: 256, 5ButtonUp: 512 }
		if !( n := oNick[sNick] ) {
			throw, sNick &quot; is not a valid nick.&quot;
		}
		if (x != &quot;&quot;) {
			this.mov(x, y)
		}
		this.btn(n)
	}

	; Example: _btn_press(&quot;RButton&quot;)
	_btn_press(sNick, x:=&quot;&quot;, y:=&quot;&quot;, nCount:=1) {
		static oNick := { LButton: {Down: 1, Up: 2}
		                , RButton: {Down: 4, Up: 8}
		                , MButton: {Down: 16, Up: 32}
		                , 4Button: {Down: 64, Up: 128}
		                , 5Button: {Down: 256, Up: 512} }
		if !( o := oNick[sNick] ) {
			throw, sNick &quot; is not a valid nick.&quot;
		}
		if (x != &quot;&quot;) {
			this.mov(x, y)
		}
		Loop, % nCount {
			this.btn( o.Down )
			this.btn( o.Up )
			Sleep, 5
		}
	}

	; Example: _key(&quot;F11&quot;, &quot;Down&quot;)
	;          _key(&quot;F11&quot;, &quot;Up&quot;)
	_key(sKey, sflag) {
		ddCode := this._key_to_dc(sKey)
		this.key(ddCode, (sflag=&quot;Up&quot;) ? 2 : 1 )
	}

	; Example: _key_press(&quot;F11&quot;)
	;          _key_press(&quot;Ctrl&quot;, &quot;A&quot;)
	_key_press(sKey*) {
		arr_ddCode := []

		for i, k in sKey {
			arr_ddCode[i] := this._key_to_dc(k)
			this.key(arr_ddCode[i], 1) ; Down
		}
		for i, ddCode in arr_ddCode {
			this.key(ddCode, 2) ; Up
		}
	}

	_key_pressEx(sKey, nCount := 1) {
		ddCode := this._key_to_dc(sKey)

		Loop, % nCount {
			this.key(ddCode, 1) ; Down
			this.key(ddCode, 2) ; Up
		}
	}

	; Example: _whl(&quot;down&quot;)
	;          _whl(&quot;up&quot;)
	_whl(sParam) {
		this.whl( (sParam=&quot;Up&quot;) ? 1 : 2 )
	}

	_key_to_dc(key) {
		static o := {&quot;Win&quot;: &quot;Lwin&quot;}

		if o.HasKey(key)
			key := o[key]

		return this.todc( GetKeyVK(key) )
	}
}

</code></pre></div></div></div>]]></description>
			<author><![CDATA[null@example.com (Botsy)]]></author>
			<pubDate>Sun, 13 Jun 2021 03:35:06 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=148423#p148423</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Запуск горячей кнопки через сторонний класс]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=148422#p148422</link>
			<description><![CDATA[<p>&#039;Class_DD64&#039; - можно ли на это посмотреть? Что за зверь?</p>]]></description>
			<author><![CDATA[null@example.com (__Михаил__)]]></author>
			<pubDate>Sat, 12 Jun 2021 22:29:47 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=148422#p148422</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Запуск горячей кнопки через сторонний класс]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=148421#p148421</link>
			<description><![CDATA[<p>Я ничего не понял. Что за сторонний класс эмуляции? Что значит «стандартные нажатия из ahk»? Код, вроде, никаких нажатий не отправляет.<br />Имеете в виду, определённое окно реагирует нежелательным образом, когда AHK пытается перехватить нажатия клавиш?</p>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Sat, 12 Jun 2021 21:07:42 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=148421#p148421</guid>
		</item>
		<item>
			<title><![CDATA[AHK: Запуск горячей кнопки через сторонний класс]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=148420#p148420</link>
			<description><![CDATA[<p>Подскажите пожалуйста, а есть ли способ запускать горячую клавишу через сторонний класс эмуляции?<br />Например, вместо этого:<br /></p><div class="codebox"><pre><code>
F1::
msgbox, test
return
</code></pre></div><p>Это:<br /></p><div class="codebox"><pre><code>
Class_DD64.keyboard_press(&quot;F1&quot;)::
msgbox, test
</code></pre></div><p>Или может как-то через:<br /></p><div class="codebox"><pre><code>
Hotkey, % Func, Button
Return

Func() {
Class_DD64.keyboard_press(&quot;F1&quot;)
}

Button:
msgbox, test
</code></pre></div><p>Дело в том, что лаунчер не пропускает стандартные нажатия из ahk. Если используется метод хука - то лаунчер ругается, а если стандартный reg, то запуск горячей кнопки надо делать не в активном окне лаунчера, что не очень удобно. Посмотрел через ListHotkeys.</p><p>UPD:<br />решил пока через If GetKeyState(&quot;F1&quot;, P), работает, но может есть более лучшее решение?</p>]]></description>
			<author><![CDATA[null@example.com (Botsy)]]></author>
			<pubDate>Sat, 12 Jun 2021 19:35:52 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=148420#p148420</guid>
		</item>
	</channel>
</rss>
