<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[QUIK -> DDE &mdash; Автологин в QUIK (на Lua)]]></title>
		<link>https://quik2dde.ru/viewtopic.php?id=80</link>
		<atom:link href="https://quik2dde.ru/extern.php?action=feed&amp;tid=80&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «Автологин в QUIK (на Lua)».]]></description>
		<lastBuildDate>Tue, 27 Jun 2023 15:22:48 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Автологин в QUIK (на Lua)]]></title>
			<link>https://quik2dde.ru/viewtopic.php?pid=4258#p4258</link>
			<description><![CDATA[<p>в коде есть маленькая логическая ошибка.<br />в этой процедуре</p><p>function GetWindowHandle(ClassName,Text) -- Получить дескриптор окна<br />&nbsp; local hWnd=0<br />&nbsp; while true do<br />&nbsp; &nbsp; hWnd=w32.FindWindowEx(0,hWnd,ClassName,Text)<br />&nbsp; &nbsp; if hWnd==0 then break end -- Окно не найдено<br />&nbsp; &nbsp; local ThreadId,ProcessId=w32.GetWindowThreadProcessId(hWnd)<br />&nbsp; &nbsp; if ProcessId==CurrentProcessId then break end -- Окно найдено<br />&nbsp; end<br />&nbsp; return hWnd<br />end</p><p>если есть окно &quot;Логина&quot; в соседнем квике , то этот квик насмерть виснет, а могут и оба.<br />в цикл while добавить sleep, тогда будет нормально.</p>]]></description>
			<author><![CDATA[null@example.com (fldtz4bvkp5b)]]></author>
			<pubDate>Tue, 27 Jun 2023 15:22:48 +0000</pubDate>
			<guid>https://quik2dde.ru/viewtopic.php?pid=4258#p4258</guid>
		</item>
		<item>
			<title><![CDATA[Re: Автологин в QUIK (на Lua)]]></title>
			<link>https://quik2dde.ru/viewtopic.php?pid=3848#p3848</link>
			<description><![CDATA[<p>Я лично не вижу проблем носить 3..5 библиотек рядом. Да хоть 20.<br />Все равно все они (библиотеки) подключаются единообразным образом в любой свой скрипт.<br />Зато это облегчает обновление библиотек раздельно, а не всей одной огромной, где что-то пойдет не та - и тогда всю её придется откатывать, вместе со всем новым функционалом в смысле.</p>]]></description>
			<author><![CDATA[null@example.com (swerg)]]></author>
			<pubDate>Mon, 17 Oct 2022 09:35:12 +0000</pubDate>
			<guid>https://quik2dde.ru/viewtopic.php?pid=3848#p3848</guid>
		</item>
		<item>
			<title><![CDATA[Re: Автологин в QUIK (на Lua)]]></title>
			<link>https://quik2dde.ru/viewtopic.php?pid=3844#p3844</link>
			<description><![CDATA[<p>вопрос риторический)<br />Посмотрел исходники, грустно вздохнул.. Все можно, нужно ли ,решить)</p>]]></description>
			<author><![CDATA[null@example.com (bilobrovandrey)]]></author>
			<pubDate>Sun, 16 Oct 2022 20:44:20 +0000</pubDate>
			<guid>https://quik2dde.ru/viewtopic.php?pid=3844#p3844</guid>
		</item>
		<item>
			<title><![CDATA[Re: Автологин в QUIK (на Lua)]]></title>
			<link>https://quik2dde.ru/viewtopic.php?pid=3802#p3802</link>
			<description><![CDATA[<p><strong>bilobrovandrey</strong>, не совсем мне понятно в каком вы это смысле спрашиваете: в техническом или в юридическом?<br />В любом случае лично я ничего вам запретить не могу <img src="https://quik2dde.ru/img/smilies/smile.png" width="15" height="15" alt="smile" /></p>]]></description>
			<author><![CDATA[null@example.com (swerg)]]></author>
			<pubDate>Mon, 10 Oct 2022 03:45:05 +0000</pubDate>
			<guid>https://quik2dde.ru/viewtopic.php?pid=3802#p3802</guid>
		</item>
		<item>
			<title><![CDATA[Re: Автологин в QUIK (на Lua)]]></title>
			<link>https://quik2dde.ru/viewtopic.php?pid=3800#p3800</link>
			<description><![CDATA[<p>Уважаемый swerg! можно ли объединить функционал этой w32&nbsp; dll cо своей сделанной на дельфи? сейчас хочу&nbsp; сделать&nbsp; автологин с 2 фазовой аутентификацией... Было бы круто подключать 1 длл вместо нескольких.</p>]]></description>
			<author><![CDATA[null@example.com (bilobrovandrey)]]></author>
			<pubDate>Sun, 09 Oct 2022 17:42:15 +0000</pubDate>
			<guid>https://quik2dde.ru/viewtopic.php?pid=3800#p3800</guid>
		</item>
		<item>
			<title><![CDATA[Re: Автологин в QUIK (на Lua)]]></title>
			<link>https://quik2dde.ru/viewtopic.php?pid=3478#p3478</link>
			<description><![CDATA[<p><strong>Skyspirit</strong>, приветствую вас на форуме!</p><div class="quotebox"><cite>Skyspirit пишет:</cite><blockquote><p>Верно понимаю, что он тянет полностью график, а не на 2021 только год?</p></blockquote></div><p>Ничего ниоткуда не &quot;тянется&quot;.<br />В приведённом коде просто явно прописан календарь на 2021 год.<br />Для других годов следует дополнить этот код руками по аналогии с имеющимся.</p>]]></description>
			<author><![CDATA[null@example.com (swerg)]]></author>
			<pubDate>Wed, 11 May 2022 04:50:39 +0000</pubDate>
			<guid>https://quik2dde.ru/viewtopic.php?pid=3478#p3478</guid>
		</item>
		<item>
			<title><![CDATA[Re: Автологин в QUIK (на Lua)]]></title>
			<link>https://quik2dde.ru/viewtopic.php?pid=3477#p3477</link>
			<description><![CDATA[<div class="quotebox"><cite>BlaZed пишет:</cite><blockquote><p>На данный момент пользуюсь таким вариантом скрипта.<br />QUIK 8.12.0.41<br /></p><div class="codebox"><pre><code>-- Автологин терминала QUIK
-- (c) http://quik2dde.ru/
-- Версия: 4.2 (BlaZed Edition)
QUIK_LOGIN=&quot;Логин&quot;     -- Логин
QUIK_PASSW=&quot;Пароль&quot;    -- Пароль

function OnInit()
  local luadir=&quot;x32&quot;
  if(_VERSION==&quot;Lua 5.1&quot;)then luadir=&quot;x64-Lua51&quot; end
  if(_VERSION==&quot;Lua 5.3&quot;)then luadir=&quot;x64-Lua53&quot; end
  if(_VERSION==&quot;Lua 5.4&quot;)then luadir=&quot;x64-Lua54&quot; end
  package.cpath=package.cpath..&quot;;&quot;..getWorkingFolder()..&quot;\\w32\\&quot;..luadir..&quot;\\?.dll&quot;;
  w32 = require(&quot;w32&quot;)
  CurrentProcessId=w32.GetCurrentProcessId()            -- ID процесса QUIK
  QuikMainWindowHandle=GetWindowHandle(&quot;InfoClass&quot;,&quot;&quot;)  -- Дескриптор главного окна QUIK
  if(QuikMainWindowHandle==0) then message(&quot;Дескриптор главного окна QUIK не найден&quot;) return end
  MainWindowText=w32.GetWindowText(QuikMainWindowHandle) -- Текст заголовка главного окна QUIK
  LoginWindowText=&quot;Идентификация пользователя&quot;           -- Текст заголовка окна логина Язык RU (по умолчанию)
  if(string.find(MainWindowText,&quot;version&quot;)~=nil) then LoginWindowText=&quot;User identification&quot; end -- Язык EN
  serv_n=-1 -- Порядковый номер сервера
end
function main()
  is_run = true
  while is_run do
    if(isConnected()==0)then
      if(WorkTime()==true)then QuikConnect() end -- Нажать кнопку &quot;Установить соединение с информационным сервером&quot;
      QuikLogin()                                -- Ввести Логин/Пароль и нажать кнопку &quot;Вход&quot;
      collectgarbage()                           -- Сбор мусора
    else
      serv_n=-1
    end
    sleep(1000)
  end
end
function OnStop()
  is_run=false
  return 100
end

function QuikConnect() -- Нажать кнопку &quot;Установить соединение с информационным сервером&quot;
  w32.PostMessage(QuikMainWindowHandle,w32.WM_COMMAND,100,0)
end
function QuikLogin() -- Ввести Логин/Пароль и нажать кнопку &quot;Вход&quot;
  local hWnd=GetWindowHandle(&quot;#32770&quot;,LoginWindowText) -- Получить дескриптор окна логина QUIK
  if hWnd==0 then return end                           -- Дескриптор не найден, выход
  local hServe=w32.FindWindowEx(hWnd,0,&quot;ComboBox&quot;,&quot;&quot;)  -- Сервер
  local hLogin=w32.FindWindowEx(hWnd,hServe,&quot;Edit&quot;,&quot;&quot;) -- Логин
  local nPassw=w32.FindWindowEx(hWnd,hLogin,&quot;Edit&quot;,&quot;&quot;) -- Пароль
  if(serv_count==nil)then serv_count=w32.SendMessage(hServe,w32.CB_GETCOUNT,0,0) end -- Количество серверов в списке
  if(serv_n&gt;=0)then -- при первой попытке коннект к серверу из последнего соединения, при неудачном коннекте перебор
    serv_n=serv_n%serv_count
    w32.SendMessage(hServe,w32.CB_SETCURSEL,serv_n,0)
  end
  serv_n=serv_n+1
  w32.SetWindowText(hLogin,QUIK_LOGIN)
  w32.SetWindowText(nPassw,QUIK_PASSW)
  w32.PostMessage(hWnd,w32.WM_COMMAND,1,0)
end
function GetWindowHandle(ClassName,Text) -- Получить дескриптор окна
  local hWnd=0
  while true do
    hWnd=w32.FindWindowEx(0,hWnd,ClassName,Text)
    if hWnd==0 then break end -- Окно не найдено
    local ThreadId,ProcessId=w32.GetWindowThreadProcessId(hWnd)
    if ProcessId==CurrentProcessId then break end -- Окно найдено
  end
  return hWnd
end

function WorkTime() -- Возвращает флаг рабочего времени
  local GMT3=10800   -- Часовой пояс биржи GMT+3 Москва (3*60*60=10800 - количество секунд в 3 часах)
  dt=os.date(&quot;!*t&quot;,os.time()+GMT3)
-- Торговый календарь московской биржи
-- 2021 год https://www.moex.com/s3196
-- true - рабочий день, false - не рабочий день, nil - проверяем день недели
  local calendar={[20210101]=false,[20210107]=false,[20210220]=true,[20210223]=false,[20210308]=false,[20210503]=false,[20210510]=false,[20210614]=false,[20211104]=false,[20211231]=false}
  local today=calendar[dt.year*10000+dt.month*100+dt.day]
  if(today==false)or((today==nil)and((dt.wday==1)or(dt.wday==7)))then return false end
  if(dt.hour*60+dt.min&lt;590) then return false end -- Отсекаем время до 9:50 (9*60+50=590 - количество минут с 0:00 до 9:50)
  return true
end</code></pre></div><p><strong>!!! ОБЯЗАТЕЛЬНО К ПРОЧТЕНИЮ !!!</strong><br />Обратите внимание на изменение пути к библиотеке w32.dll</p><p>Чтобы скрипт нашел библиотеку, создаем в папке с квиком папку w32 и распаковываем архив с библиотекой в нее<br />В папке w32 должны появиться подпапки x32, x64-Lua51, x64-Lua53, x64-Lua54, в каждой из них должна находиться w32.dll для нужной версии LUA</p><p>Не забываем из папки с квиком удалить файл w32.dll, если ранее вы туда его помещали.</p></blockquote></div><br /><p>Добрый день. </p><div class="codebox"><pre><code>-- Торговый календарь московской биржи
-- 2021 год https://www.moex.com/s3196
-- true - рабочий день, false - не рабочий день, nil - проверяем день недели
  local calendar={[20210101]=false,[20210107]=false,[20210220]=true,[20210223]=false,[20210308]=false,[20210503]=false,[20210510]=false,[20210614]=false,[20211104]=false,[20211231]=false}
  local today=calendar[dt.year*10000+dt.month*100+dt.day]
  </code></pre></div><p>Немного туплю. Верно понимаю, что он тянет полностью график, а не на 2021 только год? </p><p>Спасибо.</p>]]></description>
			<author><![CDATA[null@example.com (Skyspirit)]]></author>
			<pubDate>Tue, 10 May 2022 05:42:01 +0000</pubDate>
			<guid>https://quik2dde.ru/viewtopic.php?pid=3477#p3477</guid>
		</item>
		<item>
			<title><![CDATA[Re: Автологин в QUIK (на Lua)]]></title>
			<link>https://quik2dde.ru/viewtopic.php?pid=3407#p3407</link>
			<description><![CDATA[<p>С github и его желанием видеть все исходники только в uft8 кодировке - прям беда в самом деле <img src="https://quik2dde.ru/img/smilies/sad.png" width="15" height="15" alt="sad" /><br />Было исследование одного из пользователей форума, где выявлялась система, по которой github все же может корректно &quot;видеть&quot; файлы и в другой кодировке, но определение идет по определённому имени файла, что очень неудобно, конечно для готовых проектов.</p><p><span style="color: #d33"><em><strong>admin:</strong> обсуждение [url=https://quik2dde.ru/viewtopic.php?id=365]про GitHub вынесено в отдельную ветку[/url].</em></span></p>]]></description>
			<author><![CDATA[null@example.com (swerg)]]></author>
			<pubDate>Mon, 10 Jan 2022 05:43:54 +0000</pubDate>
			<guid>https://quik2dde.ru/viewtopic.php?pid=3407#p3407</guid>
		</item>
		<item>
			<title><![CDATA[Re: Автологин в QUIK (на Lua)]]></title>
			<link>https://quik2dde.ru/viewtopic.php?pid=3406#p3406</link>
			<description><![CDATA[<div class="quotebox"><cite>ecoreon пишет:</cite><blockquote><p>Скрипт в сообщении 95 в версии 9.2.2.11 при запуске не заполняет поле &quot;пароль&quot;</p></blockquote></div><p>У меня в версии 9.2.3.15 тоже не работало и как выше написано, помогло изменение кодировка на Windows-1251. Смотрите сообщение 91.</p>]]></description>
			<author><![CDATA[null@example.com (votor)]]></author>
			<pubDate>Sat, 08 Jan 2022 21:20:37 +0000</pubDate>
			<guid>https://quik2dde.ru/viewtopic.php?pid=3406#p3406</guid>
		</item>
		<item>
			<title><![CDATA[Re: Автологин в QUIK (на Lua)]]></title>
			<link>https://quik2dde.ru/viewtopic.php?pid=3361#p3361</link>
			<description><![CDATA[<p>Скрипт в сообщении 95 в версии 9.2.2.11 при запуске не заполняет поле &quot;пароль&quot;</p>]]></description>
			<author><![CDATA[null@example.com (ecoreon)]]></author>
			<pubDate>Mon, 15 Nov 2021 19:44:36 +0000</pubDate>
			<guid>https://quik2dde.ru/viewtopic.php?pid=3361#p3361</guid>
		</item>
		<item>
			<title><![CDATA[Re: Автологин в QUIK (на Lua)]]></title>
			<link>https://quik2dde.ru/viewtopic.php?pid=3015#p3015</link>
			<description><![CDATA[<p><strong>Внимание тем, кто торгует на срочном рынке!</strong><br />С сегодняшнего дня (1.03.2021) срочный рынок на ММВБ открывается ни с 10:00 как было раньше, а с 7:00.<br />Исправьте время подключения в скрипте.</p>]]></description>
			<author><![CDATA[null@example.com (BlaZed)]]></author>
			<pubDate>Mon, 01 Mar 2021 07:09:20 +0000</pubDate>
			<guid>https://quik2dde.ru/viewtopic.php?pid=3015#p3015</guid>
		</item>
		<item>
			<title><![CDATA[Re: Автологин в QUIK (на Lua)]]></title>
			<link>https://quik2dde.ru/viewtopic.php?pid=3014#p3014</link>
			<description><![CDATA[<p>Всем, привет. С третьей попытки поставить новый скрипт все заработало. Спасибо огромное!!!!!</p>]]></description>
			<author><![CDATA[null@example.com (vfu81)]]></author>
			<pubDate>Mon, 01 Mar 2021 07:01:20 +0000</pubDate>
			<guid>https://quik2dde.ru/viewtopic.php?pid=3014#p3014</guid>
		</item>
		<item>
			<title><![CDATA[Re: Автологин в QUIK (на Lua)]]></title>
			<link>https://quik2dde.ru/viewtopic.php?pid=3013#p3013</link>
			<description><![CDATA[<p>Blazed,спасибо помогло</p>]]></description>
			<author><![CDATA[null@example.com (266157921)]]></author>
			<pubDate>Thu, 25 Feb 2021 19:34:17 +0000</pubDate>
			<guid>https://quik2dde.ru/viewtopic.php?pid=3013#p3013</guid>
		</item>
		<item>
			<title><![CDATA[Re: Автологин в QUIK (на Lua)]]></title>
			<link>https://quik2dde.ru/viewtopic.php?pid=3012#p3012</link>
			<description><![CDATA[<p>На данный момент пользуюсь таким вариантом скрипта.<br />QUIK 8.12.0.41<br /></p><div class="codebox"><pre><code>-- Автологин терминала QUIK
-- (c) http://quik2dde.ru/
-- Версия: 4.2 (BlaZed Edition)
QUIK_LOGIN=&quot;Логин&quot;     -- Логин
QUIK_PASSW=&quot;Пароль&quot;    -- Пароль

function OnInit()
  local luadir=&quot;x32&quot;
  if(_VERSION==&quot;Lua 5.1&quot;)then luadir=&quot;x64-Lua51&quot; end
  if(_VERSION==&quot;Lua 5.3&quot;)then luadir=&quot;x64-Lua53&quot; end
  if(_VERSION==&quot;Lua 5.4&quot;)then luadir=&quot;x64-Lua54&quot; end
  package.cpath=package.cpath..&quot;;&quot;..getWorkingFolder()..&quot;\\w32\\&quot;..luadir..&quot;\\?.dll&quot;;
  w32 = require(&quot;w32&quot;)
  CurrentProcessId=w32.GetCurrentProcessId()            -- ID процесса QUIK
  QuikMainWindowHandle=GetWindowHandle(&quot;InfoClass&quot;,&quot;&quot;)  -- Дескриптор главного окна QUIK
  if(QuikMainWindowHandle==0) then message(&quot;Дескриптор главного окна QUIK не найден&quot;) return end
  MainWindowText=w32.GetWindowText(QuikMainWindowHandle) -- Текст заголовка главного окна QUIK
  LoginWindowText=&quot;Идентификация пользователя&quot;           -- Текст заголовка окна логина Язык RU (по умолчанию)
  if(string.find(MainWindowText,&quot;version&quot;)~=nil) then LoginWindowText=&quot;User identification&quot; end -- Язык EN
  serv_n=-1 -- Порядковый номер сервера
end
function main()
  is_run = true
  while is_run do
    if(isConnected()==0)then
      if(WorkTime()==true)then QuikConnect() end -- Нажать кнопку &quot;Установить соединение с информационным сервером&quot;
      QuikLogin()                                -- Ввести Логин/Пароль и нажать кнопку &quot;Вход&quot;
      collectgarbage()                           -- Сбор мусора
    else
      serv_n=-1
    end
    sleep(1000)
  end
end
function OnStop()
  is_run=false
  return 100
end

function QuikConnect() -- Нажать кнопку &quot;Установить соединение с информационным сервером&quot;
  w32.PostMessage(QuikMainWindowHandle,w32.WM_COMMAND,100,0)
end
function QuikLogin() -- Ввести Логин/Пароль и нажать кнопку &quot;Вход&quot;
  local hWnd=GetWindowHandle(&quot;#32770&quot;,LoginWindowText) -- Получить дескриптор окна логина QUIK
  if hWnd==0 then return end                           -- Дескриптор не найден, выход
  local hServe=w32.FindWindowEx(hWnd,0,&quot;ComboBox&quot;,&quot;&quot;)  -- Сервер
  local hLogin=w32.FindWindowEx(hWnd,hServe,&quot;Edit&quot;,&quot;&quot;) -- Логин
  local nPassw=w32.FindWindowEx(hWnd,hLogin,&quot;Edit&quot;,&quot;&quot;) -- Пароль
  if(serv_count==nil)then serv_count=w32.SendMessage(hServe,w32.CB_GETCOUNT,0,0) end -- Количество серверов в списке
  if(serv_n&gt;=0)then -- при первой попытке коннект к серверу из последнего соединения, при неудачном коннекте перебор
    serv_n=serv_n%serv_count
    w32.SendMessage(hServe,w32.CB_SETCURSEL,serv_n,0)
  end
  serv_n=serv_n+1
  w32.SetWindowText(hLogin,QUIK_LOGIN)
  w32.SetWindowText(nPassw,QUIK_PASSW)
  w32.PostMessage(hWnd,w32.WM_COMMAND,1,0)
end
function GetWindowHandle(ClassName,Text) -- Получить дескриптор окна
  local hWnd=0
  while true do
    hWnd=w32.FindWindowEx(0,hWnd,ClassName,Text)
    if hWnd==0 then break end -- Окно не найдено
    local ThreadId,ProcessId=w32.GetWindowThreadProcessId(hWnd)
    if ProcessId==CurrentProcessId then break end -- Окно найдено
  end
  return hWnd
end

function WorkTime() -- Возвращает флаг рабочего времени
  local GMT3=10800   -- Часовой пояс биржи GMT+3 Москва (3*60*60=10800 - количество секунд в 3 часах)
  dt=os.date(&quot;!*t&quot;,os.time()+GMT3)
-- Торговый календарь московской биржи
-- 2021 год https://www.moex.com/s3196
-- true - рабочий день, false - не рабочий день, nil - проверяем день недели
  local calendar={[20210101]=false,[20210107]=false,[20210220]=true,[20210223]=false,[20210308]=false,[20210503]=false,[20210510]=false,[20210614]=false,[20211104]=false,[20211231]=false}
  local today=calendar[dt.year*10000+dt.month*100+dt.day]
  if(today==false)or((today==nil)and((dt.wday==1)or(dt.wday==7)))then return false end
  if(dt.hour*60+dt.min&lt;590) then return false end -- Отсекаем время до 9:50 (9*60+50=590 - количество минут с 0:00 до 9:50)
  return true
end</code></pre></div><p><strong>!!! ОБЯЗАТЕЛЬНО К ПРОЧТЕНИЮ !!!</strong><br />Обратите внимание на изменение пути к библиотеке w32.dll</p><p>Чтобы скрипт нашел библиотеку, создаем в папке с квиком папку w32 и распаковываем архив с библиотекой в нее<br />В папке w32 должны появиться подпапки x32, x64-Lua51, x64-Lua53, x64-Lua54, в каждой из них должна находиться w32.dll для нужной версии LUA</p><p>Не забываем из папки с квиком удалить файл w32.dll, если ранее вы туда его помещали.</p>]]></description>
			<author><![CDATA[null@example.com (BlaZed)]]></author>
			<pubDate>Thu, 25 Feb 2021 19:22:00 +0000</pubDate>
			<guid>https://quik2dde.ru/viewtopic.php?pid=3012#p3012</guid>
		</item>
		<item>
			<title><![CDATA[Re: Автологин в QUIK (на Lua)]]></title>
			<link>https://quik2dde.ru/viewtopic.php?pid=3011#p3011</link>
			<description><![CDATA[<p>подскажите скрипт для квика 8.12 способ с заменой строк не подошел, кнопка всеравно не нажимается</p>]]></description>
			<author><![CDATA[null@example.com (266157921)]]></author>
			<pubDate>Thu, 25 Feb 2021 18:59:08 +0000</pubDate>
			<guid>https://quik2dde.ru/viewtopic.php?pid=3011#p3011</guid>
		</item>
	</channel>
</rss>
