Send CTRL+ALT+END over RDP
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
09-05-16 05:40 PM
Does anyone know a way of acheiving this?
So far i have the following code:
[DllImport("user32.dll", SetLastError = true)]
static extern void keybd_event(byte bVk, byte bScan, int dwFlags, int dwExtraInfo);
public const int VK_MENU = 0x12;
public const int VK_CONTROL = 0x11;
public const int VK_END = 0x23;
public const int KEYEVENTF_EXTENDEDKEY = 0x0001;
public const int KEYEVENTF_KEYUP = 0x0002;
public static void ctrlAltEnd()
{
keybd_event(VK_MENU,0xb8,0 , 0); //Alt Press
keybd_event(VK_CONTROL,0x9d,0 , 0); // Ctrl Press
keybd_event(VK_END, 0x4f,0,0); //press end
keybd_event(VK_END, 0x4f,KEYEVENTF_KEYUP,0); //release end
keybd_event(VK_CONTROL,0x9d,KEYEVENTF_KEYUP,0); // Ctrl Release
keybd_event(VK_MENU,0xb8,KEYEVENTF_KEYUP,0); // Alt Release
}
6 REPLIES 6
Anonymous
Not applicable
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
09-05-16 06:17 PM
I would usually use Global Send Keys Event in a navigate stage instead. Using:
""{CTRL}""
But I'm guessing you started developing a code stage due to the fact that a navigate stage didn't work - but what exactly is the problem? - does it not compile?
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
09-05-16 06:55 PM
Hi Timmorthorst,
It compiles fine, but it doesn't sending the key strokes as expected (Nothing happens)
I've created a method that presses CTRL+ALT which works fine. I can then manually press the END button and it works.
I've tried to use the method that presses CTRL+ALT, then use Global Send Key Events ""{END}"" before release CTRL+END, but this doesn't work either.
-Tom
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
10-05-16 02:06 PM
Hi Peter,
The RDP windows was attached and activated to so is in focus.
-Tom
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
10-05-16 03:09 PM
OK - I've figured it out:
public static void ctrlAltEnd(){
keybd_event(VK_MENU, 0xb8, 0, 0); //Holds down the ALT key
keybd_event(VK_CONTROL, 0x9d, 0, 0); //Holds down the CTRL key
keybd_event(VK_END, 0x4f, KEYEVENTF_EXTENDEDKEY | 0, 0); //Holds down the END key
keybd_event(VK_END, 0x4f, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0); //Releases the END key
keybd_event(VK_CONTROL, 0x9d, KEYEVENTF_KEYUP, 0); //Releases the CTRL key
keybd_event(VK_MENU, 0xb8, KEYEVENTF_KEYUP, 0); //Releases the ALT key
}
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
12-05-16 03:18 PM
I think timmorthorst's answer was the correct one. Is there a reason you are implementing bespoke code rather than using the standard SendKey or SendKeyEvents actions already exposed by the Blue Prism navigate stage?
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
12-05-16 04:31 PM
Hi Denis,
A few reasons really; the main being that the standard SendKeyEvents did not work over and RDP connection to a terminal server and I wasn't able to figure out why.
The second is that this bespoke code solution was developed as a quick extension to of one of our Virtual Key utility object.
The initial purpose of this object was to hold a particular key down, then carry on processing, then release the key (e.g hold down shift, press down button until certain image is shown in a region, then release shift). The other purpose was that it allows me to drag and drop via Surface Automation by sending virtual mouse clicks down, setting a new cursor position and releasing the mouse button. As far as I am aware this functionality not available natively within Blue Prism.
I am however curious to find out if other users require this level of functionality or if Blue Prism is looking to implement into the product. I always find myself in need of these type of actions on various projects.
- Tom.
