[Помощь] Активация на зажатие кнопки - Форум Cheat-Master.ru
  • Страница 1 из 1
  • 1
Модератор форума: Sanoxxx, Alowir, Phoenixxx_Czar  
[Помощь] Активация на зажатие кнопки
iMaran Дата: Воскресенье, 06.11.2016, 15:15 | Сообщение # 1
Новичок
Сообщений: 19
Статус: Offline
Помогите сделать так, чтобы скрипт работал при зажатии боковой кнопки мыши.
Код
;<COMPILER: v1.1.22.09>
#SingleInstance, force
#NoEnv
#include SAMP-UDF-Developer.ahk

work := 0
WindowTitle2 := "GTA:SA:MP"
gta := new memory(WindowTitle2)
While(true)
{
    While GetKeyState("vk01", "P")
    {    
  if(work == 1)
  {
   Targetped := gta.read(0xB6F5F0, "UInt", 0x79c)
   if (Targetped = 0)
   {
   }
   else
   {
    sleep 1
    MyPosX := gta.read(0xB6F5F0, "float", 0x14, 0x30)
    MyPosY := gta.read(0xB6F5F0, "float", 0x14, 0x34)
    MyPosZ := gta.read(0xB6F5F0, "float", 0x14, 0x38)
    RotAngle := gta.read(0xB6F5F0, "float", 0x558)
    Xwping := MyPosX + 1.35*cos(RotAngle + 1.26000)
    Ywping := MyPosY + 1.35*sin(RotAngle + 1.46000)
    Zwping := MyPosZ + 0.2
    EnemyXpos := gta.write(0xB6F5F0, Xwping,"float", 0x79c, 0x14, 0x30)
    EnemyYpos := gta.write(0xB6F5F0, Ywping,"float", 0x79c, 0x14, 0x34)
    EnemyZpos := gta.write(0xB6F5F0, Zwping,"float", 0x79c, 0x14, 0x38)
   }
  }
    }
}

XButton1::
    if(work == 0)
    {
  work := 1
    Text := "{00FF00}1"
Addchatmessage(text)
    }
    else
    {
  work := 0
    Text1 := "{FF0000}2"
Addchatmessage(text1)
    }
    Return
class memory
{
    static baseAddress, hProcess
    , insertNullTerminator := True
    , readChunkSize := 128
    , aTypeSize := {    "UChar": 1, "Char":    1
    , "UShort":    2, "Short":    2
    , "UInt": 4, "Int": 4
    , "UFloat": 4, "Float": 4
    ,    "Int64": 8, "Double": 8}
    
    __new(program, dwDesiredAccess := "", byRef handle := "", windowMatchMode := 3)
    {
  if !(handle := this.openProcess(program, dwDesiredAccess, windowMatchMode))
  return ""
  this.BaseAddress := this.getProcessBaseAddress(program, windowMatchMode)
  return this
    }
    
    __delete()
    {
  this.closeProcess(this.hProcess)
  return
    }
    
    openProcess(program, dwDesiredAccess := "", windowMatchMode := 3)
    {
  if dwDesiredAccess is not integer
   dwDesiredAccess := (PROCESS_QUERY_INFORMATION := 0x0400) | (PROCESS_VM_OPERATION := 0x8) | (PROCESS_VM_READ := 0x10) | (PROCESS_VM_WRITE := 0x20)
  if windowMatchMode
  {
   mode := A_TitleMatchMode
   SetTitleMatchMode, %windowMatchMode%
  }
  WinGet, pid, pid, % this.currentProgram := program
  if windowMatchMode
   SetTitleMatchMode, %mode%
  if !pid
   return this.hProcess := 0
  return this.hProcess := DllCall("OpenProcess", "UInt", dwDesiredAccess, "Int", False, "UInt", pid)
    }
    closeProcess(hProcess)
    {
  if hProcess
  return DllCall("CloseHandle", "UInt", hProcess)
  return
    }

    read(address, type := "UInt", aOffsets*)
    {
  VarSetCapacity(buffer, bytes := this.aTypeSize[type])
  if !DllCall("ReadProcessMemory","UInt", this.hProcess, "UInt", aOffsets.maxIndex() ? this.getAddressFromOffsets(address, aOffsets*) : address, "Ptr", &buffer, "UInt", bytes, "Ptr",0)
  return !this.hProcess ? "Handle Is closed: " this.hProcess : "Fail"
  return numget(buffer, 0, Type)
    }

    ReadRawMemory(address, byref buffer, bytes := 4, aOffsets*)
    {
  VarSetCapacity(buffer, bytes)
  if !DllCall("ReadProcessMemory", "UInt", this.hProcess, "UInt", aOffsets.maxIndex() ? this.getAddressFromOffsets(address, aOffsets*) : address, "Ptr", &buffer, "UInt", bytes, "Ptr*", bytesRead)
  return !this.hProcess ? "Handle Is closed: " this.hProcess : "Fail"
  return bytesRead
    }

    readString(address, length := 0, encoding := "utf-8", aOffsets*)
    {
  size := (encoding ="utf-16" || encoding = "cp1200") ? 2 : 1
  VarSetCapacity(buffer, length ? length * size : (this.readChunkSize < size ? this.readChunkSize := size : this.readChunkSize), 0)
  if aOffsets.maxIndex()
  address := this.getAddressFromOffsets(address, aOffsets*)
  if !length
  {
   VarSetCapacity(string, this.readChunkSize * 2)
   Loop
   {
    success := DllCall("ReadProcessMemory", "UInt", this.hProcess, "UInt", address + (A_index - 1) * this.readChunkSize, "Ptr", &buffer, "Uint", this.readChunkSize, "Ptr", 0)
    if (ErrorLevel || !success)
    {
     if (A_Index = 1 && !this.hProcess)
     return "Handle Is closed: " this.hProcess
     else if (A_index = 1 && this.hProcess)
     return "Fail"
     else
     break
    }
   loop, % this.readChunkSize / size
   {
    if ("" = char := StrGet(&buffer + (A_Index -1) * size, 1, encoding))
     break, 2
    string .= char
   }
   }
  }
  Else
  {
   if !DllCall("ReadProcessMemory", "UInt", this.hProcess, "UInt", address, "Ptr", &buffer, "Uint", length * size, "Ptr", 0)
   return !this.hProcess ? "Handle Is closed: " this.hProcess : "Fail"
   string := StrGet(&buffer, length, encoding)
  }
  return string
    }

    writeString(address, string, encoding := "utf-8", aOffsets*)
    {
  encodingSize := (encoding = "utf-16" || encoding = "cp1200") ? 2 : 1
  requiredSize := StrPut(string, encoding) * encodingSize - (this.insertNullTerminator ? 0 : encodingSize)
  VarSetCapacity(buffer, requiredSize)
  StrPut(string, &buffer, this.insertNullTerminator ? StrLen(string) : StrLen(string) + 1, encoding)
  DllCall("WriteProcessMemory", "UInt", this.hProcess, "UInt", aOffsets.maxIndex() ? this.getAddressFromOffsets(address, aOffsets*) : address, "Ptr", &buffer, "Uint", requiredSize, "Ptr*", BytesWritten)
  return BytesWritten
    }

    write(address, value, type := "Uint", aOffsets*)
    {
  if !bytes := this.aTypeSize[type]
  return "Non Supported data type"
  VarSetCapacity(buffer, bytes)
  NumPut(value, buffer, 0, type)
  return DllCall("WriteProcessMemory", "UInt", this.hProcess, "UInt", aOffsets.maxIndex() ? this.getAddressFromOffsets(address, aOffsets*) : address, "Ptr", &buffer, "Uint", bytes, "Ptr", 0)
    }

    pointer(base, finalType := "UInt", offsets*)
    {
  For index, offset in offsets
  {
   if (index = offsets.maxIndex() && A_index = 1)
    pointer := offset + this.Read(base)
   Else
   {
    IF (A_Index = 1)
    pointer := this.Read(offset + this.Read(base))
    Else If (index = offsets.MaxIndex())
    pointer += offset
    Else pointer := this.Read(pointer + offset)
   }
  }
  Return this.Read(offsets.maxIndex() ? pointer : base, finalType)
    }

    getAddressFromOffsets(address, aOffsets*)
    {
  lastOffset := aOffsets.Remove()
  return    this.pointer(address, "UInt", aOffsets*) + lastOffset
    }

    getProcessBaseAddress(WindowTitle, windowMatchMode := 3)
    {
  if windowMatchMode
  {
   mode := A_TitleMatchMode
   SetTitleMatchMode, %windowMatchMode%
  }
  WinGet, hWnd, ID, %WindowTitle%
  if windowMatchMode
  SetTitleMatchMode, %mode%
  if !hWnd
  return
  BaseAddress := DllCall(A_PtrSize = 4
  ? "GetWindowLong"
  : "GetWindowLongPtr", "Ptr", hWnd, "Uint", -6, "UInt")
  return BaseAddress
    }

    getBaseAddressOfModule(module := "")
    {
  if !this.hProcess
  return -2
  if (A_PtrSize = 4)
  {
   DllCall("IsWow64Process", "Ptr", this.hProcess, "Int*", result)
   if !result
   return -4
  }
  if !module
  {
   VarSetCapacity(mainExeNameBuffer, 2048 * (A_IsUnicode ? 2 : 1))
   DllCall("psapi\GetModuleFileNameEx", "Ptr", this.hProcess, "Uint", 0
   , "Ptr", &mainExeNameBuffer, "Uint", 2048 / (A_IsUnicode ? 2 : 1))
   mainExeName := StrGet(&mainExeNameBuffer)
  }
  size := VarSetCapacity(lphModule, 4)
  loop
  {
   DllCall("psapi\EnumProcessModules", "Ptr", this.hProcess, "Ptr", &lphModule
   , "Uint", size, "Uint*", reqSize)
   if ErrorLevel
    return -3
   else if (size >= reqSize)
    break
   else
    size := VarSetCapacity(lphModule, reqSize)
  }
  VarSetCapacity(lpFilename, 2048 * (A_IsUnicode ? 2 : 1))
  loop % reqSize / A_PtrSize
  {
   DllCall("psapi\GetModuleFileNameEx", "Ptr", this.hProcess, "Uint", numget(lphModule, (A_index - 1) * A_PtrSize)
   , "Ptr", &lpFilename, "Uint", 2048 / (A_IsUnicode ? 2 : 1))
   if (!module && mainExeName = StrGet(&lpFilename) || module && instr(StrGet(&lpFilename), module))
   {
    VarSetCapacity(MODULEINFO, A_PtrSize = 4 ? 12 : 24)
    DllCall("psapi\GetModuleInformation", "Ptr", this.hProcess, "UInt", numget(lphModule, (A_index - 1) * A_PtrSize)
    , "Ptr", &MODULEINFO, "UInt", A_PtrSize = 4 ? 12 : 24)
    return numget(MODULEINFO, 0, "Ptr")
   }
  }
  return -1
    }
}
MrGPro Дата: Пятница, 11.11.2016, 17:20 | Сообщение # 2
Боец
Сообщений: 202
Статус: Offline
iMaran, АИМ =)

Код
XButton1::
work := 1
Text := "{00FF00}1"
Addchatmessage(text)
return
    
XButton1 UP::
work := 0
Text1 := "{FF0000}2"
Addchatmessage(text1)
Return

--------------------- или -----------------------
VK_XBUTTON1       0x05 -> vk05
VK_XBUTTON2       0x06 -> vk06

сюда

While GetKeyState("vk01", "P")



Тебе помогли не забывай про благодарность >> тыкни репутацию
---------------------------------------͡ ͋̏̏̏̏̏̏̏̏̏̏̏̏̏̏̏̏̏̏̏̏͋͋' ͡ ͋̏̏̏̏̏̏̏̏̏̏̏̏̏̏̏̏̏̏̏̏͋͋' ͡ ͋̏̏̏̏̏̏̏̏̏ -----------------------------------------------------
Зам.Администратора на проекте "DayZ Epoсh SPN" сервер Arma 2OA DayZ Epoch пиратка и лицензия
iMaran Дата: Пятница, 11.11.2016, 19:05 | Сообщение # 3
Новичок
Сообщений: 19
Статус: Offline
Цитата MrGPro ()
АИМ =)

Код
XButton1::
work := 1
Text := "{00FF00}1"
Addchatmessage(text)
return
    
XButton1 UP::
work := 0
Text1 := "{FF0000}2"
Addchatmessage(text1)
Return

--------------------- или -----------------------
VK_XBUTTON1       0x05 -> vk05
VK_XBUTTON2       0x06 -> vk06

сюда

While GetKeyState("vk01", "P")

Спасибо, всё получилось)
mounty Дата: Пятница, 20.01.2017, 18:06 | Сообщение # 4
Новичок
Сообщений: 9
Статус: Offline
дай полный код с зажатием...
  • Страница 1 из 1
  • 1
Поиск:
Статистика Форума