problem with ctrl+shift+home

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
jsarver1
Newbie
Posts: 5
Joined: Wed Jul 15, 2009 6:35 pm

problem with ctrl+shift+home

Post by jsarver1 » Thu Aug 13, 2009 5:00 am

I am trying to copy all of the text in a text box in an unfriendly windows terminal services application. I have run into this problem:

The following works well on the local machine (wordpad):

'Go to end of text block
Press>Ctrl
Press>End
Release>Ctrl
Release>End

'Select text back to beginning
Press>Ctrl
Press>Shift
Press>Home
Wait>.5
Release>Ctrl
Release>Shift
Release>Home

'Copy text to clipboard
Wait>.5
Press>Ctrl
Send>c
Release>Ctrl

However, when I am running in the windows terminal services, I am unable to get it to work at all. If I set the legacy to 1, with
Let>SK_LEGACY=1

then I can get the copy function to work (if I manually highlight the text by manually typing ctrl+shift+home), and the cursor will move to the end of the text block and to the beginning of the text block, but will not highlight.

Any thoughts?

I appreciate your help,
---Josh

gdyvig
Automation Wizard
Posts: 447
Joined: Fri Jun 27, 2008 7:57 pm
Location: Seattle, WA

What machine is macro scheduler on?

Post by gdyvig » Thu Aug 13, 2009 3:02 pm

Hi jsaver1,


I could not get your script to run locally unless I removed the > from the Press and Release Commands.

Press Ctrl
not
Press>Ctrl


If you are running the macro scheduler script locally the terminal services window may not be receiving the key strokes. They will be going to the currently active window on your local machine.

To see what is happening run this script on your local machine, start terminal services, open an app such as notepad on the remote desktop, minimize the remote desktop, stop the script.

Code: Select all

Let>MSG_STAYONTOP=1
Let>x=0
repeat>x
  GetActiveWindow>sActiveWindowTitle,nXPos,nYPos,,
  Timestamp>C:\ActiveWindow.txt,%nXPos%/%nYPos% ActiveWin:%sActiveWindowTitle%
  wait>1
Until>x>500
Open up C:\ActiveWindow.txt and you will see that the only windows listed are those on the local machine, not the windows within the remote desktop.

If you are allowed to install Macro Scheduler on the remote desktop place the same script there and run it. Note the difference in the contents of C:\ActiveWindow.txt located on the remote machine.


If you must run Macro Scheduler locally ensure that all keystrokes go to the currently active window within the remote desktop by adding this statement to the top of your script:

Code: Select all

SetFocus>Remote Desktop*

I tried my own advice and found that the script is still not working on the remote desktop for the Ctrl Home where Macro Scheduler is installed locally. The next thing to check is keyboard mappings for Remote Desktop and Macro Scheduler. You probably have to substitute some other Press commands. For example, I found Alt EA works for most apps to select all text.http://www.mjtnet.com/forum/viewtopic.p ... te+desktop

This might help:

[url][http://www.mjtnet.com/forum/viewtopic.p ... esktop/url]


You will have more control over your script if you can install it on the remote desktop. You will be able to do SetFocus commands on specific windows on the remote desktop rather than hoping for the best.


Hope this helps,


Gale

jsarver1
Newbie
Posts: 5
Joined: Wed Jul 15, 2009 6:35 pm

Post by jsarver1 » Thu Aug 13, 2009 5:06 pm

Gale,

Thanks for your thoughts. I have the setfocus commands earlier in the script--sorry that I omitted those in the snippet. If I set the legacy value to 1, everything works on windows terminal services except the text does not highlight. If I set legacy to 0, nothing works on the windows terminal services application that I working with. On the local machine, if I set legacy to 0, then it all works fine. For the particular application, some of the text boxes I want to capture support ctrl a, while others do not. Manually typed, all the boxes will highlight with ctrl+shift+home. I will look into alt ea. It seems like I am just not able to get the windows terminal services application to recognize that the shift is being pressed with the ctrl+home when legacy is set to 1, but the windows terminal services application will not recognize any of the commands without legacy set to 1. I tried sending shift t, just to see if the shift is being recognized at all, and I get a capital T.

Unfortunately, I cannot install my application on the server and must instead install on the multiple workstations accessing the server throughout the department.

Thanks again for your help. I will look into alt ea. Please let me know if any other ideas occur to you.

Thanks,
---Josh

gdyvig
Automation Wizard
Posts: 447
Joined: Fri Jun 27, 2008 7:57 pm
Location: Seattle, WA

Not recognizing SHIFT

Post by gdyvig » Thu Aug 13, 2009 7:57 pm

When I tried your script against WordPad where the cursor was at the last line of text I found that Ctlr-Shift-Home moved the cursor to the top of the text area. This is what happends when I manually do a Ctrl-Home. It appears the Shift is ignored.

Try putting a short wait between each of the Press commands.

I don't have time to test it myself right now.


Gale

gdyvig
Automation Wizard
Posts: 447
Joined: Fri Jun 27, 2008 7:57 pm
Location: Seattle, WA

Ctrl-Shift-Home experiments using RDP

Post by gdyvig » Mon Aug 17, 2009 3:47 pm

These Results with MSTSC Keybord Option set to "On the :Local computer"

I tried putting the waits between the Press commands, makes no difference.

I was a standard user on the remote desktop, so I tried it again as a local admin on the same remote desktop, makes no difference.

Tried setting SK_LEGACY=0. No keystrokes or press commands went through.

Did these experiements manually on the RDP:
Created a WordPad file, entered 4 lines of text.
Left cursor at the end of the last line of text.
Press Home moves cursor to left margin on last line
Press Ctrl Home moves cursor to Home
Press Shift Home highlights last line of text
Press Ctrl Shift Home highlights all lines of text.


Repeated experiment with script.
Macro Scheduler on the local machine
WordPad on the RDP.
SK_LEGACY set to 1
Press Home moves cursor to left margin on last line
Press Ctrl Home moves cursor to Home
Press Shift Home moves cursor to left margin
Press Ctrl Shift Home moves cursor to home


SK_LEGACY 1 works for the Ctrl key for these key combinations,
but fails for the Shift key.


Some vbscript posts found on other sites suggest that RDP may be doing some "key binding", to not allow some combinations of key strokes to pass through via automation.

There have been numerous Microsoft updates lately dealing with privilege elevation security issues for XP, Vista, and Window Servers 2003/7. One of these may be the root cause of this problem.

Has the "Press Shift" ever worked for anyone in RDP windows?


Gale

gdyvig
Automation Wizard
Posts: 447
Joined: Fri Jun 27, 2008 7:57 pm
Location: Seattle, WA

More experiments

Post by gdyvig » Mon Aug 17, 2009 5:26 pm

These Results with MSTSC Keybord Option set to "On the remote computer"

I tried putting the waits between the Press commands, makes no difference.

I was a standard user on the remote desktop, so I tried it again as a local admin on the same remote desktop, makes no difference.

Tried setting SK_LEGACY=0. No keystrokes or press commands went through.

Did these experiements manually on the RDP:
Created a WordPad file, entered 4 lines of text.
Left cursor at the end of the last line of text.
Press Home moves cursor to left margin on last line
Press Ctrl Home moves cursor to Home
Press Shift Home highlights last line of text
Press Ctrl Shift Home highlights all lines of text.

Repeated experiment with script.
Macro Scheduler on the local machine
WordPad on the RDP.
SK_LEGACY set to 1
Press Home appends a 7 to the last line
Press Ctrl Home does nothing
Press Shift Home moves cursor to left margin
Press Ctrl Shift Home moves cursor to home

Behavior is different but still incorrect.

However this did work, but not consistantly:
Press Ctrl
Send>A
Release Ctrl





Gale

gdyvig
Automation Wizard
Posts: 447
Joined: Fri Jun 27, 2008 7:57 pm
Location: Seattle, WA

Full Screen

Post by gdyvig » Mon Aug 17, 2009 5:55 pm

These Results with MSTSC Keybord Option set to "In full screen mode only"

I tried putting the waits between the Press commands, makes no difference.

I was a standard user on the remote desktop, so I tried it again as a local admin on the same remote desktop, makes no difference.

Tried setting SK_LEGACY=0. No keystrokes or press commands went through.

Did these experiements manually on the RDP:
Created a WordPad file, entered 4 lines of text.
Left cursor at the end of the last line of text.
Press Home moves cursor to left margin on last line
Press Ctrl Home moves cursor to Home
Press Shift Home highlights last line of text
Press Ctrl Shift Home highlights all lines of text.

Repeated experiment with script.
Macro Scheduler on the local machine
WordPad on the RDP.
SK_LEGACY set to 1
Press Home appends a 7 to the last line in full screen mode
Press Home moves cursor to left margin if not in full screen mode
Press Ctrl Home does nothing if in full screen mode
Press Ctrl Home move cursor home if not in full screen mode
Press Shift Home moves cursor to left margin in both modes
Press Ctrl Shift Home moves cursor to home in both modes

Behavior is different but still incorrect.

However this did not work consistantly if window is in full screen mode
Press Ctrl
Send>A
Release Ctrl


In conclusion:
The behavior of RDP screen under SK_LEGACY 1 varies according to:
1. Whether MSTSC option is "Local Computer", "Remote Computer", or "Full Screen".
2. Whether the actual RDP display is full screen or restored (resizable).
3. Ctrl Shift Home does not work for any of the above
4. Ctrl+A may be an alternative for Full Screen option and display.
5. Consistance problems remain.

Gale





Gale

User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Mon Aug 17, 2009 8:19 pm

I confirm I get the same behaviour. Does seem as if things change from Windows update to update as I'm sure this once worked fine! It will be investigated.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

jbas
Junior Coder
Posts: 29
Joined: Tue Dec 15, 2009 4:59 pm

Updates

Post by jbas » Tue Dec 15, 2009 5:12 pm

Any updates on this issue? I have the same problem - the curosr moves as expected but the text does not remain highlighted so it cannot be deleted or copied / cut to the clipboard.

User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Tue Dec 15, 2009 5:16 pm

No updates yet. You can be assured all updates will be announced.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

jbas
Junior Coder
Posts: 29
Joined: Tue Dec 15, 2009 4:59 pm

Post by jbas » Tue Dec 15, 2009 5:39 pm

- From what I see it appears that the problem is with the 'shift' key not being recognized.
- With 'sk-legacy=1' Home, End, Ctrl+Right, Ctrl+Left all work as expected.

Any ideas of alternative ways to get info to the clipboard? Ctrl+A isn't recognized by the application.

Thanks!

User avatar
JRL
Automation Wizard
Posts: 3502
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Tue Dec 15, 2009 6:05 pm

Any ideas of alternative ways to get info to the clipboard?
Have you tried GetControlText> or GetTextInRect> functions? Also a number of different OCR techniques have been discussed on this forum.

lolkid
Newbie
Posts: 6
Joined: Mon Dec 21, 2009 2:57 pm

Post by lolkid » Mon Dec 21, 2009 3:33 pm

I'm having the same sort of issue with a Non-Terminal Services set-up.

I'm running Vista Ultimate and using MacroScheduler to handle a Browser based app which has controls that are not visible to MacroScheduler. This generally isn't a problem for me - I've coped with everything reasonably easily so far.

However, when I try and grab the text from an edit box using the relevant keystrokes, it simply fails. The code works on Notepad, and the same manual steps

I've tried differing keystrokes (CTRL-INSERT v CTRL-C), set 0/1values for SK_LEGACY, peppered the code with a bunch of WaitClipboard statements to try and lock the clipboard, and waited prior to the copy to ensure that the data I want is correctly highlighted.

If I do the copy manually with the keyboard, it works every time (using the same keystrokes). If I use MacroScheduler nothing hits the clipboard, and the relvant variable is non-existent.

Rough example code follows. I've tried many variants - giving up after a couple of hours. Any help greatly appreciated (the alternative mechanisms for accessing the clipboard are no good for me).

MouseMove>iX,iY
LClick
Press Home
Release Home
Press CTRL
Press Shift
Press End
Release End
Release Shift
WaitClipBoard
SendText>C
Release CTRL
WaitClipBoard
GetClipBoard>iBlah
WaitClipBoard

User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Mon Dec 21, 2009 4:33 pm

Are you able to provide a link to the web app in question?


If I understand you correctly it works fine in Notepad. I also have no issue in notepad. While typing this reply I tried it also against this textarea message box on the forum and it worked fine. Here's my code:

Code: Select all

SetFocus>Post a reply*

//ctrl-shift-end
Press CTRL
Press SHIFT
Press End
Release SHIFT
Release CTRL

Wait>0.5

//ctrl-c
Press CTRL
Send>c
Release CTRL

WaitClipBoard
GetClipBoard>text
MessageModal>text
This worked fine against the message body box in the forums, on Chrome.

If you can send me a link to the web site you're having a problem with I can try to replicate.

BTW have you tried:

Press CTRL
Press LShift
Press End
Release LShift
Release CTRL

Just curious if that is any different.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

lolkid
Newbie
Posts: 6
Joined: Mon Dec 21, 2009 2:57 pm

Post by lolkid » Tue Dec 22, 2009 7:44 pm

Unfortunately, I'm not able to provide a Weblink (confidential).

I've worked around the issue by double clicking the field to highlight the text (I have to wait for an image, and then I know the field's relative position - I'm already kinda tied to just one resolution, so this isn't an issue for me). Unfortunately, this workaround doesn't really solve the other guy's problem with the keys.

The following code now works for me. I'm pretty sure I don't need the Legacy SK stuff (Soft Key, I assume), or possibly the WaitClipboards, but haven't got round to trying without it yet (other things to do today).

LDblClick
REM We seem to need this wait ...
Wait>1
Let>SK_LEGACY=1
WaitClipBoard
Press CTRL
Press Ins
Release CTRL
Release Ins
Let>SK_LEGACY=0
WaitClipBoard
GetClipBoard>iFoo

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts