Page 1 of 1 1
Topic Options
#174762 - 2007-03-19 10:56 PM SendKeys for Shift not working
Publius Offline
Lurker

Registered: 2007-03-19
Posts: 3
we are calling SendKeys("^+{END}" to select from the cursor to end of file and the cursor goes to end of file without selecting (Behaves as pressing CTRL+END)
When we use SendKeys("+{END}" the cursor goes to the end of line without selecting (Behaves as pressing END)

Any help is appreciated

Top
#174766 - 2007-03-19 11:57 PM Re: SendKeys for Shift not working [Re: Publius]
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
Indeed, no selection is made.
What is your goal? Maybe there are other ways to help you?

Top
#174768 - 2007-03-20 02:45 AM Re: SendKeys for Shift not working [Re: Witto]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4545
Loc: USA
Looks like this has been around a while... verified on @kix 4.22 and 4.53
shift + end doesnt work
shift + home doesn't work either.

Ctrl + Shift + Esc does work.

Smells like a bug.

Top
#174770 - 2007-03-20 07:26 AM Re: SendKeys for Shift not working [Re: Allen]
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
Maybe a bug.
But maybe Publius could tell what he wants so we can think of a workaround?

Top
#174780 - 2007-03-20 02:17 PM Re: SendKeys for Shift not working [Re: Witto]
Publius Offline
Lurker

Registered: 2007-03-19
Posts: 3
I have a word document that has the first part in english and second half is french , and where the french start I have a text "FRENCH STARTS HERE".

So I want to search for the text and then select the text to the end to create a new file with the french text ,and select the top part to create a english doc.

What I am doing now is search for the text and then I want to do Ctrl+Shift+End to select everything to the end of file and copy to clipbooard.


Thank you all for the help

Top
#174784 - 2007-03-20 05:00 PM Re: SendKeys for Shift not working [Re: Publius]
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
You might try making two array's

 Code:
$Text = ReadLine(1)
$Counter = 0
DO 
  ReDim Preserve $Array1[$Counter]
  $Array1[$counter] = $Text
  $Text = Readline(1)
  $Counter = $Counter + 1
Until $Text = "FRENCH STARTS HERE"

$Text = ReadLine(1)
$Counter = 0
Do
  ReDim Preserve $Array2[$Counter]
  $Array2[$Counter] = $Text
  $Counter = $Counter + 1
  $Text = Readline(1)
Until @Error = 0

_________________________
Today is the tomorrow you worried about yesterday.

Top
#174785 - 2007-03-20 05:01 PM Re: SendKeys for Shift not working [Re: Allen]
BillBarnard Offline
Starting to like KiXtart

Registered: 2007-03-14
Posts: 141
Loc: Leighton Buzzard, Bedfordshire...
The following code works for me:-

break on

Run "C:\Windows\Notepad"

Sleep 3

If SetFocus("Untitled - Notepad") <> 0

"Error SetFocus to Notepad" ?
Exit 2

Endif

$ = SendKeys("The cat sat on the mat{ENTER}")
$ = SendKeys("{UP}")
$ = SendKeys("+{END}")
_________________________
Bill

Top
#174788 - 2007-03-20 06:41 PM Re: SendKeys for Shift not working [Re: BillBarnard]
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
Dear BillBarnard,
I tried your code with kix32.exe v4.53 and nothing was selected. Could you tell wich executable and version you are using?

Dear Publius,
IIWY, I would try COM scripting and work with a Word object.
I have too less time to try something.
Part of the code I would write, I would try to get from the macro wizard in Word.

Top
#174793 - 2007-03-20 09:25 PM Re: SendKeys for Shift not working [Re: Witto]
Publius Offline
Lurker

Registered: 2007-03-19
Posts: 3
Thank you all for all your help
I will use a combination of the code from Gargoyle and the suggestion from Witto.

Thank you again

Top
#174797 - 2007-03-21 12:02 AM Re: SendKeys for Shift not working [Re: Publius]
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
Oh well
Something to get you started
;*************************************************************************
; Script Name:
; Author: Publius
; Date: 20/03/2007
; Description: Find "FRENCH STARTS HERE"
;************************************************************************* 


;Script Opions
If
NOT @LOGONMODE
    Break On
Else
    Break Off
EndIf
Dim $RC
$RC = SetOption("Explicit", "On")
$RC = SetOption("NoMacrosInStrings", "On")
$RC = SetOption("NoVarsInStrings", "On")
$RC = SetOption("WrapAtEOL", "On")

;Declare variables
Dim
$objWord
, $strWordFile, $strFind
$strWordFile = "\\Server\Share\Deeper\YourFile.doc"
$strFind = "FRENCH STARTS HERE"

;Create Word object
$objWord
= CreateObject("Word.Application")
If @ERROR
    ? "Error creating Word object"
    ? "Error " + @ERROR + ": " + @SERROR
    Quit @ERROR
EndIf

;Open Word document
;Maybe you can do everything invisible and comment the next line

$objWord.Visible = 1
$RC = $objWord.Documents.Open($strWordFile)
$objWord.Selection.Find.Text = $strFind
$RC = $objWord.Selection.Find.Execute

; Other stuff
; Complete your script


;Do not forget to close word if working invisible
$RC
=
$objWord.Application.Quit

The File/Open and the Find are easy to recreate if you just play a while with your macro recorder in Word. Just give it a try.

Top
#174802 - 2007-03-21 01:13 AM Re: SendKeys for Shift not working [Re: Witto]
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
About the select that is not working with SendKeys.
Can this be considered as a bug or as a hidden feature? Wouldn't it be better to see it more work as expected? Should it be posted in the Beta forum?

Top
#174815 - 2007-03-21 11:26 AM Re: SendKeys for Shift not working [Re: Witto]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
I'm not sure that this is a bug. From a quick test I just did, there is no "Shifted" equivalent of the Insert/Delete/Home/End/Page Up/Page Down keys. Holding Ctrl+End does generate a different code.

If this is the case then you cannot possibly send a Shift-End key combination.

My guess is that the application receives an "End" key, then checks the state of the keyboard to see if the shift key is being pressed *at the same time*. You cannot emulate this by using SendKeys(), which is just forcing keypresses into the keyboard buffer.

You might get around this with a tool like AutoIT which has a "{SHIFTDOWN}", but even with this you would probably need to wait until the application is ready, send the shift-down, send the "End" key and wait for it to be actioned. Then you can send the shift-up.

Top
#174820 - 2007-03-21 02:26 PM Re: SendKeys for Shift not working [Re: Richard H.]
Benny69 Offline
Moderator
*****

Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
Richard prolly just forgot about this but there is a solution with KiX, all you have to do is turn the numlock off and the shift+end ("+{END}) will work.
in this example i am using Word to determain if the numlock is on:
 Code:
$WordShell = CreateObject("Word.Application")
$NumLock = $WordShell.NumLock

Run "notepad.exe"

$ = SetFocus("Untitled - Notepad")
Sleep 1
$Key = SendKeys("abcdefg")
Sleep 1
$Key = SendKeys("{ENTER}")
Sleep 1
$Key = SendKeys("{UP}")
Sleep 1

If $NumLock = -1
	$Key = SendKeys("{NUMLOCK}")
	Sleep 1
	$Key = SendKeys("+{END}")
	Sleep 1
	$Key = SendKeys("{NUMLOCK}")
	Sleep 1
Else
	$Key = SendKeys("+{END}")
	Sleep 1
EndIf
_________________________
Wait don't order yet,... get KiXforms Designer .NET 2.0 (Beta)
KiXforms Designer .NET 2.0 (Beta)

Top
#174828 - 2007-03-21 05:20 PM Re: SendKeys for Shift not working [Re: Benny69]
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
Whow, a NumLock bug.
Anyway, I would rely more on COM scripting, because the line
 Code:
$ = SetFocus("Untitled - Notepad")
is depending on the language of the operating system

Top
#174829 - 2007-03-21 05:21 PM Re: SendKeys for Shift not working [Re: Witto]
Benny69 Offline
Moderator
*****

Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
well that was just as an example to show that it works if the numlock is off.


Edited by Benny69 (2007-03-21 05:23 PM)
_________________________
Wait don't order yet,... get KiXforms Designer .NET 2.0 (Beta)
KiXforms Designer .NET 2.0 (Beta)

Top
#174833 - 2007-03-21 06:19 PM Re: SendKeys for Shift not working [Re: Benny69]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4545
Loc: USA
Numlock on or off!!! Nice find. How in the world did you figure that out?
Top
#174835 - 2007-03-21 07:32 PM Re: SendKeys for Shift not working [Re: Allen]
Benny69 Offline
Moderator
*****

Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
My Kung-Fu is strong ;\)
_________________________
Wait don't order yet,... get KiXforms Designer .NET 2.0 (Beta)
KiXforms Designer .NET 2.0 (Beta)

Top
#174840 - 2007-03-21 09:02 PM Re: SendKeys for Shift not working [Re: Benny69]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4545
Loc: USA
ahhh... so that's what you call that smell. ;\)
Top
#174843 - 2007-03-21 11:57 PM Re: SendKeys for Shift not working [Re: Allen]
Benny69 Offline
Moderator
*****

Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
lol
_________________________
Wait don't order yet,... get KiXforms Designer .NET 2.0 (Beta)
KiXforms Designer .NET 2.0 (Beta)

Top
Page 1 of 1 1


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 515 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.077 seconds in which 0.028 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org