Кто понимает в AHK, гляньте. Тут код интересный

Статус
В этой теме нельзя размещать новые ответы.

serhiyrubin

Известный
Автор темы
396
106
Вот скрипт который в нужное время [Час:Минуты:Секунды] отправляет сообщение в чат сампа
Может кто сделать чтобы я с этим скриптом в игре ввел например /timer /unload 10:49:12
И потом в заданое время отправляется команда /unload
Гляньте код, вроде оно и с секундами работает
Просто я в АХК биндеры создавать ток могу xD
Код:
#include samp.ahk
GetUTC10() {
    WebRequest := ComObjCreate("WinHttp.WinHttpRequest.5.1")
    WebRequest.Open("GET", "http://www.unn.ru/time/")
    WebRequest.Send()
    return RegExReplace(WebRequest.ResponseText, ".*.*<div.*servertime. >\n(.*).......<d.*", "$1")
}
mmtime = % GetUTC10()
    SelectedFile = %A_ScriptDir%\STRINGS\1 string.txt
    FileReadLine, 1str, %SelectedFile%, 1
MyTime1= %mmtime%
MyTime2= %mmtime%
MyTime3= %mmtime%
MyTime4= %mmtime%
Gui, Add, Edit, x16 y10 w300 h20 vMyEdit11, %1str%
Gui, Add, Edit, x16 y40 w300 h20 vMyEdit12, 2 строка
Gui, Add, Edit, x16 y70 w300 h20 vMyEdit13, 3 строка
Gui, Add, Button, x326 y70 w90 h20 g1save, Сохранить
Gui, Add, Button, x326 y40 w90 h20 g1Open, Обзор
Gui, Add, Text, +center x16 y95, -----------------------------------------------------------------------------------------------------------------------------
Gui, Add, Edit, x16 y110 w300 h20 vMyEdit21, %1str%
Gui, Add, Edit, x16 y140 w300 h20 vMyEdit22, 2 строка
Gui, Add, Edit, x16 y170 w300 h20 vMyEdit23, 3 строка
Gui, Add, Button, x326 y170 w90 h20 g2save, Сохранить
Gui, Add, Button, x326 y140 w90 h20 g2Open, Обзор
Gui, Add, Text, +center x16 y195, -----------------------------------------------------------------------------------------------------------------------------
Gui, Add, Edit, x16 y210 w300 h20 vMyEdit31, %1str%
Gui, Add, Edit, x16 y240 w300 h20 vMyEdit32, 2 строка
Gui, Add, Edit, x16 y270 w300 h20 vMyEdit33, 3 строка
Gui, Add, Edit, x16 y310 w300 h20 vMyEdit4, 1 строка
Gui, Add, Button, x326 y270 w90 h20 g3save, Сохранить
Gui, Add, Button, x326 y240 w90 h20 g3Open, Обзор
Gui, Add, Text, +center x16 y295, -----------------------------------------------------------------------------------------------------------------------------
Gui, Add, Button, x326 y370 w90 h20 g1MyButton, Старт
Gui, Add, Button, x326 y335 w90 h20 g4Open, Обзор
Gui, Add, Button, x226 y335 w90 h20 g4save, Сохранить
Gui, Add, Text, vClock +right x246  y395, XXXXXXXXXХХХХХХХХХХХХХХХХХ
Gui, Add, Text, vClock1 +right x246  y410, XXXXXXXXXХХХХХХХХХXХХХХХХХ
Gui, Add, Text, +Left x16  y410, By Avram_Stivenson
Gui, Add, Edit, x326 y10 w90 h20 vMyTime1, %MyTime1%
Gui, Add, Edit, x326 y110 w90 h20 vMyTime2, %MyTime2%
Gui, Add, Edit, x326 y210 w90 h20 vMyTime3, %MyTime3%
Gui, Add, Edit, x326 y310 w90 h20 vMyTime4, %MyTime4%
Gui, Add, Text, +center x16 y355, -----------------------------------------------------------------------------------------------------------------------------
SetTimer, UpdateOSD, 500

Gosub, UpdateOSD ;

Gui, Show, x380 y240 h436 w430 ,, Gnews by A.Stivenson

UpdateOSD:
FormatTime, TimeString,,Ваше время HH:mm:ss
GuiControl,, Clock, %TimeString%
GetUTC() {
    WebRequest := ComObjCreate("WinHttp.WinHttpRequest.5.1")
    WebRequest.Open("GET", "http://www.unn.ru/time/")
    WebRequest.Send()
    return RegExReplace(WebRequest.ResponseText, ".*.*<div.*servertime. >\n(.*).......<d.*", "$1")
}
mtime = % GetUTC()
TimeString1 = Время на сервере %mtime%
GuiControl,, Clock1, %TimeString1%
return


;---------\ open 1 \ ---------

1Open:
FileSelectFile, SelectedFile, 3, , Open a file, Text Documents (*.txt)
if SelectedFile =
    MsgBox, The user didn't select anything.
else
    FileReadLine, 2str, %SelectedFile%, 1
    GuiControl,, MyEdit12, %2str%
       FileReadLine, 3str, %SelectedFile%, 2
    GuiControl,, MyEdit13, %3str%
return



;---------\ open 2 \ ---------

2Open:
FileSelectFile, SelectedFile, 3, , Open a file, Text Documents (*.txt)
if SelectedFile =
    MsgBox, The user didn't select anything.
else
    FileReadLine, 2str, %SelectedFile%, 1
    GuiControl,, MyEdit22, %2str%
    FileReadLine, 3str, %SelectedFile%, 2
    GuiControl,, MyEdit23, %3str%
return

;---------\ open 3 \ ---------

3Open:
FileSelectFile, SelectedFile, 3, , Open a file, Text Documents (*.txt)
if SelectedFile =
    MsgBox, The user didn't select anything.
else
    FileReadLine, 2str, %SelectedFile%, 1
    GuiControl,, MyEdit32, %2str%
    FileReadLine, 3str, %SelectedFile%, 2
    GuiControl,, MyEdit33, %3str%
return

;---------\ open 4 \ ---------

4Open:
FileSelectFile, SelectedFile, 3, , Open a file, Text Documents (*.txt)
if SelectedFile =
    MsgBox, The user didn't select anything.
else
    FileReadLine, 2str, %SelectedFile%, 1
    GuiControl,, MyEdit4, %2str%
return


;---------\ Save 1 \ ---------

1save:
FileSelectFile, SelectedFile, 3, , Save a file, Text Documents (*.txt)
if SelectedFile =
    MsgBox, The user didn't select anything.
else
    GuiControlGet, MyEdit12
    GuiControlGet, MyEdit13
    me12 = % MyEdit12
    me13 = % MyEdit13
    FSave1 = %me12%`n%me13%
    FileDelete, %SelectedFile%
    FileAppend, %FSave1%, %SelectedFile%
return

;---------\ Save 2 \ ---------

2save:
FileSelectFile, SelectedFile, 3, , Save a file, Text Documents (*.txt)
if SelectedFile =
    MsgBox, The user didn't select anything.
else
    GuiControlGet, MyEdit22
    GuiControlGet, MyEdit23
    me22 = % MyEdit22
    me23 = % MyEdit23
    FSave2 = %me22%`n%me23%
    FileDelete, %SelectedFile%
    FileAppend, %FSave2%, %SelectedFile%
return

ctime = %TimeString%
;---------\ Save 3 \ ---------

3save:
FileSelectFile, SelectedFile, 3, , Save a file, Text Documents (*.txt)
if SelectedFile =
    MsgBox, The user didn't select anything.
else
    GuiControlGet, MyEdit32
    GuiControlGet, MyEdit33
    me32 = % MyEdit32
    me33 = % MyEdit33
    FSave3 = %me32%`n%me33%
    FileDelete, %SelectedFile%
    FileAppend, %FSave3%, %SelectedFile%
return

;---------\ Save 4 \ ---------

4save:
FileSelectFile, SelectedFile, 3, , Save a file, Text Documents (*.txt)
if SelectedFile =
    MsgBox, The user didn't select anything.
else
    GuiControlGet, MyEdit4
    me4 = % MyEdit4
    FSave4 = %me4%
    FileDelete, %SelectedFile%
    FileAppend, %FSave4%, %SelectedFile%
return

ctime = %TimeString%

;sleep, 1000

;---------\ Start 1 \ ---------

1MyButton:
loop
{
GuiControlGet, MyTime1
GuiControlGet, MyEdit11
GuiControlGet, MyEdit12
GuiControlGet, MyEdit13
GuiControlGet, MyTime2
GuiControlGet, MyEdit21
GuiControlGet, MyEdit22
GuiControlGet, MyEdit23
GuiControlGet, MyTime3
GuiControlGet, MyEdit31
GuiControlGet, MyEdit32
GuiControlGet, MyEdit33
GuiControlGet, MyTime4
GuiControlGet, MyEdit4
t1= % MyTime1
me11 = % MyEdit11
me12 = % MyEdit12
me13 = % MyEdit13
t2= % MyTime2
me21 = % MyEdit21
me22 = % MyEdit22
me23 = % MyEdit23
t3= % MyTime3
me31 = % MyEdit31
me32 = % MyEdit32
me33 = % MyEdit33
t4= % MyTime4
me4 = % MyEdit4
me1 = /gnews %me11%`n/gnews %me12%`n/gnews %me13%`n
me2 = /gnews %me21%`n/gnews %me22%`n/gnews %me23%`n
me3 = /gnews %me31%`n/gnews %me32%`n/gnews %me33%`n
me4 = /gnews %me4%`n
GetUTC1() {
    WebRequest := ComObjCreate("WinHttp.WinHttpRequest.5.1")
    WebRequest.Open("GET", "http://www.unn.ru/time/")
    WebRequest.Send()
    return RegExReplace(WebRequest.ResponseText, ".*.*<div.*servertime. >\n(.*).......<d.*", "$1")
}
Flag=0
d1= % GetUTC1()
if t1 not contains %mmtime%
    {
      if t1 contains %d1%
       {
        SoundPlay, %A_WinDir%\Media\ding.wav
        sleep, 1000
        SoundPlay, %A_WinDir%\Media\ding.wav
        sleep, 1000
        SoundPlay, %A_WinDir%\Media\ding.wav
        sleep, 500
        SoundPlay, %A_WinDir%\Media\ding.wav
        sleep, 500
        SoundPlay, %A_WinDir%\Media\ringin.wav
        ;MsgBox, %me1%
        FileDelete, %A_ScriptDir%\STRINGS\1gnews.txt
        Loop
        {
            FileReadLine, line, %A_ScriptDir%\STRINGS\Otigrovka do.txt, %A_Index%
            if ErrorLevel
                break

            FileAppend,%line%`n, %A_ScriptDir%\STRINGS\1gnews.txt 
        }
        FileAppend,%me1%, %A_ScriptDir%\STRINGS\1gnews.txt
        Loop
        {
            FileReadLine, line, %A_ScriptDir%\STRINGS\Otigrovka posle.txt, %A_Index%
            if ErrorLevel
                break

            FileAppend,%line%`n, %A_ScriptDir%\STRINGS\1gnews.txt 
        }
        Loop
        {
            FileReadLine, line, %A_ScriptDir%\STRINGS\1gnews.txt, %A_Index%
            if ErrorLevel
                break

                sendchat(line)
                sleep, 3000
        }
        GuiControl,, MyTime1, %mmtime%
        }
        flag=1
    }
if t2 not contains %mmtime%
    {
    if t2 contains %d1%
        {
        SoundPlay, %A_WinDir%\Media\ding.wav
        sleep, 1000
        SoundPlay, %A_WinDir%\Media\ding.wav
        sleep, 1000
        SoundPlay, %A_WinDir%\Media\ding.wav
        sleep, 500
        SoundPlay, %A_WinDir%\Media\ding.wav
        sleep, 500
        SoundPlay, %A_WinDir%\Media\ringin.wav
        ;MsgBox, %me1%
        FileDelete, %A_ScriptDir%\STRINGS\2gnews.txt
        Loop
        {
            FileReadLine, line, %A_ScriptDir%\STRINGS\Otigrovka do.txt, %A_Index%
            if ErrorLevel
                break

            FileAppend,%line%`n, %A_ScriptDir%\STRINGS\2gnews.txt 
        }
        FileAppend,%me2%, %A_ScriptDir%\STRINGS\2gnews.txt
        Loop
        {
            FileReadLine, line, %A_ScriptDir%\STRINGS\Otigrovka posle.txt, %A_Index%
            if ErrorLevel
                break

            FileAppend,%line%`n, %A_ScriptDir%\STRINGS\2gnews.txt 
        }
        Loop
        {
            FileReadLine, line, %A_ScriptDir%\STRINGS\2gnews.txt, %A_Index%
            if ErrorLevel
                break

                sendchat(line)
                sleep, 3000
        }
        GuiControl,, MyTime2, %mmtime%
        }
        flag=1
    }
if t3 not contains %mmtime%
    {
    if t3 contains %d1%
        {
        SoundPlay, %A_WinDir%\Media\ding.wav
        sleep, 1000
        SoundPlay, %A_WinDir%\Media\ding.wav
        sleep, 1000
        SoundPlay, %A_WinDir%\Media\ding.wav
        sleep, 500
        SoundPlay, %A_WinDir%\Media\ding.wav
        sleep, 500
        SoundPlay, %A_WinDir%\Media\ringin.wav
        ;MsgBox, %me1%
        FileDelete, %A_ScriptDir%\STRINGS\3gnews.txt
        Loop
        {
            FileReadLine, line, %A_ScriptDir%\STRINGS\Otigrovka do.txt, %A_Index%
            if ErrorLevel
                break

            FileAppend,%line%`n, %A_ScriptDir%\STRINGS\3gnews.txt 
        }
        FileAppend,%me3%, %A_ScriptDir%\STRINGS\3gnews.txt
        Loop
        {
            FileReadLine, line, %A_ScriptDir%\STRINGS\Otigrovka posle.txt, %A_Index%
            if ErrorLevel
                break

            FileAppend,%line%`n, %A_ScriptDir%\STRINGS\3gnews.txt 
        }
        Loop
        {
            FileReadLine, line, %A_ScriptDir%\STRINGS\3gnews.txt, %A_Index%
            if ErrorLevel
                break

                sendchat(line)
                sleep, 3000
        }
        GuiControl,, MyTime3, %mmtime%
        }
        flag=1
    }
if t4 not contains %mmtime%
    {
    if t4 contains %d1%
        {
        SoundPlay, %A_WinDir%\Media\ding.wav
        sleep, 1000
        SoundPlay, %A_WinDir%\Media\ding.wav
        sleep, 1000
        SoundPlay, %A_WinDir%\Media\ding.wav
        sleep, 500
        SoundPlay, %A_WinDir%\Media\ding.wav
        sleep, 500
        SoundPlay, %A_WinDir%\Media\ringin.wav
        ;MsgBox, %me1%
        FileDelete, %A_ScriptDir%\STRINGS\4gnews.txt
        Loop
        {
            FileReadLine, line, %A_ScriptDir%\STRINGS\Otigrovka do.txt, %A_Index%
            if ErrorLevel
                break

            FileAppend,%line%`n, %A_ScriptDir%\STRINGS\4gnews.txt 
        }
        FileAppend,%me4%, %A_ScriptDir%\STRINGS\4gnews.txt
        Loop
        {
            FileReadLine, line, %A_ScriptDir%\STRINGS\Otigrovka posle.txt, %A_Index%
            if ErrorLevel
                break

            FileAppend,%line%`n, %A_ScriptDir%\STRINGS\4gnews.txt 
        }
        Loop
        {
            FileReadLine, line, %A_ScriptDir%\STRINGS\4gnews.txt, %A_Index%
            if ErrorLevel
                break

                sendchat(line)
                sleep, 3000
        }
        GuiControl,, MyTime4, %mmtime%
        }
        flag=1
    }
sleep, 500
if flago in 0
{
return
}
}




return

GuiClose:
ExitApp
 

RellaX

Известный
80
9
ну не

ну да

Код:
#Persistent
#IfWinActive GTA:SA:MP

Loop
{
   if (A_Hour==unhour and A_Min==unmin and A_Sec==unsec)
   {
      Чё то тут должно произойти, когда наступит указанное время
   }
}
Return

$~Enter::
if (isInChat()=="1" and isDialogOpen()=="0")
{
    Sleep 250
    dwAddress := dwSAMP + 0x12D8F8
    text := readString(hGTA, dwAddress, 256)
    if RegExMatch(text, "^/unload\s([0-9]{2}.*):([0-9]{2}.*):([0-9]{2}.*)", timeunl) ; в чате сампа: /unload 00:00:00
    {
        unhour = %timeunl1%
        unmin = %timeunl2%
        unsec = %timeunl3%
    }
}
Return
 

serhiyrubin

Известный
Автор темы
396
106
ну не


ну да

Код:
#Persistent
#IfWinActive GTA:SA:MP

Loop
{
   if (A_Hour==unhour and A_Min==unmin and A_Sec==unsec)
   {
      Чё то тут должно произойти, когда наступит указанное время
   }
}
Return

$~Enter::
if (isInChat()=="1" and isDialogOpen()=="0")
{
    Sleep 250
    dwAddress := dwSAMP + 0x12D8F8
    text := readString(hGTA, dwAddress, 256)
    if RegExMatch(text, "^/unload\s([0-9]{2}.*):([0-9]{2}.*):([0-9]{2}.*)", timeunl) ; в чате сампа: /unload 00:00:00
    {
        unhour = %timeunl1%
        unmin = %timeunl2%
        unsec = %timeunl3%
    }
}
Return


Спасибо большое!
Все работает)
 
Статус
В этой теме нельзя размещать новые ответы.