다른 명령
새 문서: <source lang=autoit> ; 초기 커서 위치 설정 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 </source> [... |
편집 요약 없음 |
||
| 12번째 줄: | 12번째 줄: | ||
EndFunc | EndFunc | ||
</source> | |||
== 커서 위치의 문자 인식 == | |||
<source lang=autoit> | |||
#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 | |||
</source> | </source> | ||
[[category:autoit]] | [[category:autoit]] | ||
2024년 11월 29일 (금) 08:40 기준 최신판
; 초기 커서 위치 설정
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