|
Hi guys.
How can we access to a textbox in other programs ?
For example , I wanna access to a textbox in Firefox and change the content of it.
Is it possible with API and C#?
Is there a sample of it ?
Thank you
|
|
|
|
|
Do you even know what API means ?
Yes, if you can get the window handle of the textbox, you can interact with it. You'll essentially be using C++ tho, even if you do it via p/invoke.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Christian Graus wrote: Do you even know what API means ?
Well, it is a way for relate C# and windows functions . Isn't it ?
|
|
|
|
|
Mohammad Dayyan wrote: Well, it is a way for relate C# and windows functions . Isn't it
Ya. That is P-Invoke. Check this[^] to see if somebody has already done what you are looking for.
|
|
|
|
|
I haven't tried, but if you have the other program's handle, SendMessage[^] function can be used.
|
|
|
|
|
I use a PrintDialog to set up printer and page setting. I select 'PDFCreator' as printer, and then open 'property'->'Advance' page to select paper size. The wierd thing is, if I select standard paper size('A4', 'A2' .etc), the paper size setting can be remembered correctly next time I show the PrintDialog; but if I choose 'Postscript custom page size' and input custom paper size, this paper setting can not remembered. The next time I show the PrintDialog, the paper size setting is changed to 'A4'. I wonder if any one knows what's the problem. Thanks.
|
|
|
|
|
Hi all!
I'm trying to create a program that automates some web activity. The form has a few input controls and a WebBrowser control. When the automation is run I would like the WebBrowser control to show what the automation is doing. However, when I try and create a second thread to do the work (using the WebBrowser control on the main form) I receive errors for unsafe threading. Okay, no problem. When I create the WebBrowser control within my second thread, I receive an exception because the WebBrowser control needs to be attached to a form. When I try and attach the WebBrowser control that was created in my second thread to my main form, I again receive unsafe threading errors...
I have searched all over for an example that uses threading and a WebBrowser control, with no luck. Can someone point me in the right direction or give a hit as to how I can make this work (while still only having one form)?
Thank you!
|
|
|
|
|
Hi,
All Controls, including WebBrowser, need to be handled by a single thread; the thread that creates a Control is the only one allowed to call its methods and properties; since all Controls somehow are interconnected in a normal app, they all belong to the main or GUI thread.
Other threads wanting access need to use Control.InvokeRequired and Control.Invoke;
look them up on CP or google for details.
|
|
|
|
|
Adding to what Luc said,
Anticast wrote: When I create the WebBrowser control within my second thread
Let the control be on the main thread. Your worker thread can tell main thread to update the control when required. See this[^] article which explains about Invoke/BeginInvoke to avoid cross thread communication errors.
If you are using .NET 2.0 or above, you have one more choice which is SynchronizationContext[^] class.
modified on Tuesday, December 23, 2008 11:12 PM
|
|
|
|
|
Thank you both! The way you two explained it made me realize "what I was missing."
In case this will help anyone else, I got my multithreading web automation to work by creating a new Form inside my void Run(); method, then attaching a new WebBrowser to it, and using that WebBrowser to perform my automatioins.
_WBForm = new Form();
_WBForm.Size = new System.Drawing.Size(410, 310);
_WBForm.Visible = false;
_WBForm.Resize += new EventHandler(_WBForm_Resize);
_WB = new WebBrowser();
_WBForm.Controls.Add(_WB);
_WB.Location = new System.Drawing.Point(5, 5);
_WB.Size = new System.Drawing.Size(400, 300);
While this didn't allow me to view the WebBrowser on my main form, it does allow me to actually multithread my search requests by having multiple webbrowser objects. I added a property to allow me to view what the thread was doing if I wanted to:
public bool ShowBrowser
{
get
{
if(_WBForm != null && _WBForm.Visible)
return true;
else
return false;
}
set
{
if (_WBForm != null)
{
if(value)
_WBForm.Show();
else
_WBForm.Hide();
}
}
}
Thanks again all!
|
|
|
|
|
Hi,
Does anyone know the best place to locate programmers who want to sell their apps or programs? Is there any place on the web where programmers post their creations for sale?
Thanks for any input as I am looking to purchase any apps or programs that are useful and operate in Windows.
|
|
|
|
|
|
kevindill wrote: that are useful and operate in Windows.
A very broad request.
only two letters away from being an asset
|
|
|
|
|
There's a number of sites like download.com that let people download shareware.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Check out rentacoder.com
I do some freelance work there and its a work-for-hire type site, so if you need something made, post your request and a price range and see what people offer.
|
|
|
|
|
You must be in the third world. I don't think that's what he was asking.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Hello,
I have an assignment for my Algorithm Design course and I can't seem to find where to start.
The problem is some sort of pathfinding algorithm but with a dice, and I must compute the minimum cost/path
I've done other pathfinding problems with A*, Lee, but in this one that dice can go through the same spot multiple times and I can't figure out a condition for this.
Here's a PDF with my problem
http://adcfils.files.wordpress.com/2008/12/cube.pdf[^]
|
|
|
|
|
xnastyx wrote: I can't seem to find where to start
Just a strange thought, but maybe you could ask your professor
only two letters away from being an asset
|
|
|
|
|
That won't work, the professor does not know, he has been asking the same problem for
many years now, hoping to finally get a solution.
|
|
|
|
|
Hi All,
I have 5 textboxs, 1 button and 1 Gridview control.
I just want that when I click the button, text of each textbox will be added in the Gridview in separate column. Each time I will click the button, a new row must be inserted in the Gridview below the last row.
Please tell me some simplest way to do so. I have tried it by binding Gridview to List<> datasource but the problem is that when ever I clicked the button, new instance of List<> is created ( e.g List<T> mylist = new List<T>(); ) and the any existing data in the List<> is lost. I used my own entity in the List<>.
Please help me with this or any other simple idea in C#.
|
|
|
|
|
The list idea will work fine. It's your code that is the issue. Have the list as a member, add to it and rebind.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Grid.aspx -- Page Design Code
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Grid.aspx.cs" Inherits="Grid" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<table style="width: 287px">
<tr>
<td>
<asp:Label ID="lblId" runat="server" Text="Id"></asp:Label></td>
<td>
<asp:TextBox ID="txtId" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td>
<asp:Label ID="lblFirstName" runat="server" Text="First Name" Width="71px"></asp:Label></td>
<td>
<asp:TextBox ID="txtFirstName" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td>
<asp:Label ID="lblLastName" runat="server" Text="Last Name"></asp:Label></td>
<td>
<asp:TextBox ID="txtLastName" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td>
<asp:Label ID="lblNickName" runat="server" Text="Nick Name"></asp:Label></td>
<td>
<asp:TextBox ID="txtNickName" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td>
<asp:Label ID="lblCity" runat="server" Text="City"></asp:Label></td>
<td>
<asp:TextBox ID="txtCity" runat="server"></asp:TextBox></td>
<td>
<asp:Button ID="btnInsert" runat="server" OnClick="btnInsert_Click" Text="Insert" />
&nbsp; &nbsp; &nbsp;
</td>
</tr>
</table>
</div>
<br />
<asp:GridView ID="GridView1" runat="server" CellPadding="4" ForeColor="#333333" GridLines="None">
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<EditRowStyle BackColor="#999999" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
</asp:GridView>
</form>
</body>
</html>
Grid.aspx.cs -- Code for Insert Data into Grid
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
DataTable dt = new DataTable();
dt.Columns.Add("Id", typeof(string));
dt.Columns.Add("First Name", typeof(string));
dt.Columns.Add("Last Name", typeof(string));
dt.Columns.Add("Nick Name", typeof(string));
dt.Columns.Add("City", typeof(string));
VSDataTable = dt.Copy();
}
}
private DataTable VSDataTable
{
get
{
return (DataTable)ViewState["VsDt"];
}
set
{
ViewState["VsDt"] = value;
}
}
protected void btnInsert_Click(object sender, EventArgs e)
{
DataRow dr = VSDataTable.NewRow();
dr["Id"] = txtId.Text;
dr["First Name"] = txtFirstName.Text;
dr["Last Name"] = txtLastName.Text;
dr["Nick Name"] = txtNickName.Text;
dr["City"] = txtCity.Text;
VSDataTable.Rows.Add(dr);
GridView1.DataSource = VSDataTable;
GridView1.DataBind();
ClearTextBoxes();
}
public void ClearTextBoxes()
{
txtId.Text = "";
txtFirstName.Text = "";
txtLastName.Text = "";
txtNickName.Text = "";
txtCity.Text="";
}
Faisal and Prathap
|
|
|
|
|
If I have 2 datasets in which an updating to a table at dataset1 perform changes to the other table at dataset2... How to update this changes at Dataset2?. Must use tableadapter.fill( dataset2.mytable);
does exist other way than refill?. thanks...
|
|
|
|
|
I can't really understand your explanation, but I think you said you wanted to make changes to, or update the contents of, DataSet2 based on a change in DataSet1?? There is no automatic facility to do this. You have to write the code to get the data for DataSet2 or make the appropriate changes to it.
Like I said, your explanation is not very clear or understandable.
|
|
|
|
|
Yes Dave. This is the question. and sorry if it was ununderstandable.
Thank you very much....
|
|
|
|