mfc >> Simulate user interactions on an HTML site

by Peter Meier » Fri, 23 Apr 2004 15:32:44 GMT

I would like to simulate user interactions within a
browser (e.g. IE) programatically without using the
browser (IE NOT open!). For example I want to simulate a
button click on a web site which I loaded into memory
before.

I looked into the MSDN WalkAll example, but this is just
too complicated. I didn't understand it. And I also looked
at IWebBrowser2 and IHTMLDocument2 but it was not clear to
me how to use them.

Can anyone provide some simple code example how to open an
HTML site and get the elements, e.g. an edit field, button
and then perform an action, e.g. button click? Thanks a
lot!

Peter

mfc >> RE: Simulate user interactions on an HTML site

by QXBwelNvZnQ » Fri, 23 Apr 2004 20:01:06 GMT


Hi

if you are ready to pay for it I will be glad to help you

Regards

mfc >> RE: Simulate user interactions on an HTML site

by Peter Meier » Fri, 23 Apr 2004 20:28:36 GMT

This is a joke, right?
Anyone else who can help me?
This can't be too difficult...?

mfc >> Simulate user interactions on an HTML site

by Julia Weber » Mon, 26 Apr 2004 16:23:04 GMT

Hi Peter,
take a look at the "Creating an Internet Explorer Helper
Class" in Codeguru:

http://www.codeguru.com/Cpp/I-
N/internet/browsercontrol/article.php/c6175/

Hope that helps you...

Julia


looked
to
an
button

Similar Threads

1. Printing HTML from memory (no user interaction)

Hello,


I hope you can help me with this issue. I am trying to build an
application in C# that converts text from XML with an XSL to a HTML
file and prints it according to some printersettings that can be made
by an user interface. This application needs to run as an automatic
process, so user intervention is not preferred.


I managed to get the XML+XSL->HTML conversion working with the
following code:

[code]
public static StringWriter MergeXSL_XML(string xml, string xsl)
{
	try
	{
		XPathDocument xPath = new XPathDocument(xml);
		XslTransform xTrans = new XslTransform();
		xTrans.Load(xsl);
		StringWriter strW = new StringWriter();
		xTrans.Transform(xPath,null,strW);
		strW.Close();
		return strW;
	}
	catch(Exception e)
	{
		MessageBox.Show(e.ToString());
		return null;
	}
}
[/code]

The XML and XSL are read from a file or database. This is working
correct. The string writer contains the information I wanted as HTML.
But now the bottleneck, I cannot print the HTML.

On some sites and newsgroups people run a command through the shell
that executes the printer option. But this needs a temporary file on
the server, but that's not what I want. Some also use:

[code]
 wbElement.QueryStatusWB(SHDocVw.OLECMDID.OLECMDID_PRINT);
[/code]
But that does not give any satisfying results.


I already managed to place the HTML in the Active X component

[code]
 wbCom.Navigate("about:blank");
 mshtml.IHTMLDocument2 hDoc = (mshtml.IHTMLDocument2)wbCom.Document;
 hDoc.write(html);
[/code]

The item shows the HMTL, but I cannot request the data later (when
requesting wbCom.Document I won't get my edited document), but that
is not the real problem. The real problem is that I cannot parse the
document to the printer. There is a print document method in the item:

[code]
 hDoc.execCommand("Print",false,0);
[/code]

But calling it shortly after the placement of the HTML in the document
will cause a empty document to be print out. But by pressing a button
to start the print will print out a document. I already tried to insert
a small sleep, but how long the sleep does not matter, an empty
document will be printed.

The thing that I want is that the document can be parsed to a printable
document so I can print it with the default print components of
C#/.NET. Casting does not work, I tried all the IHTMLDocument* classes
to find something useful, but none of them seem to have a usable
function to create a printable document for the printer components in
.NET. One of the casts I tried:

[code]
 MessageBox.Show(hDoc.ToString());
 printDialog1.Document = (PrintDocument)hDoc;
 printDialog1.Document = (PrintDocument)hDoc;
 hDoc.execCommand("Print",false,0);
[/code]

Another problem is that it seems I cannot change the printer settings,
I need to change the default printer settings in windows. For example,
I need to change the paper source, I can request the sources via:

[code]
for(int i=0; i < printDocument1.PrinterSettings.PaperSources.Count;
i++)
{

MessageBox.Show(printDocument1.PrinterSettings.PaperSources[i].ToString());
}
[/code]

But I am not able to change them

Can someone help me with this problem?

Thanks in advance...

2. Service that Prints HTML on server (NO user interaction, NO dialog - CSharp/C#

3. Service that Prints HTML on server (NO user interaction, NO di

This is the idea:

A "web" admin user selects what a NOTICE from a list. That notice has an 
HTML text on the database. When the user clicks on Print, the list of 
NoticeID goes to a queue that gets processes at night. 

I need to write the server side that reads the NoticeID list, gets from the 
server each HTML value located on the database ...and print it on a specified 
Server Printer

So my task is to print that HTML to a printer directly as batch, where there 
is NO USER involved.

-f

So I need to work out the 3 steps.

I think I have the code to print PDFs using ShellExecute
I now no

4. Interaction with Message box from Web site - CSharp/C#

5. Touch screens and user interaction

Hi all,

Well, my company has asked me to look into the feasability of creating
an restaurant ordering system for one of their clients. The type
waitresses use with touch screens to input your order when you go to a
restaurant or bar...

I am thinking a server app with different ui's depending on location:
dining room, bar, kitchen, office... all available through IE.

My question is, how would I implement code againts a touch screen using
ASP.NET and IE? Would implementation be like on Windows CE where I
would detect if a touch was placed inside specific boundaries or would
the monitor driver return the touch as a mouse click at a specific
location? If its so, then life is good and I 'm breaking my head for
nothing :-)

Does anyone have experience building apps that use touch screens? Will
I have to use winforms to handle user input or is my EI idea feasable?

I've googled around a bit but haven't found anything talking about user
interaction using touch screens apart from mobile devices.

Any input, thoughts and ideas are welcome and appreciated.

thanks and best regards,

Swayze

6. Service that Prints PDF on the server (NO user interaction, NO dia - CSharp/C#

7. User Controls and Form Button Interaction

I will do my best to try an explain this as accurately and as briefly as 
possible.

I am attempting to write a Windows application.  In it I have one form that 
uses panels; a Top Panel, Left Panel and Right Panel.  There are no other 
forms.  The form itself contains buttons, that when pressed, determine which 
UserControl will be loaded into the Right Panel.  The buttons are NOT part 
of the UserControl.  As I press the correct buttons on my Windows form, the 
corresponding UserControl is correctly displayed in my Right Panel. 
Everything up to this point in my application works great!

Each UserControl is intended to collect information and obviously store them 
for later use.  As of right now there are only TextBox and Label controls in 
the UserControls that are loaded.  Make sense so far?  Good!

Below I have pasted what I hope to be sufficient code from what I have so 
far in an attempt to help understand what I am asking and trying to do.  The 
"Windows Form" is what contains the NEXT button control that allows a user 
to move ahead.  When the next UserControl is loaded the NEXT button is 
disabled because the fields in that UserControl need to be validated first. 
The OnPaint method of each UserControl uses the WizardData class to help me 
determine where I am in the entire process.

If you notice in the UserControl sets the NEXT button to disabled.  I do not 
want the user to move ahead until all TextBox control fields are valid. 
When they are valid I would like to have the NEXT button enabled.

It is easy for the NEXT button to be disabled because it is set as part of 
the UserControl being loaded in the UpdateWizardControl() method.  I think 
what I need is a delegate or event  when all the TextBox controls on 
UserControl are validated.

I hope that this all makes sense!  Thank you all for your assistance.

////////////////////////  Windows Form ///////////////////////
public static System.Boolean IsNextButtonEnabled;

private void buttonNext_Click(object sender, EventArgs e)
{
    System.Int32 CurrentWizardStep = 
WizardControls.WizardData.CurrentWizardStep;
    UpdateWizardControl(++CurrentWizardStep);
}

private void UpdateWizardControl(System.Int32 WizardStep)
{
    System.String ErrorString;

    // Verify that the wizard step needed is not out of the enumeration 
range used.
    if (
        WizardStep <= 
System.Enum.GetValues(typeof(WizardControls.WizardData.WizardSteps)).Length 
&&
        WizardStep >= 
(System.Int32)WizardControls.WizardData.WizardSteps.Step1)
        {
        /// Determine which user control is to be displayed.
        switch (WizardStep)
        {
            case 1:
                this.panelRight.Controls.Add(new Default());
	break;
            case 2:
                this.panelRight.Controls.Add(new AccountInformation());
                break;
        case 3:
                this.panelRight.Controls.Add(new TestType());
                break;
        case 4:
                this.panelRight.Controls.Add(new TestOptions());
                break;
        }

        // Remove the user control that is no longer needed.
        this.panelRight.Controls.Remove(WizardControls.WizardData.ActiveUserControl);

        // Update the top panel control properties.
        this.labelTopPanelTitle.Text = WizardControls.TopPanel.Title;
        this.labelTopPanelDescription.Text = 
WizardControls.TopPanel.Description;

        // Set the user's option to move forward or backward depending on 
the current wizard step.
        if (WizardStep == 
(System.Int32)WizardControls.WizardData.WizardSteps.Step1)
        {
            this.buttonBack.Enabled = false;
            this.buttonNext.Enabled = true;
        }
        else
        {
            this.buttonBack.Enabled = true;
            this.buttonNext.Enabled = IsNextButtonEnabled;		// Determined by 
the loaded user control.
        }

        // Disable the ability to move forward if the user is at the end of 
the wizard.
        if (WizardStep == 
(System.Int32)WizardControls.WizardData.WizardSteps.Step4)
        {
            this.buttonNext.Enabled = false;
        }
    }
    // The wizard step needed is out of the enumeration range used.
    else
    {
    ErrorString = "The wizard step provided is out of range.";
    this.CustomException(this, ErrorString);
    return;
    }
}

////////////////////////  UserControl ///////////////////////
private void AccountInformation_Load(object sender, EventArgs e)
{
    // Disable the Next button until all fields are validated.
    InheritedForm.IsNextButtonEnabled = false;

    .....
}

protected override void OnPaint(PaintEventArgs e)
{
    WizardControls.WizardData.ActiveUserControl = this;
    WizardControls.WizardData.CurrentWizardStep = 
(System.Int32)WizardControls.WizardData.WizardSteps.Step2;
    base.OnPaint(e);
}

////////////////////////  Properties ///////////////////////
namespace WizardControls
{
    public class WizardData
    {
        public enum WizardSteps : int
        {
            Step1 = 1,		/// The start of the wizard application launch 
introduction.
            Step2 = 2,
            Step3 = 3,
            Step4 = 4		/// The end of the wizard application.
        }

        private static System.Int32 myCurrentWizardStep;
        private static System.Windows.Forms.UserControl myActiveUserControl;

        public static System.Windows.Forms.UserControl ActiveUserControl
        {
        get { return myActiveUserControl; }
        set { myActiveUserControl = value; }
        }
    }
} 

8. BeginInvoke and user-interaction - CSharp/C#