Answer the question
In order to leave comments, you need to log in
How to run JS in a browser with a command from a windows application?
For example, an arbitrary page is opened in the browser with the content that we came up with.
A windows application is launched (written in C# or Python or Delphi, it doesn't matter) with the logic that we came up with.
How to run Java Script in a page from a Windows application or pass a simple boolean value there?
For example, what would alert work.
Answer the question
In order to leave comments, you need to log in
The application opens a local port for itself on which it listens for HTTP requests.
The Javascript in the page constantly pulls this port for new data.
There is no way to transfer it to an external browser, for security reasons, not only there is no API for this, but there is also protection against "tricks" such as patching on disk and in memory, one of the main protection factors is constant browser updates, so it is very difficult to write for them any "tricks", it needs to be almost on duty 24/7, so there is nothing like that.
What do you really want to do?
If you answer your question, then you need to write an extension to the browser that is already running not outside, but inside it, uses its official API, then all that remains is to make a "bridge" between the application and the extension, it can be an NPAPI / PPAPI plugin or something simple type of a shared file in localstorage, the extension reads it and the application writes commands there.
But judging by the comments, you don’t need this, you need to write a bot for the site, then an external browser is not what you need, you either need to use HTTP requests, or a browser but not an external one, but a headless browser built into the application - Phantom.js, Selenium , Chromium Embedded Framework, WebKit, Awesomium, Selenium, IE WebBrowser.
It sounds complicated because you don’t understand what you are talking about, if we are talking about writing a bot, then you don’t need to intercept requests all the time, it’s enough to do it once and then just send them from your application. There are sniffers for one-time interception of requests - Fiddler, Wireshark, Charles, F12 console.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question