Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Open Selected Process - Need more help with script

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1668

PostPosted: Sun Apr 12, 2015 11:34 pm    Post subject: Open Selected Process - Need more help with script Reply with quote

Hello again guy and specially Panraven bro..

I have used your script and put it to my form trainer function.
Anyhow, i am a newbie and still need help to learn everything about making a trainer.

I have facing a problem. After i click "CLICK-OPEN PROCESS" label and Process list form opened, after make a selected process and double click on it, the process which selected not come to "CLICK-OPEN PROCESS: label.
Would you help me to fix this problem ?.

One other problem, i made a button with function to scan value type double (the value already state as 100.00 and change to -1.00), when I click the button. But it not work.
Also, any hint or solution to fix it ?

Here is my trainer form properties :

MyForm : TCEForm
MyLabel : TCELabel (Info)
btnOpenProcess : TCEButton (Click to open selected process)
HACK1_button : TCEButton (Click to process AOB scan)
HACK2_button : TCEButton (Click to process value type double scan)

and here is the script :

Code:

---- Function open process
function Click_ProcessClick(sender)
function pidDialog(doPid)
  local plugname = {"iexplore","flashplayerplugin","plugin-container","opera","chrome","awesomium_process","torch","dragon","maxthon","palemoon","safari" }
  local function tmerge(t,o,...) for k,v in pairs(o) do t[k]=v end if select('#',...)>0 then return tmerge(t,...) else return t end end
  local function callLater(f,...)
    local t = createTimer()
    local a,n = {...},select('#',...)
    t.Interval = 100
    t.OnTimer = function(sender) sender.Enabled=false sender.Destroy() f(unpack(a,1,n)) end
    t.Enabled = true
    return t
  end
  local function parseProc(s)
    local p,n
    for pid,name in string.gmatch(s,'([0-9A-F]+)-(.*)') do
      p = pid ; n = name
    end
    return  p,n
  end
  local function prec(i,p,n)
    local weight = 0
    for _,v in ipairs(plugname) do
      if string.find(string.lower(n),string.lower(v),1,true) then weight = weight + 1 end
    end
    return {pid=p,desc=string.format('%5d-%04X-%s',p,p,n),name=n,w=weight+i/2048}
  end

  local FP = createForm(false)
  tmerge(FP,{FormStyle='fsStayOnTop',AutoSize=true,BorderWidth=4,Color=0x80,Position='poScreenCenter',BorderStyle='bsToolWindow',Caption='Double Click to Select'})
  local LB = createListBox(FP)
  tmerge(LB,{MultiSelect=false,AutoSize=true,Color=0x80})
  local cs = LB.Constraints
  tmerge(cs,{MinHeight=300,MinWidth=400})
  local fn = LB.Font
  tmerge(fn,{Color=0xffffff,Name='Courier New',Height=-16,Style='[bsBold]'})

  LB.OnDblClick = function()
    local idx,PID,NAME = LB.ItemIndex,nil,''
    if idx >= 0 then
      for pid,pID,name in string.gmatch(LB.Items[idx],'([0-9]+)-\s*([0-9A-F]+)-(.*)') do
        PID = tonumber(pid,10)
        NAME = name
      end
    end
--    print(tostring(PID))
    if PID ~= nil then callLater(doPid,PID,NAME) end
    FP.close()
  end -- LB.OnDblClick

  FP.OnClose = function()  FP.destroy(); FP = nil end

  getProcesslist(LB.Items)
  local plist = {}
  for i=1,LB.Items.getCount() do
    local p,n = parseProc(LB.Items[i-1])
    p = tonumber(p,16)
    table.insert(plist,prec(i,p,n))
  end

  table.sort(plist,function(a,b) return a.w > b.w end)
  local currProcId = getOpenedProcessID()
  for i=1,LB.Items.getCount() do
    LB.Items.setString(i-1,plist[i].desc)
    if plist[i].pid == currProcId then LB.setItemIndex(i-1) end
  end

  FP.show()
end

-- usage:
--pidDialog(print)
--pidDialog(openProcess)

pidDialog(function(pid,name) print(string.format('%04X-%s',pid,name)) end)
end

-----
 function btnOpenProcessClick(sender)
 if openProcess(MyForm.edtProcessname.text) then
    MyForm.HACK1_Button.enabled=true
    MyForm.HACK2_Button.enabled=true
  else
    showMessage("Failed opening this process")
  end
end


----- HACK1 (Use for another AOB hack code)
function HACK1_ButtonClick(sender)
return autoAssemble[[aobscan(myaob,aa bb cc dd)
myaob:
db aa bb cc xx]]
end


----- HACK2 (Use for scan value type double)
function HACK2_ButtonClick(sender)
function findDoubleValueAndReplace(findValue, replaceWith)
  memscan = createMemScan()
  foundlist = createFoundList(memscan)
  protectionflags = "-W*X-C"

  -- firstScan(scanoption, vartype, roundingtype, input1, input2,
  --           startAddress, stopAddress, protectionflags,
  --           alignmenttype, "alignmentparam",
  --           isHexadecimalInput, isNotABinaryString, isunicodescan, iscasesensitive)

  --    scanOption: soUnknownValue, soExactValue, soValueBetween, soBiggerThan, soSmallerThan
  --    vartype: vtByte, vtWord, vtDword, vtQword, vtSingle, vtDouble, vtString,
  --             vtByteArray, vtGrouped, vtBinary, vtAll
  --    roundingtype: rtRounded, rtTruncated, rtExtremerounded
  --    alignmenttype: fsmNotAligned, fsmAligned, fsmLastDigits
  --    protectionflags: X W C   (+ to indicate that flag MUST be set, - MUST NOT, * whatever)

  memscan.firstScan(soExactValue, vtDouble, rtTruncated, findValue, nil,
               "0","7fffffff",protectionflags,
               fsmAligned,"4",
               false, false, false, false)
  memscan.waitTillDone()
  foundlist.initialize()

  for i=0,foundlist.Count-1 do
   fullAccess(  getAddress(foundlist.Address[i])  , 8)
   writeDouble(  foundlist.Address[i], replaceWith)
  end

  sleep(50)
  foundlist.destroy()
  sleep(50)
  memscan.destroy()


function doit()
  findDoubleValueAndReplace(100.00, -1.00)
end

myForm = createForm()
myForm.OnClose = function () return caFree end
myForm.height = 100
myForm.width = 240
myForm.caption = "Double scan"
myForm.centerScreen()

myButton = createButton(myForm)
myButton.caption = "100 to -1 DO IT"
myButton.height = 20
myButton.width = 60
myButton.top = 31
myButton.left = 100
myButton.onClick = doit
end


function FormClose(sender)
  closeCE();
  return caHide --Possible options: caHide, caFree, caMinimize, caNone
end

</LuaScript>
</CheatTable>


Thank you and regards[/code]



ProcessForm.JPG
 Description:
 Filesize:  125.33 KB
 Viewed:  4515 Time(s)

ProcessForm.JPG


Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites