[AHK] Взаимодействие с диалогом

qqerty

Новичок
Автор темы
11
0
Почему при открытие 1 диалога работает {Enter} , а при переходе на 2 диалог при нажатии {Enter} - ничего не происходит?


Код:
#IfWinActive, GTA:SA:MP
!F3::
a:=1
menu:=1
myid := getId()
mynick := getUsername()
ShowDialog("2", "Помощь", "{0066ff}Меню для проведения мероприятий`n{ffff66}Последний диалог с победителем`n{bf4040}F.A.Q - по ахк для мп","Закрыть")
return
~UP::
if a>1
{
    a:=a-1
}
return
~Down::
if a<b
{
    a:=a+1
}
return
~Enter::
Sleep, 500
if (menu==1) {
    punk:="label"+a
    Gosub, %punk%
    menu:=0
}
return
label1:
{
ShowDialog("2", "Помощник в МП от Фиста", "{0000FF}[1]{58FA58}Мероприятие 'Обстрел'`n{0000FF}[2]{58FA58}Мероприятие 'Прятки на Корабле'`n{0000FF}[3]{F78181}Мероприятие 'Русская Рулетка'`n{0000FF}[4]{F78181}Мероприятие 'Перестрелка'`n{0000FF}[5]{F78181}Мероприятие 'Поливалка'`n{0000FF}[6]{00FFFF}Мероприятие 'Давка'`n{0000FF}[7]{FFFF00}Мероприятие 'Золотой Гонщий'","Закрыть")
return

label4:
loop, 1{
    targ:=getId() 
    SendChat("/plveh "targ " 425 1 ")
         Sleep 5000
     SendChat("/eventmenu")
    Send,{Enter}
         Sleep 500
    Send,{down}{Enter}
         Sleep 500
         Send,{down}{Enter}
         Sleep 500
    PostMessage, 0x50,, 0x4190419,, A
    SendInput,Сейчас пройдет МП "Обстрел".Желающим поучаствовать /готп{enter}
         Sleep 500
    Send, {down}{down}{Enter}0
         Sleep 500
    SendMessage, 0x50,, 0x4190419,, A
    SendInput,100{Enter}
         Sleep 500
    Send, {down}{down}{down}{Enter}
         Sleep 500
    SendMessage, 0x50,, 0x4190419,, A
    SendInput,0{Enter}
         Sleep 500
    Send, {down}{down}{down}{down}{down}{down}{Enter}
         Sleep 500
    SendMessage, 0x50,, 0x4190419,, A
    SendInput,50{Enter}
         Sleep 500
          Send, {down}{down}{down}{down}{down}{down}{down}{Enter}
         Sleep 500
    SendMessage, 0x50,, 0x4190419,, A
    SendInput,30{Enter}
         Sleep 500
          Send, {down}{down}{down}{down}{down}{down}{down}{down}{Enter}
         Sleep 500
    SendChat("/ao Сейчас пройдет МП 'Обстрел' на 100.000$. Всем желающим поучаствовать /готп")
         Sleep 30000
    SendChat("/azakon 50")
          Sleep 1000
    SendChat("/hpall 100")
          Sleep 1000
    SendChat("/smp Вы попали на мероприятие 'Обстрел'. мероприятие идет до 1 игрока.")
         Sleep 3000
    SendChat("/smp Запрещено использовать : Аптечки , броник , маску.")
         Sleep 3000
    SendChat("/smp Начали!") 
         Sleep 3000
    addchatmsg("{F20B0B}Удачного мероприятия!.")
    reload   
}
return
label5:
loop, 1{
    SendChat("/eventmenu")
    Send,{Enter}
         Sleep 1000
    Send,{down}{Enter}
         Sleep 1000
         Send,{down}{Enter}
         Sleep 1000
    PostMessage, 0x50,, 0x4190419,, A
    SendInput,Сейчас пройдет МП "Прятки на Корабле".Желающим поучаствовать /готп{enter}
         Sleep 1000
    Send, {down}{down}{Enter}0
         Sleep 1000
    SendMessage, 0x50,, 0x4190419,, A
    SendInput,100{Enter}
         Sleep 1000
    Send, {down}{down}{down}{Enter}
         Sleep 1000
    SendMessage, 0x50,, 0x4190419,, A
    SendInput,0{Enter}
         Sleep 1000
    Send, {down}{down}{down}{down}{down}{down}{Enter}
         Sleep 1000
    SendMessage, 0x50,, 0x4190419,, A
    SendInput,30{Enter}
         Sleep 1000
          Send, {down}{down}{down}{down}{down}{down}{down}{Enter}
         Sleep 1000
    SendMessage, 0x50,, 0x4190419,, A
    SendInput,30{Enter}
         Sleep 1000
          Send, {down}{down}{down}{down}{down}{down}{down}{down}{Enter}
         Sleep 1000
    SendChat("/ao Сейчас пройдет МП 'Прятки на Корабле' на 100.000$. Всем желающим поучаствовать /готп")
         Sleep 20000
    SendChat("/smp Делаем строй, кого нет - кик!")
         Sleep 2000
    SendChat("/smp Делаем строй, кого нет - кик!")
         Sleep 2000
    SendChat("/smp Делаем строй, кого нет - кик!")
         Sleep 2000
    SendChat("/smp Делаем строй, кого нет - кик!")
         Sleep 2000
    SendChat("/smp Делаем строй, кого нет - кик!")
         Sleep 2000
    SendChat("/smp Делаем строй, кого нет - кик!")
         Sleep 2000
    SendChat("/smp Делаем строй, кого нет - кик!")
         Sleep 2000
    SendChat("/smp Делаем строй, кого нет - кик!")
         Sleep 2000
    SendChat("/freezeall 50")
          Sleep 1000
    SendChat("/azakon 50")
          Sleep 1000
    SendChat("/hpall 100")
          Sleep 1000
    SendChat("/smp Вы попали на мероприятие 'Прятки на Корабле'. мероприятие идет до 1 игрока.")
         Sleep 3000
    SendChat("/smp Запрещено использовать : Аптечки , броник , маску.")
         Sleep 1000
    SendChat("/unfreezeall 50")
         Sleep 3000
    SendChat("/smp Начали!")   
         Sleep 3000
    addchatmsg("{F20B0B}Удачного мероприятия!.")
    reload
}
return
label6:
loop, 1{
    SendChat("/eventmenu")
    Send,{Enter}
         Sleep 1000
    Send,{down}{Enter}
         Sleep 1000
         Send,{down}{Enter}
         Sleep 1000
    PostMessage, 0x50,, 0x4190419,, A
    SendInput,Сейчас пройдет МП "Русская Рулетка".Желающим поучаствовать /готп{enter}
         Sleep 1000
    Send, {down}{down}{Enter}0
         Sleep 1000
    SendMessage, 0x50,, 0x4190419,, A
    SendInput,100{Enter}
         Sleep 1000
    Send, {down}{down}{down}{Enter}
         Sleep 1000
    SendMessage, 0x50,, 0x4190419,, A
    SendInput,0{Enter}
         Sleep 1000
    Send, {down}{down}{down}{down}{down}{down}{Enter}
         Sleep 1000
    SendMessage, 0x50,, 0x4190419,, A
    SendInput,30{Enter}
         Sleep 1000
          Send, {down}{down}{down}{down}{down}{down}{down}{Enter}
         Sleep 1000
    SendMessage, 0x50,, 0x4190419,, A
    SendInput,30{Enter}
         Sleep 1000
          Send, {down}{down}{down}{down}{down}{down}{down}{down}{Enter}
         Sleep 1000
    SendChat("/ao Сейчас пройдет МП 'Русская Рулетка' на 100.000$. Всем желающим поучаствовать /готп")
         Sleep 20000
    SendChat("/smp Делаем строй, кого нет - кик!")
         Sleep 2000
    SendChat("/smp Делаем строй, кого нет - кик!")
         Sleep 2000
    SendChat("/smp Делаем строй, кого нет - кик!")
         Sleep 2000
    SendChat("/smp Делаем строй, кого нет - кик!")
         Sleep 2000
    SendChat("/smp Делаем строй, кого нет - кик!")
         Sleep 2000
    SendChat("/smp Делаем строй, кого нет - кик!")
         Sleep 2000
    SendChat("/smp Делаем строй, кого нет - кик!")
         Sleep 2000
    SendChat("/smp Делаем строй, кого нет - кик!")
         Sleep 2000
    SendChat("/freezeall 50")
          Sleep 1000
    SendChat("/azakon 50")
          Sleep 1000
    SendChat("/hpall 100")
          Sleep 1000
    SendChat("/smp Вы попали на мероприятие 'Русская Рулетка'. мероприятие идет до 1 игрока.")
         Sleep 3000
    SendChat("/smp Запрещено использовать : Аптечки , броник , маску.")
         Sleep 3000
    SendChat("/smp Начали!")   
         Sleep 3000
    addchatmsg("{F20B0B}Удачного мероприятия!.")
    reload
}
return
label7:
loop, 1{
  
    SendChat("/eventmenu")
    Send,{Enter}
         Sleep 1000
    Send,{down}{Enter}
         Sleep 1000
         Send,{down}{Enter}
         Sleep 1000
    PostMessage, 0x50,, 0x4190419,, A
    SendInput,Сейчас пройдет МП "Перестрелка".Желающим поучаствовать /готп{enter}
         Sleep 1000
    Send, {down}{down}{Enter}0
         Sleep 1000
    SendMessage, 0x50,, 0x4190419,, A
    SendInput,100{Enter}
         Sleep 1000
    Send, {down}{down}{down}{Enter}
         Sleep 1000
    SendMessage, 0x50,, 0x4190419,, A
    SendInput,100{Enter}
         Sleep 1000
    Send, {down}{down}{down}{down}{down}{down}{Enter}
         Sleep 1000
    SendMessage, 0x50,, 0x4190419,, A
    SendInput,50{Enter}
         Sleep 1000
          Send, {down}{down}{down}{down}{down}{down}{down}{Enter}
         Sleep 1000
    SendMessage, 0x50,, 0x4190419,, A
    SendInput,30{Enter}
         Sleep 1000
          Send, {down}{down}{down}{down}{down}{down}{down}{down}{Enter}
         Sleep 1000
    SendChat("/ao Сейчас пройдет МП 'Перестрелка' на 100.000$. Всем желающим поучаствовать /готп")
          Sleep 30000
    SendChat("/azakon 50")
          Sleep 1000
    SendChat("/hpall 100")
          Sleep 1000
    SendChat("/armourall 100")
          Sleep 1000    
    SendChat("/smp Вы попали на мероприятие 'Перестрелка'. мероприятие идет до 1 игрока.")
         Sleep 3000
    SendChat("/smp Запрещено использовать : Аптечки , броник , маску.")
         Sleep 1000
    SendChat("/freezeall 50")
         Sleep 1000
    SendChat("/gunall 100 24 500")
         Sleep 1000
    SendChat("/gunall 100 31 500")
         Sleep 1000
    SendChat("/gunall 100 31 500")
         Sleep 3000
    SendChat("/unfreezeall 50")
         Sleep 1000
    SendChat("/smp Начали!")   
         Sleep 3000
    addchatmsg("{F20B0B}Удачного мероприятия!.")
    reload
}
return
label8:
loop, 1{
   targ:=getId() 
    SendChat("/plveh "targ " 601 1 ")
    Sleep 2000
    SendChat("/eventmenu")
    Send,{Enter}
         Sleep 1000
    Send,{down}{Enter}
         Sleep 1000
         Send,{down}{Enter}
         Sleep 1000
    PostMessage, 0x50,, 0x4190419,, A
    SendInput,Сейчас пройдет МП "Поливалка".Желающим поучаствовать /готп{enter}
         Sleep 1000
    Send, {down}{down}{Enter}0
         Sleep 1000
    SendMessage, 0x50,, 0x4190419,, A
    SendInput,100{Enter}
         Sleep 1000
    Send, {down}{down}{down}{Enter}
         Sleep 1000
    SendMessage, 0x50,, 0x4190419,, A
    SendInput,0{Enter}
         Sleep 1000
    Send, {down}{down}{down}{down}{down}{down}{Enter}
         Sleep 1000
    SendMessage, 0x50,, 0x4190419,, A
    SendInput,30{Enter}
         Sleep 1000
          Send, {down}{down}{down}{down}{down}{down}{down}{Enter}
         Sleep 1000
    SendMessage, 0x50,, 0x4190419,, A
    SendInput,30{Enter}
         Sleep 1000
          Send, {down}{down}{down}{down}{down}{down}{down}{down}{Enter}
         Sleep 1000
    SendChat("/ao Сейчас пройдет МП 'Поливалка' на 100.000$. Всем желающим поучаствовать /готп")
          Sleep 30000
    SendChat("/azakon 50")
          Sleep 1000
    SendChat("/hpall 100")
          Sleep 1000
    SendChat("/smp Вы попали на мероприятие 'Поливалка'. мероприятие идет до 1 игрока.")
         Sleep 3000
    SendChat("/smp Запрещено использовать : Аптечки , броник , маску.")
         Sleep 1000
    SendChat("/smp Начали!")   
         Sleep 3000
    addchatmsg("{F20B0B}Удачного мероприятия!.")
    reload
}
label9:
loop, 1{
   targ:=getId() 
    SendChat("/plveh "targ " 577 1 ")
    Sleep 2000
    SendChat("/eventmenu")
    Send,{Enter}
         Sleep 1000
    Send,{down}{Enter}
         Sleep 1000
         Send,{down}{Enter}
         Sleep 1000
    PostMessage, 0x50,, 0x4190419,, A
    SendInput,Сейчас пройдет МП "Давка".Желающим поучаствовать /готп{enter}
         Sleep 1000
    Send, {down}{down}{Enter}0
         Sleep 1000
    SendMessage, 0x50,, 0x4190419,, A
    SendInput,100{Enter}
         Sleep 1000
    Send, {down}{down}{down}{Enter}
         Sleep 1000
    SendMessage, 0x50,, 0x4190419,, A
    SendInput,0{Enter}
         Sleep 1000
    Send, {down}{down}{down}{down}{down}{down}{Enter}
         Sleep 1000
    SendMessage, 0x50,, 0x4190419,, A
    SendInput,30{Enter}
         Sleep 1000
          Send, {down}{down}{down}{down}{down}{down}{down}{Enter}
         Sleep 1000
    SendMessage, 0x50,, 0x4190419,, A
    SendInput,30{Enter}
         Sleep 1000
          Send, {down}{down}{down}{down}{down}{down}{down}{down}{Enter}
         Sleep 1000
    SendChat("/ao Сейчас пройдет МП 'Давка' на 100.000$. Всем желающим поучаствовать /готп")
          Sleep 30000
    SendChat("/azakon 50")
          Sleep 1000
    SendChat("/hpall 100")
          Sleep 1000
    SendChat("/smp Вы попали на мероприятие 'Давка'. мероприятие идет до 1 игрока.")
         Sleep 3000
    SendChat("/smp Запрещено использовать : Аптечки , броник , маску.")
         Sleep 1000
    SendChat("/smp Начали!")   
         Sleep 3000
    addchatmsg("{F20B0B}Удачного мероприятия!.")
    reload
}
label10:
loop, 1{
   targ:=getId() 
    SendChat("/plveh "targ " 411 1 ")
         Sleep 2000
     SendChat("/ao Сейчас пройдет МП 'Золотой Гонщий' на 100.000$. Всем желающим поучаствовать /готп")
         Sleep 3000
     SendChat("/ao По городу Лос-Сантос катается инфернус, ваша задача догнать и передать 1$")
         Sleep 3000
    addchatmsg("{F20B0B}Удачного мероприятия!.")
    reload
}
}
return
Label2:
Loop, 1{
SendChat("Поздравляю игрок вы победили в мероприятии.")
sleep, 1500
SendChat("Ждите сейчас вам выдадут приз.")
sleep, 1500
SendChat("Напишите свой ник по русски.")
sleep, 15000
SendChat("/spplayers 5.")
Sleep, 1500
addchatmsg("{FFFF00}Пример:/ao Победитель МП 'Прятки на корабле' - Грей Прайс[636]. Он получает приз: 500.000$.")
}
return
Label3:
{
ShowDialog( "0", "F.A.Q.", "{0000FF}[1]{70db70}Для начала МП вы должны телепортироватся на место проведения мп.`n{0000FF}[2]{70db70}Вызвать меню Alt+F3.`n{0000FF}[3]{70db70}Когда вы запустили скрипт , не трогайте до слов в чате 'Начали'`n{0000FF}[4]{70db70}Скрипт полонстью за вас настроит и запустит МП.", "Закрыть")
}
return
!F12::
addchatmsg("{F20B0B}Скрипт перезагружен.")
reload
return
Справка:
msgbox 32,,
(
• Команды скрипта: -1 ... -20 | Альт + F3 | F12 |
• Важно: После ввода команды следует нажимать SPACE(пробел) вместо ENTER.
• Автор - Matthew_Fist  .
)
return
Выйти:
ExitApp
return
 

darksoor

Известный
674
353
Твой код гавно, по другому не сказать.
Во-первых - он старый очень, во-вторых - ты не проставил переменные menu:=2 (3,4 и т.п.), когда вызываешь новый диалог. Так как нет этой переменной, нет и никаких действий по нему. Я тебе предложу воспользоваться иным кодом, вот пример:
AutoHotKey:
; Твой вариант, только улучшенный

~ESC::
~F6::
menu:=0
return

~F3:: ;активация на кнопку F3
menu := 1
text =
(
{808080}1. {ffffff}Первая строка
{808080}2. {ffffff}Вторая строка
{808080}3. {ffffff}Третья строка
{808080}4. {ffffff}Четвертая строка
)
ShowDialog(2, "Диалог 1", text, "Выбрать")
return

~LButton::
if (A_PriorHotkey <> "~LButton" or A_TimeSincePriorHotkey > 500)
{
    KeyWait, LButton
    return
}
checkdialogMenu:
ifWinNotActive, GTA:SA:MP
{
    return
}

if (menu == 1)
{
    menu := 0
    line_num  := getDialogLineNumber()
    line_text  := getDialogLine(line_num)
    addChatMessage(line_text)
    if (line_num == 1) {
        SendChat("1 строка")
    } else if (line_num == 2) {
        SendChat("2 строка")
    } else if (line_num == 3) {
        SendChat("3 строка")
    } else if (line_num == 4) {
        SendChat("4 строка")
    }
}
; сюда вставляешь условие для второго меню (if (menu := 2))
Return

~NumpadEnter::
~Enter::
gosub, checkdialogMenu
return

Еще есть вариант другого плана, там с переменными мучаться не нужно:
AutoHotKey:
; Функция, которая выводит номер выбранной строки в диалоге
LineResult() {
    if (!isDialogOpen())
        return false
    if (getDialogStyle() = 0 || getDialogStyle() = 1 || getDialogStyle() = 3)
        return false
    while(!GetKeyState("LButton", "P") &&!GetKeyState("Enter", "P") && !GetKeyState("Esc", "P"))
       continue
    if (GetKeyState("Enter", "P"))
        return getDialogIndex()
    else if (GetKeyState("Esc", "P"))
        return false
    else {
        KeyWait, LButton
        KeyWait, LButton, D T0.4
        if (isDialogOpen())
            return LineResult()
        else
            return getDialogIndex()
    }
}

F10::
sleep 100
showDialog(2, "Меню MST", "1.Function 1. `n2. Function 2.","Ок")
ResultFunc := LineResult()
if (!ResultFunc)
   return
if(ResultFunc == 1) {
        addChatMessage("Выбрана линия = " ResultFunc)
} else if(ResultFunc == 2) {
        addChatMessage("Выбрана линия = " ResultFunc)
}
Return

В-третьих - много лишних блоков в коде. При метке и одной строчке кода они ни к чему.
В-четвёртых - Loop, 1 в метке - это полный зашквар. Убирай этот позор. Цикл, который просто прогонит раз себя тут не нужен.
И последнее - это можно сократить:
AutoHotKey:
targ:=getId()     
SendChat("/plveh "targ " 411 1 ")
;Так лучше будет
SendChat("/plveh " getId() " 411 1")
 
  • Нравится
Реакции: Kvisk

Kvisk

Известный
204
208
Твой код гавно, по другому не сказать.
Во-первых - он старый очень, во-вторых - ты не проставил переменные menu:=2 (3,4 и т.п.), когда вызываешь новый диалог. Так как нет этой переменной, нет и никаких действий по нему. Я тебе предложу воспользоваться иным кодом, вот пример:
AutoHotKey:
; Твой вариант, только улучшенный

~ESC::
~F6::
menu:=0
return

~F3:: ;активация на кнопку F3
menu := 1
text =
(
{808080}1. {ffffff}Первая строка
{808080}2. {ffffff}Вторая строка
{808080}3. {ffffff}Третья строка
{808080}4. {ffffff}Четвертая строка
)
ShowDialog(2, "Диалог 1", text, "Выбрать")
return

~LButton::
if (A_PriorHotkey <> "~LButton" or A_TimeSincePriorHotkey > 500)
{
    KeyWait, LButton
    return
}
checkdialogMenu:
ifWinNotActive, GTA:SA:MP
{
    return
}

if (menu == 1)
{
    menu := 0
    line_num  := getDialogLineNumber()
    line_text  := getDialogLine(line_num)
    addChatMessage(line_text)
    if (line_num == 1) {
        SendChat("1 строка")
    } else if (line_num == 2) {
        SendChat("2 строка")
    } else if (line_num == 3) {
        SendChat("3 строка")
    } else if (line_num == 4) {
        SendChat("4 строка")
    }
}
; сюда вставляешь условие для второго меню (if (menu := 2))
Return

~NumpadEnter::
~Enter::
gosub, checkdialogMenu
return

Еще есть вариант другого плана, там с переменными мучаться не нужно:
AutoHotKey:
; Функция, которая выводит номер выбранной строки в диалоге
LineResult() {
    if (!isDialogOpen())
        return false
    if (getDialogStyle() = 0 || getDialogStyle() = 1 || getDialogStyle() = 3)
        return false
    while(!GetKeyState("LButton", "P") &&!GetKeyState("Enter", "P") && !GetKeyState("Esc", "P"))
       continue
    if (GetKeyState("Enter", "P"))
        return getDialogIndex()
    else if (GetKeyState("Esc", "P"))
        return false
    else {
        KeyWait, LButton
        KeyWait, LButton, D T0.4
        if (isDialogOpen())
            return LineResult()
        else
            return getDialogIndex()
    }
}

F10::
sleep 100
showDialog(2, "Меню MST", "1.Function 1. `n2. Function 2.","Ок")
ResultFunc := LineResult()
if (!ResultFunc)
   return
if(ResultFunc == 1) {
        addChatMessage("Выбрана линия = " ResultFunc)
} else if(ResultFunc == 2) {
        addChatMessage("Выбрана линия = " ResultFunc)
}
Return

В-третьих - много лишних блоков в коде. При метке и одной строчке кода они ни к чему.
В-четвёртых - Loop, 1 в метке - это полный зашквар. Убирай этот позор. Цикл, который просто прогонит раз себя тут не нужен.
И последнее - это можно сократить:
AutoHotKey:
targ:=getId()    
SendChat("/plveh "targ " 411 1 ")
;Так лучше будет
SendChat("/plveh " getId() " 411 1")
а что так можно было ?!)))) эх думаю парень не расстроился )))
 
  • Нравится
Реакции: darksoor

Kvisk

Известный
204
208
Можно))
Поисковиком чаще нужно пользоваться)
да не, я не к тому)) просто я тоже хотел сказать что "мне не очень нравится этот код", но не хотел обидеть парня) Ты же всё так просто и прямо сказал :D
 

darksoor

Известный
674
353
да не, я не к тому)) просто я тоже хотел сказать что "мне не очень нравится этот код", но не хотел обидеть парня) Ты же всё так просто и прямо сказал :D

Всегда говорю, то что думаю.
Быстрее парень научится. Критику необходимо принимать, какая она есть.
Да и если этого не делать, потом будут выкладывать свои программки с быдлокодом)))
 
  • Нравится
Реакции: Kvisk