theAutoitSpammer Posted October 14, 2009 Posted October 14, 2009 is there a function like _moveCaret($handle,"line","column") ??????? or a method to do so??
Yashied Posted October 14, 2009 Posted October 14, 2009 On 10/14/2009 at 6:42 PM, 'alram said: is there a function like _moveCaret($handle,"line","column") ??????? or a method to do so?? _GUICtrlEdit_SetSel($hEdit, $iPos, $iPos) _GUICtrlEdit_Scroll($hEdit, $SB_SCROLLCARET) My UDFs: Reveal hidden contents iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More...
theAutoitSpammer Posted October 14, 2009 Author Posted October 14, 2009 On 10/14/2009 at 7:00 PM, 'Yashied said: _GUICtrlEdit_SetSel($hEdit, $iPos, $iPos) _GUICtrlEdit_Scroll($hEdit, $SB_SCROLLCARET) Thanks for the replay but this functions do not move the caret to a line and column, they move the caret by caracter index. Any other ideas??
Yashied Posted October 14, 2009 Posted October 14, 2009 (edited) On 10/14/2009 at 8:25 PM, 'alram said: Thanks for the replay but this functions do not move the caret to a line and column, they move the caret by caracter index. Are you sure? You may use any text in the Edit control as one "string". I suggest you try it. $Line1 & @CRLF & $Line2 & @CRLF & ... Determine where the row and column it is not too difficult. EDIT: #Include <GUIConstantsEx.au3> #Include <GUIEdit.au3> #Include <ScrollBarConstants.au3> #Include <WindowsConstants.au3> $sFile = RegRead('HKLM\SOFTWARE\AutoIt v3\AutoIt', 'InstallDir') & '\include\changelog.txt' GUICreate('MyGUI', 400, 300) $hEdit = GUICtrlCreateEdit('', 2, 2, 394, 268, BitOR($ES_WANTRETURN, $WS_VSCROLL)) GUISetState() _GUICtrlEdit_SetText($hEdit, FileRead($sFile)) _GUICtrlEdit_SetSel($hEdit, 2217, 2217) _GUICtrlEdit_Scroll($hEdit, $SB_SCROLLCARET) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE Edited October 14, 2009 by Yashied My UDFs: Reveal hidden contents iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More...
theAutoitSpammer Posted October 14, 2009 Author Posted October 14, 2009 (edited) Thanks again maybe I'm not making myself clear, I want to move the caret to line 20 and column 5 for instance, on an equally spaced font. how do I translate this into a number of characters since different lines have different amount of characters?. your example adds all characters per line until it reaches 2217 then moves the caret there. What I really want is to move the caret to a specific line and a specific column in autoit editor. Any help is appreciated. Edited October 14, 2009 by alram
Yashied Posted October 15, 2009 Posted October 15, 2009 I see people very lazy. OK expandcollapse popup#Include <GUIEdit.au3> #Include <ScrollBarConstants.au3> #Include <WindowsConstants.au3> $sFile = RegRead('HKLM\SOFTWARE\AutoIt v3\AutoIt', 'InstallDir') & '\Include\ChangeLog.txt' GUICreate('MyGUI', 400, 300) $Edit = GUICtrlCreateEdit('', 10, 10, 380, 280, BitOR($ES_WANTRETURN, $WS_VSCROLL, $WS_HSCROLL)) GUISetState() _GUICtrlEdit_SetText($Edit, FileRead($sFile)) _GUICtrlEdit_SetPos($Edit, 37, 10) Do Until GUIGetMsg() = -3 ; #FUNCTION# ==================================================================================================================== ; Name...........: _GUICtrlEdit_SetPos ; Description....: Sets the caret to the specified line and column. ; Syntax.........: _GUICtrlEdit_SetPos ( $hWnd, $iLine [, $iColumn] ) ; Parameters.....: $hWnd - Handle or identifier (controlID) to the control. ; $iLine - The zero-based index of the line on which must set the caret. If this parameter is (-1), ; the caret will be set on the last line. ; $iColumn - The zero-based index of the column on which must set the caret. If this parameter is (-1), ; the caret will be set at the end of the specified line. Default is 0. ; Return values..: Success - 1. ; Failure - 0 and sets the @error flag to non-zero. ; Author.........: Yashied ; Modified.......: ; Remarks........: None ; Related........: _GUICtrlEdit_Scroll(), _GUICtrlEdit_SetSel() ; Link...........: None ; Example........: Yes ; =============================================================================================================================== Func _GUICtrlEdit_SetPos($hWnd, $iLine, $iColumn = 0) If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd) If $hWnd = 0 Then Return SetError(1, 0, 0) EndIf EndIf Local $Lenght, $Num = 0, $Count = _GUICtrlEdit_GetLineCount($hWnd) If $iLine > $Count - 1 Then $Num = _GUICtrlEdit_GetTextLen($hWnd) Else If $iLine < 0 Then $iLine = $Count - 1 EndIf For $i = 0 To $iLine - 1 $Num += _GUICtrlEdit_LineLength($hWnd, $i) + 2 ; + @CR + @LF Next $Lenght = _GUICtrlEdit_LineLength($hWnd, $iLine) If ($iColumn < 0) Or ($iColumn > $Lenght) Then $iColumn = $Lenght EndIf $Num += $iColumn EndIf _GUICtrlEdit_SetSel($hWnd, $Num, $Num) _GUICtrlEdit_Scroll($hWnd, $SB_SCROLLCARET) Return 1 EndFunc ;==>_GUICtrlEdit_SetPos My UDFs: Reveal hidden contents iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More...
theAutoitSpammer Posted October 20, 2009 Author Posted October 20, 2009 Thanks Yashied I just saw your response because I was busy trying to solve the problem and since I only need to goto line in SciTE, I came out with this (see below) It works in any resolution, zoom and window size and position (at least so far) I haven't try yours yet, but I'm almost sure it will work (not sure it will work in Scite). I really appreciate your help. By the way, you guys in Moscow need a lesson or two in English because I'm sure you meant "busy" instead of "lazy" local $Line = 20 _move_caret_SciTE($Line) Func _move_caret_SciTE($moveL) Local $L1, $L2, $Ydiff, $yMove Opt("CaretCoordMode", 2) ControlSend("[CLASS:SciTEWindow]", "", "Scintilla1", "^{home}") $L1 = WinGetCaretPos() ControlSend("[CLASS:SciTEWindow]", "", "Scintilla1", "{down}") $L2 = WinGetCaretPos() $Ydiff = ($L2[1] - $L1[1]) $yMove = ($moveL - 1) * $Ydiff Sleep(300) ControlClick("[CLASS:SciTEWindow]", "", "Scintilla1", "left", 1, $L1[0], $yMove) EndFunc ;==>_move_caret
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now