<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; AHK: Как добавить %шанс срабатывания функции? Либо 1 к 5 и.т.д.]]></title>
		<link>https://forum.script-coding.com/viewtopic.php?id=13629</link>
		<atom:link href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=13629&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «AHK: Как добавить %шанс срабатывания функции? Либо 1 к 5 и.т.д.».]]></description>
		<lastBuildDate>Sun, 15 Apr 2018 07:17:01 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[AHK: Как добавить %шанс срабатывания функции? Либо 1 к 5 и.т.д.]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=124710#p124710</link>
			<description><![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>]]></description>
			<author><![CDATA[null@example.com (MirchikAhtung)]]></author>
			<pubDate>Sun, 15 Apr 2018 07:17:01 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=124710#p124710</guid>
		</item>
	</channel>
</rss>
