Jump to content

Get Scite text in Au3 - how to ?


Recommended Posts

Hi all!

I was Wondering how to get the text written in the scite...

does somebody know ?

thanks in advance

:)

Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org

Link to comment
Share on other sites

I was Wondering how to get the text written in the scite...

does somebody know ?

SciTE draws its own edit control "[CLASS:Scintilla]", which is not a standard Windows API control. Therefore the text is not directly visible to AutoIt. But, it was coded with standard shortcuts for select all, copy, and paste. So this works:
Opt("WinTitleMatchMode", 4)

; Read text from SciTE (already open)
WinWait("[CLASS:SciTEWindow; INSTANCE:1]")
$hSciTE = WinGetHandle("[CLASS:SciTEWindow; INSTANCE:1]")
WinActivate($hSciTE)
WinWaitActive($hSciTE)
ControlFocus($hSciTE, "", "[CLASS:Scintilla; INSTANCE:1]")
ControlSend($hSciTE, "", "[CLASS:Scintilla; INSTANCE:1]", "^a")
ControlSend($hSciTE, "", "[CLASS:Scintilla; INSTANCE:1]", "^c")

; Paste text to Notepad
Run("Notepad.exe")
WinWait("[TITLE:Untitled - Notepad]")
$hNotepad = WinGetHandle("[TITLE:Untitled - Notepad]")
WinActivate($hNotepad)
WinWaitActive($hNotepad)
ControlSend($hNotepad, "", "[CLASS:Edit; INSTANCE:1]", "^v")

The Scintilla Text Editor (SciTE) is an open source project, and maybe there is more elegant way to read the text using some automation interface, but the brute-force hack above gets the job done.

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

  • Developers

Just an alternative with less "hacking" :)

SendSciTE_Command("insert:text to insert at cursor replacing possible selected text.")
;
;
Func SendSciTE_Command($sCmd)
    Opt("WinSearchChildren", 1)
; Get SciTE DirectorHandle
    $SciTE_hwnd = WinGetHandle("DirectorExtension")
    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', 'SendMessage', 'HWnd', $SciTE_hwnd, _
            'Int', $WM_COPYDATA, 'HWnd', 0, _
            'Ptr', DllStructGetPtr($COPYDATA))
EndFunc  ;==>SendSciTE_Command

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

And I bet I'm the only one who noticed that he says he wants to Get the text written in SciTe :)

:)

thanks PsaltyDS & JOS!

Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org

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