Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Get the line number of current cursor position

by Samy_rio (Vicar)
on Sep 07, 2006 at 06:35 UTC ( [id://571616]=perlquestion: print w/replies, xml ) Need Help??

Samy_rio has asked for the wisdom of the Perl Monks concerning the following question:

Hi monks, I need to get line number of current cursor position in a file which is opened in any editor like "UltraEdit".

Another thing is I need to get the selected text in a variable. I have tried as:

use Win32::GuiTest qw(:ALL :SW); $Win32::GuiTest::debug = 0; my ($ultra) = FindWindowLike(0, "^Ultra"); print "$ultra\t", GetWindowText($ultra), "\n"; SetForegroundWindow($ultra); SendKeys("^+{HOME}"); SendKeys("^c"); my $str = SendKeys("^v"); #Selected text to be stored in $str variab +le (Not Working) print $str;

I can select the text but I can't store it in a variable. My questions are:
1. How can I get the line number of current cursor position?
2. How can I get the selected text in a variable? Please suggest me.

Thanks in advance.

Regards,
Velusamy R.


eval"print uc\"\\c$_\""for split'','j)@,/6%@0%2,`e@3!-9v2)/@|6%,53!-9@2~j';

Replies are listed 'Best First'.
Re: Get the line number of current cursor position
by ikegami (Patriarch) on Sep 07, 2006 at 06:45 UTC
    I don't think windows have a concept of lines and columns. On the other hand, GetCaretPos can get you its pixel address. It's accessible via Win32::GuiTest according to the change log in the pod. (You might also be interested in ClientToScreen.)
Re: Get the line number of current cursor position
by mreece (Friar) on Sep 07, 2006 at 06:55 UTC
    it sounds like you are getting it into the clipboard. does it paste if you press ctrl-v in an editor? if so, try Win32::Clipboard for your next step.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://571616]
Approved by ikegami
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (5)
As of 2024-04-19 12:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found