Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #SingleInstance force
- OnExit, ExitSequence
- SplitPath, A_ScriptName,,,,ProgramNameNoExt
- menu, tray, tip, %ProgramNameNoExt%
- menu, tray, NoStandard
- menu, tray, Add, Restart Program, RestartSequence
- menu, tray, Add, Exit, ExitSequence
- RefreshRate = 20
- TrayTip, GTA VC No Mouse Sensitivity Reset, The script will prevent the game from resetting the mouse sensitivity on reset. To close the script right click on the tray icon here and select exit. The effect will last until the game is closed. `n`nMade by Lighnat0r,20,
- If (IsLabel("DebugFunctions") AND A_IsCompiled != 1)
- gosub DebugFunctions
- goto MainScript
- MainScript:
- WindowClass := "Grand theft auto 3"
- WindowName := "GTA: Vice City"
- WinWait ahk_class %WindowClass%
- WinGetTitle, CurrentWindowName
- If (CurrentWindowName != WindowName)
- goto MainScript
- WinGet, PID, PID
- Memory(1, PID)
- Process, Exist, %PID%
- if ErrorLevel != 0
- VersionOffset := GameVersionCheck()
- else
- goto MainScript
- GameRunningAddress := 0x00400000
- if VersionOffset = -4088
- MouseSensitivity := 0x0046F5D1 ; Steam
- Else if VersionOffset = -12280
- MouseSensitivity := 0x0046F823 ; JP
- Else
- MouseSensitivity := 0x0046F4B1 ; Retail
- Target := 0x90 ; 144. This magic number seems to fix the mouse sens being reset on new games for some reason.
- While Memory(3, GameRunningAddress, 1) != "Fail"
- {
- sleep %RefreshRate%
- ; If memory read from mouse sens address is not equal to the Target,
- ; write 144 to the mouse sens address and two addresses past it.
- if Memory(3, MouseSensitivity, 1) != Target
- {
- loop 3 ; For VC JP, default values of the address range are 1) 216, 2) 171, 3) 148
- {
- Address := MouseSensitivity + A_Index - 1
- Memory(4, Address, Target, 1)
- }
- }
- }
- sleep 5000
- goto MainScript
- ExitSequence:
- exitapp
- RestartSequence:
- reload
- sleep 1000
- return
- DebugFunctions:
- Hotkey, F7, DebugListvars, On
- return
- DebugListvars:
- Listvars
- return
- Memory(Type=3,Param1=0,Param2=0,Param3=0,Param4=0)
- {
- Static ProcessHandle
- If Type = 1
- {
- ProcessHandle := DllCall("OpenProcess","Int",2035711,"Int", 0,"UInt",Param1)
- If ProcessHandle = 0
- {
- Error := GetLastErrorMessage()
- outputdebug Open process error`: %Error%
- Return % DllCall("GetLastError")
- }
- Else
- Return 0
- }
- Else If Type = 2
- DllCall("CloseHandle","UInt",ProcessHandle)
- Else If Type = 3 ; Read memory value
- {
- Param2 := ((!Param2) ? 4 : Param2)
- VarSetCapacity(MVALUE,Param2,0)
- If (Param3 = "Unicode" OR Param3 = "Ascii")
- {
- CharLength := ((Param3 = "Unicode") ? 2 : 1)
- LoopAmount := Param2/CharLength
- Loop %LoopAmount%
- {
- ReadAddress := Param1+((A_Index-1)*CharLength)
- OutputChar%A_Index% := Memory(3, ReadAddress, CharLength)
- OutputChar%A_Index% := Chr(OutputChar%A_Index%)
- OutputString := OutputString . OutputChar%A_Index%
- }
- Return OutputString
- }
- If (ProcessHandle) && DllCall("ReadProcessMemory","UInt",ProcessHandle,"UInt",Param1,"Str",MVALUE,"UInt",Param2,"UInt",0)
- {
- Result = 0
- Loop %Param2%
- Result += *(&MVALUE + A_Index-1) << 8*(A_Index-1)
- If (Param3 = "Float")
- Result := HexToFloat(Result)
- Return Result
- }
- Return !ProcessHandle ? "Handle Closed: " Closed : "Fail"
- }
- Else If Type = 4 ; Write memory value
- {
- If (Param4 = "Unicode" OR Param4 = "Ascii")
- {
- CharLength := ((Param4 = "Unicode") ? 2 : 1)
- StringSplit, InputStringArray, Param2
- Param3 := ((!Param3) ? InputStringArray0 : Param3)
- Loop %Param3%
- {
- TextCharacter%A_Index%Address := Param1 + (A_Index-1) * CharLength
- Memory(4, TextCharacter%A_Index%Address, 0, 1)
- }
- If (InputStringArray0 > Param3)
- InputStringArray0 := Param3
- Loop %InputStringArray0%
- {
- CurrentLetter := InputStringArray%A_Index%
- If CurrentLetter = `%
- CurrentLetter = 37
- Else
- CurrentLetter := Asc(CurrentLetter)
- TextCharacter%A_Index%Address := Param1 + (A_Index-1) * CharLength
- Memory(4, TextCharacter%A_Index%Address, CurrentLetter, 1)
- }
- }
- Else
- {
- If (Param4 = "Float")
- Param2 := FloatToHex(Param2)
- Param3 := ((!Param3) ? 4 : Param3)
- ; WriteProcessMemory DLL call accepts 5 parameters (in order):
- ; Process handle, base address (Param1), buffer of data to be written (Param2), # of bytes to be written (always 1 in this program), and 0 (unused in this program).
- If (ProcessHandle) && DllCall("WriteProcessMemory","UInt",ProcessHandle,"UInt",Param1,"Uint*",Param2,"Uint",Param3,"Uint",0)
- Return "Success"
- Return !ProcessHandle ? "Handle Closed: " closed : "Fail"
- }
- }
- Else If Type = 5
- {
- Param1 := Memory(3, Param1)
- If Param1 is not xdigit
- Return Param1
- Return Param1 + Param2
- }
- }
- GameVersionCheck()
- {
- Value := Memory(3, 0x00608578, 1)
- if Value = 0x5D
- Return 0
- if Value = 0x81
- Return 8
- if Value = 0x5B
- Return -0xFF8
- if Value = 0x44
- Return -0x2FF8
- Msgbox Error`: The script could not determine the version of GTA Vice City %Value%
- }
- GetLastErrorMessage()
- {
- ErrorCode := DllCall("GetLastError")
- VarSetCapacity(ReturnedMessage, 2000)
- ReturnValue := DllCall("FormatMessage", "UInt", 0x1000, "UInt", 0, "UInt", ErrorCode, "UInt", 0x800, "Str", ReturnedMessage, "UInt", 2000, "UInt", 0)
- If ReturnValue = 0
- {
- ErrorCode := DllCall("GetLastError")
- outputdebug Error getting error message`: %ErrorCode%
- }
- Else
- {
- Error = %ErrorCode%`: %ReturnedMessage%
- return Error
- }
- }
- HexToFloat(x)
- {
- Return (1-2*(x>>31)) * (2**((x>>23 & 255)-150)) * (0x800000 | x & 0x7FFFFF)
- }
- FloatToHex(f)
- {
- form := A_FormatInteger
- SetFormat Integer, HEX
- v := DllCall("MulDiv", Float,f, Int,1, Int,1, UInt)
- SetFormat Integer, %form%
- Return v
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement