Jump cursor to line number & column number on Notepad window?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
omareg94
Posts: 94
Joined: 27 Jun 2016, 22:46

Jump cursor to line number & column number on Notepad window?

Post by omareg94 » 26 Apr 2020, 04:29

Hello,

I know I can jump cursor to (Go to) specific line and column numbers on a Notepad window by sending multiple sequence of up/down/right/left keys to a notepad window.

Is there a more straightforward/high-performing way to achieve this (may be like send message or something) that gets me instantly there and something that's more error-free?

Odlanir
Posts: 659
Joined: 20 Oct 2016, 08:20

Re: Jump cursor to line number & column number on Notepad window?

Post by Odlanir » 26 Apr 2020, 06:03

Code: Select all

JumpInNotepad(7,3) ; row,column ( column is optional )
ExitApp

JumpInNotepad(row,col:=1) {
   ControlGetText,ovar,Edit1,ahk_class Notepad
   arr := StrSplit(ovar,  "`n" , "`r")
   char := 0
   for k, v in arr {
      if (k < row )
         char += StrLen(v) +2
   }
   ControlGet, hCtl, Hwnd,, Edit1, ahk_class Notepad
   if col > 1
      char += col-1   
   SendMessage, 0xB1, % char, % char, ,ahk_id %hctl%   
}
____________________________________________________________________________
Windows 10 Pro 64 bit - Autohotkey v1.1.30.01 64-bit Unicode

Post Reply

Return to “Ask for Help (v1)”