Targeting a specific Chrome process? - c#

When I open the Chrome's Task Manager, I can see something like this?
Now, programatically, is it somehow possible to target the Chrome instance that is being used to run the Flash Plug-In? Maybe using System.Diagnostics.Process class or native API calls?

I was able to do this with native api calls. My solution worked perfectly on my machine. Here is what I did:
First, get Microsoft Process Explorer. Using this tool, I was able to get the flash plugin dll's name that chrome uses which is called pepflashplayer.dll in my case.
Next, a little search on Bing got me this article. It's C code so I converted to C# and after some coding I was able to retrieve the correct Chrome process ID that uses flash plug-in.
I have uploaded my solution to SkyDrive for you to check here. Note that I am not closing any handles in my sample so you'll have to add that for a real project.
There might be better solutions out there but this one should work. Hope it helps.

Related

Get info from current webpage in Chrome

I am member of a website and want to grab some info from the current open window in Chrome. That is, if I am looking a persons profile in Chrome, I want my C# program to be able to get the source code of that website so I can retrieve birthday, location, etc from it. Is there a way to do this?
I guess a solution is to incorporate the webbrowser control in a winforms project and use that instead of chrome. but it would be nicer if I could just use Chrome as I normally do and then when I switch to my C# program it copies the source code and parses whatever info in it that I find relevant.
You can try to use the C# version of Selenium for automating your browser. It's mainly designed for testing, but it should help you solving your problem. It comes with a driver for Google Chrome.

Link Tracker C#

I am creating a download manager, and I need to be able to find out what link was clicked on (so my download manager can begin downloading the file), and also need to be able to stop the browser from launching its default download manager.
Does anyone know how to go about doing this, or know of any links to articles/tutorials/related docs?
As far as I know, the only way is to write a pluggin for IE which is done through Browser Helper Objects and that is unmanaged C++. Have a look at this:
http://msdn.microsoft.com/en-us/library/bb250436(VS.85).aspx

C# plugin for Google Chrome

Can I communicate to Google Chrome in C#?
For writing a chrome plugin for example.
<Spoilers>
Quick short answer: No, because Extensions require JSON, JavaScript, and HTML.
</Spoilers>
Hi Tony,
There are multiple templates on the internet that you can download to build a chrome extension project using Visual Studio.
Downloading one of these templates just gives you the files and folders that you need which I call "the setup".
That won't let you build a Google extension using C#.
Andrey mentioned that there are libraries like Bridge.NET that will compile your code into HTML/JavaScript. That will help you write HTML and JavaScript using C#. You still need a manifest.json file.
I don't recommend that. That library is not designed for Chrome Extensions. Also, you will have to compile the code into JavaScript and store that JavaScript code in a JavaScript file. I recommend using HTML/JavaScript with no compilers when building your Chrome Extension.
You need to keep in mind that there are 3 main parts in a chrome extension. These are:
manifest.json
A JavaScript file
HTML file
There are multiple steps and it's not hard to build a google chrome extension. This link will give you the complete tutorial on developing a chrome extension with detailed explanation. This tutorial installs a template so that you can develop it in Visual Studio just like I mentioned before.
What I have done to address is use Simple Message Host, it will trigger an executable on the local machine that you code in c#, sending stdin messages and listening to stdout messages so you can build this host to use as a bridge, but like I said, it needs to be on your local network at least, and you have to do some editing in the windows registry, so it has its limitations.
But for the system I am working with, this solution worked perfectly because I have a controlled environment that I can set up all these prerequisites.
So, just to clarify, what I did here is:
Create a chrome extension with background.js opening up the listener to the website's javascript.
Add a registry in windows registry pointing to the path of the executable.
Create the executable in C# doing all your logic.
Send a response from the executable to the extension and then back to the website.
There are several guides on how to do this, so I won't detail these steps here so I don't replicate it.
But for the moment, it is the best way to do what you want, if you have control of your environment that is.
So, if your plugin (extension or chrome app) will work on a controlled environment, this is the way to go, otherwise, I would consider something related to ClickOnce perhaps or WebAssembly but that's not fully released yet.
Chrome own extension manager supports extensions written in js and html.
that said, to execute c# code within the extension you have two options:
Compile c# code to javascript code which then can be added as a normal javascript extension to chrome (take a look at scriptsharp)
Use c# as a back-end system. just like most of download managers:
for case 2 you need a c# application installed in client device(or in the cloud) listing to a specific port (using httplistener or self hosted webapi (you can use netcore) which do these steps
Listing to incoming requests
parse request data eg. json and do something with it
return the result to javascript extension which can display it to user or do other things with it.
The topic is quite old, but I'd like to share that sample:
https://github.com/Retyped/Demos/tree/master/ChromeDemo
In a few words, the sample is implemented in C#. The Retyped.chrome NuGet package provides bindings (Chrome API) for Bridge.NET projects. So yes, now you can implement your logic in C#, then C# code will be transparently compiled into JavaScript by Bridge.NET compiler.
With that approach you can build your Chrome extension on top of .NET Framework as well as utilize thousands of JavaScript libraries.

C# - Possible to use Subinacl or something else (an api maybe?) from C# code?

I've created a program in C# which creates users and adds them to groups, everything is working fine. But I also want to create a "home folder", which is on another server, and the share will be like this: 81file01/users/username. And of course set the rights of the folder to the newly created AD-user. Now we're using a vb-script to do this, and this part is done with Subinacl, but is there a way to do this through my c# code?
I'm using .net 3.5 by the way :)
You can shell out using System.Diagnostics.Process and just call Subinacl directly as you do now.
Or you roll your sleeves up, and get your hands dirty calling what appear to be mainly a Win32 set of APIs. The friendliest article on that subject I could find from Microsoft talks about using the COM interface via COM interop.
There are some wrappers to these APIs floating around, but how good they are, I don't know.

I want to use an exe file programatically

I am using a software named Daisy 2.02 Validator and it is with GUI but i want to access it programatically so that i can control all the validation process through my C# project. I am unable to find any help about it's libraries, any .net Api or any DOS command for controlling it. Please provide me help.
Thanks,
Regard,
Muhammad Waqas
If it's a .NET executable, try and use ILDASM.exe or better still - use Reflector to find out whether it has a public API. You may then be able to add it as a reference (all you need to do is simply rename the .exe to .dll) to your project or alternatively load it as an assembly and use reflection to use its API.
Obviously the first option is much preferred.
If it isn't a .NET executable, you could use scraping, but you would have to profile your app for that first and work out what low level windows messages and controls it responds to. Bit of a nightmare.
from what I see Daisy 2.02 Validator is an open source project.
if the API is not implemented you can just add it yourself
Worst case maybe send keystrokes to it.

Categories