Page 1 of 1

Clearing Clipboard

Posted: Sun Feb 05, 2023 1:24 pm
by ArniVLK
Enigma x 64 7.20
Use checkup of executed processes ->Terminate if hidden process found.
Q:
How can I clear the clipboard when closing the program?
(So that the user cannot paste the data copied from the protected program window after closing it into another program.)
Maybe there is a plugin?

Re: Clearing Clipboard

Posted: Mon Feb 06, 2023 12:56 pm
by Enigma
Yes, this is possible to make through plugin. In plugin you can use Enigma API functions, like EP_CheckupFindProcess, to find the process yourselves. If process found - clear clipboard and close application.

In this case, the option Checkup - Executed Process - Terminate application should be disabled (together with the message).

Re: Clearing Clipboard

Posted: Mon Feb 06, 2023 6:12 pm
by ArniVLK
Enigma wrote: Mon Feb 06, 2023 12:56 pm use Enigma API functions, like EP_CheckupFindProcess
I'm an amateur, I'm trying to improve, if possible, see if I'm doing the right thing
(it is possible in the PM or by mail (I am an official user)

Code: Select all

unit test_Clipboard;
uses
  Windows, Clipbrd, enigma_ide;
function Enigma_Plugin_About : PWideChar;
begin
  Enigma_Plugin_About := 'Enigma Clipboard Clear&Terminate Apps if present process notepad';
end;
function Enigma_Plugin_Description : PWideChar;
begin
  Enigma_Plugin_Description := 'Enigma Clipboard Clear&Terminate Apps if present process notepad';
end;
procedure Enigma_Plugin_OnInit;
function EP_CheckupFindProcess : PAnsiChar;
begin
  if EP_CheckupFindProcess (FileName('Notepad.exe'),(WindowText('Notepad'))) then
  begin
    if OpenClipboard(0) then
        try
           EmptyClipboard;
        finally
           CloseClipboard;
  end else
  begin
    TerminateProcess(DWORD(-1), 0)
  end;
end;
exports
  Enigma_Plugin_About,
  Enigma_Plugin_Description,
  Enigma_Plugin_OnInit,
begin
end.

Re: Clearing Clipboard

Posted: Tue Feb 07, 2023 3:57 pm
by Enigma
This looks ok, if it fits your needs.

If you need more accurate filters for detection, worth to use Enigma API function EP_CheckupFindProcessEx.

Re: Clearing Clipboard

Posted: Tue Feb 07, 2023 5:25 pm
by ArniVLK
This looks ok, if it fits your needs.
thanks!
q- "uses enigma_ide"
- no need to specify the path to enigma_ide.pas ?
q2 - " if EP_CheckupFindProcess (FileName('Notepad.exe'),(WindowText('Notepad'))) then"
- how it works - (FileName('Notepad.exe') OR (WindowText('Notepad') /(FileName('Notepad.exe') AND (WindowText('Notepad') ? No need to specify here "IS", "CONTAINS" ?
q3 - how do I specify the frequency of the process detection check? (2s, 5s etc) ?
******
q4 - attach

Sorry for the possibly lamers questions :(

Re: Clearing Clipboard

Posted: Wed Feb 08, 2023 3:32 pm
by Enigma
ArniVLK wrote: Tue Feb 07, 2023 5:25 pm q- "uses enigma_ide"
- no need to specify the path to enigma_ide.pas ?
You can just take it from EnigmaSDK folder and add to your Delphi project.
ArniVLK wrote: Tue Feb 07, 2023 5:25 pm q2 - " if EP_CheckupFindProcess (FileName('Notepad.exe'),(WindowText('Notepad'))) then"
- how it works - (FileName('Notepad.exe') OR (WindowText('Notepad') /(FileName('Notepad.exe') AND (WindowText('Notepad') ? No need to specify here "IS", "CONTAINS" ?
If both parameters are specified, it works as AND. If you need to simulate OR, then call EP_CheckupFindProcess two times with either file name, either WindowText.

"IS", "CONTAINS" can be specified in the function EP_CheckupFindProcessEx, I recommend to use it since it is more smart. EP_CheckupFindProcess is kept for compatibility with old versions.
ArniVLK wrote: Tue Feb 07, 2023 5:25 pm q3 - how do I specify the frequency of the process detection check? (2s, 5s etc) ?
Create a thread in plugin and check the thread execution time (or just delay it in 2s, 5s etc). Check sources of other plugins in Enigma, some of them are using thread also.
ArniVLK wrote: Tue Feb 07, 2023 5:25 pmq4 - attach
Unfortunately no, because this option is useful for you only, it will over-complicate interface. Moreover, it can be easy done through plugin.

Re: Clearing Clipboard

Posted: Wed Feb 08, 2023 4:52 pm
by ArniVLK
Enigma wrote: Wed Feb 08, 2023 3:32 pm If both parameters are specified, it works as AND. If you need to simulate OR, then call EP_CheckupFindProcess two times with either file name, either WindowText.
Thanks!
it can be easy done through plugin.
:roll:
Of course it's easy for you :)

I tried to compile a test project - an error...
Can you tell me what my mistake is?

Re: Clearing Clipboard

Posted: Thu Feb 09, 2023 9:06 am
by Enigma
ArniVLK wrote: Wed Feb 08, 2023 4:52 pm I tried to compile a test project - an error...
Can you tell me what my mistake is?
Function EP_CheckupFindProcess should receive 3 parameters. When I said that you need to pass just FileName this means that other parameters should be empty, but they have to exists. Like that:
EP_CheckupFindProcess(FileName, nil, nil);
EP_CheckupFindProcess(nil, WindowsText, nil);
EP_CheckupFindProcess(nil, nil, WindowsClass);

But again, better to use EP_CheckupFindProcessEx function.