|
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
ByTransient Expert Cheater Reputation: 5
Joined: 05 Sep 2020 Posts: 240
|
Posted: Tue Aug 03, 2021 2:14 pm Post subject: Print the clicked word. |
|
|
Print the clicked word.
I tried many different combinations, but this is the closest result.
There are some parts that don't work properly.
It doesn't read at the beginning, I have to click at the beginning of the words, (even if clicked in the middle of the word, it should find the word)
and it gives a long list.
Is there a way to just print the word I clicked on?
I'm looking for a way to get the word that was clicked, whether I click on the beginning, end or middle of the word..
Here is the starting code;
Code: | local texxt="No matter how hard you try..\nWithout adding another code\nYou will not find the best.\nFor that, you have to ask him."
local slstrt=0
if f then f.destroy() end
f=createForm()
f.Popupmode = 0; f.Position=poDesktopCenter
local Memo1 = createMemo(f)
Memo1.Left=10 Memo1.Height=220 Memo1.Top=10 Memo1.Width=300
Memo1.ScrollBars=ssAutoBoth Memo1.WordWrap=false
Memo1.Lines.Text=texxt
function selectWord()
str=Memo1.Lines.Text
local slcWord = ''
local nmbr=0
for word in str :gmatch( '%w+' ) do
nmbr=tonumber(nmbr) + #word + 1
--print(nmbr.." - "..slstrt.." - "..word)
if slstrt>=nmbr then
word1=word
slcWord=word1
--print(slcWord)
end
end
return slcWord
--print(slcWord)
end
Memo1.OnClick=function()
slstrt=0
slstrt=Memo1.SelStart - 1
slstxt=selectWord()
print(slstrt.."\n"..slstxt)
end
|
|
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25294 Location: The netherlands
|
Posted: Tue Aug 03, 2021 2:26 pm Post subject: |
|
|
there is a bug with the sel* methods, but it's fixed in the next version though
_________________
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 |
|
|
ByTransient Expert Cheater Reputation: 5
Joined: 05 Sep 2020 Posts: 240
|
Posted: Tue Aug 03, 2021 3:08 pm Post subject: |
|
|
Actually no. The "flood" test works fine in my code.
There is an example you gave from your previous posts;
Code: | r1,r2=string.find(UDF1.CEMemo1.Lines.Text,'something')
if r1 then
UDF1.CEMemo1.selstart=r1
UDF1.CEMemo1.sellength=r2-r1
end |
This code still works fine.
And I'm still trying to get the clicked word.
|
|
Back to top |
|
|
panraven Grandmaster Cheater Reputation: 55
Joined: 01 Oct 2008 Posts: 942
|
Posted: Tue Aug 03, 2021 5:03 pm Post subject: |
|
|
use sender.CaretPos?
It is a table with x,y entries, zero-based string pos and line number.
Let cp = sender.CaretPos
The string in Caret is ss = sender.Lines[cp.y]
The char after Caret is ss:sub(cp.x+1,cp.x+1), may be empty string.
With some loop and a chars pattern (eg. %w) it should found the pattern under the caret position.
_________________
- Retarded. |
|
Back to top |
|
|
ByTransient Expert Cheater Reputation: 5
Joined: 05 Sep 2020 Posts: 240
|
Posted: Tue Aug 03, 2021 6:00 pm Post subject: |
|
|
panraven wrote: | use sender.CaretPos?
It is a table with x,y entries, zero-based string pos and line number.
Let cp = sender.CaretPos
The string in Caret is ss = sender.Lines[cp.y]
The char after Caret is ss:sub(cp.x+1,cp.x+1), may be empty string.
With some loop and a chars pattern (eg. %w) it should found the pattern under the caret position. |
Rather, I aim for code that I can understand.
Sample; Adding 10 to the range captured by "Memo1.SelStart" and undoing it.
And I'm trying to do something like Code: | (newSelStart:match("\n\r%s .. %s\n")) | at the beginning and end.
But I haven't been able to use or match format characters.
---------------------------
EDIT;
While simple codes have limited capabilities,
What I'm trying to do looks like this:
Code: | local texxt="No matter how hard you try..\nWithout adding another code\nYou will not find the best.\nFor that, you have to ask him."
local slstrt=0
if f then f.destroy() end
f=createForm()
f.Popupmode = 0; f.Position=poDesktopCenter
local Memo1 = createMemo(f)
Memo1.Left=10 Memo1.Height=220 Memo1.Top=10 Memo1.Width=300
Memo1.ScrollBars=ssAutoBoth Memo1.WordWrap=false
Memo1.Lines.Text=texxt
Memo1.OnClick=function()
aa5=""
aa3=Memo1.SelStart - 6
aa4=Memo1.SelStart + 6
aa5=string.sub(Memo1.Lines.Text,aa3, aa4):gsub("%s", "___")
print("aa5: "..aa5)
aa6=string.match(aa5, "___(.-)___")
print("aa6: "..aa6)
end |
|
|
Back to top |
|
|
DaSpamer Grandmaster Cheater Supreme Reputation: 52
Joined: 13 Sep 2011 Posts: 1578
|
Posted: Wed Aug 04, 2021 12:55 pm Post subject: |
|
|
Code: |
Memo1.OnClick = function(o)
local wordPattern = "[%w%p]+"; -- what kind of word are we looking for? letters,numbers and punctuation symbols
local caretPos,line = o.CaretPos.x,o.Lines[o.CaretPos.y] --x - caret position, y - line number
if (line:sub(caretPos,caretPos):match(wordPattern)) then -- alphanumeric+punctuation, we care only about our pattern
-- let's find the end of this word...
local _,y = line:find(wordPattern,caretPos) -- finds the first occurence of our pattern which is the word we click on (second paramter is start position)
--returns x,y... but we dont care about x. , accepts 3rd parameter for plain search
if (y) then
-- aight, so we can cut the string off here
local trimmedLine = line:sub(1,y);
-- now we can use the same wordPattern to match the very last word of our trimmed line
local word = trimmedLine:match(("(%s)$"):format(wordPattern));
if (word) then
print(("You have press on \"%s\""):format(word))
end
end
end
end |
Edit:
OnClick method does not tell you what button has been pressed so you have to use either OnMouseDown or OnMouseUp, then you can check which button was pressed and if its not left you could call mouse_event.
Simplified and shrunk the function too, its the same as above though.
Code: | local f = createForm();f.Position = poDesktopCenter
local m = CreateMemo(f); m.align = 'alClient'; m.ScrollBars=ssAutoBoth;m.WordWrap=false
m.Lines.Text="No matter how hard you try..\nWithout adding another code\nYou will not find the best.\nFor that, you have to ask him."
m.OnMouseDown = function(o,b,...)
if (b > 0) then
return mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP)
end
local x,l,p = o.CaretPos.x,o.Lines[o.CaretPos.y],"[%w%p]+";
if (l:sub(x,x):match(p)) then
print(("You have press on \"%s\""):format(l:sub(1,select(2,l:find(p,x))):match(("(%s)$"):format(p))))
end
end |
_________________
|
|
Back to top |
|
|
ByTransient Expert Cheater Reputation: 5
Joined: 05 Sep 2020 Posts: 240
|
Posted: Wed Aug 04, 2021 1:30 pm Post subject: |
|
|
This is worth everything. Thanks.
Code: | print("line: "..o.caretPos.y.." - word: "..word) |
You are on the stage again and you have solved the problem.
Actually this project (coding) is for a common thread.
Thanks for joining @daSpamer.
I wanted to give +1 reputation, but I guess the following error is waiting to be resolved.
@DarkByte: (Are you aware of this error?)
"SQL query failed
DEBUG MODE
INSERT INTO cephpbb_reputation (modification, user_id, voter_id, post_id, forum_id, poster_ip, date) VALUES (1, 313095, 550424, 5772590, 126, '', 1628105006)
Line : 1075
File : functions.php"
|
|
Back to top |
|
|
DaSpamer Grandmaster Cheater Supreme Reputation: 52
Joined: 13 Sep 2011 Posts: 1578
|
Posted: Thu Aug 12, 2021 11:16 am Post subject: |
|
|
Adjusted to CE TSynEdit(Plus) using CE 7.2
Cannot tell if it would work in previous version nor future,as we are gettingCaretPos point by reading memory.
Code: | MainForm.frmAutoInject.Assemblescreen.OnClick = function(o) -- Lua Script TSynEdit ...
local TSynEditPtr = userDataToInteger(o)
local is64Bit,x,y = cheatEngineIs64Bit()
if (is64Bit) then
x = readIntegerLocal(readIntegerLocal(TSynEditPtr+0x5F8)+0x28)
y = readIntegerLocal(readIntegerLocal(TSynEditPtr+0x5F8)+0x24)
else
x = readIntegerLocal(readIntegerLocal(readIntegerLocal(TSynEditPtr+0x18)+0x20)+0x78)
y = readIntegerLocal(readIntegerLocal(readIntegerLocal(TSynEditPtr+0x18)+0x20)+0x74)
end
local o_CaretPos = { x = x, -- caret position in line
y = y - 1} -- current caret line adjusted,
local wordPattern = "[%w%p]+"; -- what kind of word are we looking for? letters,numbers and punctuation symbols
local caretPos,line = o_CaretPos.x-1,o.Lines[o_CaretPos.y] --x - caret position, y - line number
if (line:sub(caretPos,caretPos+1):match(wordPattern)) then -- alphanumeric+punctuation, we care only about our pattern
-- let's find the end of this word...
local _,y = line:find(wordPattern,caretPos) -- finds the first occurence of our pattern which is the word we click on (second paramter is start position)
--returns x,y... but we dont care about x. , accepts 3rd parameter for plain search
if (y) then
-- aight, so we can cut the string off here
local trimmedLine = line:sub(1,y);
-- now we can use the same wordPattern to match the very last word of our trimmed line
local word = trimmedLine:match(("(%s)$"):format(wordPattern));
if (word) then
print(("You have press on \"%s\""):format(word))
end
end
end
end |
_________________
|
|
Back to top |
|
|
AylinCE Grandmaster Cheater Supreme Reputation: 32
Joined: 16 Feb 2017 Posts: 1257
|
Posted: Thu Aug 12, 2021 1:47 pm Post subject: |
|
|
DaSpamer wrote: | Adjusted to CE TSynEdit(Plus) using CE 7.2
Cannot tell if it would work in previous version nor future,as we are gettingCaretPos point by reading memory.
Code: | MainForm.frmAutoInject.Assemblescreen.OnClick = function(o) -- Lua Script TSynEdit ...
local TSynEditPtr = userDataToInteger(o)
local is64Bit,x,y = cheatEngineIs64Bit()
if (is64Bit) then
x = readIntegerLocal(readIntegerLocal(TSynEditPtr+0x5F8)+0x28)
y = readIntegerLocal(readIntegerLocal(TSynEditPtr+0x5F8)+0x24)
else
x = readIntegerLocal(readIntegerLocal(readIntegerLocal(TSynEditPtr+0x18)+0x20)+0x78)
y = readIntegerLocal(readIntegerLocal(readIntegerLocal(TSynEditPtr+0x18)+0x20)+0x74)
end
local o_CaretPos = { x = x, -- caret position in line
y = y - 1} -- current caret line adjusted,
local wordPattern = "[%w%p]+"; -- what kind of word are we looking for? letters,numbers and punctuation symbols
local caretPos,line = o_CaretPos.x-1,o.Lines[o_CaretPos.y] --x - caret position, y - line number
if (line:sub(caretPos,caretPos+1):match(wordPattern)) then -- alphanumeric+punctuation, we care only about our pattern
-- let's find the end of this word...
local _,y = line:find(wordPattern,caretPos) -- finds the first occurence of our pattern which is the word we click on (second paramter is start position)
--returns x,y... but we dont care about x. , accepts 3rd parameter for plain search
if (y) then
-- aight, so we can cut the string off here
local trimmedLine = line:sub(1,y);
-- now we can use the same wordPattern to match the very last word of our trimmed line
local word = trimmedLine:match(("(%s)$"):format(wordPattern));
if (word) then
print(("You have press on \"%s\""):format(word))
end
end
end
end |
|
This is my homework and thanks for untying the biggest knot.
I'm out of town for another 3-4 days for the mission, I'll try this code when I get home. Thank you grandmaster, you combine code and magic. This is great.
@DarkByte I've seen you get a head start on "Lua Engine" for my project. Please wait for me for "Cheat Table, Lua Script".
It's my project and everyone contributed.
_________________
|
|
Back to top |
|
|
|
|
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
|
|