How would I make a embedded browser in c# non-selectable? - c#

I am currently making an application for someone using an eyegaze system which tracks his eye movements to the screen and uses it as a mouse. When he hovers over a button for a little bit (.6 seconds) it sends a mouse click to the screen where he was hovering. We have an embedded browser within the application that reading the info on the browser is much more important than selecting anything on the browser and with the nature of his device, browsing is selecting if he hovers for too long. How would I go about making the content within the browser read-only, or not able to be selected?

Have you tried putting a transparent panel over the embedded browser? Would be like placing a piece of glass over a book. You can still read it, but you won't be able to touch(select) the page.

Related

Trying to detect and gather data on click outside application

I would like to know if it is possible to, while running a WPF window application in Visual Studio, wait for the user to click anywhere on the screen (not necessarily inside the window of my application - for the purpose of my application, the click would most likely occur inside a browser page) and then gather the information about the click (like inside the window of which application the user clicked, or the selector of the html element the user clicked)? I know this question might be very confunsing but this is basically my last resort since researching on the Internet hasn't helped me much. Just to provide a better idea of what I seek, it's like what the 'Extract Structured Data' Activity does in UiPath. Oh and I'm using C# by the way.
You can try and use this external library called GlobalMouseHook.
This library allows you to tap keyboard and mouse, detect and record their activity even when an application is inactive and runs in background.
Here is what you can do with this library:
Mouse coordinates
Mouse buttons clicked
Mouse drag actions
Mouse wheel scrolls
Key presses and releases
Special key states
Hope this helps.

Internet Explorer PDF Reader

I apologize for the length of this question, but some background explanation is required.
Background:
I'm working on an internal web application that will display a pdf in an iframe. Adobe Reader X offers a "Read Mode" for displaying the pdf in the browser. This removes the shell and adds a menu box to the bottom of the pdf when the mouse is over the "middle center". In versions prior to X you could use JavaScript to modify the toolbar menu items.
What I Need:
I need to display the pdf in "Read Mode" AND remove all menu items. The computers that are to run this app are basically a kiosk and are literally a computer, monitor and mouse. No printers, no keyboard, no other interactivity.
My question is this:
How can I load a pdf for reading in internet explorer, and disable all interaction except scrolling. That is, no menus, no context menu, and no "shadow bar" when the bottom center is moused over. I've been searching for alternatives to Adobe, and there are some great ones, but the ones I've found that have a browser plugin, do not have a plugin for IE.
If someone know a way to just load the PDF Contents that would be an even better route.
More Information:
If it helps, while this is being built for Internet Explorer, the web-page will be loaded into a windows form that is just a full-screen browser control.
Other things I've tried:
I have also tried positioning a transparent iFrame on top of the pdf iFrame, covering only the displayed content, but leaving the scrollbars intact. This worked perfect if I loaded anything BUT a pdf. If I loaded any other website then it worked as expected (except the scroll wheel of course doesn't scroll the webpage). If a pdf was loaded, then all that would appear is a white square. Use the dev toolbar to remove the transparent iFrame and the PDF looks good.
I've found a good partial solution. A product called PDFObject.
Using it, I can add the following JavaScript to my page:
function embedPDF() {
var myPDF = new PDFObject({
url: 'PathToPdf.pdf',
pdfOpenParams: {
scrollbars: '1',
toolbar: '0',
statusbar: '0',
messages: '0',
navpanes: '0'
}
}).embed('DivToLoadPdfInto');
}
window.onload = embedPDF;
This will embed the pdf into a div and remove the toolbar, statusbar, message, navpanes, but still allow scrollbars. This prevents the shadow box menu from appearing, which is great!
Users can still right-click on the pdf so I'll try the standard Right-Click blockers in JavaScript and edit if I can get something to work.
Edit:
A good resource for URL Parameters can be found here.
Ok, so I have come up with a final solution.
Needs:
Load PDF in iFrame in "Reader Mode" but with no shadow bar
PDF Context Menu should be disabled
Addressing the first need is easy with some caveats. Set the source of the iFrame to "pathToPdf/document.pdf#toolbar=0&navpanes=0". The caveats here are that (in IE at least) once this breaks, then the browser needs to be closed and re-opened to work again. So, what can break it?
User right clicks and opens the navigation pane buttons.
User presses the escape button on the keyboard.
The webpage is loaded into the browser control of a windows form, and luckily once broken there it works fine without closing and reopening. Could still be a problem though for the PDF being viewed. I don't have to worry about the escape key, because the app is running on a KIOSK(basically) and there is no keyboard, only a mouse.
Disabling the context menu has proved to be the most difficult thing to do. The web browser control has a "IsWebBrowserContextMenuEnabled" property that when set to "False" will disable the context menu for the browser. Probably because the adobe reader is a plugin, this does not effect the PDF. With Reader X there is no registry setting (that I could find) or JavaScript method, or general setting that will disable context menu.
I was ready to give up when I remembered something. This is a kiosk, and there is no need for the right mouse button. So the solution; modify the registry and turn off the right click for the internal OS. To do that simply open regedit and goto:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer
Find (or create if it is not there) a DWORD key named "NoViewContextMenu".
A value of 1 will disable right clicking, 0 will enable.
Summary:
Use "pathToPdf/document.pdf#toolbar=0&navpanes=0"
Disable right click in windows registry
Edit:
The registry hack only disables the right mouse button in windows explorer. We are having no luck in finding a good software solution, so we are left with either writing our own custom mouse drivers or simply popping open the mice and removing the physical trigger mechanism.

Check to see if mouse is pressed anywhere on screen from silverlight control?

I have a silverlight control which acts as a drop down. I'd like to get a mouse pressed event when the mouse ISNT hovering over the dropdown control or any one of its children.
how can I go about doing that?
Well that depends on what you mean by "Screen".
With in Silverlight you are only going to be able to detect mouse down when the mouse is over the part of the screen that the Silverlight pluging is actually using.
The first step would be use this code:-
Application.Current.RootVisual.AddHandler(UIElement.MouseLeftButtonDown, myMouseButtonHandlerMethod, true)
This may well be enough for you, however, if you still need to detect mouse down when Popup or ChildWindow controls are in use you will need to attach this handler to those as well (since the sit above the RootVisual).
You may be able to take things further if you want to reach out into Javascript in the host html page. If your SL component only occupies a portion of the HTML Page presented you could get further events from via the HTMLBridge to detect mouse down anywhere in the browser client area.
If you really mean the whole screen then that isn't possible currently.

UI Automation cannot control embedded browser

This is about testing a desktop application. I have been trying to click a hyperlink on an embedded browser of a Windows form. I could move the mouse anywhere if the component (buttons, or whatever) is part of the form, but elements inside the browser, i can't seem to control at all....sigh.....yes, I could move the mouse if I use the screen coordinates but I plan to control the embedded browser using Watin, etc..without opening a new IE....Using Microsoft's UISpy tool (when I hover the cursor to the link..it shows a Pane ControlType)....the hyperlink is part of the tree structure but only the name property is available...some of the parent's properties are blank....
I tried extending the example from the link below
http://archive.msdn.microsoft.com/uiautomation
and this is where i'm stuck (I have tried FindChildByName and other related methods too...sigh..no luck):
var commontab=AutomationElement.RootElement.FindFirstChildHavingDescendantWhere(new[] { new PropertyCondition(AutomationElement.NameProperty, "Search")});
Mouse.MoveTo(menutab.GetClickablePoint().ToDrawingPoint());
Mouse.Click(MouseButton.Left);
Somehow the mouse cannot find the 'Search' hyperlink...sigh...please guys...any ideas??
Would it not be a simpler idea to split this into 2 testing strategies? The first is testing the desktop UI, buttons etc. as you are. The second is to test the html which is to be placed within the embedded browser frame.
You shouldn't be testing that the embedded browser works, that's Microsofts job. The only testing that you may want to do on the frame is to ensure that it's content is loaded, that the call is to the correct (internal) url etc.

Screenshot of the content of a textbox

is it possible to take a screenshot of what a textbox holds when the user presses the sumbit button for example?
EDIT: this is an aspx webpage
In short, no it is not possible to do this in a consistent, cross browser fashion (that I am aware of). If your textbox was implemented inside of a flash movie, it would be possible to take a 'screenshot' of what the flash movie was displaying when a button was pressed (discussion on this subject available here). But otherwise, you are going to have to do this processing on the server.
You could simulate this process by having the server render a copy of the page itself (feeding it the data the user entered) and then doing what you wanted with it from there. There are free and paid for solutions to assist you in taking a screenshot of a website (browse options available here).
On the client side I think you're stuck with the limitations of javascript, which might not be possible. Here is another question that is very similar to yours:
Take a screenshot of a webpage with JavaScript?
In the general sense, no, you can't. However if you have a constrained environment (e.g. kiosk, intranet), you can create a browser plug-in which can essentially do anything, including snapping a screenshot and sending it to the server.
If you have lots of control over the environment, you can create your own web browser which can take screenshots. In fact, I've done this with C#. I just wrote an app that hosts a browser control and sends screenshots to the server on certain key presses or at a user-defined interval.

Categories