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 


Select Directory

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Hacubi
How do I cheat?
Reputation: 0

Joined: 29 Nov 2020
Posts: 5

PostPosted: Wed Dec 09, 2020 9:57 am    Post subject: Select Directory Reply with quote

need help about this
i just want to select the the directory of an exe using button1, then it will show its name on textbox, is that possible?
also i have button2 to run exe using shellcode,



Capture.JPG
 Description:
Sample button1(select) button2(Run exe)
textbox(show exe name)
 Filesize:  10.63 KB
 Viewed:  1450 Time(s)

Capture.JPG



_________________
Just a Passerby
Back to top
View user's profile Send private message
ByTransient
Expert Cheater
Reputation: 5

Joined: 05 Sep 2020
Posts: 240

PostPosted: Wed Dec 09, 2020 12:03 pm    Post subject: Reply with quote

You cannot open many files by name.
Example: Can run "textFile.txt" with "notepad.exe".
"shellExecute ()" will ask for the file path.
Below is an example you can edit.

Code:
if f then f.destroy() end

f=createForm(true)
f.Position=poDesktopCenter
f.Width=255 f.Height=105

e1 = createEdit(f)
e1.Height=24 e1.Left=5 e1.Top=10 e1.Width=160

e2 = createEdit(f)
e2.Height=24 e2.Left=5 e2.Top=40 e2.Width=245 --e2.visible=false -- or  true !

b1 = createButton(f)
b1.Left=175 b1.Top=9 b1.caption="Select"

b2 = createButton(f)
b2.Left=5 b2.Top=70 b2.Width=160 b2.caption="Run Solitaire"

local file_name = ""

b1.OnClick=function()
local file_dialog = createOpenDialog()
file_dialog.InitialDir = os.getenv('%USERPROFILE%')
file_dialog.Filter = 'All files (*.*)|*'
if file_dialog.execute() then
   file_name = file_dialog.FileName
name=file_name:match("[^\\]*$")
name1 = string.match(name, '(.*).exe')
   b2.caption="Open: "..name1
   e2.Text=file_name
   e1.Text=name
   return
else
   return nil
end
end

b2.OnClick=function()
shellExecute(e2.Text) -- or file_name
end
Back to top
View user's profile Send private message
Hacubi
How do I cheat?
Reputation: 0

Joined: 29 Nov 2020
Posts: 5

PostPosted: Wed Dec 09, 2020 12:30 pm    Post subject: Reply with quote

ByTransient wrote:
You cannot open many files by name.
Example: Can run "textFile.txt" with "notepad.exe".
"shellExecute ()" will ask for the file path.
Below is an example you can edit.

Code:
if f then f.destroy() end

f=createForm(true)
f.Position=poDesktopCenter
f.Width=255 f.Height=105

e1 = createEdit(f)
e1.Height=24 e1.Left=5 e1.Top=10 e1.Width=160

e2 = createEdit(f)
e2.Height=24 e2.Left=5 e2.Top=40 e2.Width=245 --e2.visible=false -- or  true !

b1 = createButton(f)
b1.Left=175 b1.Top=9 b1.caption="Select"

b2 = createButton(f)
b2.Left=5 b2.Top=70 b2.Width=160 b2.caption="Run Solitaire"

local file_name = ""

b1.OnClick=function()
local file_dialog = createOpenDialog()
file_dialog.InitialDir = os.getenv('%USERPROFILE%')
file_dialog.Filter = 'All files (*.*)|*'
if file_dialog.execute() then
   file_name = file_dialog.FileName
name=file_name:match("[^\\]*$")
name1 = string.match(name, '(.*).exe')
   b2.caption="Open: "..name1
   e2.Text=file_name
   e1.Text=name
   return
else
   return nil
end
end

b2.OnClick=function()
shellExecute(e2.Text) -- or file_name
end


Ok, thanks for the help, gonna try this,

EDIT :
Actually this is more than as I expected,
but, I made a form in form designer,
it consist of CEbutton1(select), CEbutton2(Run *.*) and CEEdit1(text)

I manage to recode the buttons but the CEEdit didn't show the file name when i select the file, im not actually confident with my code sorry
I you could show me the full code that will be a big help.

EDIT
Sorry i manage to recode, thanks for the help! Smile

_________________
Just a Passerby
Back to top
View user's profile Send private message
ByTransient
Expert Cheater
Reputation: 5

Joined: 05 Sep 2020
Posts: 240

PostPosted: Thu Dec 10, 2020 10:23 am    Post subject: Reply with quote

I am sorry for my late answer.
I overlooked that it might be "EDIT" instead of the new answer.

There are 2 solutions, the first is alternative to learn the solution.
The second solution may be what you want.
Just change your Trainer name instead of "UDF1".

solition (1)

Code:

local e1=UDF1.CEEdit1
local b1=UDF1.CEButton1
local b2=UDF1.CEButton2

b1.caption="Select"
b2.caption="Run Solitaire"

local file_name = ""

b1.OnClick=function()
local file_dialog = createOpenDialog()
file_dialog.InitialDir = os.getenv('%USERPROFILE%')
file_dialog.Filter = 'All files (*.*)|*'
if file_dialog.execute() then
   file_name = file_dialog.FileName
name=file_name:match("[^\\]*$")
name1 = string.match(name, '(.*).exe')
--Print zone here
print(file_name)
   b2.caption="Open: "..name1
  -- e2.Text=file_name
   e1.Text=name
   return
else
   return nil
end
end

b2.OnClick=function()
shellExecute(file_name)
end


solition (2)
Code:

local file_name = ""

UDF1.CEButton1.OnClick=function()
local file_dialog = createOpenDialog()
file_dialog.InitialDir = os.getenv('%USERPROFILE%')
file_dialog.Filter = 'All files (*.*)|*'
if file_dialog.execute() then
   file_name = file_dialog.FileName
name=file_name:match("[^\\]*$")
name1 = string.match(name, '(.*).exe')

--Print zone here
print(file_name)
   UDF1.CEButton2.caption="Open: "..name1
  --UDF1.CEEdit2.Text=file_name
   UDF1.CEEdit1.Text=name
   return
else
   return nil
end
end

UDF1.CEButton2.OnClick=function()
shellExecute(file_name)
end
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