How to close Find window in a webbrowser control - c#

I use a WebBrowser control and it's find functionality:
private void findToolStripMenuItem_Click(object sender, EventArgs e)
{
webBrowser1.Select();
SendKeys.Send("^f");
}
Which works fine. Only problem that there is a case when user can make WebBrowser unvisible to perform some other tasks:
webBrowser1.Visible = false;
But Find window remains visible. Any suggestions?
Thank you.

To close, try this
webBrowser1.Select();
SendKeys.Send("^f");
SendKeys.Send("{ESCAPE}");
There is no easy/direct way to control the Find dialog. One way to close the Find dialog is by sending "ESCAPE" to the dialog when it has focus. If you send "^f" prior to sending "ESCAPE", that will force the find dialog to get focus.

Related

Windows lock mode while sendkeys or mouse control c#

So I've got application that uses webbrowser and going through specified website.
At the end of the process it clicks on button and Download dialog box appear. Problem is: to download this file I have to either SendKeys or position properly mouse and simulate clicks.. When I have remote desktop open it works well, but when I disconnect SendKeys give error "Access denied" - I believe it's related to windows lock mode, and mouse is not moving at all..
Is there any possibility that I can make it work? I found that there is no other option to download that file than SendKeys or simulate mouse position and clicks.. I have to stick to webbrowser.
Why are you trying to visually click on the button, or link? just in DocumentCompleted event of the WebBrwoser invoke the click event:
public void WebBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
WebBrowser wb = (WebBrowser)sender;
wb.Document.GetElementById("someElementId").InvokeMember("click");
}
Of course in this example I have used GetElementById() however you may use any method or loops, ... to find the element you want.

Perform mouse click on TextBox or window

I know that this is not a good practice, but I would like to simulate a mouse click event on a textbox, or a window in my wpf application.
I need this, because I am calling this application with some kind of interceptor and the window doesn't get the full focus, it is in front, textbox has a focus but u can't directlly type on textbox.
on window load I call these methods
this.Activate();
this.Topmost = true;
TextBox1.Focus();
Keyboard.Focus(TextBox1);
Thank you.
I had the same issue in VB. i just wanted the focus in the SpinEdit1 (or any control) when the form load. Here is:
private void formX_Load(object sender, EventArgs e)
{
this.ActiveControl = SpinEdit1;
}

How to get back the focus on popup, after losing it in WPF?

I have a main window, If I click a certain button, I have a popUp window, that pops up with few different component (input, button, dropdownlist etc) on it. Everything works fine, until I lose focus by simply clicking outside. And if I want to come back, I click back on Popup, but it can't be active again, and for that to be active, I have to click on the Main window, or to click on the appIcon on the taskBar.
Have you guys ever had such problem?
And How to resolve it?
Thank you!
I think you are looking for PreviewMouseDown event. I have tested it and it does recover lost focus.
private void Popup_PreviewMouseDown(object sender, MouseButtonEventArgs e)
{
this.Focus();
}

how can closed the TAB page by click?

I am making a Web Browser , I have done some parts like that new tab Page,Bookmark,home page,Default Search Engine and so on. I'm confused about how to closed the TAB PAGE. I have tried Double click , Mouse down, up and many more but I can't solve the problem.
I have create the TABPAGE like that . Thanks in advance waiting reply.....
private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
{
if (tabControl1.SelectedTab.Text == "+")
{
AddNewTab();
}
foreach (Control item in tabControl1.SelectedTab.Controls)
{
if (item.GetType() == typeof(WebBrowser))
{
WebBrowser wb = (WebBrowser)item;
toolStripButton1.Enabled = wb.CanGoBack;
toolStripButton2.Enabled = wb.CanGoForward;
}
}
Snapshot my Window form application
Just try disposing of the TabPage. Assuming a button called "Close Tab" on the form:
private void closeTab_Click(object sender, EventArgs e) {
if (tabControl1.SelectedTab != null) {
tabControl1.SelectedTab.Dispose();
}
}
You will need Javascript to do this. Use window.close():
close();
Note: the current window is implied. This is equivalent:
window.close();
or you can specify a different window.
So:
function close_window() {
if (confirm("Close Window?")) {
close();
}
}
with HTML:
close
or:
close
You return false here to prevent the default behavior for the event. Otherwise the browser will attempt to go to that URL (which it obviously isn't).
Now the options on the window.confirm() dialog box will be OK and Cancel (not Yes and No). If you really want Yes and No you'll need to create some kind of modal Javascript dialog box.
Note: there is browser-specific differences with the above. If you opened the window with Javascript (via window.open()) then you are allowed to close the window with javascript. Firefox disallows you from closing other windows. I believe IE will ask the user for confirmation. Other browsers may vary.
If you have more than one tab, changing tabs should fire the code. Does your markup have runat="server" in the tag declaration?

How to close the PopUp window in TelerikRadGrid on save?

I am using TelerikRadGrid in ASP.NET. When I press edit or add new, a new PopUp window appears, when I fill the data and save everything is OK, but the popup window stays.
So how can I save and close the window at the same time (I know how to save, but I don't know how to close the window after saving?)
Did you search the Telerik's forum? Popup Edit form not closing
When your page reloads after saving the data you need to put a JavaScript window.close()
Or programatically you can try:
protected void RadGrid1_ItemInserted(object sender, GridInsertedEventArgs e)
{
e.KeepInInsertMode = false;
}

Categories

Resources