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.
Related
I want to monitor changes in background in complex web application. This is one-page application with many scripts and so on. I need to be logged in to have access to data I want to monitor.
I tried to use webrequest, but I think that the application is to complex to do it that way. There is also a problem with authentication.
I also tried WebBrowser component, but web application is telling me, that this browser is too old and I should get newer one.
Perfect solution would:
Open this web application in chrome (or some other modern browser) in background
Save the page to memory
Extract values using something like HtmlAgilityPack
While this will be happening I want to normally use the computer (so opening chrome window is not a good solution for me).
Is there any way to achieve something like that?
if you can cope with an extra browser running, have a look at SeleniumHQ. with its webdriver-backed selenium you can start a dedicated browser instance and perform user actions by coding in high-level programming languages like java. it should not interfere your manual work at all, but will take up the same amount of memory and cpu time your "real" browser would.
if the web application has no captcha and does not object to automated script accessing it, you could also login in a background program by sending appropriate HTTP requests and parse the response. python's urllib2 would be my first choice.
if you dont want any additional processes running, you could also create a browser plugin, that autorefreshs and parses a certain open tab every few seconds.
I was playing around with Microsoft Spy++ and noticed that not only does it find the open processes, but can find the individual components running in each process. For example there is this application that allows you to open a window in which there is a textbox for an IP address and textbox for a port. Spy++ can detect these components. Knowing that Spy++ can detect them, is there anyway possible to find them in a separate c# application and go on to MODIFY their contents and otherwise interact with the program? (such as firing a click event on a button)
This is feasible. Try use PInvoke (InterOp) or AutomationElement, or AutomationPeer (for WPF applications) to automate all you wish to do.
Also you might wish to try Inspect and UISpy application as well.
Automation elements/peer is a non-intrusive mechanism to control UI using accessibility framework. One of the weaknesses in windows is its lack of defence against code injection. Put simply:
As a privileged user,
- You can Open and Modify a running Process image
- Make it load your OWN DLL
- Make it run your OWN thread (that potentially listens to commands from your process) and
- allows you to read any bits of memory you want.
Look at detours (http://research.microsoft.com/en-us/projects/detours/) for how to do it with Managed Processes.. Unfortunately, Microsoft removed the inject at runtime features.
Also look at http://msdn.microsoft.com/en-us/magazine/cc163617.aspx for doing things in the managed world (Apps like Snoop utilise that)
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.
I have a web-based picking/packing solution for delivering orders (asp.net/c#). Orders are marked as packed in the browser and then immediately the label information is added to our database, ready for the next part...
The label printing is done via a Windows application (written in C#) and was done this way because I couldn't find a way of getting the browser to print the label automatically (i.e. without the user having to click Print/OK, etc.)
The problem:
The Windows application polls every 10 seconds (subject to change) to see if there are any new labels for that picker/packer. Now, if I could get the browser to communicate with the label application then the polling would be unnecessary, since the picker/packer would have just clicked "Ready to Ship" and the label data would be created.
The data that is pulled down by the polling process isn't vast, but I'm concerned that as we add more picker/packer stations the polling process could have a knock on effect to the web server/database (since all stations would be polling). Also, pickers/packers don't want to wait around waiting for labels, so extending the polling time isn't possible (if anything I'd like it as quick as possible)
Solutions?
So, ideally, I'd like a way of communicating between the browser and the application (if possible). Or any method that removes the need for polling. Perhaps something akin to Comet, that allows the server to send a message to the application when a new label is added.
Ideally, a solution that wouldn't require a specific browser. But this may be asking too much.
A long-term solution would be to move the web-based picking-packing solution into the label application, but that would be a lot of work!
I hope that's clear and not too wordy. Let me know if I can add any other details in here. Thanks in advance.
Edit
Am looking into websockets as an idea. Any advice will be more than welcome!
Update
Thanks for all comments. I've now got a few ideas on how to solve the problem:
Websockets. May be problematic with firewall issues since I don't have easy access to the system (geographical distance)
Read browser cookies from the application. Possible solution http://www.codeproject.com/Articles/330142/Cookie-Quest-A-Quest-to-Read-Cookies-from-Four-Pop. This covers all the browsers that are in use in the warehouse. I can poll the local cookie values and see if any new labels have been created, then download them. Therefore no polling on the database server.
ActiveX control. Limited to IE and perhaps there'd be some security/setup issues with installing this on each PC.
Leave the code as is. Gauge whether the load on the database server is too much or ok.
You could create a local WebSocket server in your C# application and then make the browser connect to it and send the data you need to print.
I'm not sure, though, that this is what you need. As I see it you need to pass graphical data to your application, which could be really tricky to do using only javascript.
The appropriate way to achieve the communication between a web application and a desktop application would be to go through a server both apps talk to.
You can get any web-server (e.g. node.js nodejs.org that will let you use the same javascript you use for the web-app on the server) and interact with it. How you talk with the server from the desktop app depends on its technology. However all languages have some way to do http communications like SOAP.
Or you can try to make:
Both apps talk to the server using socket.io. You can borrow code from the following project.
Create an MSMQ (or a queue implementation of your choice) and host a WCF service in your windows application that polls the MSMQ.
Have your ASP.NET application write any relevant information to this queue so that the WCF service in the windows app that pulls this information will know what to make of it and print your labels.
The reason I mention a queue is for reliability, if your windows app goes down for any reason, the queue will at least be preserved and waiting for you to bring the windows application back up.
Although there is a bit of polling involved, it is very quick and almost neglibible. Implementing it is automatic with NetMsmqBinding, it's all taken care of. All you need to do is configure it.
If you go for a non-MSMQ queue, then I don't know whether you can still use NetMsmqBinding, you may have to create your own.
I'm not sure, but it seems like your application is polling a filesystem for these new labels to print? Have you considered using a FileSystemWatcher in your application? You can set that to watch a directory and be notified of anything new.
We are looking into the possibility of allowing users to opt into a program where they report what button clicks etc. they do, and I was wondering if anyone can suggest a good library which already does this. Based on the way the app is implemented, we have access to the base "Button" class and can add code on the click which records the fact that the button was clicked.
What we're looking for is a library which can record all these clicks, store them locally, and then send them to us at some point in the future when the user has internet access.
Does something like this exist in an open or closed form?
Thanks,
Liron
Our app can run code in either c# or javascript, since it runs in Unity3d, but we have other desktop apps which are pure c# and would prefer a library we can run across all our applications.
We ended up going with DeskMetrics, which seemed like a good fit for our needs. We also looked at TrackerBird which has some nice features which weren't necessary for our particular requirement and wasn't working within the limited requirements of Unity3d.