FireFox Posted February 8, 2009 Share Posted February 8, 2009 (edited) Hi, I want to know how to replace edit cursor to the saved place, for example your click on line 101 and to character 58 save both pos and change to another position then I want to replace edit cursor to the last pos for the moment I have this : $GetText = _SciTE_GetStatusBarText() ConsoleWrite($GetText[1] & '/' & $GetText[2] & @CRLF) Msgbox(64, 'test manual', 'place the cursor to line 1 and character 1') Send('{DOWN ' & $GetText[1] & '}') Send('{RIGHT ' & $GetText[2] & '}') ; #FUNCTION# ============================================================= ; Name............: _SciTE_GetStatusBarText ; Description.....: Get SciTE StatusBar text ; Return Value(s).: $text ; Author(s).......: FireFox ; Note............: None ;========================================================================= Func _SciTE_GetStatusBarText() Local $text[3] $SciTE = '[CLASS:SciTEWindow]' $s_Text = ControlGetText($SciTE, '', '[CLASS:msctls_statusbar32; INSTANCE:1]') $text[1] = StringTrimLeft(StringLeft($s_Text, StringInStr($s_Text, ' co=') - 1), 3) $text[2] = StringTrimRight(StringMid($s_Text, StringInStr($s_Text, 'co=') + StringLen('co=')), 13) Return $text EndFunc ;==>_SciTE_GetStatusBarText Cheers, FireFox. Edited February 10, 2009 by FireFox Link to comment Share on other sites More sharing options...
martin Posted February 8, 2009 Share Posted February 8, 2009 Hi, I want to know how to replace eidt cursor to the last place, for example your click on line 101 and to character 58 save both pos and change to another position then I want to replace edit cursor to the last pos for the moment I have this : $GetText = _SciTE_GetStatusBarText() ConsoleWrite($GetText[1] & '/' & $GetText[2] & @CRLF) Msgbox(64, 'test manual', 'place the cursor to line 1 and character 1') Send('{DOWN ' & $GetText[1] & '}') Send('{RIGHT ' & $GetText[2] & '}') ; #FUNCTION# ============================================================= ; Name............: _SciTE_GetStatusBarText ; Description.....: Get SciTE StatusBar text ; Return Value(s).: $text ; Author(s).......: FireFox ; Note............: None ;========================================================================= Func _SciTE_GetStatusBarText() Local $text[3] $SciTE = '[CLASS:SciTEWindow]' $s_Text = ControlGetText($SciTE, '', '[CLASS:msctls_statusbar32; INSTANCE:1]') $text[1] = StringTrimLeft(StringLeft($s_Text, StringInStr($s_Text, ' co=') - 1), 3) $text[2] = StringTrimRight(StringMid($s_Text, StringInStr($s_Text, 'co=') + StringLen('co=')), 13) Return $text EndFunc ;==>_SciTE_GetStatusBarText Cheers, FireFox. Maybe you can do it like this. Use SetSel with a starting position of -1 so that any selection is removed. Then use GetSel which gives the start and end of a selection, but since there is no selection it should give 2 identical values which are the cursor position. I haven't tried it. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
FireFox Posted February 8, 2009 Author Share Posted February 8, 2009 @martin Thanks for your reply but I dont understand this RichEdit functions Cheers, FireFox. Link to comment Share on other sites More sharing options...
martin Posted February 8, 2009 Share Posted February 8, 2009 @martin Thanks for your reply but I dont understand this RichEdit functions Cheers, FireFox. Well I didn't know you were using a rich Edit but here is an example to do what I thought you needed. expandcollapse popup#include <GuiEdit.au3> #include <GuiStatusBar.au3> #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> Global $StatusBar, $hEdit, $hGUI,$cp HotKeySet("{F10}","getcurpos") HotKeySet("{F11}","setcurback") _Main() Func _Main() Local $sFile = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\AutoIt v3\AutoIt", "InstallDir") & "\include\changelog.txt" Local $aPartRightSide[3] = [190, 378, -1], $aSel ; Create GUI $hGUI = GUICreate("Edit Get Sel", 400, 300) $hEdit = GUICtrlCreateEdit("", 2, 2, 394, 268, BitOR($ES_WANTRETURN, $WS_VSCROLL)) $StatusBar = _GUICtrlStatusBar_Create($hGUI, $aPartRightSide) _GUICtrlStatusBar_SetIcon($StatusBar, 2, 97, "shell32.dll") GUISetState() ; Set Margins _GUICtrlEdit_SetMargins($hEdit, BitOR($EC_LEFTMARGIN, $EC_RIGHTMARGIN), 10, 10) ; Set Text _GUICtrlEdit_SetText($hEdit, FileRead($sFile)) ; Set Sel _GUICtrlEdit_SetSel($hEdit, 15, 20) ; Get Sel $aSel = _GUICtrlEdit_GetSel($hEdit) _GUICtrlStatusBar_SetText($StatusBar, "Start: " & $aSel[0]) _GUICtrlStatusBar_SetText($StatusBar, "End: " & $aSel[1], 1) ; Loop until user exits Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>_Main Func getcurpos() _GUICtrlEdit_SetSel($hEdit,-1,0) $cp = _GUICtrlEdit_GetSel($hEdit) ConsoleWrite("cursor is at " & $cp[0] & ', ' & $cp[1] & @CRLF) EndFunc Func setcurback() ;either of these will set the cursor at $cp[0] _Guictrledit_setsel($hEdit,$cp[0],$cp[1]) ;or ;_GUICtrlEdit_InsertText($hEdit,"",$cp[0]) EndFunc Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
ProgAndy Posted February 8, 2009 Share Posted February 8, 2009 Hmm, do you want to set the selection in a SciTe-window? SciTe doesn't use RichEdit, but Scintilla control.(UDF: http://www.autoitscript.com/forum/index.ph...mp;hl=scintilla ) *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes Link to comment Share on other sites More sharing options...
FireFox Posted February 8, 2009 Author Share Posted February 8, 2009 @martin ops sorry, I though it was RichEdit functions because I found nothing in help file Thanks anyway ! Cheers, FireFox. Link to comment Share on other sites More sharing options...
FireFox Posted February 8, 2009 Author Share Posted February 8, 2009 @ProgAndy Thanks Cheers, FireFox. Link to comment Share on other sites More sharing options...
FireFox Posted February 8, 2009 Author Share Posted February 8, 2009 @ProgAndy How can I use Sci functions ? Local $SciTE = '[CLASS:SciTEWindow]' $Gcl = Sci_GetCurrentLine($SciTE) $Gh = Sci_GetChar($SciTE, $Gcl) ConsoleWrite($Gcl & '/' & $Gh & @CRLF) Thanks for anyhelp. Cheers, FireFox. Link to comment Share on other sites More sharing options...
ProgAndy Posted February 8, 2009 Share Posted February 8, 2009 This way: #include<scilexer/_Scilexer.au3> Local $SciTE = '[CLASS:SciTEWindow]' $HWND = ControlGetHandle($SciTE, '', '[CLASS:Scintilla; INSTANCE:1]') $Gcl = Sci_GetCurrentLine($HWND) ; current line $Glcp = SCI_GetLineStartPos($HWND, $Gcl) ; first char of line $Gh = Sci_GetChar($HWND, $Gclp) ; the ASCII code of the char ConsoleWrite($Gcl & '/' & ChrW($Gh) & @CRLF) *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes Link to comment Share on other sites More sharing options...
FireFox Posted February 8, 2009 Author Share Posted February 8, 2009 @ProgAndy Thanks, but I only get current line :S #include <scilexer/_Scilexer.au3> Local $SciTE = '[CLASS:SciTEWindow]' $HWND = ControlGetHandle($SciTE, '', '[CLASS:Scintilla; INSTANCE:1]') $Gcl = Sci_GetCurrentLine($HWND) ; current line $Gclp = SCI_GetLineStartPos($HWND, $Gcl) ; first char of line $Gh = Sci_GetChar($HWND, $Gclp) ; the ASCII code of the char ConsoleWrite($Gcl & '/' & ChrW($Gh) & @CRLF) Cheers, FireFox. Link to comment Share on other sites More sharing options...
martin Posted February 8, 2009 Share Posted February 8, 2009 (edited) @ProgAndy Thanks, but I only get current line :S #include <scilexer/_Scilexer.au3> Local $SciTE = '[CLASS:SciTEWindow]' $HWND = ControlGetHandle($SciTE, '', '[CLASS:Scintilla; INSTANCE:1]') $Gcl = Sci_GetCurrentLine($HWND) ; current line $Gclp = SCI_GetLineStartPos($HWND, $Gcl) ; first char of line $Gh = Sci_GetChar($HWND, $Gclp) ; the ASCII code of the char ConsoleWrite($Gcl & '/' & ChrW($Gh) & @CRLF) Cheers, FireFox. I don't know the _Scilexer.au3 udf, but you can get lots of information from this site. To get the current cursor position Global Const $SCI_GETCURRENTPOS=2008 $cursorpos = _SendMessage($hSci, $SCI_GETCURRENTPOS);$hSci is the handle to the edit and to set the cursor Global Const $SCI_SETCURRENTPOS=2141 _SendMessage($hSci, $SCI_SETCURRENTPOS,$cursorpos) Edited February 8, 2009 by martin Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
Authenticity Posted February 8, 2009 Share Posted February 8, 2009 expandcollapse popup#include <Constants.au3> #include <EditConstants.au3> #include <SendMessage.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> Global $Pos[2] = [0,0] Global $hUser32 = DllOpen('user32.dll') Dim $hGUI = GUICreate('Title', 400, 385) Dim $Edit = GUICtrlCreateEdit('', 0, 40, 400, 345, BitOR($ES_MULTILINE, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_WANTRETURN)) Dim $hEdit = GUICtrlGetHandle($Edit) Dim $bt1 = GUICtrlCreateButton('Button&1', 100, 10, 80, 25) Dim $bt2 = GUICtrlCreateButton('Button&2', 220, 10, 80, 25) Dim $TheFunc = DllCallbackRegister('Edit_Handler', 'ptr', 'hwnd;uint;wparam;lparam') Dim $WNDPROC = _WinAPI_GetWindowLong($hEdit, $GWL_WNDPROC) _WinAPI_SetWindowLong($hEdit, $GWL_WNDPROC, DllCallbackGetPtr($TheFunc)) GUISetState() Do Until GUIGetMsg() = -3 GUIDelete($hGUI) DllCallbackFree($TheFunc) DllClose($hUser32) Exit Func Edit_Handler($hWnd, $uMsg, $wParam, $lParam) Dim $ret Switch $uMsg Case $WM_KILLFOCUS $ret = DllCall($hUser32, 'ptr', 'SendMessage', 'hwnd', $hWnd, 'uint', $EM_GETSEL, 'ptr', 0, 'ptr', 0) If Not @error Then $Pos[0] = BitAND($ret[0], 0x0000FFFF) ;$Pos[1] = Hex($ret / 0x10000) EndIf Case $WM_SETFOCUS DllCall($hUser32, 'ptr', 'SendMessage', 'hwnd', $hWnd, 'uint', $EM_SETSEL, 'int', $Pos[0], 'int', $Pos[0]) EndSwitch Return _WinAPI_CallWindowProc($WNDPROC, $hWnd, $uMsg, $wParam, $lParam) EndFunc Subclassing the edit's message handler. I believe the concept is quite similar to external controls (non owner-drawn) Link to comment Share on other sites More sharing options...
martin Posted February 8, 2009 Share Posted February 8, 2009 expandcollapse popup#include <Constants.au3> #include <EditConstants.au3> #include <SendMessage.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> Global $Pos[2] = [0,0] Global $hUser32 = DllOpen('user32.dll') Dim $hGUI = GUICreate('Title', 400, 385) Dim $Edit = GUICtrlCreateEdit('', 0, 40, 400, 345, BitOR($ES_MULTILINE, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_WANTRETURN)) Dim $hEdit = GUICtrlGetHandle($Edit) Dim $bt1 = GUICtrlCreateButton('Button&1', 100, 10, 80, 25) Dim $bt2 = GUICtrlCreateButton('Button&2', 220, 10, 80, 25) Dim $TheFunc = DllCallbackRegister('Edit_Handler', 'ptr', 'hwnd;uint;wparam;lparam') Dim $WNDPROC = _WinAPI_GetWindowLong($hEdit, $GWL_WNDPROC) _WinAPI_SetWindowLong($hEdit, $GWL_WNDPROC, DllCallbackGetPtr($TheFunc)) GUISetState() Do Until GUIGetMsg() = -3 GUIDelete($hGUI) DllCallbackFree($TheFunc) DllClose($hUser32) Exit Func Edit_Handler($hWnd, $uMsg, $wParam, $lParam) Dim $ret Switch $uMsg Case $WM_KILLFOCUS $ret = DllCall($hUser32, 'ptr', 'SendMessage', 'hwnd', $hWnd, 'uint', $EM_GETSEL, 'ptr', 0, 'ptr', 0) If Not @error Then $Pos[0] = BitAND($ret[0], 0x0000FFFF) ;$Pos[1] = Hex($ret / 0x10000) EndIf Case $WM_SETFOCUS DllCall($hUser32, 'ptr', 'SendMessage', 'hwnd', $hWnd, 'uint', $EM_SETSEL, 'int', $Pos[0], 'int', $Pos[0]) EndSwitch Return _WinAPI_CallWindowProc($WNDPROC, $hWnd, $uMsg, $wParam, $lParam) EndFunc Subclassing the edit's message handler. I believe the concept is quite similar to external controls (non owner-drawn)That looks like similar to my reply in post #4 which was not correct because Firefox is using a Scintilla edit control, so the messages in the previous post (#11) should be the ones to use I think. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
FireFox Posted February 9, 2009 Author Share Posted February 9, 2009 @Martin & Authenticity Thank you both for your help, I will try it as I can Cheers, FireFox. Link to comment Share on other sites More sharing options...
FireFox Posted February 10, 2009 Author Share Posted February 10, 2009 @martin Thanks it works fine for place edit cursor to last position, but the problem is that highlight text between the edit cursor and the top of script ... I dont want any Mouse or Send functions because it would be unstable Thanks for anyhelp. Cheers, FireFox. Link to comment Share on other sites More sharing options...
JSThePatriot Posted February 10, 2009 Share Posted February 10, 2009 (edited) Too bad you don't want send........Send("^{END}")That'd solve your issues...Edit01: Grammatical ErrorJarvis Edited February 10, 2009 by JSThePatriot AutoIt Links File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out. ComputerGetInfo UDF's Updated! 11-23-2006 External Links Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more) Link to comment Share on other sites More sharing options...
FireFox Posted February 10, 2009 Author Share Posted February 10, 2009 @JSThePatriot I dont want send function because I want it to work very well and not failing because if at last time, another window come on top... your example isn't a solution for me because it will replace the cursor at the end...(thats what I dont want ) Cheers, FireFox. Link to comment Share on other sites More sharing options...
JSThePatriot Posted February 10, 2009 Share Posted February 10, 2009 (edited) @JSThePatriot I dont want send function because I want it to work very well and not failing because if at last time, another window come on top... your example isn't a solution for me because it will replace the cursor at the end...(thats what I dont want ) Cheers, FireFox.FireFox, I must be missing what you're trying to do...Do you or don't you want the cursor at the end of the edit box? I understand very well the significance of using Send() in relation to windows and such, but you could also do ControlSend (no need to worry about windows). ControlSend("Title or Handle", "", "Scintilla1", "^{END}") Now if you're not wanting to move the cursor to the end of the edit control then I have completely misread what you're trying to do, and if you supply me another or different explanation, then I will proceed to helping you in that direction. Thanks, Jarvis Edited February 10, 2009 by JSThePatriot AutoIt Links File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out. ComputerGetInfo UDF's Updated! 11-23-2006 External Links Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more) Link to comment Share on other sites More sharing options...
Authenticity Posted February 10, 2009 Share Posted February 10, 2009 I believe that he wants sort of behavior like when tabbing around and the "edit" control is losing the focus, if you'll tab in again to set the focus to the edit the caret will be in the same spot it was the last time the "edit" lost it's focus. The problem is not with the tab though because it'll automatically set the caret to this position but I believe it's when mouse clicking the control, it'll automatically move the caret to the most logical spot in the control the mouse is clicking on... Link to comment Share on other sites More sharing options...
martin Posted February 10, 2009 Share Posted February 10, 2009 (edited) @martin Thanks it works fine for place edit cursor to last position, but the problem is that highlight text between the edit cursor and the top of script ... I dont want any Mouse or Send functions because it would be unstable Thanks for anyhelp. Cheers, FireFox.@JsThePatriot. I think you've misunderstood what Firefox wants to do. He wants to set the cursor position to a given place and not have any selected text. He doessn't want the cursor at the end of the text. @FireFox The answer is (Not that I've tried it again) on the page I gave a link to. First set the anchor positoin to the new cursor position, then set the cursor position and you shouldn't have any selected text. Global Const $SCI_SETANCHOR=2026 Global Const $SCI_SETCURRENTPOS=2141 _SendMessage($hSci,$SCI_SETANCHOR, $cursorpos) _SendMessage($hSci, $SCI_SETCURRENTPOS,$cursorpos) Please have a good look at the link I gave you because it gives all this information. You can get all the constant definitions needed for the scintilla edit from the file scintilla.h.au3 from here. Edited February 10, 2009 by martin Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
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