Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

calling a series of clicks from inside the program

Posted on 2002-06-24
6
Medium Priority
?
180 Views
Last Modified: 2010-04-04
Hi All,

I have Delphi4 and win2K. I have an internet application that runs flawlessly when I click the buttons as I see the data come in. I apply the next click always when I see that it is has started downloading ready for the next click what ever that was.

When I automate it by calling out the next click from within the program from the previous click there is a message of ..... (named button clicked by a call inside the program)... Not ready.

I know all the Clicks I need/want  to perform, in what sequence but I want to automate it.  

TIA.

Delphi3
0
Comment
Question by:delphi3
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 3

Expert Comment

by:raidos
ID: 7104149
I need more information...
How do you call the buttons clickfunctions ?

<Button>.Click;
<Button>OnClick(<Button>);

Regards
//raidos
0
 
LVL 4

Author Comment

by:delphi3
ID: 7104537
raidos,
The program is a news reader that is a ICS program by Francois Piette.
Using the demo "NewsRdr.dpr" provided with ICS, enter the following infos:
Server: newsgroups.borland.com
Group: borland.public.delphi.graphics
User: "Your Name" <your.name@yourcompany.domain>

Then click "Connect" and the "Group" and then "ArtcileByNum". All those
buttons correspond to NNTP component methods.
I call the various functions  by this text form of the .dfm

object NNTPForm: TNNTPForm
  Left = 564
  Top = 82
  Width = 741
  Height = 547
  Caption = 'NNTP - http://www.rtfm.be/fpiette'
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -14
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = True
  OnClose = FormClose
  OnShow = FormShow
  PixelsPerInch = 120
  TextHeight = 16
  object Panel1: TPanel
    Left = 0
    Top = 0
    Width = 733
    Height = 228
    Align = alTop
    TabOrder = 0
    object Label1: TLabel
      Left = 10
      Top = 15
      Width = 40
      Height = 16
      Caption = 'Server'
    end
    object Label2: TLabel
      Left = 39
      Top = 103
      Width = 13
      Height = 16
      Caption = 'ID'
    end
    object Label3: TLabel
      Left = 5
      Top = 73
      Width = 53
      Height = 16
      Caption = 'Art. Num.'
    end
    object Label4: TLabel
      Left = 15
      Top = 42
      Width = 37
      Height = 16
      Caption = 'Group'
    end
    object Label5: TLabel
      Left = 32
      Top = 132
      Width = 22
      Height = 16
      Caption = 'File'
    end
    object Label6: TLabel
      Left = 25
      Top = 160
      Width = 29
      Height = 16
      Caption = 'User'
    end
    object Label7: TLabel
      Left = 69
      Top = 191
      Width = 66
      Height = 16
      Caption = 'UserName'
    end
    object Label8: TLabel
      Left = 246
      Top = 191
      Width = 64
      Height = 16
      Caption = 'PassWord'
    end
    object ServerEdit: TEdit
      Left = 59
      Top = 10
      Width = 257
      Height = 24
      Hint = 'Enter the NNTP server host name'
      ParentShowHint = False
      ShowHint = True
      TabOrder = 0
      Text = 'newsgroups.borland.com'
    end
    object ConnectButton: TButton
      Left = 325
      Top = 10
      Width = 92
      Height = 26
      Hint = 'Connect to the NNTP server'
      Caption = '&Connect'
      ParentShowHint = False
      ShowHint = True
      TabOrder = 5
      OnClick = ConnectButtonClick
    end
    object AbortButton: TButton
      Left = 423
      Top = 39
      Width = 93
      Height = 26
      Hint = 'Abort current job'
      Caption = 'A&bort'
      Enabled = False
      ParentShowHint = False
      ShowHint = True
      TabOrder = 10
      OnClick = AbortButtonClick
    end
    object GroupButton: TButton
      Left = 325
      Top = 39
      Width = 92
      Height = 26
      Hint = 'Select the group'
      Caption = '&Group'
      ParentShowHint = False
      ShowHint = True
      TabOrder = 6
      OnClick = GroupButtonClick
    end
    object GroupEdit: TEdit
      Left = 59
      Top = 39
      Width = 257
      Height = 24
      Hint = 'Enter the newsgroup name such as borland.public.delphi.internet'
      ParentShowHint = False
      ShowHint = True
      TabOrder = 1
      Text = 'borland.public.delphi.graphics'
    end
    object ArticleNumEdit: TEdit
      Left = 59
      Top = 69
      Width = 110
      Height = 24
      Hint = 'Enter the article number to retreive'
      ParentShowHint = False
      ShowHint = True
      TabOrder = 2
      Text = 'ArticleNumEdit'
    end
    object ArticleByNumberButton: TButton
      Left = 522
      Top = 10
      Width = 92
      Height = 26
      Hint = 'Retreive an article (header and body) by article number'
      Caption = '&ArticleByNum'
      ParentShowHint = False
      ShowHint = True
      TabOrder = 15
      OnClick = ArticleByNumberButtonClick
    end
    object ArticleByIDButton: TButton
      Left = 620
      Top = 10
      Width = 93
      Height = 26
      Hint = 'Retreive an article (header and body) by article ID'
      Caption = 'ArticleBy&ID'
      ParentShowHint = False
      ShowHint = True
      TabOrder = 20
      OnClick = ArticleByIDButtonClick
    end
    object NextButton: TButton
      Left = 423
      Top = 69
      Width = 93
      Height = 26
      Hint = 'Get next article info'
      Caption = '&Next'
      ParentShowHint = False
      ShowHint = True
      TabOrder = 12
      OnClick = NextButtonClick
    end
    object LastButton: TButton
      Left = 423
      Top = 98
      Width = 93
      Height = 26
      Hint = 'Get previous article info'
      Caption = '&Last'
      ParentShowHint = False
      ShowHint = True
      TabOrder = 13
      OnClick = LastButtonClick
    end
    object HeadByNumberButton: TButton
      Left = 522
      Top = 39
      Width = 92
      Height = 26
      Hint = 'Request a header only, by article number'
      Caption = 'HeadByNum'
      ParentShowHint = False
      ShowHint = True
      TabOrder = 16
      OnClick = HeadByNumberButtonClick
    end
    object HeadByIDButton: TButton
      Left = 620
      Top = 39
      Width = 93
      Height = 26
      Hint = 'Retreive an article header, by article ID'
      Caption = 'HeadByID'
      ParentShowHint = False
      ShowHint = True
      TabOrder = 21
      OnClick = HeadByIDButtonClick
    end
    object BodyByNumberButton: TButton
      Left = 522
      Top = 69
      Width = 92
      Height = 26
      Hint = 'Request an article body, by article number'
      Caption = 'BodyByNum'
      ParentShowHint = False
      ShowHint = True
      TabOrder = 17
      OnClick = BodyByNumberButtonClick
    end
    object BodyByIDButton: TButton
      Left = 620
      Top = 69
      Width = 93
      Height = 26
      Hint = 'Retreive an article body, by article ID'
      Caption = 'BodyByID'
      ParentShowHint = False
      ShowHint = True
      TabOrder = 22
      OnClick = BodyByIDButtonClick
    end
    object StatByNumberButton: TButton
      Left = 522
      Top = 98
      Width = 92
      Height = 26
      Hint = 'Request stats about an article by number'
      Caption = 'StatByNum'
      ParentShowHint = False
      ShowHint = True
      TabOrder = 18
      OnClick = StatByNumberButtonClick
    end
    object StatByIDButton: TButton
      Left = 620
      Top = 98
      Width = 93
      Height = 26
      Hint = 'Request stats about an article by ID'
      Caption = 'StatByID'
      ParentShowHint = False
      ShowHint = True
      TabOrder = 23
      OnClick = StatByIDButtonClick
    end
    object ListButton: TButton
      Left = 522
      Top = 128
      Width = 92
      Height = 26
      Hint = 'List ALL newsgroups. Will take a VERY LONG time.'
      Caption = 'List'
      ParentShowHint = False
      ShowHint = True
      TabOrder = 19
      OnClick = ListButtonClick
    end
    object ArticleIDEdit: TEdit
      Left = 59
      Top = 98
      Width = 257
      Height = 24
      Hint = 'Enter the article ID to retreive'
      ParentShowHint = False
      ShowHint = True
      TabOrder = 3
      Text = 'ArticleIDEdit'
    end
    object PostButton: TButton
      Left = 325
      Top = 69
      Width = 92
      Height = 26
      Hint = 'Post a hard coded article to the group'
      Caption = '&Post'
      ParentShowHint = False
      ShowHint = True
      TabOrder = 7
      OnClick = PostButtonClick
    end
    object QuitButton: TButton
      Left = 423
      Top = 10
      Width = 93
      Height = 26
      Hint = 'Quit the NNTP server'
      Caption = '&Quit'
      ParentShowHint = False
      ShowHint = True
      TabOrder = 11
      OnClick = QuitButtonClick
    end
    object FileEdit: TEdit
      Left = 59
      Top = 128
      Width = 257
      Height = 24
      Hint = 'Enter the file name and path for the destination file'
      ParentShowHint = False
      ShowHint = True
      TabOrder = 4
      Text = 'FileEdit'
    end
    object NewGroupsButton: TButton
      Left = 325
      Top = 128
      Width = 92
      Height = 26
      Hint = 'Request the new groups (hardcoded for 10 days)'
      Caption = 'NewGroups'
      ParentShowHint = False
      ShowHint = True
      TabOrder = 9
      OnClick = NewGroupsButtonClick
    end
    object NewNewsButton: TButton
      Left = 423
      Top = 128
      Width = 93
      Height = 26
      Hint = 'Request the new news (hardcoded for 1 day)'
      Caption = 'NewNews'
      ParentShowHint = False
      ShowHint = True
      TabOrder = 14
      OnClick = NewNewsButtonClick
    end
    object HelpButton: TButton
      Left = 325
      Top = 98
      Width = 92
      Height = 26
      Hint = 'Request help from the NNTP server'
      Caption = 'Help'
      ParentShowHint = False
      ShowHint = True
      TabOrder = 8
      OnClick = HelpButtonClick
    end
    object XOverButton: TButton
      Left = 620
      Top = 128
      Width = 93
      Height = 26
      Hint =
        'List articles overview. Art. Num. can be a single number, a numb' +
        'er and a dash or two numbers separated by a dash.'
      Caption = 'XOver'
      ParentShowHint = False
      ShowHint = True
      TabOrder = 24
      OnClick = XOverButtonClick
    end
    object OverViewFmtButton: TButton
      Left = 325
      Top = 158
      Width = 92
      Height = 25
      Caption = 'OverViewFmt'
      TabOrder = 25
      OnClick = OverViewFmtButtonClick
    end
    object DateButton: TButton
      Left = 423
      Top = 158
      Width = 93
      Height = 25
      Caption = 'Date'
      TabOrder = 26
      OnClick = DateButtonClick
    end
    object UserEdit: TEdit
      Left = 59
      Top = 158
      Width = 257
      Height = 24
      Hint =
        'Enter "your name" <your.name@yourcompany.domain> with the double' +
        ' quotes and angle backets.'
      ParentShowHint = False
      ShowHint = True
      TabOrder = 27
      Text = 'bherbst@ezo.net'
    end
    object UserNameEdit: TEdit
      Left = 138
      Top = 187
      Width = 100
      Height = 24
      TabOrder = 28
      Text = 'UserNameEdit'
    end
    object PasswordEdit: TEdit
      Left = 325
      Top = 187
      Width = 90
      Height = 24
      TabOrder = 29
      Text = 'PasswordEdit'
    end
    object AuthenticateButton: TButton
      Left = 423
      Top = 187
      Width = 93
      Height = 26
      Caption = 'Authenticate'
      TabOrder = 30
      OnClick = AuthenticateButtonClick
    end
    object ModeReaderButton: TButton
      Left = 522
      Top = 158
      Width = 92
      Height = 25
      Caption = 'Mode Reader'
      TabOrder = 31
      OnClick = ModeReaderButtonClick
    end
    object XHdrButton: TButton
      Left = 620
      Top = 158
      Width = 93
      Height = 25
      Caption = 'XHdr'
      TabOrder = 32
      OnClick = XHdrButtonClick
    end
    object Button1: TButton
      Left = 522
      Top = 187
      Width = 92
      Height = 25
      Caption = 'Close '
      TabOrder = 33
      OnClick = Button1Click
    end
    object Edit1: TEdit
      Left = 184
      Top = 69
      Width = 121
      Height = 24
      TabOrder = 34
      Text = 'UpperLimit'
    end
  end
  object DisplayMemo: TMemo
    Left = 0
    Top = 228
    Width = 733
    Height = 291
    Align = alClient
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clWindowText
    Font.Height = -15
    Font.Name = 'Courier New'
    Font.Style = []
    Lines.Strings = (
      'DisplayMemo')
    ParentFont = False
    ScrollBars = ssBoth
    TabOrder = 1
  end
  object NntpCli1: TNntpCli
    OnSessionConnected = NntpCli1SessionConnected
    OnSessionClosed = NntpCli1SessionClosed
    OnDataAvailable = NntpCli1DataAvailable
    OnRequestDone = NntpCli1RequestDone
    OnMessageBegin = NntpCli1MessageBegin
    OnMessageEnd = NntpCli1MessageEnd
    OnMessageLine = NntpCli1MessageLine
    OnXHdrBegin = NntpCli1XHdrBegin
    OnXHdrEnd = NntpCli1XHdrEnd
    OnXHdrLine = NntpCli1XHdrLine
    Left = 640
    Top = 192
  end
end


the .pas is very large and so are the other various components that go along with it. They are too large to place here.

Delphi3  
0
 
LVL 3

Accepted Solution

by:
raidos earned 150 total points
ID: 7104814
I don't really understand what you're trying to do...but try this.. =)

Procedure TNNTPForm.FakeClick(Obj: TButton);
Var
  Done : Boolean;
Begin
  If Not Assigned(Obj) then
    Exit;
  Done := FALSE;
  Repeat
    Try
      Obj.Click;
      Done := TRUE;
      Except On E:Exception Do Begin
        //Fail!! Who Cares ? =))
      end;
    End;
    Sleep(5);
    Application.ProcessMessages;
  Until Done;
End;


and just call it like this

FakeClick(GroupButton);
FakeClick(ArticleByNumberButton);

Regards
//raidos
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Author Comment

by:delphi3
ID: 7105978
Not Working....
Tried your suggestions.

Seems listing the click or the call to the does not work as it raises  flags that it is not ready. Also  it does not like the  Obj: TButton


My D4 uses a statement  procedure TNNTPForm.ArticleByNumberButtonClick(Sender: TObject);

Procedure TNNTPForm.FakeClick(Obj: TButton);
Var
 Done : Boolean;
Begin
 If Not Assigned(Obj) then
   Exit;  
Done := FALSE;
 Repeat
   Try
ConnectButtonClick(Self);
Sleep(5);
GroupButtonClick(Self);
Sleep(5);
ArticleByIDButtonClick(Self);
Sleep(5);
NextButtonClick(Self);
.......
Application.ProcessMessages


Neither does listing this arrangement work:

Procedure TNNTPForm.FakeClick(Obj: TButton);
Var
 Done : Boolean;
Begin
 If Not Assigned(Obj) then
   Exit;  
Done := FALSE;
 Repeat
   Try    
 NntpCli1.Connect; // listing what was inside ConnectButtonClick(Self);
Sleep(5);
  NntpCli1.Group(GroupEdit.Text);  // listing what was inside GroupButtonClick(Self);
Sleep(5);
  NntpCli1.ArticleByNumber(StrToInt(ArticleNumEdit.Text), GetStream);  // listing what  was                                                                   // inside  ArticleByIDButtonClick(Self);
 Sleep(5);
 NntpCli1.Next; // listing what was inside NextButtonClick(Self);
 Sleep(5);

.......
Application.ProcessMessages

I need some other suggestions.

Delphi3
0
 
LVL 4

Author Comment

by:delphi3
ID: 7115324
I appreciate you stopping by. The solution to this type of problem, that I learned elsewhere is  calling another internet address.

Here is the solution:

/Dummy Button  AutoConnect_Group_ArticleByNumber[5]

procedure TNNTPForm.Button1Click(Sender: TObject);
var
  I: Integer;
begin
  DisplayMemo.Clear;
  ConnectButton.Enabled := FALSE;
  NntpCli1.Host := ServerEdit.Text;
  NntpCli1.Connect;

  // Connect CreateAnInternetWait
  CreateAnInternetWait(Self);

  NntpCli1.Group(GroupEdit.Text);

  // Connect CreateAnInternetWait
  CreateAnInternetWait(Self);

  ArticleNumEdit.Text := Edit1.Text; // This is an update to the present stored record

  for I := 1 to 5 do // 5 ArticleByNumber files
  begin

    NntpCli1.ArticleByNumber(StrToInt(ArticleNumEdit.Text), GetStream);
  //or NntpCli1.BodyByNumber(StrToInt(ArticleNumEdit.Text), GetStream);

  // Connect CreateAnInternetWait
    CreateAnInternetWait(Self);

    if not RenameFile('nntprdr.txt', 'Number ' + ArticleNumEdit.Text + '.txt') then
      ShowMessage('Error renaming file!');
    NntpCli1.Next;

  // Connect CreateAnInternetWait
    CreateAnInternetWait(Self);

  end;
  NntpCli1.Quit;

end;

procedure TNNTPForm.CreateAnInternetWait(Sender: TObject);
var
  S: string;
begin
  Memo1.Clear;
  HttpCli1.URL := 'http://www.msn.com/';
  HttpCli1.RcvdStream := TFileStream.Create('View1.html', fmCreate);
  try
    try
      HttpCli1.Get;
    except
      on E: EHttpException do begin
        Memo1.lines.add('Failed : ')
      end
    else
      raise;
    end;
  finally
    HttpCli1.RcvdStream.Seek(0, soFromBeginning);
    SetLength(S, HttpCli1.RcvdStream.Size);
    HttpCli1.RcvdStream.Read(S[1], length(S));
    Memo1.Text := S;
    HttpCli1.RcvdStream.Destroy;
    HttpCli1.RcvdStream := nil;
  end;
end;




 
0
 
LVL 4

Author Comment

by:delphi3
ID: 7121031
Thanks for stopping by.

Delphi3
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question