I went through the script again to find any mistakes, I also changed it a bit here and there to be able to test it better, but couldn't find anything what could be the cause of your problem.
It works for me, please test it again and maybe another forum user would be kind enough to test it and say whether it works or not.
Code: Select all
#Requires Autohotkey v2.0
#SingleInstance
Loop Lines := 1000
Message .= A_Index (A_Index < Lines ? "`n" : "")
MaxLines := 25
Border := 2 ; Edit border, probably 2 pixels
DPIScale := 96/A_ScreenDPI ; if you use -DPIScale change this to DPIScale := 1
;DPIScale := 1
MyGui := Gui("-Caption", "MyGui")
MyGui.BackColor := 0x333333
MyGui.SetFont("s16 cWhite", "Georgia")
MyGui.AddEdit("r" MaxLines " ReadOnly w600 Wrap Background333333 vEdit", Message)
MyGui["Edit"].GetPos(&Xe, &Ye, &We, &He)
MyGui.OnEvent("Escape", (*)=>ExitApp())
MyGui.Show("AutoSize Center")
OnMessage(0x0200, WM_MOUSEMOVE)
WM_MOUSEMOVE(*) {
static ClassNN := MyGui["Edit"].ClassNN
, Hwnd := "ahk_id" MyGui.Hwnd
if WinActive(Hwnd) {
;CoordMode "Mouse", "Client" ; CoordMode must be client. If you don't use CoordMode somewhere else in the script, this line can be omitted.
MouseGetPos(&Xm, &Ym, &Wm, &Hm)
if Ym >= (YE-Border+He)/DPIScale ; Cursor below the edit field
LineNumber := 0
else
LineNumber := Round(((Ym-Ye+Border+He/(MaxLines*2))/He*MaxLines)*DPIScale) + ThumbPos(ClassNN, Hwnd)
}
else
LineNumber := -1
ToolTip LineNumber
Sleep 100
ThumbPos(Control, WinTitle) {
static SIF_POS := 0x04
, SB_VERT := 0x1
, Hwnd := ControlGetHwnd(Control, WinTitle)
, ScrollInfo := Buffer(28)
, N := NumPut("UInt", ScrollInfo.Size, ScrollInfo, 0)
, N := NumPut("UInt", SIF_POS, ScrollInfo, 4)
DllCall("GetScrollInfo", "Ptr", Hwnd, "Int", SB_VERT, "Ptr", ScrollInfo)
return NumGet(ScrollInfo, 20, "Int")
}
}