I have an application which injects keystrokes into applications via SendKeys.
Unfortunately, the application will not work when I am running it via Remote Desktop
because of the well known issue that SendKeys doesn't work with Remote Desktop.
Has anyone solved this issue before, or have any good suggestions on how to resolve it?
SendKeys is not a good fit mainly due to:
It can only send keys to active/focused application, which is never guaranteed to work because the the active application can change between the time the keys are actually sent.
RDP and many other libraries (e.g., DirectX) block them mainly for security reasons.
Better alternatives:
Use SendMessage or SendInput for simple needs
Some good examples of how to use SendMessage can be found:
Send strings to another application by using Windows messages
SendMessage via pInvoke
How To Send Keystrokes To Extern Win Application
For more elaborate needs, it is recommended to use WCF
To get you started, read this Basic Tutorial that talks about Inter Process Communication
Sample code using SendMessage:
HWND hwndNotepad = FindWindow(_T("Notepad"), NULL);
HWND hwndEdit = FindWindowEx(hwndNotepad, NULL, _T("Edit"), NULL);
SendMessage(hwndEdit, WM_SETTEXT, NULL, (LPARAM)_T("hello"));
In my case I was successfully using WinAPI's SendInput with hardware scan codes. It seems like SendKeys maps chars to scan codes incorrectly.
You can workaround RDP issue by having desktop always logged in before use (or configured for auto-login # every boot).
And even with the auto-login, if you ever need remote desktop access to run automation, or manage system, etc., the preferred method is using VNC for remote access rather than RDP. Reason is VNC is cross platform and you won't run into this RDP issue. VNC works like a relay of your actual desktop (RDP console session 0 or the "head" of the machine), the disadvantage being one remote session at a time only (or you all share the same desktop + keyboard + mouse). VNC will work for virtual machines too. Use VNC instead of RDP or local (RDP) access from the (VMWare/Hyper-V/Xen) virtual machine manager software.
The only thing to watch out for with VNC still is that the desktop not be configured to auto-lock on idle or screensaver, that may also stop send keys and GUI automation from running, so be sure to disable that. Screensaver & monitor power save is ok, just no auto-lock & password protect.
NOTE: I'm not sure, but believe since VNC relays the desktop "as is", it is the same as executing locally from the app/system's point of view, so it should in theory also be able to fool the system/app that doesn't allow SendKeys via RDP. I've had no issues using this VNC method for AutoIt + SendKeys, whether I was actively connected via VNC, or disconnected (sendkeys/automation still continues to work after disconnect because on the actual desktop, it's still logged in, just that VNC not active).
In my case I was using sendkeys as part of test automation. It would not work from my build machine, where the build agent runs through remote desktop protocol. I'm not happy about it but I was able to skip that test as part of my automated builds.
Using Win32 calls to send window messages might work, if I have time I may try that someday.
Anyhow, here is the check to see if the current code is running in a remote desktop session:
System.Environment.GetEnvironmentVariable("SESSIONNAME").StartsWith("RDP-")
Related
I am trying to find a way to secure our robot against unwanted Choregraphe connections. We are required to work on a University-wide network, and we need a way to stop people from connecting who may have obtained the robot's IP address at some stage without our knowledge.
As there is no access to the root user account on the Pepper, I cannot simply lock down access using iptables, so I thought I might try looking at a way to forcibly close connections from ALChoregraphe when it registers on the robot.
However, running the command:
qicli info ALChoregraphe
I can see that the only method available is requestDisconnection. There is no way to close the connection forcibly.
I have tried using ALServiceManager to stop the service, but it apparently only knows about services that are installed as packages.
So far the only solution I have is to change the color of the eye LEDs to indicate that a connection has been established, and reset them when a disconnect is received.
Aside from moving the robot to its own network, do you have any suggestions on how I could go about handling this?
Thanks!
At the moment, there is no other way to prevent connections to the robots. All you can do is to make sure that unwanted clients cannot access the network of your robot.
In Choregraphe 2.4 and later, you can kick the existing Choregraphe after 30 seconds. If anyway it fails, you should unregister the services ALChoregraphe and ALChoregrapheRecorder using qicli call ServiceDirectory.unregisterService <serviceID> where serviceID is the number facing the services when listed with qicli info.
In other socket applications you can’t open a port that is already in use but bluetoothd seems to accept several listening GATT servers running in parallel, how is that possible?
I try to setup a GATT server using bluez 5.35 on Raspberry Pi Jessie. I have made an application that starts the GATT server much like the example btgatt-server.c using l2cap socket. I have a custom characteristic that a client application can connect and use. I have also setup to enable advertising using hci commands (it is set to enable just after listen() command on the socket).
I have done so the application auto start in rc.local. My problem is that after reboot, sometimes I don't see my own characteristics but I get a complete other list of services/characteristics. If I don’t start my own application and only enable advertising (sudo hciconfig hci0 leadv) I see the same list so it seems to be running a GATT server by default.
What mechanism in bluez decide if my services/characteristics or the other ones (I guess loaded by default plugins) are visible? They are never combined and visible at the same time and I don’t see any error messages during my application startup even if I can’t see the characteristics from the client and don’t get anything by accept(). How can I be sure my characteristics is always visible?
I'm writing some code in C for an IrDA project on one win7 32bit computer. I have another computer setup to display any data received via in infrared. This part works. However the as soon as I connect the IrDA dongle to the PC, it starts to send periodic data for searching other IrDA devices. I want to disable this behavior programmatically so I see only the data sends as a result of my code. Anyone know which command to use? Is it WSASetService? I didn't learn socket programming, not sure what "removes from the registry a service instance within one or more namespaces. " really means. http://msdn.microsoft.com/en-us/library/windows/desktop/ms742211%28v=vs.85%29.aspx
Have you disabled the Infrared Monitor Service manually?
I experienced problems with this functionality in win7 when using Windows to communicating with an embedded micro-controller based device that worked well with windows XP.
I disabled the Infrared Monitor Service manually and found that windows was still polling the IrDA periodically!
I have not found any documentation available that describes it or how to disable it, I will continue searching...
I am creating a screensharing application that would work in a similar manner like Google Hangout Screen Shares, and I'd like to know how the Google Talk plugin (used for Screen Shares) spawns child processes and uses a dynamic port range.
I am creating a background running application that user will have to install, and which talks with browser like how they describe here, http://www.codeproject.com/Articles/36517/Communicating-from-the-Browser-to-a-Desktop-Applic
But when I look at googleTalkPlugin, which is responsible for google hangout screen sharing, I saw that there are a lot of processes running, and whenever I open a new browser, a new talk plugin for that browser starts, as child service.
Here are some snapshots
and when I noticed the port used by googleTalkPlugin, I came to know its dynamic! If you saw the above link, the Browser Desktop communication is on static port.
I am very interested in knowing, how do I use dynamic port numbers? Also, should I create child process for every browser?
Or something better?
The reason there is a separate child process for each browser is that the Google Talk application is implemented as a browser plugin. Each browser has a Google Talk plugin installed and doesn't know about the other browsers, their plugins or their subprocesses. Each browser will launch the plugins that it has installed and, as Eduard mentioned in the comments, some plugins are started in a separate process. This isn't behavior that is special about Google Talk, it is behavior you will see with most plugins. If you implement your application as a browser plugin you will have the same behavior. If you don't want your application to run as a subprocess of a browser then you will need to write it as a standalone application, not a browser plugin.
If you want to learn more about spawning subprocesses read up on fork(). There are lots of other good resources around the internet on subprocesses.
Your other question is around dynamic port numbers. The easiest way to do this is to bind to port 0 and you will be assigned a random open port by the operating system. You can then use getsockname() to find out what port you ended up with. If you are working with a client/server situation you can have the client do this and then just tell the server which port it is using.
I'm facing a problem that gives me a quite hard time ...
People having trouble to execute a program that needs specific ports to be open, sadly they don't know if its a clientside problem caused by blocked ports, of it its simply a software problem.
So I thought about making a program that checks if the user can access the provided ports, after I made the WPF application, I was thinking about having an easier access to such functionality and tried to produce a Silverlight Version.
Questions:
a.) Is there even a way to check if the user can connect to specific ports that aren't in the range of 4502 - 4534 within a silverlight application that runs as plugin in the web browser ?
b.) Is there a way to do this, even without having access to the specific server to provide a policy file?
If you trying to do it from the in-browser application that its a no. Trusted silverlight application should be able to connect to any port without restrictions.