Corroder Grandmaster Cheater Supreme Reputation: 75
Joined: 10 Apr 2015 Posts: 1667
|
Posted: Tue Feb 07, 2017 10:27 pm Post subject: Switch 2 Game In a Trainer |
|
|
Hi there,
Code: | fo = createForm()
fo.Height = 90
fo.Width = 352
fo.Position = poScreenCenter
fo.Caption = "Switch Game"
Pn = createPanel(fo)
Pn.Height = 90
Pn.Width = 352
lb = createLabel(Pn)
lb.Top = 55
lb.Left = 150
lb.Caption = "Waiting for open game"
B1 = createButton(Pn)
B1.Height = 25
B1.Width = 75
B1.Left = 20
B1.Top = 20
B1.Caption = "Explorer"
--B1.onClick = exploreFile
B2 = createButton(Pn)
B2.Height = 25
B2.Width = 75
B2.Left = 100
B2.Top = 20
B2.Caption = "Game 1"
--B2.onClick = game_check1()
B3 = createButton(Pn)
B3.Height = 25
B3.Width = 75
B3.Left = 180
B3.Top = 20
B3.Caption = "Game 2"
--B3.onClick = game_check2()
B4 = createButton(Pn)
B4.Height = 25
B4.Width = 75
B4.Left = 260
B4.Top = 20
B4.Caption = "Exit"
--B4.onClick = exitTrainer
-------------------------------
function exploreFile()
local dialog = createOpenDialog(nil)
dialog.options = "[ofAllowMultiSelect]"
local result = dialog.execute()
if result then
local files = dialog.files
for i = 0, files.count - 1 do
shellExecute("cmd", [[/c start "" "]]..files[i]..[["]])
end
end
dialog.destroy()
end
function getProcess_NameFromID(processId)
local processName = nil
local list = createStringlist()
getProcesslist(list)
for i = 0, list.Count-1 do
local id, name = list.String[i]:match("(.*)-(.*)")
if processId == tonumber(id, 16) then
processName = name
break
end
end
return processName
end
function game_check1()
if readInteger("PlantsvsZombies.exe") ~= nil then
shellExecute("taskkill", "/IM PlantsvsZombies.exe /F")
end
game = "Kingdom Rush - "
if readInteger("Kingdom.exe") == nil then
lb.Caption = string.format(game.."not detected")
lb.Font.Color = 0x009900
beep()
else
openProcess("Kingdom.exe")
local id = getOpenedProcessID()
local name = getProcess_NameFromID(processId)
lb.Caption = string.format("Detected " ..id.." - "..name)
lb.Font.Color = 0x009900
end
end
function game_check2()
if readInteger("Kingdom.exe") ~= nil then
shellExecute("taskkill", "/IM Kingdom.exe /F")
end
game = "Plants vs Zombies - "
if readInteger("PlantsvsZombies.exe") == nil then
lb.Caption = string.format(game.."not detected")
lb.Font.Color = 0x009900
beep()
else
openProcess("PlantsvsZombies.exe")
local id = getOpenedProcessID()
local name = getProcess_NameFromID(processId)
lb.Caption = string.format("Detected " ..id.." - "..name)
lb.Font.Color = 0x009900
end
end
function exitTrainer()
closeCE()
return caFree
end
B1.onClick = exploreFile
B2.onClick = game_check1()
B3.onClick = game_check2()
B4.onClick = exitTrainer
form_onClose(fo, exitTrainer)
fo.Show() |
B1 button = use to explorer games in a folder (similar to windows explorer)
B2 button = use to open game 1, while kill game 2 if game 2 running in memory
B3 button = use to open game 2, while kill game 1 if game 1 running in memory
lb label = to show what name game opened + PID (also use to show message if needed)
Problem :
1. Label lb Caption directly show "Plants vs Zombies - Not Detected" when opening trainer without waiting for a button clicked
2. No game process attached when click button B2 or B3 even game already open using button B1 (explorer game)
What's wrong need to fix ?
Thank you
|
|