Remote Desktop Mobile autologinAs you may know, Remote Desktop Mobile (RDM) does not support auto-login. But sometimes you may want that a user does not change settings and is directly connected to a Terminal Server. Ruggedized devices are often used in warehouses and the IT structure uses a terminal server to gather data and manage goods. Although I think Windows Mobile is not the right OS for such barcode scanner devices, you may have no choice and have to use a handheld computer with Windows Mobile instead of one that uses Windows CE. The RDM or Terminal Service Client provided with Windows CE devices is much more flexible and can be configured by the OEM to enable you to auto-login into a Terminal Server (TS). OK, the challenge was to automate the startup and login of RDM on a Windows Mobile 6.1 device. I started using embedded Visual C++ 4.0 although this is outdated by VS2005 and VS2008. The idea was to launch the EXE, fill in the values and click the Connect bar. Finding the Connect Dialog WindowNormally, on desktop windows, windows and their children are located in their own tree (see desktop PC spy++ screenshot). On WM61, I found that the RDM window (
RDM Connect Dialog Filling the FieldsKnowing the right window, I was able to set the text entries by knowing their Execute the ConnectThe fields are filled with the connection details and now I needed a way to simulate a click onto the connect button (which is a menu in reality) to let the dialog execute a connect. I tried several approaches, the best is to use //Solution three, best solution, ensure you use the scancode value too!
//AFAIK the scancode for F1 is always 0x70
keybd_event(VK_F1, 0x70, 0, 0);
Sleep(30);
keybd_event(VK_F1, 0x70, KEYEVENTF_KEYUP, 0);
I was unable to send Sending the SoftKey1 (F1) was also unsuccessful for window handles of The PitfallsEverything seems to work OK, but sometimes the tool was unable to fill the fields and execute the connect. I did search several hours and then I found that the registry and a file is involved in the connect. The tool always failed to autoconnect after the first clean boot. So I did a snapshot with the famous free SSNAP by “S-K tools” and found the changes that caused a manual connect to be successful. Registry ChangesFirst, the registry will get be changed, if you manually connect. As I did not like to have my tool to emulate a user typing into the fields using RDP file default.rdpWhen you fill the connect dialog and then press [Connect] RDM will save your values in a file \Windows\default.rdp. You may know, that rdp files are commonly used on desktop windows to save/load Remote Desktop Session connection data. Yes, WM6.1 does use a similar technique. The tool had to provide a default.rdp with the data of the connection settings. So I wrote a function to create and write this file from scratch on every start (see ConclusionSo far, the tool works. Don't download if you don't like spaghetti. The code is written as grown. UsageWrite the correct values for the connection to the registry: [HKEY_LOCAL_MACHINE\Software\RDP_autologin]
"FitToScreen"="1"
"FullScreen"="1"
"Status"="connecting..."
"Save Password"="1"
"Domain"=""
"Password"="xxxxxxxxxx"
"Username"="rdesktop"
"Computer"="192.168.0.130"
Then simply start the tool. First it will terminate a running instance of RDM. Then it starts a new instance and starts to fill the fields and do the connect. WarrantyNo warranty, code is provided as is. Hopefully it is useful for the one or other. ChangesSome values are hard coded, i.e. the control IDs used. These IDs may be different on other devices or within other RDM releases. So far, the code works on my testing device. If you need to change the control IDs, you may use the Have fun!
| |||||||||||||||||