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 Dialog Help in Lua Script
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Death GOD 7
Expert Cheater
Reputation: 0

Joined: 21 Jan 2017
Posts: 105
Location: Heaven and Hell

PostPosted: Sat Aug 26, 2017 11:20 am    Post subject: Open Dialog Help in Lua Script Reply with quote

I have written code in button click that opens a dialog box.But in dialog box how to change to file type *.exe and show only exe files.And I also want to open file (lets call it X.exe) and only open that X.exe file from that dialog.
Anybody?Any help is appreciated. Question

_________________

"If you are good at something,never do it for free"-The Joker
I know you are looking at this post, Hitler
Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Sat Aug 26, 2017 4:59 pm    Post subject: Reply with quote

Why not use shell execute to open specify exe file ?

Code:
shellExecute('C:\\path\\sub path\\x.exe"')


or to related topic :

http://www.cheatengine.org/forum/viewtopic.php?p=5714191&sid=9acaa5fdc0580a1dedafe15a33a4045a

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
Death GOD 7
Expert Cheater
Reputation: 0

Joined: 21 Jan 2017
Posts: 105
Location: Heaven and Hell

PostPosted: Sun Aug 27, 2017 12:12 am    Post subject: Reply with quote

Corroder wrote:
Why not use shell execute to open specify exe file ?

Code:
shellExecute('C:\\path\\sub path\\x.exe"')


or to related topic :

http://www.cheatengine.org/forum/viewtopic.php?p=5714191&sid=9acaa5fdc0580a1dedafe15a33a4045a

I used shell execute code.but I only want other users to open X.Exe file and in open dialog box I want to show only *.exe extension files to show

_________________

"If you are good at something,never do it for free"-The Joker
I know you are looking at this post, Hitler
Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Sun Aug 27, 2017 7:43 am    Post subject: Reply with quote

This code below will show files in a directory.
Anyway, I don;t know how to filtering only exe files to display.

f = createForm()
Code:
b = createButton(f)
b.width = 100
b.height = 30
b.Caption = 'Test Me'

function GetFileName(f)
 local str = f
 local temp = ""
 local result = ""
 for i = str:len(), 1, -1 do
 if str:sub(i,i) ~= "/"  then
 temp = temp..str:sub(i,i)
 else
 break
 end
 end
 for j = temp:len(), 1, -1 do
 result = result..temp:sub(j,j)
 end
 return result
end

function exploFile()
 load_dialog = createOpenDialog(self)
 load_dialog.InitalDir = os.getenv('%USERPROFILE%')
 load_dialog.execute()
 file = load_dialog.FileName
 a = GetFileName(file)
 if a == nil then
 return a
 else
 print(a)  --- should be change to shellExecute here...
 end
end

b.onClick = exploFile
f.show()

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
FreeER
Grandmaster Cheater Supreme
Reputation: 53

Joined: 09 Aug 2013
Posts: 1091

PostPosted: Sun Aug 27, 2017 1:07 pm    Post subject: Reply with quote

Corroder wrote:
Anyway, I don;t know how to filtering only exe files to display.
Simple enough, the celua.txt file mentions that a FileDialog has the property " Filter: string - A filter formatted string" and a simple google search gives the format as 'Name|mask[;mask...]' with each name/mask separated by '|' eg.
Code:
load_dialog.Filter = 'Executable files|*.EXE;*.BAT;*.CMD;*.sh|Bat files (*.bat)|*.BAT|Exe files (*.exe)|*.EXE|All files (*.*)|*'


also, since Windows uses \ for paths so looking for / is probably not correct...
Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Sun Aug 27, 2017 4:38 pm    Post subject: Reply with quote

Ok, Thanks @FreeER

After read this from http://wiki.cheatengine.org/index.php?title=OpenDialog
and by your sample, here a simple way to filtering files type and displaying its using openDialog.

Code:
load_dialog = createOpenDialog(self)
 load_dialog.InitalDir = os.getenv('%USERPROFILE%')
 load_dialog.Filter = 'Executable files|*.EXE;*.BAT;*.CMD;*.sh|Bat files (*.bat)|*.BAT|Exe files (*.exe)|*.EXE|All files (*.*)|*'
 load_dialog.execute()
 print(load_dialog.FileName)   --- shoud be change to shell execute to run app

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
Death GOD 7
Expert Cheater
Reputation: 0

Joined: 21 Jan 2017
Posts: 105
Location: Heaven and Hell

PostPosted: Mon Aug 28, 2017 9:32 am    Post subject: Reply with quote

Got it thanks...
I again need help
1. I want trainer to close and music to stop when I press exit button so I wrote this
And I also want user to confirm that they want to exit.if the users presses yes then exit else do nothing
Code:

function exitbttnClick(sender)
messageDialog ("...Are you sure?",mtWarning, mbYes,mbCancel)
--and if yes then
closeCE()
xmplayer.stop()
end

Please complete the code

2.can you help me in code when process is attached I want music to stop...Help?

_________________

"If you are good at something,never do it for free"-The Joker
I know you are looking at this post, Hitler
Back to top
View user's profile Send private message
FreeER
Grandmaster Cheater Supreme
Reputation: 53

Joined: 09 Aug 2013
Posts: 1091

PostPosted: Mon Aug 28, 2017 12:15 pm    Post subject: Reply with quote

well print out what messageDialog returns (print(messageDialog(...)).... if it's something like false/0 when you click cancel but true/1 when you click ok then it's as simple as
Code:
if messageDialog(......) then -- or messageDialog == 1
  closeCE()
  -- xmplayer.stop() -- if CE closes then the music should stop too
  return caFree -- I think something wants this as the return value...
end
return caNone


alternatively you can check celua.txt and/or defines.lua for more information (message dialog results might be of particular interest)
Back to top
View user's profile Send private message
Death GOD 7
Expert Cheater
Reputation: 0

Joined: 21 Jan 2017
Posts: 105
Location: Heaven and Hell

PostPosted: Mon Aug 28, 2017 8:05 pm    Post subject: Reply with quote

FreeER wrote:
well print out what messageDialog returns (print(messageDialog(...)).... if it's something like false/0 when you click cancel but true/1 when you click ok then it's as simple as
Code:
if messageDialog(......) then -- or messageDialog == 1
  closeCE()
  -- xmplayer.stop() -- if CE closes then the music should stop too
  return caFree -- I think something wants this as the return value...
end
return caNone


alternatively you can check celua.txt and/or defines.lua for more information (message dialog results might be of particular interest)

Thanks again...but the result for yes button was 6 and for cancel was 2.
BTW can you also tell me the code to stop music when process is attached.
Your help is appreciated.

_________________

"If you are good at something,never do it for free"-The Joker
I know you are looking at this post, Hitler
Back to top
View user's profile Send private message
FreeER
Grandmaster Cheater Supreme
Reputation: 53

Joined: 09 Aug 2013
Posts: 1091

PostPosted: Mon Aug 28, 2017 9:33 pm    Post subject: This post has 1 review(s) Reply with quote

Code:
onOpenProcess = function() xmplayer.stop() end
should work
Back to top
View user's profile Send private message
Death GOD 7
Expert Cheater
Reputation: 0

Joined: 21 Jan 2017
Posts: 105
Location: Heaven and Hell

PostPosted: Tue Aug 29, 2017 9:52 am    Post subject: Reply with quote

FreeER wrote:
Code:
onOpenProcess = function() xmplayer.stop() end
should work

Thanks for your help.I have +Rep you.
Sorry for bugging you but can we type like this in messagedialog box:
Code:

Hello,this is my  trainer. --with enter pressed like line breaker
HOPE you enjoy it

I could only type single straight line

And also in messagedialog box can we use code in Lua Script that makes text bold or align center
Thanks again
Regards 7[/quote]

_________________

"If you are good at something,never do it for free"-The Joker
I know you are looking at this post, Hitler
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 457

Joined: 09 May 2003
Posts: 25262
Location: The netherlands

PostPosted: Tue Aug 29, 2017 10:14 am    Post subject: Reply with quote

Code:

messageDialog([[something
with
multiple
lines]], mtInformation,mbOK)

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
FreeER
Grandmaster Cheater Supreme
Reputation: 53

Joined: 09 Aug 2013
Posts: 1091

PostPosted: Tue Aug 29, 2017 1:15 pm    Post subject: Reply with quote

DB already showed multiline strings in lua, I believe you could also use \n (or possibly \r\n) to insert line breaks into regular strings as well. However as far as I know you can't have formatted text in a message box.
Back to top
View user's profile Send private message
Death GOD 7
Expert Cheater
Reputation: 0

Joined: 21 Jan 2017
Posts: 105
Location: Heaven and Hell

PostPosted: Tue Aug 29, 2017 8:06 pm    Post subject: Reply with quote

Dark Byte wrote:
Code:

messageDialog([[something
with
multiple
lines]], mtInformation,mbOK)

FreeER wrote:

DB already showed multiline strings in lua, I believe you could also use \n (or possibly \r\n) to insert line breaks into regular strings as well. However as far as I know you can't have formatted text in a message box

Thanks to you both Admin and FreeER.I prefer dark bytes way for multiple lines.

I again have a question for you in messagedialog box can we add custom box type rather than warning,Information, error. ..etc and have custom logo.
Regards 7

_________________

"If you are good at something,never do it for free"-The Joker
I know you are looking at this post, Hitler
Back to top
View user's profile Send private message
FreeER
Grandmaster Cheater Supreme
Reputation: 53

Joined: 09 Aug 2013
Posts: 1091

PostPosted: Tue Aug 29, 2017 8:17 pm    Post subject: Reply with quote

No, it's just a simple wrapper for Windows' message box. If you want more control/customization then you'll need to create your own form
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
Goto page 1, 2  Next
Page 1 of 2

 
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