Jump to content

Pinball Trainer?


Dellairion
 Share

Recommended Posts

Wel hello out there, i was bussy with making a trainer for pinball but i think im going to quit autoit becouse im going to learn C++ at school. :)

but i will post what i already had... (just one last question is it possible to keep the freeze button down when its pressed? :P no nvm. )

I tested this only on windows xp media center... not sure if adresses and pointers are same on other computers. (you can always change them ofcourse)

It works, atleast for me it does.

; Pinball Trainer (Trainer_Pinball.au3)
; By kristof 2006-2007
; 
;

#NoTrayIcon
#include <GUIConstants.au3>
Opt("WinTitleMatchMode", 2)
AutoItSetOption("PixelCoordMode", 0)

$title =    "Pinball Space Cadet Trainer - By Kristof"
$title_pinball = ", Space Cadet"
$exe =      "PINBALL.EXE"
$Process =  ProcessExists($exe)
If $Process > 0 Then MsgBox(0, $title, "Pinball is already running. Please close it and restart pinball with this trainer."&@CR&"Some functions will possible not work if you don't do this.")

$Mem_Players =      0x01025658 ; pointer
$Mem_curplayer =    0x00CAAEA2 ; pointer
$Mem_Score_p1 =     0x00B33D74
$Mem_Score_p2 =     0x00B33DC4
$Mem_Score_p3 =     0x00B33E14
$Mem_Score_p4 =     0x00B33E64
$Mem_Score_write =  0x00CAAEBA
$Mem_Balls =        0x00CAAE9E ; pointer
$Mem_replayball =   0x01023D04 ; pointer
$Mem_hyper1 =       0x00CADA2C ; pointer
$Mem_hyper2 =       0x00CAD448 ; pointer
$Mem_hyper3 =       0x00CBA49C ; pointer
$Mem_hyper4 =       0x00CBA4A0 ; pointer
$Mem_magnet =       0x00CCBC3A ; pointer
$Mem_ball_x =       0x00B30E84
$Mem_ball_y =       0x00B30E88

Dim $Mem_Players_offset[2]
Dim $Mem_Balls_offset[2]
Dim $Mem_replayball_offset[2]
Dim $Mem_curplayer_offset[2]
Dim $Mem_hyper1_offset[2]
Dim $Mem_hyper2_offset[2]
Dim $Mem_hyper3_offset[2]
Dim $Mem_hyper4_offset[2]
Dim $Mem_magnet_offset[2]
$Mem_players_offset[1] =    Dec("D6")
$Mem_Balls_offset[1] =      Dec("00")
$Mem_replayball_offset[1] = Dec("4E")
$Mem_curplayer_offset[1] =  Dec("00")
$Mem_hyper1_offset[1] =     Dec("4E")
$Mem_hyper2_offset[1] =     Dec("4E")
$Mem_hyper3_offset[1] =     Dec("4E")
$Mem_hyper4_offset[1] =     Dec("4E")
$Mem_magnet_offset[1] =     Dec("05")

$Maxplayers =       1
$Currentplayer =    1
$Balls =        1
$score_p1 =     0
$score_p2 =     0
$score_p3 =     0
$score_p4 =     0
$ratio =    1
$X =        0
$Y =        0

$Flipper_left_x_start =     130
$Flipper_left_x_end =       165
$Flipper_left_y_start =     365
$Flipper_left_y_end =       405
$Flipper_right_x_start =    183
$Flipper_right_x_end =      212
$Flipper_right_y_start =    360
$Flipper_right_y_end =      405
$Launch_x_start =   315
$Launch_y_start =   368
$Launch_x_end =     325
$Launch_y_end =     375
$Ball_color =       0xD4CCCC
$Flipper_left =     "LEFT"
$Flipper_right =    "RIGHT"
$Launch =           "SPACE"

$GUI = GUICreate($title, 506, 445, 236, 141)
Opt("GUIOnEventMode", 1)
$M_main = GUICtrlCreateMenu("&Start")
$M_pinball = GUICtrlCreateMenuItem("Start Pinball", $M_main)
GUICtrlSetOnEvent(-1, "Start_Pinball")
$M_about = GUICtrlCreateMenuItem("About", $M_main)
GUICtrlSetOnEvent(-1, "About")
$M_exit = GUICtrlCreateMenuItem("Exit", $M_main)
GUICtrlSetOnEvent(-1, "Quit")
GUISetOnEvent($GUI_EVENT_CLOSE, "Quit")

$L_maxplayers = GUICtrlCreateLabel("Max players:", 8, 16, 63, 17)
$L_currentplayer = GUICtrlCreateLabel("Current player:", 8, 32, 72, 17)
$LV_maxplayers = GUICtrlCreateLabel($Maxplayers, 96, 16, 62, 17)
$LV_currentplayer = GUICtrlCreateLabel($Currentplayer, 96, 32, 71, 17)

$G_ball = GUICtrlCreateGroup("Ball", 8, 56, 201, 73)
$L_balls = GUICtrlCreateLabel("Ball nr:", 21, 72, 36, 17)
$LV_balls = GUICtrlCreateLabel($Balls, 60, 72, 26, 17)
$L_x = GUICtrlCreateLabel("Poss X:", 24, 88, 40, 17)
$L_y = GUICtrlCreateLabel("Poss Y:", 24, 104, 40, 17)
$LV_x = GUICtrlCreateLabel($X, 72, 88, 30, 17)
$LV_y = GUICtrlCreateLabel($Y, 72, 104, 30, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)

$B_editballs = GUICtrlCreateInput($Balls, 387, 9, 22, 21, $ES_NUMBER)
$L_editball = GUICtrlCreateLabel("Edit current ball nr:", 283, 16, 92, 17)
$BT_freezeball = GUICtrlCreateCheckbox("Freeze", 412, 12, 41, 17, $BS_PUSHLIKE)
$BT_setball = GUICtrlCreateButton("Set", 457, 12, 41, 17, 0)
$CB_hyper1 = GUICtrlCreateCheckbox("Hyper space level 1", 229, 61, 121, 17)
$CB_hyper2 = GUICtrlCreateCheckbox("Hyper space level 2", 229, 76, 121, 17)
$CB_hyper3 = GUICtrlCreateCheckbox("Hyper space level 3", 229, 91, 121, 17)
$CB_hyper4 = GUICtrlCreateCheckbox("Hyper space level 4", 229, 106, 121, 17)
$CB_pin = GUICtrlCreateCheckbox("Pin between 2 flippers", 365, 76, 129, 17)
$CB_magnet = GUICtrlCreateCheckbox("Magnet", 365, 91, 129, 17)
$CB_flipper = GUICtrlCreateCheckbox("Auto flipper (Win mode)", 365, 106, 129, 17)
$L_ratio = GUICtrlCreateLabel("Points ratio:", 283, 40, 59, 17)
$BT_setratio = GUICtrlCreateButton("Set", 412, 35, 41, 17, 0)
GUICtrlSetOnEvent(-1, "ratio_set")
;$L_ratio2 = GUICtrlCreateLabel("/10", 410, 40, 59, 17)
$B_ratio = GUICtrlCreateInput($ratio, 379, 31, 30, 21, $ES_NUMBER)
$CB_replayball = GUICtrlCreateCheckbox("Replay ball", 365, 61, 97, 17)
$G_player1 = GUICtrlCreateGroup("Player 1", 8, 136, 489, 65)
$L_score_p1 = GUICtrlCreateLabel("Score:", 24, 168, 35, 17)
$LV_score_P1 = GUICtrlCreateLabel($Score_p1, 64, 168, 54, 17)
$B_score_p1 = GUICtrlCreateInput($Score_p1, 272, 161, 65, 21, $ES_NUMBER)
$L_editscore_p1 = GUICtrlCreateLabel("Edit score:", 209, 168, 54, 17)
$BT_freezescore_p1 = GUICtrlCreateCheckbox("Freeze", 345, 164, 41, 17, $BS_PUSHLIKE)
GUICtrlSetOnEvent(-1, "score_freeze_p1")
$BT_setscore_p1 = GUICtrlCreateButton("Set", 390, 164, 41, 17, 0)
GUICtrlSetOnEvent(-1, "score_write_p1")
GUICtrlCreateGroup("", -99, -99, 1, 1)
$G_player2 = GUICtrlCreateGroup("Player 2", 9, 208, 489, 65)
$L_score_p2 = GUICtrlCreateLabel("Score:", 25, 240, 35, 17)
$LV_score_p2 = GUICtrlCreateLabel($Score_p2, 65, 240, 54, 17)
$B_score_p2 = GUICtrlCreateInput($Score_p2, 273, 233, 65, 21, $ES_NUMBER)
$L_editscore_p2 = GUICtrlCreateLabel("Edit score:", 210, 240, 54, 17)
$BT_freezescore_p2 = GUICtrlCreateCheckbox("Freeze", 345, 236, 41, 17, $BS_PUSHLIKE)
GUICtrlSetOnEvent(-1, "score_freeze_p2")
$BT_setscore_p2 = GUICtrlCreateButton("Set", 390, 236, 41, 17, 0)
GUICtrlSetOnEvent(-1, "score_write_p2")
GUICtrlCreateGroup("", -99, -99, 1, 1)
$G_player3 = GUICtrlCreateGroup("Player 3", 9, 280, 489, 65)
$L_score_p3 = GUICtrlCreateLabel("Score:", 25, 312, 35, 17)
$LV_score_p3 = GUICtrlCreateLabel($Score_p3, 65, 312, 54, 17)
$B_score_p3 = GUICtrlCreateInput($Score_p3, 273, 305, 65, 21, $ES_NUMBER)
$L_editscore_p3 = GUICtrlCreateLabel("Edit score:", 210, 312, 54, 17)
$BT_freezescore_p3 = GUICtrlCreateCheckbox("Freeze", 345, 308, 41, 17, $BS_PUSHLIKE)
GUICtrlSetOnEvent(-1, "score_freeze_p3")
$BT_setscore_p3 = GUICtrlCreateButton("Set", 390, 308, 41, 17, 0)
GUICtrlSetOnEvent(-1, "score_write_p3")
GUICtrlCreateGroup("", -99, -99, 1, 1)
$G_player4 = GUICtrlCreateGroup("Player 4", 9, 352, 489, 65)
$L_score_p4 = GUICtrlCreateLabel("Score:", 25, 384, 35, 17)
$LV_score_p4 = GUICtrlCreateLabel($Score_p4, 65, 384, 54, 17)
$B_score_p4 = GUICtrlCreateInput($Score_p4, 273, 377, 65, 21, $ES_NUMBER)
$L_editscore_p4 = GUICtrlCreateLabel("Edit score:", 210, 384, 54, 17)
$BT_freezescore_p4 = GUICtrlCreateCheckbox("Freeze", 345, 380, 41, 17, $BS_PUSHLIKE)
GUICtrlSetOnEvent(-1, "score_freeze_p4")
$BT_setscore_p4 = GUICtrlCreateButton("Set", 390, 380, 41, 17, 0)
GUICtrlSetOnEvent(-1, "score_write_p4")
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)

GUICtrlSetState($BT_freezeball, $GUI_DISABLE)
GUICtrlSetState($BT_setball, $GUI_DISABLE)
GUICtrlSetState($B_editballs, $GUI_DISABLE)
GUICtrlSetState($B_ratio, $GUI_DISABLE)
GUICtrlSetState($BT_setratio, $GUI_DISABLE)

Func Start_Pinball()
    if Not ProcessExists($exe) then
        Run(@HomeDrive & "\Program Files\Windows NT\Pinball\PINBALL.EXE", @HomeDrive & "\Program Files\Windows NT\Pinball")
        $Process = ProcessExists($exe)
    endif
EndFunc

Func Quit()
    If $Process > 0 Then
        $M_open = _MemoryOpen($Process)
        _MemoryPointerWrite($M_open, $Mem_replayball, $Mem_replayball_offset, 0)
        _MemoryPointerWrite($M_open, $Mem_magnet, $Mem_magnet_offset, 0)
        _MemoryPointerWrite($M_open, $Mem_hyper1, $Mem_hyper1_offset, 0)
        _MemoryPointerWrite($M_open, $Mem_hyper2, $Mem_hyper2_offset, 0)
        _MemoryPointerWrite($M_open, $Mem_hyper3, $Mem_hyper3_offset, 0)
        _MemoryPointerWrite($M_open, $Mem_hyper4, $Mem_hyper4_offset, 0)
        _MemoryClose($M_open)
    EndIf
    Exit
EndFunc

Func About()
    GUISetState(@SW_HIDE)
    MsgBox(0, "3D Pinball Space Cadet Trainer", "A creation by Kris - Copyright 2006-2007"  & @CRLF & "Tested on Windows XP Media Center" & @CRLF & "For more information or help e-mail:" & @CRLF & "thealphateamonline@gmail.com")
    GUISetState(@SW_SHOW)
EndFunc

Func ratio_set()
    $ratio_read = GUICtrlRead($B_ratio)
    If $ratio_read = 0 Then $ratio_read = 1
    $ratio = $ratio_read
    ConsoleWrite("ratio: "&$ratio&@CR)
EndFunc


$Flipper_time = TimerInit()
$Launch_time = TimerInit()
$Flipper_down = 0
$Launch_down = 0
Func auto_flipper()
    If $Launch_down = 1 And TimerDiff($Launch_time) > 500 Then
        Send("{"&$Launch&" up}")
        $Launch_down = 0
    EndIf
    
    ;If TimerDiff($Flipper_time) < 200 Then Return
    If $Flipper_down = 1 And TimerDiff($Flipper_time) > 200 Then
        Send("{"&$Flipper_left&" up}")
        Send("{"&$Flipper_right&" up}")
        $Flipper_down = 0
    EndIf
    
    If WinActive($title_pinball) Then
        $M_open = _MemoryOpen($Process)
        $X = _MemoryRead($M_open, $Mem_ball_x)
        $Y = _MemoryRead($M_open, $Mem_ball_y)
        _MemoryClose($M_open)
        
        If $X >= $Flipper_left_x_start And $X <= $Flipper_left_x_end Then
            If $Y >= $Flipper_left_y_start And $Y <= $Flipper_left_y_end Then
                Send("{"&$Flipper_left&" down}")
                $Flipper_time = TimerInit()
                $Flipper_down = 1
            EndIf
        EndIf
        
        If $X >= $Flipper_right_x_start And $X <= $Flipper_right_x_end Then
            If $Y >= $Flipper_right_y_start And $Y <= $Flipper_right_y_end Then
                Send("{"&$Flipper_right&" down}")
                $Flipper_time = TimerInit()
                $Flipper_down = 1
            EndIf
        EndIf
        
        If $X >= $Launch_x_start And $X <= $Launch_x_end Then
            If $Y >= $Launch_y_start And $Y <= $Launch_y_end And $Launch_down = 0 Then
                Send("{"&$Launch&" down}")
                $Launch_time = TimerInit()
                $Launch_down = 1
            EndIf
        EndIf
        
        ;PixelSearch($Flipper_left_x_start, $Flipper_left_y_start, $Flipper_left_x_end, $Flipper_left_y_end, $Ball_color)
        ;If Not @Error Then 
        ;   Send("{"&$Flipper_left&" down}")
        ;   $Flipper_time = TimerInit()
        ;   ;ConsoleWrite(@CR&$pixel[0]&" | "&$pixel[1]&@CR)
        ;   $Flipper_down = 1
        ;EndIf
        ;
        ;PixelSearch($Flipper_right_x_start, $Flipper_right_y_start, $Flipper_right_x_end, $Flipper_right_y_end, $Ball_color)
        ;If Not @Error Then 
        ;   Send("{"&$Flipper_right&" down}")
        ;   $Flipper_time = TimerInit()
        ;   ;ConsoleWrite(@CR&$pixel2[0]&" | "&$pixel2[1]&@CR)
        ;   $Flipper_down = 1
        ;EndIf
        ;
        ;PixelSearch($Launch_x_start, $Launch_y_start, $Launch_x_end, $Launch_y_end, $Ball_color)
        ;If Not @Error Then
        ;   
        ;   $Launch_down = 1
        ;EndIf
    EndIf
EndFunc

$Player_stat = 1
Func Read()
    $M_open = _MemoryOpen($Process)
    $Maxplayers_read = _MemoryPointerRead($M_open, $Mem_Players, $Mem_players_offset)
    $Balls_read = _MemoryPointerRead($M_open, $Mem_Balls, $Mem_Balls_offset)
    $Currentplayer_read = _MemoryPointerRead($M_open, $Mem_curplayer, $Mem_curplayer_offset)
    
    $Maxplayers = $Maxplayers_read[1]
    $Balls = $Balls_read[1]
    $Currentplayer = $Currentplayer_read[1]
    
    $X = _MemoryRead($M_open, $Mem_ball_x)
    $Y = _MemoryRead($M_open, $Mem_ball_y)
    
    $Score_read = _MemoryRead($M_open, $Mem_Score_write)
    ;ConsoleWrite(GUICtrlRead($LV_score_p2)&@CR&$Score_read&@CR&$Currentplayer&@CR&@CR)
    If $Currentplayer = 1 And GUICtrlRead($LV_score_p1) <> $Score_read And $Player_stat = 4 Then
        _MemoryWrite($M_open, $Mem_Score_write, GUICtrlRead($LV_score_p1))
        _MemoryWrite($M_open, $Mem_Score_p1, GUICtrlRead($LV_score_p1))
        $Player_stat = 1
    ElseIf $Currentplayer = 2 And GUICtrlRead($LV_score_p2) <> $Score_read And $Player_stat = 1 Then
        _MemoryWrite($M_open, $Mem_Score_write, GUICtrlRead($LV_score_p2))
        _MemoryWrite($M_open, $Mem_Score_p2, GUICtrlRead($LV_score_p2))
        $Player_stat = 2
    ElseIf $Currentplayer = 3 And GUICtrlRead($LV_score_p3) <> $Score_read And $Player_stat = 2 Then
        _MemoryWrite($M_open, $Mem_Score_write, GUICtrlRead($LV_score_p3))
        _MemoryWrite($M_open, $Mem_Score_p3, GUICtrlRead($LV_score_p3))
        $Player_stat = 3
    ElseIf $Currentplayer = 4 And GUICtrlRead($LV_score_p4) <> $Score_read And $Player_stat = 3 Then
        _MemoryWrite($M_open, $Mem_Score_write, GUICtrlRead($LV_score_p4))
        _MemoryWrite($M_open, $Mem_Score_p4, GUICtrlRead($LV_score_p4))
        $Player_stat = 4
    EndIf
    
    $Score_p1_ratio = 0
    $Score_p1_ratio = 0
    $Score_p1_ratio = 0
    $Score_p1_ratio = 0
    
    ;If $Currentplayer = 1 Then
        $Score_p1 = _MemoryRead($M_open, $Mem_Score_p1)
        ;$Score_p1_read = _MemoryRead($M_open, $Mem_Score_p1)
        ;If $Score_p1_read < 0 Then $Score_p1_read = 0
        If $Score_p1 < 0 Then $Score_p1 = 0
        ;
        ;If $Score_p1 < $Score_p1_read Then 
        ;   $Score_p1_ratio = ($Score_p1_read - $Score_p1)*$ratio
        ;   ConsoleWrite("Score: "&$score_p1&" DIFF: "&$Score_p1_ratio/$ratio&@CR)
        ;   
        ;   _MemoryWrite($M_open, $Mem_Score_p1, $Score_read)
        ;   If $Currentplayer = 1 Then _MemoryWrite($M_open, $Mem_Score_write, $Score_read)
        ;   
        ;ElseIf $Score_p1 <> $Score_p1_read Then
        ;   $Score_p1_ratio = $Score_p1_read
        ;EndIf
        ;$Score_p1 += Round($Score_p1_ratio)
        
        ;_MemoryWrite($M_open, $Mem_Score_p1, $Score_read)
        ;If $Currentplayer = 1 Then _MemoryWrite($M_open, $Mem_Score_write, $Score_read)
        
    ;ElseIf $Currentplayer = 2 Then
        $Score_p2 = _MemoryRead($M_open, $Mem_Score_p2)
        If $Score_p2 < 0 Then $Score_p2 = 0
    ;ElseIf $Currentplayer = 3 Then
        $Score_p3 = _MemoryRead($M_open, $Mem_Score_p3)
        If $Score_p3 < 0 Then $Score_p3 = 0
    ;ElseIf $Currentplayer = 4 Then
        $Score_p4 = _MemoryRead($M_open, $Mem_Score_p4)
        If $Score_p4 < 0 Then $Score_p4 = 0
    ;EndIf
    
    _MemoryClose($M_open)
EndFunc

#cs
;;;;;;
GUICtrlCreateMenuitem("test", $M_main)
GUICtrlSetOnEvent(-1, "test")
Func test()
    $M_open = _MemoryOpen($Process)
    _MemoryWrite($M_open, 0x00CAAEBA, 1)
    _MemoryClose($M_open)
    ConsoleWrite("test " & @error & @CR)
EndFunc
;;;;;;;
#ce

$Score_p1_freeze_val = -1
$Score_p2_freeze_val = -1
$Score_p3_freeze_val = -1
$Score_p4_freeze_val = -1
Func Score_Freeze($player)
    If Eval("Score_p"&$player&"_freeze_val") >= 0 Then
        Assign("Score_p"&$player&"_freeze_val", -1)
        ;ConsoleWrite("EX0" & @CR)
    Else
        Assign("Score_p"&$player&"_freeze_val", Eval("score_p"&$player))
        ;ConsoleWrite("EX1" & @CR)
    EndIf
EndFunc

;Func Balls_Write()
    ;$Balls = GUICtrlRead($B_editballs)
    ;$M_open = _MemoryOpen($Process)
    ;_MemoryWrite($M_open, $Mem_Balls + $Mem_Balls_offset, "0x" & Hex($Balls))
    ;;_MemoryWrite($M_open, "0x" & $Mem_Balls_p1, "0x" & Hex($Balls_p1_Read))
    ;_MemoryClose($M_open)
;EndFunc

Func Score_Write($player)
    If $player > 4 Or $player < 1 Then Return
    ;If $player <> $Currentplayer Then Return
    
    $Score_read = GuiCtrlRead(Eval("B_score_p"&$player))
    If Eval("Score_p"&$player&"_freeze_val") >= 0 Then Assign("Score_p"&$player&"_freeze_val", $Score_read)
    
    $M_open = _MemoryOpen($Process)
    If $player = $Currentplayer Then _MemoryWrite($M_open, $Mem_Score_write, $Score_read)
    _MemoryWrite($M_open, Eval("Mem_Score_p"&$player), $Score_read)
    _MemoryClose($M_open)
EndFunc

Func score_write_p1()
    Score_Write(1)
EndFunc
Func score_write_p2()
    Score_Write(2)
EndFunc
Func score_write_p3()
    Score_Write(3)
EndFunc
Func score_write_p4()
    Score_Write(4)
EndFunc

Func score_freeze_p1()
    Score_freeze(1)
EndFunc
Func score_freeze_p2()
    Score_freeze(2)
EndFunc
Func score_freeze_p3()
    Score_freeze(3)
EndFunc
Func score_freeze_p4()
    Score_freeze(4)
EndFunc

$Replayball = 0
$Magnet = 0
$Hyper1 = 0
$Hyper2 = 0
$Hyper3 = 0
$Hyper4 = 0
$Process_state = 1
$Maxplayers_rec = 0
$refresh = TimerInit()
GUISetState(@SW_SHOW)
while 1 
    If GUICtrlRead($CB_flipper) = $GUI_CHECKED And $Process > 0 Then auto_flipper()
    If TimerDiff($refresh) > 300 Then
        $Process = ProcessExists($exe)
        If $Process > 0 Then
            Read()
            
            $M_open = _MemoryOpen($Process)
            If GUICtrlRead($CB_replayball) = $GUI_CHECKED Then 
                _MemoryPointerWrite($M_open, $Mem_replayball, $Mem_replayball_offset, 1)
                $Replayball = 1
            ElseIf $Replayball = 1 And GUICtrlRead($CB_replayball) = $GUI_UNCHECKED Then
                _MemoryPointerWrite($M_open, $Mem_replayball, $Mem_replayball_offset, 0)
                $Replayball = 0
            EndIf
            If GUICtrlRead($CB_magnet) = $GUI_CHECKED Then 
                _MemoryPointerWrite($M_open, $Mem_magnet, $Mem_magnet_offset, 1)
                $Magnet = 1
            ElseIf $Magnet = 1 And GUICtrlRead($CB_magnet) = $GUI_UNCHECKED Then
                _MemoryPointerWrite($M_open, $Mem_magnet, $Mem_magnet_offset, 0)
                $Magnet = 0
            EndIf
            
            If GUICtrlRead($CB_hyper1) = $GUI_CHECKED Then 
                _MemoryPointerWrite($M_open, $Mem_hyper1, $Mem_hyper1_offset, 1)
                $Hyper1 = 1
            ElseIf $Hyper1 = 1 And GUICtrlRead($CB_hyper1) = $GUI_UNCHECKED Then
                _MemoryPointerWrite($M_open, $Mem_hyper1, $Mem_hyper1_offset, 0)
                $Hyper1 = 0
            EndIf
            If GUICtrlRead($CB_hyper2) = $GUI_CHECKED Then 
                _MemoryPointerWrite($M_open, $Mem_hyper2, $Mem_hyper2_offset, 1)
                $Hyper2 = 1
            ElseIf $Hyper2 = 1 And GUICtrlRead($CB_hyper2) = $GUI_UNCHECKED Then
                _MemoryPointerWrite($M_open, $Mem_hyper2, $Mem_hyper2_offset, 0)
                $Hyper2 = 0
            EndIf
            If GUICtrlRead($CB_hyper3) = $GUI_CHECKED Then 
                _MemoryPointerWrite($M_open, $Mem_hyper3, $Mem_hyper3_offset, 1)
                $Hyper3 = 1
            ElseIf $Hyper3 = 1 And GUICtrlRead($CB_hyper3) = $GUI_UNCHECKED Then
                _MemoryPointerWrite($M_open, $Mem_hyper3, $Mem_hyper3_offset, 0)
                $Hyper3 = 0
            EndIf
            If GUICtrlRead($CB_hyper4) = $GUI_CHECKED Then 
                _MemoryPointerWrite($M_open, $Mem_hyper4, $Mem_hyper4_offset, 1)
                $Hyper4 = 1
            ElseIf $Hyper4 = 1 And GUICtrlRead($CB_hyper1) = $GUI_UNCHECKED Then
                _MemoryPointerWrite($M_open, $Mem_hyper4, $Mem_hyper4_offset, 0)
                $Hyper4 = 0
            EndIf
            _MemoryClose($M_open)
            
            GUICtrlSetData($LV_maxplayers, $Maxplayers)
            GUICtrlSetData($LV_currentplayer, $Currentplayer)
            GUICtrlSetData($LV_score_p1, $Score_p1)
            GUICtrlSetData($LV_score_p2, $Score_p2)
            GUICtrlSetData($LV_score_p3, $Score_p3)
            GUICtrlSetData($LV_score_p4, $Score_p4)
            GUICtrlSetData($LV_balls, $Balls)
            GUICtrlSetData($B_editballs, $Balls)
            GUICtrlSetData($LV_x, $X)
            GUICtrlSetData($LV_y, $Y)
            
            If GuiCtrlRead($B_score_p1) = $score_p1 Or Not WinActive($title) And GuiCtrlRead($B_score_p1) <> "" Then
                ;If $Currentplayer = 1 Then
                GUICtrlSetData($B_Score_p1, $Score_p1)
            EndIf
            If GuiCtrlRead($B_score_p2) = $score_p2 Or Not WinActive($title) And GuiCtrlRead($B_score_p2) <> "" Then
                ;If $Currentplayer = 2 Then
                GUICtrlSetData($B_Score_p2, $Score_p2)
            EndIf
            If GuiCtrlRead($B_score_p3) = $score_p3 Or Not WinActive($title) And GuiCtrlRead($B_score_p3) <> "" Then
                ;If $Currentplayer = 3 Then
                GUICtrlSetData($B_Score_p3, $Score_p3)
            EndIf
            If GuiCtrlRead($B_score_p4) = $score_p4 Or Not WinActive($title) And GuiCtrlRead($B_score_p4) <> "" Then
                ;If $Currentplayer = 4 Then
                GUICtrlSetData($B_Score_p4, $Score_p4)
            EndIf
            
            If Eval("Score_p"&$Currentplayer&"_freeze_val") >= 0 Then
                If Eval("Score_p"&$Currentplayer&"_freeze_val") <> Eval("score_p"&$Currentplayer) Then
                    $M_open = _MemoryOpen($Process)
                    _MemoryWrite($M_open, $Mem_Score_write, Eval("Score_p"&$Currentplayer&"_freeze_val"))
                    _MemoryClose($M_open)
                EndIf
            EndIf
        EndIf
        $refresh = TimerInit()
    EndIf
    
    If $Maxplayers <> $Maxplayers_rec Then
        If $Maxplayers > 3 Then
            GUICtrlSetState($B_Score_p2, $GUI_ENABLE)
            GUICtrlSetState($BT_freezescore_p2, $GUI_ENABLE)
            GUICtrlSetState($BT_setscore_p2, $GUI_ENABLE)
            GUICtrlSetState($B_Score_p3, $GUI_ENABLE)
            GUICtrlSetState($BT_freezescore_p3, $GUI_ENABLE)
            GUICtrlSetState($BT_setscore_p3, $GUI_ENABLE)
            GUICtrlSetState($B_Score_p4, $GUI_ENABLE)
            GUICtrlSetState($BT_freezescore_p4, $GUI_ENABLE)
            GUICtrlSetState($BT_setscore_p4, $GUI_ENABLE)
        ElseIf $Maxplayers > 2 Then
            GUICtrlSetState($B_Score_p2, $GUI_ENABLE)
            GUICtrlSetState($BT_freezescore_p2, $GUI_ENABLE)
            GUICtrlSetState($BT_setscore_p2, $GUI_ENABLE)
            GUICtrlSetState($B_Score_p3, $GUI_ENABLE)
            GUICtrlSetState($BT_freezescore_p3, $GUI_ENABLE)
            GUICtrlSetState($BT_setscore_p3, $GUI_ENABLE)
            GUICtrlSetState($B_Score_p4, $GUI_DISABLE)
            GUICtrlSetState($BT_freezescore_p4, $GUI_DISABLE)
            GUICtrlSetState($BT_setscore_p4, $GUI_DISABLE)
        ElseIf $Maxplayers > 1 Then
            GUICtrlSetState($B_Score_p2, $GUI_ENABLE)
            GUICtrlSetState($BT_freezescore_p2, $GUI_ENABLE)
            GUICtrlSetState($BT_setscore_p2, $GUI_ENABLE)
            GUICtrlSetState($B_Score_p3, $GUI_DISABLE)
            GUICtrlSetState($BT_freezescore_p3, $GUI_DISABLE)
            GUICtrlSetState($BT_setscore_p3, $GUI_DISABLE)
            GUICtrlSetState($B_Score_p4, $GUI_DISABLE)
            GUICtrlSetState($BT_freezescore_p4, $GUI_DISABLE)
            GUICtrlSetState($BT_setscore_p4, $GUI_DISABLE)
        Else
            GUICtrlSetState($B_Score_p2, $GUI_DISABLE)
            GUICtrlSetState($BT_freezescore_p2, $GUI_DISABLE)
            GUICtrlSetState($BT_setscore_p2, $GUI_DISABLE)
            GUICtrlSetState($B_Score_p3, $GUI_DISABLE)
            GUICtrlSetState($BT_freezescore_p3, $GUI_DISABLE)
            GUICtrlSetState($BT_setscore_p3, $GUI_DISABLE)
            GUICtrlSetState($B_Score_p4, $GUI_DISABLE)
            GUICtrlSetState($BT_freezescore_p4, $GUI_DISABLE)
            GUICtrlSetState($BT_setscore_p4, $GUI_DISABLE)
        EndIf
        $Maxplayers_rec = $Maxplayers
    EndIf
    
    If Not $Process > 0 And $Process_state = 1 Then
        $Process_state = 0
        GUICtrlSetState($CB_hyper1, $GUI_DISABLE)
        GUICtrlSetState($CB_hyper2, $GUI_DISABLE)
        GUICtrlSetState($CB_hyper3, $GUI_DISABLE)
        GUICtrlSetState($CB_hyper4, $GUI_DISABLE)
        GUICtrlSetState($CB_magnet, $GUI_DISABLE)
        GUICtrlSetState($CB_replayball, $GUI_DISABLE)
        ;GUICtrlSetState($CB_pin, $GUI_DISABLE)
        GUICtrlSetState($CB_flipper, $GUI_DISABLE)
        
        GUICtrlSetState($B_Score_p1, $GUI_DISABLE)
        GUICtrlSetState($BT_freezescore_p1, $GUI_DISABLE)
        GUICtrlSetState($BT_setscore_p1, $GUI_DISABLE)
        GUICtrlSetState($B_Score_p2, $GUI_DISABLE)
        GUICtrlSetState($BT_freezescore_p2, $GUI_DISABLE)
        GUICtrlSetState($BT_setscore_p2, $GUI_DISABLE)
        GUICtrlSetState($B_Score_p3, $GUI_DISABLE)
        GUICtrlSetState($BT_freezescore_p3, $GUI_DISABLE)
        GUICtrlSetState($BT_setscore_p3, $GUI_DISABLE)
        GUICtrlSetState($B_Score_p4, $GUI_DISABLE)
        GUICtrlSetState($BT_freezescore_p4, $GUI_DISABLE)
        GUICtrlSetState($BT_setscore_p4, $GUI_DISABLE)
        ;GUICtrlSetState($BT_freezeball, $GUI_DISABLE)
        ;GUICtrlSetState($BT_setball, $GUI_DISABLE)
        ;GUICtrlSetState($B_editballs, $GUI_DISABLE)
    ElseIf $Process > 0 And $Process_state = 0 Then
        GUICtrlSetState($CB_hyper1, $GUI_ENABLE)
        GUICtrlSetState($CB_hyper2, $GUI_ENABLE)
        GUICtrlSetState($CB_hyper3, $GUI_ENABLE)
        GUICtrlSetState($CB_hyper4, $GUI_ENABLE)
        GUICtrlSetState($CB_magnet, $GUI_ENABLE)
        GUICtrlSetState($CB_replayball, $GUI_ENABLE)
        ;GUICtrlSetState($CB_pin, $GUI_ENABLE)
        GUICtrlSetState($CB_flipper, $GUI_ENABLE)
        
        ;GUICtrlSetState($BT_freezeball, $GUI_ENABLE)
        ;GUICtrlSetState($BT_setball, $GUI_ENABLE)
        ;GUICtrlSetState($B_editballs, $GUI_ENABLE)
        GUICtrlSetState($B_Score_p1, $GUI_ENABLE)
        GUICtrlSetState($BT_freezescore_p1, $GUI_ENABLE)
        GUICtrlSetState($BT_setscore_p1, $GUI_ENABLE)
        $Process_state = 1
    EndIf
    
WEnd

#Region MEM
Func _MemoryOpen($iv_Pid, $iv_DesiredAccess = 0x1F0FFF, $if_InheritHandle = 1)
    If Not ProcessExists($iv_Pid) Then
        SetError(1)
        Return 0
    EndIf
    Local $ah_Handle[2] = [DllOpen('kernel32.dll')]
    If @Error Then
        SetError(2)
        Return 0
    EndIf
    Local $av_OpenProcess = DllCall($ah_Handle[0], 'int', 'OpenProcess', 'int', $iv_DesiredAccess, 'int', $if_InheritHandle, 'int', $iv_Pid)
    If @Error Then
        DllClose($ah_Handle[0])
        SetError(3)
        Return 0
    EndIf
    $ah_Handle[1] = $av_OpenProcess[0]
    Return $ah_Handle
EndFunc

Func _MemoryRead($ah_Handle, $iv_Address, $sv_Type = 'dword')
    If Not IsArray($ah_Handle) Then
        SetError(1)
        Return 0
    EndIf
    Local $v_Buffer = DllStructCreate($sv_Type)
    If @Error Then
        SetError(@Error + 1)
        Return 0
    EndIf
    DllCall($ah_Handle[0], 'int', 'ReadProcessMemory', 'int', $ah_Handle[1], 'int', $iv_Address, 'ptr', DllStructGetPtr($v_Buffer), 'int', DllStructGetSize($v_Buffer), 'int', '')
    If Not @Error Then
        Local $v_Value = DllStructGetData($v_Buffer, 1)
        Return $v_Value
    Else
        SetError(6)
        Return 0
    EndIf
EndFunc

Func _MemoryWrite($ah_Handle, $iv_Address, $v_Data, $sv_Type = 'dword')
    If Not IsArray($ah_Handle) Then
        SetError(1)
        Return 0
    EndIf
    Local $v_Buffer = DllStructCreate($sv_Type)
    If @Error Then
        SetError(@Error + 1)
        Return 0
    Else
        DllStructSetData($v_Buffer, 1, $v_Data)
        If @Error Then
            SetError(6)
            Return 0
        EndIf
    EndIf
    DllCall($ah_Handle[0], 'int', 'WriteProcessMemory', 'int', $ah_Handle[1], 'int', $iv_Address, 'ptr', DllStructGetPtr($v_Buffer), 'int', DllStructGetSize($v_Buffer), 'int', '')
    If Not @Error Then
        Return 1
    Else
        SetError(7)
        Return 0
    EndIf
EndFunc

Func _MemoryClose($ah_Handle)
    If Not IsArray($ah_Handle) Then
        SetError(1)
        Return 0
    EndIf
    DllCall($ah_Handle[0], 'int', 'CloseHandle', 'int', $ah_Handle[1])
    If Not @Error Then
        DllClose($ah_Handle[0])
        Return 1
    Else
        DllClose($ah_Handle[0])
        SetError(2)
        Return 0
    EndIf
EndFunc

Func _MemoryPointerRead ($ah_Handle, $iv_Address, $av_Offset, $sv_Type = 'dword')
    If IsArray($av_Offset) Then
        If IsArray($ah_Handle) Then
            Local $iv_PointerCount = UBound($av_Offset) - 1
        Else
            SetError(2)
            Return 0
        EndIf
    Else
        SetError(1)
        Return 0
    EndIf
    Local $iv_Data[2], $i
    Local $v_Buffer = DllStructCreate('dword')
    For $i = 0 to $iv_PointerCount
        If $i = $iv_PointerCount Then
            $v_Buffer = DllStructCreate($sv_Type)
            If @Error Then
                SetError(@Error + 2)
                Return 0
            EndIf
            $iv_Address = '0x' & hex($iv_Data[1] + $av_Offset[$i])
            DllCall($ah_Handle[0], 'int', 'ReadProcessMemory', 'int', $ah_Handle[1], 'int', $iv_Address, 'ptr', DllStructGetPtr($v_Buffer), 'int', DllStructGetSize($v_Buffer), 'int', '')
            If @Error Then
                SetError(7)
                Return 0
            EndIf
            $iv_Data[1] = DllStructGetData($v_Buffer, 1)
        ElseIf $i = 0 Then
            DllCall($ah_Handle[0], 'int', 'ReadProcessMemory', 'int', $ah_Handle[1], 'int', $iv_Address, 'ptr', DllStructGetPtr($v_Buffer), 'int', DllStructGetSize($v_Buffer), 'int', '')
            If @Error Then
                SetError(7)
                Return 0
            EndIf
            $iv_Data[1] = DllStructGetData($v_Buffer, 1)
        Else
            $iv_Address = '0x' & hex($iv_Data[1] + $av_Offset[$i])
            DllCall($ah_Handle[0], 'int', 'ReadProcessMemory', 'int', $ah_Handle[1], 'int', $iv_Address, 'ptr', DllStructGetPtr($v_Buffer), 'int', DllStructGetSize($v_Buffer), 'int', '')
            If @Error Then
                SetError(7)
                Return 0
            EndIf
            $iv_Data[1] = DllStructGetData($v_Buffer, 1)
        EndIf
    Next
    $iv_Data[0] = $iv_Address
    Return $iv_Data
EndFunc

Func _MemoryPointerWrite ($ah_Handle, $iv_Address, $av_Offset, $v_Data, $sv_Type = 'dword')
    If IsArray($av_Offset) Then
        If IsArray($ah_Handle) Then
            Local $iv_PointerCount = UBound($av_Offset) - 1
        Else
            SetError(2)
            Return 0
        EndIf
    Else
        SetError(1)
        Return 0
    EndIf
    Local $iv_StructData, $i
    Local $v_Buffer = DllStructCreate('dword')
    For $i = 0 to $iv_PointerCount
        If $i = $iv_PointerCount Then
            $v_Buffer = DllStructCreate($sv_Type)
            If @Error Then
                SetError(@Error + 3)
                Return 0
            EndIf
            DllStructSetData($v_Buffer, 1, $v_Data)
            If @Error Then
                SetError(8)
                Return 0
            EndIf
            $iv_Address = '0x' & hex($iv_StructData + $av_Offset[$i])
            DllCall($ah_Handle[0], 'int', 'WriteProcessMemory', 'int', $ah_Handle[1], 'int', $iv_Address, 'ptr', DllStructGetPtr($v_Buffer), 'int', DllStructGetSize($v_Buffer), 'int', '')
            If @Error Then
                SetError(9)
                Return 0
            Else
                Return $iv_Address
            EndIf
        ElseIf $i = 0 Then
            DllCall($ah_Handle[0], 'int', 'ReadProcessMemory', 'int', $ah_Handle[1], 'int', $iv_Address, 'ptr', DllStructGetPtr($v_Buffer), 'int', DllStructGetSize($v_Buffer), 'int', '')
            If @Error Then
                SetError(3)
                Return 0
            EndIf
            $iv_StructData = DllStructGetData($v_Buffer, 1)
        Else
            $iv_Address = '0x' & hex($iv_StructData + $av_Offset[$i])
            DllCall($ah_Handle[0], 'int', 'ReadProcessMemory', 'int', $ah_Handle[1], 'int', $iv_Address, 'ptr', DllStructGetPtr($v_Buffer), 'int', DllStructGetSize($v_Buffer), 'int', '')
            If @Error Then
                SetError(3)
                Return 0
            EndIf
            $iv_StructData = DllStructGetData($v_Buffer, 1)
        EndIf
    Next
EndFunc
#endregion

[EDIT]updated it :)[/EDIT]

Edited by Dellairion
Link to comment
Share on other sites

Here are the memory locations I have found:

7AFC04 Current Player

7AB302 Current Player's Score

7AB31A Player 1's Score

7AB336 Player 2's Score

7AB352 Player 3's Score

7AB36E Player 4's Score

Thanks for the script. It helped me to learn more of AutoIt's language.

I'll try to make a script that incorporates these values.

I agree with Manadar, it's a good idea to continue with AutoIt even if you learn C++ because it is much more complicated to do the same thing in C++ as compared to AutoIt. Sometimes you want/need that complexity, but for other projects you may just want/need to be able to knock it out in short order.

Link to comment
Share on other sites

OK, I made a script that incorporates the memory locations I mentioned in my last post.

Space_Cadet_Trainer.au3

Dellairion, where did you get those memory functions? Did you write them yourself?

Also, does anyone know of a tool to help me set up the GUI? Trying to figure out the X and Y values of the controls is a real pain.

Edited by EWOlson
Link to comment
Share on other sites

  • 2 weeks later...

Thanks.

I didn't have the latest version of SciTE, so I didn't have those options. Downloaded it, and now I'm off to play. :)

Forget about very old obsolete GUIBuilder, when there is new fantastic Koda 1.6 :P

http://www.autoitscript.com/fileman/users/lookfar/formdesign.html

http://www.autoitscript.com/forum/index.php?showtopic=32299

Link to comment
Share on other sites

  • 2 weeks later...
  • 5 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...