<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: Как добавить %шанс срабатывания функции? Либо 1 к 5 и.т.д.]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=13629&amp;type=atom" />
	<updated>2018-04-15T07:17:01Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=13629</id>
		<entry>
			<title type="html"><![CDATA[AHK: Как добавить %шанс срабатывания функции? Либо 1 к 5 и.т.д.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=124710#p124710" />
			<content type="html"><![CDATA[<p>Привет всем обитателям форума. Ранее я уже создавал тему, в которой мне помогли собрать такой код:<br /></p><div class="codebox"><pre><code>values := [ {input: &quot;gg ss&quot;, function: Func(&quot;FirstFunc&quot; )}
          , {input: &quot;gg s&quot; , function: Func(&quot;SecondFunc&quot;)}  -- Вот это строка с ключ.словом что мы должны вписать. Она запустит SecondFunc со 100% шансом, если так можно выразиться.
          , {input: &quot;ss g&quot; , function: Func(&quot;ThirdFunc&quot; )} ] 

Gui, Add, Edit, vEdit gWatchEdit
Gui, Show
Return

WatchEdit()  {
   global values
   GuiControlGet, Edit
   for k, v in values
      if RegExMatch(Edit, &quot;^\Q&quot; . v.input . &quot;\E$&quot;) &amp;&amp; i := k
         break
      
   if i
      values[i].function.Call()
}

FirstFunc()  {
   ExitApp
}

SecondFunc()  {
   MsgBox, &quot;gg s&quot;
}

closeappp()  {        -- сделаем чтобы с 50% шансом &quot;gg s&quot; запустит или эту 
   MsgBox, &quot;close&quot;
}

msgboxx()  {          --50% или эту функцию.
   MsgBox, &quot;msgboxx&quot;
}

ThirdFunc()  {
   MsgBox, &quot;ss g&quot;
}</code></pre></div><p>Что я имел ввиду из названия темы. <br />Смотрите на код, возможно ли сделать так, чтобы при вводе в поле для ввода ключ.слово &quot;gg s&quot; был шанс 50 на 50 что сработает функция &quot;closeappp&quot; и &quot;msgboxx&quot;<br />Уточняйте если что-то не понятно!!<br />Возможно можно просто сделать не по %, а просто&nbsp; пусть рандомно выбирает функцию!</p>]]></content>
			<author>
				<name><![CDATA[MirchikAhtung]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=38635</uri>
			</author>
			<updated>2018-04-15T07:17:01Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=124710#p124710</id>
		</entry>
</feed>
