Тема: AHK: В GUI дублируются функции
Здравствуйте помогите пожалуйста со скриптом.
У вас на форуме нашел скрипт , который работает с памятью и все отлично у меня работает.
Я хотел сделать чтобы при нажатии кнопки в GUI мне давало определенное количество одного предмета, а при нажатии другой кнопки давало определенное количество другого предмета.
По отдельности в GUI они работают, но если их соединить вместе то пишет что функции дублируются.
Вот сам код с GUI:
Gui, Add, Button, default, Health
Gui, Add, Button, default, Armour
Gui, Show,, Simple Input Example
return
GuiClose:
ButtonHealth:
Try
SetActorHP(9)
Catch e
MsgBox,, Error, % e.Message
return
SetActorHP(value)
{
baseAddress := ReadMemory(0xB7CD98, "gta_sa.exe", "Ptr", A_PtrSize)
WriteMemory(value, baseAddress + 0x540, "gta_sa.exe", "float")
}
ReadMemory(address, processIDorName, type = "Int", numBytes = 4)
{
VarSetCapacity(MVALUE, numBytes, 0)
VarSetCapacity(numBytesRead, A_PtrSize, 0)
Process, Exist, %processIDorName%
if !processID := ErrorLevel
Throw Exception("Invalid process name or process ID:`n`n""" . processIDorName .
"""")
if !processHandle := DllCall("OpenProcess", "Int", 24, "UInt", 0, "UInt", processID,
"Ptr")
Throw Exception("Failed to open process.`n`nError code:`t" . A_LastError)
result := DllCall("ReadProcessMemory", "Ptr", processHandle, "Ptr", address, "Ptr",
&MVALUE, "UInt", numBytes, "UIntP", numBytesRead, "UInt")
if !DllCall("CloseHandle", "Ptr", processHandle, "UInt") && !result
Throw Exception("Failed to close process handle.`n`nError code:`t" . A_LastError)
if !result
Throw Exception("Failed to read process memory.`n`nError code:`t" . A_LastError)
if !numBytesRead
Throw Exception("Read 0 bytes from the`n`nprocess:`t" processIDorName "`naddress:`t"
address)
return NumGet(MVALUE, 0, type)
}
WriteMemory(data, address, processIDorName, type = "Int", numBytes = 4)
{
VarSetCapacity(buf, numBytes, 0)
NumPut(data, buf, 0, type)
Process, Exist, %processIDorName%
if !processID := ErrorLevel
Throw Exception("Invalid process name or process ID:`n`n""" . processIDorName .
"""")
if !processHandle := DllCall("OpenProcess", "Int", 40, "UInt", 0, "UInt", processID,
"Ptr")
Throw Exception("Failed to open process.`n`nError code:`t" . A_LastError)
result := DllCall("WriteProcessMemory", "Ptr", processHandle, "Ptr", address, "Ptr",
&buf, "UInt", numBytes, "UInt", 0, "UInt")
if !DllCall("CloseHandle", "Ptr", processHandle, "UInt") && !result
Throw Exception("Failed to close process handle.`n`nError code:`t" . A_LastError)
if !result
Throw Exception("Failed to write process memory.`n`nError code:`t" . A_LastError)
return result
}
ButtonArmour:
Try
SetActorAr(50)
Catch e
MsgBox,, Error, % e.Message
return
SetActorAr(value)
{
baseAddress := ReadMemory(0xB7CD98, "gta_sa.exe", "Ptr", A_PtrSize)
WriteMemory(value, baseAddress + 0x548, "gta_sa.exe", "float")
}
ReadMemory(address, processIDorName, type = "Int", numBytes = 4)
{
VarSetCapacity(MVALUE, numBytes, 0)
VarSetCapacity(numBytesRead, A_PtrSize, 0)
Process, Exist, %processIDorName%
if !processID := ErrorLevel
Throw Exception("Invalid process name or process ID:`n`n""" . processIDorName .
"""")
if !processHandle := DllCall("OpenProcess", "Int", 24, "UInt", 0, "UInt", processID,
"Ptr")
Throw Exception("Failed to open process.`n`nError code:`t" . A_LastError)
result := DllCall("ReadProcessMemory", "Ptr", processHandle, "Ptr", address, "Ptr",
&MVALUE, "UInt", numBytes, "UIntP", numBytesRead, "UInt")
if !DllCall("CloseHandle", "Ptr", processHandle, "UInt") && !result
Throw Exception("Failed to close process handle.`n`nError code:`t" . A_LastError)
if !result
Throw Exception("Failed to read process memory.`n`nError code:`t" . A_LastError)
if !numBytesRead
Throw Exception("Read 0 bytes from the`n`nprocess:`t" processIDorName "`naddress:`t"
address)
return NumGet(MVALUE, 0, type)
}
WriteMemory(data, address, processIDorName, type = "Int", numBytes = 4)
{
VarSetCapacity(buf, numBytes, 0)
NumPut(data, buf, 0, type)
Process, Exist, %processIDorName%
if !processID := ErrorLevel
Throw Exception("Invalid process name or process ID:`n`n""" . processIDorName .
"""")
if !processHandle := DllCall("OpenProcess", "Int", 40, "UInt", 0, "UInt", processID,
"Ptr")
Throw Exception("Failed to open process.`n`nError code:`t" . A_LastError)
result := DllCall("WriteProcessMemory", "Ptr", processHandle, "Ptr", address, "Ptr",
&buf, "UInt", numBytes, "UInt", 0, "UInt")
if !DllCall("CloseHandle", "Ptr", processHandle, "UInt") && !result
Throw Exception("Failed to close process handle.`n`nError code:`t" . A_LastError)
if !result
Throw Exception("Failed to write process memory.`n`nError code:`t" . A_LastError)
return result
}
ExitAppПробовал переименовать функции, но мне сложно понять что изменять и поэтому не получается(

