I need some help in placing the text cursor.
Here's the situation:
- Open a text file.
- Copy the text to the Clipboard.
- Use InStr to find the position of a specified text string.
- Next I need to position the text cursor (not the mouse cursor) at the beginning of the specified text string. How does one do that?
Thanks.
Steve
How to place text cursor?
-
- Posts: 9
- Joined: 08 Feb 2018, 09:46
Re: How to place text cursor?
You could do it by sending the left arrow key once while the text is still selected to un-select it and move the caret to the start of the line, then sending the right arrow key a number of times equal to the position that you retrieved with InStr.
Last edited by Osprey on 08 Feb 2018, 16:25, edited 1 time in total.
-
- Posts: 9
- Joined: 08 Feb 2018, 09:46
Re: How to place text cursor?
Thank you. I tried that and it will work. However, the text file is several thousand characters in length. Right-arrowing far into the document takes a relatively long time, not a good experience for the user to sit there and watch and wait. I was hoping there is a more direct, efficient way to place the cursor.
Re: How to place text cursor?
You could automate the Find dialog, if the text viewer supports it... something like:
That works in Notepad.
Code: Select all
Send, ^{home}^f ; Ctrl+Home moves the caret to the start of the document. Ctrl+F opens the Find dialog.
WinWait, Find
Send, Text string to find{enter}{esc}^{left} ; Enter begins the search. Esc closes the Find dialog. Ctrl+Left moves the caret to the start of the selection.
-
- Posts: 9
- Joined: 08 Feb 2018, 09:46
Re: How to place text cursor?
The text viewer does have a find function and it appears to work as expected. I will go that route.
Thank you Osprey
Thank you Osprey
Who is online
Users browsing this forum: tar and 91 guests