; 초기 커서 위치 설정
Local $iCursorPos = StringLen(ControlGetText($hActiveWindow, "", $hFocusedControl))
; 커서 이동 후 위치 추적
Func UpdateCursor($iMoveBy)
$iCursorPos += $iMoveBy
If $iCursorPos < 1 Then $iCursorPos = 1
If $iCursorPos > StringLen(ControlGetText($hActiveWindow, "", $hFocusedControl)) Then $iCursorPos = StringLen(ControlGetText($hActiveWindow, "", $hFocusedControl))
Return $iCursorPos
EndFunc
커서 위치의 문자 인식
#include <MsgBoxConstants.au3>
; 활성 창 및 컨트롤 정보 가져오기
Local $hActiveWindow = WinGetHandle("[ACTIVE]")
Local $hFocusedControl = ControlGetFocus($hActiveWindow)
; 텍스트 읽기
If $hFocusedControl <> "" Then
; 현재 컨트롤의 전체 텍스트 가져오기
Local $sText = ControlGetText($hActiveWindow, "", $hFocusedControl)
; 커서 이동 (5칸 왼쪽으로 이동)
ControlSend($hActiveWindow, "", $hFocusedControl, "{LEFT 5}")
; 내부적으로 커서가 이동한 후 문자를 읽기
Local $iCursorPos = StringLen($sText) - 5 ; 현재 커서 위치를 계산
If $iCursorPos > 0 Then
; 해당 위치의 문자 추출
Local $sChar = StringMid($sText, $iCursorPos, 1)
MsgBox($MB_ICONINFORMATION, "Character at Cursor", "Character at cursor: " & $sChar)
Else
MsgBox($MB_ICONWARNING, "Error", "Cursor is out of bounds!")
EndIf
Else
MsgBox($MB_ICONERROR, "Error", "No focused control found!")
EndIf