I am creating a website application which requires keyboard input, specifically without browser focus.
Without giving too much away about my great application idea (=P), I want to respond (even to just a single) keyboard key press, with the understanding that the browser will not have focus.
I have been doing a great deal of studying on this front, and I have found much help with keyboard 'hooks', so that no matter which application has focus, I can react to key inputs (the ones I have been playing with are in vc#). And these work, for executables, but I am not sure how to get them into the browser with my web application.
What my question is: Can I use ActiveX (or anything of that ilk - wpf?) to get access to keyboard input regardless of the browser having focus or not.
Thanks so very much for your time, I would love to learn if this type of thing is even possible, before wasting my time learning how to create and use ActiveX (just to learn that it is not).
The best (possibly only) way to do this would probably be to launch a seperate, medium integrity process (you have to register that properly when you install the control or it won't let you launch it) and have the process run when you need your access. Then you can use interprocess communication to report to the control when something happens that it should know about, possibly firing an event to javascript.
Be very careful how you use this, of course, because if done improperly it could cause a major security hole which would tend to make everyone hate you (most developers consider this a bad thing). For the interprocess communication you could use boost IPC stuff or named pipes.
Related
I want to use full screen mode in silverlight application but while using silverlight's own full screen feature, keyboard is disabled. So i can use browser's F11 functionality to make the application run in full screen mode.
Can anyone please suggest how to send keys in silverlight??
I suspect that you're in trouble. AFAIK, browsers do not allow programmatic access to window functionality; that is, they won't allow an untrusted application (like Silverlight, or on-page JavaScript) to invoke its "fullscreen" command.
There is also no way to "fake out" the browser as though the user sent the keystroke.
Both of these are serious security issues which is why it's not really possible.
Plausibly with Silverlight running as a trusted application in-browser, it may leverage some of the P/Invoke functionality to get around it, but I suspect that's going too far in your case.
EDIT: By the way, if you are able to host your Silverlight app as a trusted application, then keyboard events are still permitted. However, since you've tagged the question as Silverlight-4.0, I do believe you'll have to upgrade to Silverlight 5 to take advantage of the functionality.
There's an application written in C# that doesn't have any means of remote controlling. The only use scenario possible is to click the buttons with the mouse to get some result.
I'd like to create a server that would expose some common usage scenario with pre-defined clicking logic. So for example the application has a button "do thing" and I'm willing to make an HTTP (or other) server that would click it when a certain URL is loaded.
The application is intended to be used on Windows, though it should work fine with wine - my primary OS is Ubuntu, but I think that running the app in a VM is a better option. To program the rest of of the logic I can use java, python, ruby, php or node.js (I don't know C#).
What is the best approach to handle this? I would prefer not relying on click at the predefined X*Y position on the screen. Ideally the solution would also allow reading the data back.
You can easily automate the gui using the ui automation api. Check for example the White framework on codeplex
http://white.codeplex.com/
I am not sure however if yiu will be able to easily expose such automated application from an application server. The automation is not possible without explicit user session with visible desktop interface thus limiting your server processing to one active session at a time.
hmmm,
typing the title made me feel like i am a hacker asking for some illegal stuf....
but the truth is different i think. My client wants to control 3 webapplications at different computers at the same time.
I can't say exactly what the porpose of this is, but he wants, when he clicks on computer A at button 1 in the browser, that on computer B in the browser also is clicked on button 1, and also on computer C.
When i devided this process in 3 steps, i realized that none of them are things i've done before:
first thing is to get the click event out of the browser
second is to inform computer number B and C of the click event
third is to click a button in the browser of computer B and C
Three things i don't know how to accomplish (i have done some remoting in the past, maybe that can work for the communication between the three computers, but all i remember is that remoting did NOT become my friend)
So if you can give me any clue on how to catch browser events outside the browser, talk between two pc's and raise events in the browser from outside the browser, your help would be greatly appreciated.
EDIT:
i don't control the application. My client will use it to send multiple stock orders. so i think you can compare it with up-vote on a voting website
I know this is not an answer directly to your question, but it is a valid answer from a business and developer standpoint.
Unless your client is willing to pay through the nose for development time, it would be better to find out WHY the client wants this and offer possible alternatives. What they're asking can't be done without a LOT of work. I'm not sure where I'd even start - probably writing my own browser using the BrowserControl in a WinForms app, and using Remoting to control the WinForms app.
Really, you're better off researching the requirement better and proposing an alternative that is doable. Part of being a good devloper/analyst/project manager, etc is to be able to correctly divine what the customer actually needs from what the customer SAYS they want.
It could be that they just need you to track the status of something and your separate browsers need to auto-refresh. Or it could be that WinForms is not the right tool for the job. Or it could be something completely different. Heck, it could be as simple as only having one browser, and people can "watch" that browser from another PC using VNC or a similar tool.
There are usually multiple ways to meet a business need without focusing on difficult technical requirements. It's the business need that matters. and if you can find another way to meet it, you won't need to spin your wheels on this type of question.
As an added note, it makes me cringe to hear that you're even looking for "how to do this" without understanding why. Getting the requirements right is SO important in development. Most projects fail because the communication of requirements was not adequate.
What you want to do looks like 'shared browsing' or 'follow-me browsing'.
There are some questions that need to be asked :
do you want to do this with or without installing some sort of browser plugin or application ?
is the 'shared browsing' done only on a web application that you develop or do you need to browse to remote websites where you cannot add code.
If the web application can be modified, you could have all clients:
Send all actions they do a server ( #id1, click )
Poll the server for a list of actions that need to be triggered ( jQuery('#id1').click() )
If only one of the client is "master" and all the others are slave, it should be easy enough to synchronise everyone.
In a multi-master setup, synchronisation will be a little more complicated, and then maybe you will be re-developing Google Wave ;-)
Now if you need to be able to do shared browing over any website, thats a lot more complicated. Even more complicated if your solution needs to work cross-browser. You will need to develop extensions for each supported browser or native applications for all supported OSes. I advise you to look for existing solutions that already do have the shared browsing feature. You can also take a look at the VNC family of solutions (full desktop control).
I hope this will help you,
Jerome Wagner
Boring background:
I have been working with UltraVNC to control some PC's at work and it does the job great but in order to simplify things I created a program that interfaces with it in C#. Basically I take advantage of the commands the viewer offers to connect, control, watch or transmit to each PC.
Problem is anyone can access the PC's since it has one main account (no domain controller). I need everyone to sign for the PC before they can use it, so to make my job easier I open each PC and block the inputs + blank the screen that way there obligated to sign before use.
Opening each pc and press the block button can be hassle especial when you’re helping someone and a user leaves, others come (btw I work at an electronic library). UltraVNC doesn’t have a command for this; it’s been requested but I don’t think it’s much of a priority for them and the code seems very intimidating for a novice like me so I thought I could try a hack to get what I want.
Problem: I want to “click” a button in a program I use, from an application that I am building in c#. I can currently use the process class to get the handle and identify the specific window I want to use but I have no way to find the button handle which I read is what I need. I found stuff about using findwindow and sendkeys for this but I don’t see how that’ll work unless the button had a keystroke assigned to it which it doesn’t.
So can anyone point me in the right direction?
Why not use something like Eficium Cybercafe SurfShop to achieve what you want? After teh user finished you log the session out, and before someone can log in, they have to sign in.
Okay I've spent the afternoon researching and haven't had much luck finding the answer to this. I am trying to prevent an application from launching via some sort of dll or background application. It is to be used in monitoring application usage and licenses at my institution. I have found leads here regarding WqlEventQuery and also FileSystemWatcher. Neither of these solutions appear to work for me because:
With WqlEventQuery I was only able to handle an event after the process was created. Using notepad as a test, notepad was visible and accessible to me before my logic closed it. I attempted to Suspend/Resume the thread (I know this is unsafe but I was testing/playing) but this just hung the window until my logic finished.
With FileSystemWatcher I was not able to get any events from launching a .exe, only creating, renaming and deleting files.
The goal here is to not let the application launch at all unless my logic allows it to launch. Is this possible? The next best solution I came up with was forcing some type of modal dialog which does not allow the user to interact with anything, once the dialog is closed the application is killed. My concern here is killing the application nicely and handling applications with high overhead when they load such as Photoshop or something. This would also interfere with a feature I was hoping to have where the user could enter a queue until a license is available. Is this my best route? Any other suggestions?
Thanks
edit: To clarify this is not a virus or anything malicious. It's not about preventing access to a blacklist or allowing access through a whitelist. The idea is to check a database on a case by case basis for certain applications and see if there is a license available for use. If there is, let the app launch, if not display a dialog letting the user know. We also will use this for monitoring and keeping track if we have enough licenses to meet demand, etc. An example of one of these apps is SPSS which have very expensive licenses but a very limited pool of people using it.
Could you use
System.Diagnostics.Process.GetProcessesByName
in a loop to look for the process?
It might work if you don't use too aggressive a polling rate.
You are indeed close, take a look at the WMI Management Events. http://msdn.microsoft.com/en-us/library/ms186151%28VS.80%29.aspx
Sample code from Microsoft: http://msdn.microsoft.com/en-us/library/ms257355(VS.80).aspx
Subscribing to the appropriate event will provide your application with the appropriate information to perform what you described.
Not sure if this is a GOOD solution but you could do something like pass a key into main so that if the key is not present or valid the application shuts down. Then when you open the application in your code, just pass the key in. Someone would then have to know the key in order to start the application.
This is assuming you have access to the application in question's source code, which upon reading your question again, I'm not so sure of.
I assume you don't have source for the application you want to prevent from loading...
Have you considered using a system policy? That would be the best-supported way to prevent a user from launching a program.
You could have a service running that force-kills any app that isn't "whitelisted", but I can't say how well that would work.
I wonder if you are taking the wrong approach. Back in the day there was a Mac app that would prevent access to the desktop and had buttons to launch a set list of applications.
IDEA
What if you had a wrapper for the approved apps then only allow your wrapper to run on the computer?
I would expect there is some way of hooking an application launch, but can't help directly on that front.
You may be able to improve your current approach by detecting the application's window opening and hiding it (move it offscreen) so that the user can't attempt to interact with it while you are trying to shut it down.
However, another approach that may be possible (depending on your circumstances) would be to write an application launcher. This simply is a replacement for the shortcut to the application that checks your licencing conditions, and then does a Process.Start to launch the real .exe at that point. This would work well for any application. (I used a system like this for starting up applications with specialised environment settings and it works beautifully)
You could combine this with your current approach as a fall-back for "clever" users who manage to circumvent your launcher.
If my understanding is right you want to create an application what will prevent the computer user to start any other process except ones for a white-list.
If this is the case, monitor the process list of processes (in a while loop) using System.Diagnostics.Process (the GetProcesses method gives the list of all running ones)
Just kill the process when it starts.
Or if your machines have Windows 7 (Windows 2008??) you can use AppLocker. http://www.microsoft.com/windows/enterprise/products/windows-7/features.aspx#applocker Just let Windows prevent the startup.
You might want to look at this product: http://www.sassafras.com/licensing.html Personally I can't stand it, but that's because it does what you describe. Might save you some coding.
You could actually edit the registry so when you click a psd, your launcher gets called instead of photoshop. Your launcher then checks for licenses and if there is one starts photoshop with the path of the file.
This is a long shot but you may find it helpful.
Perceived Types and Application Registration
http://msdn.microsoft.com/en-us/library/cc144150(VS.85).aspx