[INTERFACE]
DIALOG, "Загрузка Cookies", 353, 134;
STATIC, "Название Cookies", 8, 8, 96, 20;
EDIT, 108, 8, 236, 20, string C;
STATIC, "Максимальное время обновления страницы", 8, 32, 232, 20;
EDIT, 244, 32, 100, 20, int Tim;
STATIC, "Использовать возврат в переменную", 8, 56, 200, 20;
EDIT_WRITE_RETURN, 212, 56, 132, 20, int Return;
BUTTON_OK, "Принять", 136, 80, 100, 24;
BUTTON_CANCEL, "Закрыть", 244, 80, 100, 24;
[END]
[APPEARANCE]
COLOR = 0, 100, 255;
SIZE_X = 8;
SIZE_Y =4;
[END]

[INFO]
[ENDL]>>C>>[ENDL]>>Return
[END]

[ASSOC_VAR]
C="MyCookies";
Tim=10;
Return=;
[END]

[GLOBAL_VAR]
int Import_Cookies=0;
int ~Return~;
[END]


[FUNCTION_BODY]function(string Cookies, int Time)
{
  if (Import_Cookies==0)  
  {  
  Import_Cookies=1; 
  __python_sync
#Импорт
import pickle
__end_python    
  }
Cookies=pathfolder()+Cookies+".pkl";
sendgetpython("name_cookies = r^""+Cookies+"^"");
sendgetpython("Time = r^'"+format(Time)+"^'");
__python
print(1)
web.delete_all_cookies()
cookies = pickle.load(open(name_cookies, "rb"))
__end_python
sleep(100);
looptime(1000){if (getpython()=="1") goto d; sleep(10);}
return -1;
d:;
__python_sync
for cookie in cookies:
    web.add_cookie(cookie)

#Максимальное время на обновление страницы
web.set_page_load_timeout(Time)
#Обновляем страницу
try:
    web.refresh()
except TimeoutException as e:
__end_python
sendpython("    print(^'0^')^n^nprint(^'1^')^n");
string Rez="ERROR_READ_PYTHON";
  while (Rez=="ERROR_READ_PYTHON")
  {
  Rez=getpython();
  sleep(10);
  }
if (Rez=="1") return 1;
else return 0; 
}
[END]

[CALL]
(C, Tim)
[END]

[FUNCTION_LOGIC]  
>0
[END]