<?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=16660&amp;type=atom" />
	<updated>2021-10-12T13:20:18Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=16660</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Вывести значения в переменные за пределы функции]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=150040#p150040" />
			<content type="html"><![CDATA[<p>UDP^ Решил вопрос глобальными переменными.</p>]]></content>
			<author>
				<name><![CDATA[grin-du]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=42050</uri>
			</author>
			<updated>2021-10-12T13:20:18Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=150040#p150040</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Вывести значения в переменные за пределы функции]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=150039#p150039" />
			<content type="html"><![CDATA[<p>Так почитайте про функции в справке. Там поясняется, как можно выводить из функции переменные.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2021-10-12T13:09:58Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=150039#p150039</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: Вывести значения в переменные за пределы функции]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=150036#p150036" />
			<content type="html"><![CDATA[<p>Вот такой код. Не мой, но мне нужен.</p><div class="codebox"><pre><code>
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.

;Example for ProShow
#IfWinActive ahk_exe proshow.exe

F4::
timelineClick([A_ScriptDir . &quot;\ProShow\ImageSearch\Blue_commet.png&quot;], [[14,30]], [109])

timelineClick(images,imageSizes, yOffsets, hold=False)
{	
	static s_lastImage, s_TagX, s_TagY
	;преобразовать отдельные свойства в массив
	If !IsObject(images)
		images := [images]
	If !IsObject(imageSizes[1])
		imageSizes := [imageSizes]
	If !IsObject(yOffsets)
		yOffsets := [yOffsets]
		
	
	MouseGetPos, MouseX, MouseY 
	;Проверить изображение на последней позиции
	Try
	{
		searchImage := images[s_lastImage]
		Imagesearch, , , s_TagX, s_TagY, (s_TagX+imageSizes[s_lastImage][1]), (s_TagY+imageSizes[s_lastImage][2]), %searchImage%		
		if ErrorLevel &gt; 0
			throw
	}
	catch e 
	{
		;искать везде все изображения
		for image in images
			{
			searchImage := images[image]
			ImageSearch, s_TagX, s_TagY, 0, 15, %A_ScreenWidth%, %A_ScreenHeight%, %searchImage%
			if ErrorLevel &gt; 0
				continue
			else
				{
				;Success
				s_lastImage := image
				break
				}
		If ErrorLevel &gt; 0
			{
			msgbox, Couldn&#039;t find reference image.
			Return
			}
			}
	}
	 a = %s_TagX%
     b = %s_TagY%
}
msgbox, %a%, %b%
return</code></pre></div><p>В общем, код работает. Находит изображение. Супер! Но не могу вывести координаты найденой картинки в переменные для дальнейшего взаимодействия. Просто буду &quot;далее плясать от этих координат.&quot; Они есть только в моменте работы функции и не отдаёт даже в msgbox. но если msgbox будет после a,b переменных (сразу), то покажет. Я новичок, и голову сломал.</p>]]></content>
			<author>
				<name><![CDATA[grin-du]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=42050</uri>
			</author>
			<updated>2021-10-12T13:02:11Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=150036#p150036</id>
		</entry>
</feed>
