samy_grecu !BEWARE! Deletes post on answer Reputation: 0
Joined: 30 Dec 2016 Posts: 12 Location: Italy
Posted: Mon Jan 22, 2018 7:31 am Post subject: PID getProcessIDFromProcessName
Hi
I try to print also the PID like this "Attached to Tutorial: .. PID ..")
Can anyone help me
Code:
PROCESS_NAME = 'Tutorial-i386.exe'
--------
-------- Auto Attach
--------
local autoAttachTimer = nil
local autoAttachTimerInterval = 1000 ---- Timer intervals are in milliseconds
local autoAttachTimerTicks = 0
local autoAttachTimerTickMax = 5000 ---- Set to zero to disable ticks max
local function autoAttachTimer_tick(timer) ---- Timer tick call back
if autoAttachTimerTickMax > 0 and autoAttachTimerTicks >= autoAttachTimerTickMax then
timer.destroy() ---- Destroy timer if max ticks is reached
end
if getProcessIDFromProcessName(PROCESS_NAME) ~= nil then ---- Check if process is running
CETrainer.Caption = "Tutorial-i386.exe not running !"
timer.destroy() ---- Destroy timer
openProcess(PROCESS_NAME) ---- Open the process
CETrainer.Caption = "Attached to Tutorial-i386.exe"
end
autoAttachTimerTicks = autoAttachTimerTicks + 1 ---- Increase ticks
end
autoAttachTimer = createTimer(getMainForm()) ---- Create timer with the main form as it's parent
autoAttachTimer.Interval = autoAttachTimerInterval ---- Set timer interval
autoAttachTimer.OnTimer = autoAttachTimer_tick ---- Set timer tick call back
-- note these do not update if the process closes
-- to check if open you can use readInteger(process) ~= nil
-- that way if there are multiple instances of the same program
-- you know that the one CE _was_ attached to is or is not still running
-- without explicitly checking that the process ids match
if process ~= nil then
use getOpenedProcessID()
end
though I'm not sure why you'd only wait five seconds....also, you could use
Code:
onOpenProcess = function(pid)
do stuff when CE attaches to a process
end
samy_grecu !BEWARE! Deletes post on answer Reputation: 0
Joined: 30 Dec 2016 Posts: 12 Location: Italy
Posted: Mon Jan 22, 2018 10:34 am Post subject:
thank you..
i use the code for multiple browsers in my trainers
the problem is that I am forced to use autoAttachTimerInterval
to check if the browser closed and reopened(
all work fine, but my pc gets very slow
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum