Jump to content

Recommended Posts

Posted (edited)

I'm looking at a better approach for SciTE Jump when monitoring the location of the caret in relation to the list of functions. So if the caret is in the function _SomethingImportant, then it will scroll in SciTE Jump to that function.

Note: At present I use AdlibRegister with a 5 second delay to check if the caret has moved.

So does anyone know of a good approach to monitoring when the scrollbar is moved up or down. I created a quick example (upon request) of capturing/hooking the WH_MSGFILTER message, but this didn't work. Thanks.

Answered by me on 20th July 2014 >> '?do=embed' frameborder='0' data-embedContent>>

Edited by guinness

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

  • Developers
Posted (edited)

How are you retrieving the caret position/current word in SciTE?

Why do you want to change your approach?

I would probably also use an AdLib but use the SciTE Director interface. I have a demo if you want: Just run it in SciTE and navigate around to see the changes in the SciTE outputpane.

#include <WindowsConstants.au3>
Global $CurrentFile, $CurrentFilePath, $CurrentWord
Global $sCurrentFile, $sCurrentFilePath, $sCurrentWord
;SciTE Director variables
Global $SciTECmd
Global $SciTE_hwnd = WinGetHandle("DirectorExtension")
; Get My GUI Handle to be able to retrieve SciTE Director messages
Global $My_Hwnd = GUICreate("SciTE interface", 300, 600, Default, Default, Default, $WS_EX_TOPMOST)
Global $My_Dec_Hwnd = Dec(StringTrimLeft($My_Hwnd, 2))
;Register COPYDATA message.
GUIRegisterMsg($WM_COPYDATA, "MY_WM_COPYDATA")
AdlibRegister("GetSciteInfo", 300)
While 1
    Sleep(50)
WEnd
;
Func GetSciTEInfo()
    ; Get SciTE program directory
    $CurrentFilePath = StringReplace(SendSciTE_GetInfo($My_Hwnd, $SciTE_hwnd, "askproperty:FilePath"), "", "")
    $CurrentFile = SendSciTE_GetInfo($My_Hwnd, $SciTE_hwnd, "askproperty:FileName")
    $CurrentWord = SendSciTE_GetInfo($My_Hwnd, $SciTE_hwnd, "askproperty:CurrentWord")
    If $sCurrentFilePath <> $CurrentFilePath Then
        $sCurrentFilePath = $CurrentFilePath
        ConsoleWrite('$CurrentFilePath = ' & $CurrentFilePath & @CRLF)
    EndIf
    If $sCurrentFile <> $CurrentFile Then
        $sCurrentFile = $CurrentFile
        ConsoleWrite('$CurrentFile = ' & $CurrentFile & @CRLF)
    EndIf
    If $sCurrentWord <> $CurrentWord Then
        $sCurrentWord = $CurrentWord
        ConsoleWrite('$CurrentWord = ' & $CurrentWord & @CRLF)
    EndIf
EndFunc   ;==>GetSciTEInfo
;
Func MY_WM_COPYDATA($hWnd, $msg, $wParam, $lParam)
    #forceref $hWnd, $msg,  $wParam
    Local $COPYDATA = DllStructCreate('Ptr;DWord;Ptr', $lParam)
    Local $SciTECmdLen = DllStructGetData($COPYDATA, 2)
    Local $CmdStruct = DllStructCreate('Char[255]', DllStructGetData($COPYDATA, 3))
    $SciTECmd = StringLeft(DllStructGetData($CmdStruct, 1), $SciTECmdLen)
;~     ConsoleWrite('<--' & $SciTECmd & @CRLF)
EndFunc   ;==>MY_WM_COPYDATA
;
Func SendSciTE_Command($My_Hwnd, $SciTE_hwnd, $sCmd)
    Local $WM_COPYDATA = 74
    Local $CmdStruct = DllStructCreate('Char[' & StringLen($sCmd) + 1 & ']')
    DllStructSetData($CmdStruct, 1, $sCmd)
    Local $COPYDATA = DllStructCreate('Ptr;DWord;Ptr')
    DllStructSetData($COPYDATA, 1, 1)
    DllStructSetData($COPYDATA, 2, StringLen($sCmd) + 1)
    DllStructSetData($COPYDATA, 3, DllStructGetPtr($CmdStruct))
    DllCall('User32.dll', 'None', 'SendMessageA', 'HWnd', $SciTE_hwnd, _
            'Int', $WM_COPYDATA, 'HWnd', $My_Hwnd, _
            'Ptr', DllStructGetPtr($COPYDATA))
;~     ConsoleWrite('-->' & $sCmd & @CRLF)
EndFunc   ;==>SendSciTE_Command
;
Func SendSciTE_GetInfo($My_Hwnd, $SciTE_hwnd, $sCmd)
    Local $retval
    $sCmd = ":" & $My_Dec_Hwnd & ":" & $sCmd
    $SciTECmd = ""
    SendSciTE_Command($My_Hwnd, $SciTE_hwnd, $sCmd)
    ; remove initial characers from the returned string
    $retval = StringRegExp($SciTECmd, ':.*:(?i:filename:|macro:stringinfo:)(.*)', 1)
    If IsArray($retval) Then $retval = $retval[0]
    Return $retval
EndFunc   ;==>SendSciTE_GetInfo

Jos

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.
  :)

Posted

How are you retrieving the caret position/current word in SciTE?

Like this (stripped from SciTE Jump) >>

#include <WinAPI.au3>

HotKeySet('{ESC}', '_Exit')

Global Enum $__hSciTEJumpGUI, $__hSciTEHandle, $__hSciTEDirector, $__hSciTEWindow, $__hSciTEEdit, $__sSciTEData, $__iSciTEMax
Global $__vSciTEAPI[$__iSciTEMax], $__aFunctionLines = 0, $__iFunctionMonitorLine = 0

_GetHandles()

Example()

Func Example()
    Local $sReturn = FileRead(@ScriptFullPath)
    $__aFunctionLines = _FunctionToLine($sReturn)

    AdlibRegister('_SciTE_MonitorFunctionLine', 500)

    While 1
        Sleep(100)
    WEnd
EndFunc   ;==>Example

Func _Exit()
    AdlibUnRegister('_SciTE_MonitorFunctionLine')
    Exit
EndFunc   ;==>_Exit

Func _FunctionToLine(ByRef $sData) ; By UEZ.
    Local $aFunctions = 0, $aReturn = 0, $sFuncName = ''
    Local $aArray = StringSplit(StringStripCR($sData), @LF)
    Local $aFunctions[$aArray[0] + 1] = [$aArray[0]]

    For $i = 1 To $aArray[0]
        $aReturn = StringRegExp($aArray[$i], '(?ims)^s*Funcs*(.*?)(', 1)
        If @error = 0 Then
            $sFuncName = $aReturn[0]
        EndIf
        $aFunctions[$i] = $sFuncName
        If StringRegExp($aArray[$i], '(?i)s*EndFuncs*', 0) Then
            $sFuncName = ''
        EndIf
    Next
    Return $aFunctions
EndFunc   ;==>_FunctionToLine

Func _GetHandles()
    $__vSciTEAPI[$__hSciTEDirector] = WinGetHandle('DirectorExtension')
    $__vSciTEAPI[$__hSciTEWindow] = WinGetHandle('[CLASS:SciTEWindow]')
    $__vSciTEAPI[$__hSciTEEdit] = ControlGetHandle($__vSciTEAPI[$__hSciTEWindow], '', '[CLASS:Scintilla; INSTANCE:1]')
EndFunc   ;==>_GetHandles

Func _SciTE_GetCurrentPosition()
    Local Const $SCI_GETCURRENTPOS = 2008
    Return _SendMessage($__vSciTEAPI[$__hSciTEEdit], $SCI_GETCURRENTPOS)
EndFunc   ;==>_SciTE_GetCurrentPosition

Func _SciTE_GetSelectedLineNumber()
    Local Const $SCI_LINEFROMPOSITION = 2166
    Return _SendMessage($__vSciTEAPI[$__hSciTEEdit], $SCI_LINEFROMPOSITION, _SciTE_GetCurrentPosition())
EndFunc   ;==>_SciTE_GetSelectedLineNumber

Func _SciTE_MonitorFunctionLine()
    If IsArray($__aFunctionLines) Then
        Local $iLine = _SciTE_GetSelectedLineNumber() + 1
        If $iLine <= $__aFunctionLines[0] Then
            Local $sFunction = $__aFunctionLines[$iLine]
            If $sFunction <> '' And $__iFunctionMonitorLine <> $iLine Then
                $__iFunctionMonitorLine = $iLine
                ConsoleWrite('Caret is in Function: ' & $sFunction & @CRLF)
            EndIf
        EndIf
    EndIf
EndFunc   ;==>_SciTE_MonitorFunctionLine

Why do you want to change your approach?

Because I presumed there is a less 'hacky' approach to what I have now, maybe some sort of hooking approach.

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Posted (edited)

Sorry but no, because your snippet is different as mine returns the function name e.g. place the caret on line 49 would return SendSciTE_Command (using your code as an example script that is open.)

Though I have said your 'script-let' for possible use in the future.

Edited by guinness

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

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
  • Recently Browsing   0 members

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