I was trying to make a pc application that helps people more conveniently when they are using a browser(e.g Chrome, Firefox, Edge ...)
For example, the application shows the default browser and let user can choose another browser as default if they want to, and the app shows all windows that are currently opened; Overmore, when the user clicks a specific window then app will focus the window.
user can select default browser
user can see all windows categorized by browser type
So, my initial planning was using Election js; however, I've found that there is no way to control a browser from the Electron application since Node js cannot access the users' system(this thinking could be wrong since I have poor English😥)
After some research, I'm guessing C# can do that by using windows api. I've saw this post that saying by using DDE, we can get tabs urls.
But I'm wondering if C# can fully control a browser; for instance, create a new window, notice if music or video is playing in the tab, request to browser for getting favorites list.
If it cannot, how about requesting api to the browser from pc application?
You cannot fully control a browser. Internet Explorer was the only browser that had a documented and supported API to control, inspect and automate. Internet Explorer is dead so this is a dead end. The basic DDE control interface is also outdated.
Accessing favorites and the content of open tabs is limited because evil people would use such APIs to inject and spy. If you want to access the favorites you will have to write custom code for each browser.
Using the accessibility and UI automation APIs is the only reliable and supported way of interacting with modern browsers. SetWinEventHook can be used to detect window creation and primitive state changes. MSAA/UI Automation needs to be used to get more information from each browser window.
The thumbnail API and/or magnifier API can be used to get the preview image.
To open a new tab, execute a new process with the URL on the command line. Some per-browser customization might be required (-new-tab parameter etc).
Use IApplicationAssociationRegistration::QueryCurrentDefault to detect the default browser.
Related
I'm developing a software on C# which has to get info from a website which the user opens in chrome, the user has to input some data and then the website returns a list of different items.
What I want is a way to be able to access to the source code of the page in order to get the info, I cant open the web myself as it doesnt show anything because I didnt input any data, so I need to get it directly from chrome.
How can I achieve this ? A chrome extension ? Or can I access to chrome directly from my software ?
Off the top of my head, I don't know any application that gets data directly from an open instance of Chrome. You'd have to write your own Chrome extension.
Alternatively, you can open the web browser from your application initially.
You can look into these libraries for doing so:
Watin (My personal favourite)
Selenium
Awesomium (You'd have to roll out your own UI, it's invisible)
Cef
Essential Objects Web Browser
EDIT: I didn't think about using QA tools as the actual browser hook as #TheAnathema mentions. That would probably work for your needs.
You're going to need to create it as Chrome extension if you must be dependent on the user actually going to a specific web site (i.e. not being able to do the requests yourself with either Selenium or standard web requests in Python).
The reason why a Chrome extension would be required is because think of how bad it could be for any software to easily read the pages you browse. Banking, medical, email, etc. could all be accessed anonymously from any process if Google allowed any outside process to tap into the web page.
Even Chrome extensions have to ask for permission to be able to do what they want, but at least it is software the user knowingly installed and agreed to the permissions.
A quick search yielded this example of modifying a page's HTML with a Chrome extension: https://blog.lateral.io/2016/04/create-chrome-extension-modify-websites-html-css/
It sounds like you want to do web scraping. Here's a good tutorial to get you started: HTML Scraping.
And this answer has a good example of how to scrape data from a website where you need to submit a form to get access to the data.
I'm developing an app for Windows 8.1 called myTrip and I'm implementing my custom scheme URI for the app. I want this URI : mytrip:place:/m/0942y1 to open my app and navigate to a place with that ID. I have the logic done, it works fine if I run it from Windows + r. I want to distribute this uris in a facebook page, and when a user clicks on it, the app will open and the place shown. It's more or less the same thing that the windows store web page of your app does:
http://apps.microsoft.com/windows/en-us/app/mytrip/ae689d16-f349-4596-8bc7-e0eeab87ec24
This works in IE and Chrome, the schema that opens the store app is this:
ms-windows-store:PDP?PFN=19185FernandoUrkijoCerced.MyTrip_q1p7rzex4ekjr
If you copy and paste it on Chrome, and you have Windows 8, the app store will open. But, if I try with my custom URI:
myTrip:place:/m/0942y1
It only works on IE, not on Chrome. Why the Windows app store schema URI works with Chrome and not with my schema? Any ideas or hacks to bypass this problem?
Thanks you.
Chrome does not automatically recognize custom protocol handlers. Firefox will recognize when you are trying to use a protocol handler and offer to create a protocol handler definition for you. IE recognizes them.
On top of this, Chrome by default excludes protocol handlers it doesn't know.
In order to add your app's handler to Chrome:
With Chrome Closed
Navigate to "C:\Users\%Username%\AppData\Local\Google\Chrome\User Data"
Edit the file "Local State" with Notepad (or Notepad++)
Go down to the section marked "protocol_handler". You can also search for "ms-windows-store"
Add a line in "excluded schemes": "myTrip": false,
Save the file
Start Chrome
You should be able to use your protocol inside Chrome now.
I have an enterprise app that automates many business functions. I make heavy use of the WebBrowser control for all of my web site interactions (web site scraping, web app automation, etc....)
I've come across two web sites that simply will NOT render properly in the WebBrowser control. Specifically:
the US Postal Service Click-N-Ship web app. Renders fine until it is time to pay for your postage. Even just using the mouse to control it within a WebBrowser control (no automation) will not allow me to pay for postage. Soon as I submit the page it just hangs forever.
the UPS Quantum View Manage web app. This page will not even LOAD in the WebBrowser control. Just hangs forever.
Both of these render just fine in my IE10 browser.
I have tried setting the registry keys to change the rendering engine from default IE7 to IE9. But still same results. Something about these web apps just will not render in the WebBrowser control.
So....is there any way to automate IE10 the browser from my C# app? By sending messages of some sort? I need to be able to click links and fill in form data for login info and such. Any advice appreciated...
You could use a testing tool like Selenium to automate IE. You can download the IE Driver from their downloads page.
A simple example using google (Make sure you read the instructions on how to get the IE Driver working):
OpenQA.Selenium.IE.InternetExplorerDriver d = new OpenQA.Selenium.IE.InternetExplorerDriver();
d.Navigate().GoToUrl("http://www.google.com");
d.FindElementByName("q").SendKeys("Stack");
d.FindElementByName("btnK").Click();
WebDriverWait waiter = new WebDriverWait(d, TimeSpan.FromSeconds(10));
waiter.Until(ExpectedConditions.ElementExists(By.CssSelector(".rc .r a")));
// Message the first element
MessageBox.Show(d.FindElementByCssSelector(".rc .r a").Text);
Setting the context:
We have an internal app that started out as a web application, but now uses the windows desktop model instead of the browser for rendering. So instead of opening in browsers, the web app opens in modeless windows that are coded in C#. The user has to install a small exe to setup the modeless windows.
You would be clicking custom built toolbars (instead of the File, Edit, View options etc) and those will launch modeless windows and trigger an HTML request. The reponse will be rendered in the modeless window.
Issue:
we used to security test using Appscan when it was a pure browser application. We also use pen testers. However, Appscan doesn't work with the modeless windows model. It only manages to capture the first request (which is usually the login request).
Would you happen to know of any tool or testing framework/model that can security test this kind of an app?
I did try to look at relevant links, but they all seem to point to pure browser based web testing. Like this one: Web application security testing
Thanks in advance!
Edit: An example - have a look at http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/showModelessDialog.htm
How would I get appscan to scan the request response in the modeless windows.
What needs to be tested (for security) beyond the login? You've essentially created a dumb terminal that passes commands to a server and renders responses from that server.
If you really need some automated tester to work, then create a command-line switch for your EXE (dumbtermina.exe /test) that renders a regular windows form with simple buttons that simulate all of the menu and other commands.
Say I have a mobile optimized website which runs with a lot of javascript on it to create awesome effects, and a user enters the website via a mobile browser which doesn't have javascript activated.
Is it then possible to (through a button click) redirect that user to his/hers browser settings?
You need to have JavaScript activated in order to browse this site properly.
Click here to change your settings
In principle, you can create an intent: URL that references an ACTION_SETTINGS Intent, though I have not tried this. Off the top of my head, the simplest way to construct that URL is to generate a scrap Android project and call:
Log.d("Something", new Intent(android.provider.Settings.ACTION_SETTINGS).toUri(Intent.URI_INTENT_SCHEME));
then check LogCat for the URL that you would put in the Web site. Of course, this URL will only work on Android devices.
I only know Windows Mobile (and there, only up to v6.1), but I would guess your clients would have to have some app of yours prior installed to access features of the device itself.
If websites could access a device's features, it would be viewed as a virus.