|
|
|||||||
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 |
||||||||
|
|
|||||||
Indeed, no selection is made. What is your goal? Maybe there are other ways to help you? |
||||||||
|
|
|||||||
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. |
||||||||
|
|
|||||||
Maybe a bug. But maybe Publius could tell what he wants so we can think of a workaround? |
||||||||
|
|
|||||||
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 |
||||||||
|
|
|||||||
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 |
||||||||
|
|
|||||||
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}") |
||||||||
|
|
|||||||
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. |
||||||||
|
|
|||||||
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 |
||||||||
|
|
|||||||
Oh well Something to get you started
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. |
||||||||
|
|
|||||||
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? |
||||||||
|
|
|||||||
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. |
||||||||
|
|
|||||||
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 |
||||||||
|
|
|||||||
Whow, a NumLock bug. Anyway, I would rely more on COM scripting, because the line Code: $ = SetFocus("Untitled - Notepad") |
||||||||
|
|
|||||||
well that was just as an example to show that it works if the numlock is off. |
||||||||
|
|
|||||||
Numlock on or off!!! Nice find. How in the world did you figure that out? |
||||||||
|
|
|||||||
My Kung-Fu is strong |
||||||||
|
|
|||||||
ahhh... so that's what you call that smell. |
||||||||
|
|
|||||||
lol |