Jump to content

How to scroll Scite editor window to a specific line using au3


2Tricky
 Share

Recommended Posts

I searched high and low and can't quite figure out how using au3 code to tell Scite to scroll to a particular code line number as the 'code' is itself running.

I'm only interested in giving the command to 'goto' line 'n' immediately prior to a msgbox() function, otherwise the window would look demented of course.

I've tried to understand how Lua could help and though I can write Lua scripts that will 'operate' on a editors contents etc, it is the act of giving instructions to Scite from Autoit that eludes me (I've seen dll's talked about but wonder whether this route is necessary in 'todays' Scite - mine is the latest on this site {part of the Autoit package} though it says 1.79 in 'About' which is odd).

If anyone can help I'd be grateful or for any suggestions as to further reading or detailed tutorials other than the rather 'dry' guides that don't seem to break the ice.

Thanks a lot.

Link to comment
Share on other sites

  • Developers

Don't understand what you are looking for that isn't there yet.

Doesn't Ctrl+G do the job for you?

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

#include <WinAPI.au3>
Opt("MustDeclareVars", 1)
;look for scintilla.h.au3 for more constants
Global Const $SCI_GOTOLINE = 2024
Global $iLine = 10
Global $hSciWin = _GetScintillaEdit(1);get editor or console
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $hSciWin = ' & $hSciWin & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
_SendMessage($hSciWin, $SCI_GOTOLINE, $iLine-1, 0)
MsgBox(0,"Goto Line", "Line: " & $iLine)
Exit

Func _GetScintillaEdit($iMode = 2) ;SciTE editor/console
;rover 2k11, thanks to Jos for the SciTE automation code
;$iMode = 1: get Editor
;$iMode = 2: get Console
If Int($iMode) <> 1 And Int($iMode) <> 2 Then Return SetError(1, 0, -1)
;check for multiple instances of scite and get handle
Local $aList = WinList('[CLASS:SciTEWindow]')
If @error Or $aList[0][0] = 0 Or $aList[0][0] > 1 Or IsHWnd($aList[1][1]) = 0 Then Return SetError(1, 0, -1)
If _WinAPI_GetClassName($aList[1][1]) <> "SciTEWindow" Then Return SetError(2, 0, -1)
;prevent posting text accidentally to the wrong window or into script in Scintilla1
Local $hSciCon2 = ControlGetHandle($aList[1][1], '', '[CLASS:Scintilla; INSTANCE:' & String($iMode) & ']')
;verify returned handle is Scintilla window instance 1 or 2 with control ID 350 or 351
Local $sClass = _WinAPI_GetClassName($hSciCon2)
Local $iCtrlID = _WinAPI_GetDlgCtrlID($hSciCon2)
Switch $iMode
  Case 1
   If $sClass == "Scintilla" And $iCtrlID = 350 Then Return SetError(0, 0, $hSciCon2)
  Case 2
   If $sClass == "Scintilla" And $iCtrlID = 351 Then Return SetError(0, 0, $hSciCon2)
  Case Else
   Return SetError(3, 0, -1)
EndSwitch
Return SetError(4, 0, -1)
EndFunc   ;==>_GetScintillaConsole

I see fascists...

Link to comment
Share on other sites

  • Developers

Granted but it's more work requiring Ctrl-G, Line number, Column number...at every Msgbox of which I have plenty - in my more experimentation scripts!

So, what it is exactly you want to do? Be able to scroll to all lines containing an MsgBox statement?

If so you can use Ctrl+F (Find) and click the MarkAll button and Hit F2 to jump from Bookmark to Bookmark.

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

So, what it is exactly you want to do? Be able to scroll to all lines containing an MsgBox statement?

If so you can use Ctrl+F (Find) and click the MarkAll button and Hit F2 to jump from Bookmark to Bookmark.

The OP wants to jump to the MsgBox() line in the script in SciTE as the code is running in SciTE,

pretty obvious from the reading.

The response I posted uses code from you...

Now two people or more can ignore my responses

Edited by rover

I see fascists...

Link to comment
Share on other sites

#include <WinAPI.au3>
Opt("MustDeclareVars", 1)
;look for scintilla.h.au3 for more constants
Global Const $SCI_GOTOLINE = 2024
Global $iLine = 10
Global $hSciWin = _GetScintillaEdit(1);get editor or console
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $hSciWin = ' & $hSciWin & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
_SendMessage($hSciWin, $SCI_GOTOLINE, $iLine-1, 0)
MsgBox(0,"Goto Line", "Line: " & $iLine)
Exit

Func _GetScintillaEdit($iMode = 2) ;SciTE editor/console
;rover 2k11, thanks to Jos for the SciTE automation code
;$iMode = 1: get Editor
;$iMode = 2: get Console
If Int($iMode) <> 1 And Int($iMode) <> 2 Then Return SetError(1, 0, -1)
;check for multiple instances of scite and get handle
Local $aList = WinList('[CLASS:SciTEWindow]')
If @error Or $aList[0][0] = 0 Or $aList[0][0] > 1 Or IsHWnd($aList[1][1]) = 0 Then Return SetError(1, 0, -1)
If _WinAPI_GetClassName($aList[1][1]) <> "SciTEWindow" Then Return SetError(2, 0, -1)
;prevent posting text accidentally to the wrong window or into script in Scintilla1
Local $hSciCon2 = ControlGetHandle($aList[1][1], '', '[CLASS:Scintilla; INSTANCE:' & String($iMode) & ']')
;verify returned handle is Scintilla window instance 1 or 2 with control ID 350 or 351
Local $sClass = _WinAPI_GetClassName($hSciCon2)
Local $iCtrlID = _WinAPI_GetDlgCtrlID($hSciCon2)
Switch $iMode
  Case 1
   If $sClass == "Scintilla" And $iCtrlID = 350 Then Return SetError(0, 0, $hSciCon2)
  Case 2
   If $sClass == "Scintilla" And $iCtrlID = 351 Then Return SetError(0, 0, $hSciCon2)
  Case Else
   Return SetError(3, 0, -1)
EndSwitch
Return SetError(4, 0, -1)
EndFunc   ;==>_GetScintillaConsole

Brilliant - it's that underscore that thwarted all my searches I think.

Cheers!

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...