Uten Posted January 9, 2007 Share Posted January 9, 2007 (edited) EDIT: Inspired by this work @lokster has made a more elaborate sample and converted more scintilla functionality to a UDF.EDIT2: @RazerM has extended upon @lokster's version and created another one which looks niceJust a simple demonstration of using the scintilla component in AutoIt (v3.2.2.0).expandcollapse popup; FILENAME au3Scite.au3 ; PURPOSE: Samml demonstartion of embeding the scintilla control in AutoIt ; CREATED BY: @Uten at www.autoitscript.com/forum ; NOTE: The SciLexer.dll must be in the PATH. I have it in the same folder as ; this script file. You can get the SciLexer.dll from scintilla.sourceforge.net ; or from the SciTE4AutoIt3 installation or zip file at ; www.autoitscript.com ; ; RESOURCE: http://scintilla.sourceforge.net/ScintillaDoc.html ; RESOURCE: http://www.riverbankcomputing.com/Docs/QScintilla1/classQextScintillaBase.html ; ;The primary comunication form on windows is through SendMessage. ;But there are a description on how to get a direct function pointer to. ;This direct methode is suposed to be faster ; #include <GuiConstants.au3> ;The SCI_* Values are found at classQextScintillaBase.html in the resource list Global Const $SCI_START = 2000 Global Const $SCI_ADDTEXT = $SCI_START + 1 Global Const $SCI_APPENDTEXT = $SCI_START + 282 Global Const $SCI_INSERTTEXT = $SCI_START + 3 Global Const $SCI_CLEARALL = $SCI_START + 4 Global Const $SCI_SETSELBACK = $SCI_START + 68 ; Generic error handler for DllCall Func errDllCall($err, $ext, $erl=@ScriptLineNumber) Local $ret = 0 If $err <> 0 Then ConsoleWrite("(" & $erl & ") := @error:=" & $err & ", @extended:=" & $ext & @LF) $ret = 1 EndIf Return $ret EndFunc ; API Wraper function Func CreateWindowEx($dwExStyle, $lpClassName, $lpWindowName="", $dwStyle=-1, $x=0, $y=0, $nWidth=0, $nHeight=0, $hwndParent=0, $hMenu=0, $hInstance=0, $lParm=0 ) Local $ret If $hInstance=0 Then ;TODO: Do we need to provide the instance handle? $ret = DLLCall( "user32.dll","long","GetWindowLong","hwnd",$hwndParent,"int",-6); $GWL_HINSTANCE=-6 $hInstance = $ret[0] EndIf $ret = DllCall("user32.dll", "hwnd", "CreateWindowEx", "long", $dwExStyle, _ "str", $lpClassName, "str", $lpWindowName, _ "long", $dwStyle, "int", $x, "int", $y, "int", $nWidth, "int", $nHeight, _ "hwnd", $hwndParent, "hwnd", $hMenu, "long", $hInstance, "ptr", $lParm) If errDllCall(@error, @extended) Then Exit Return $ret[0] EndFunc ; API Wraper function Func LoadLibrary($lpFileName) Local $ret $ret = DllCall("kernel32.dll", "int", "LoadLibrary", "str", $lpFileName) If errDllCall(@error, @extended) Then Exit Return $ret[0] EndFunc ; API Wraper function Func SendMessage($hwnd, $msg, $wp, $lp) Local $ret $ret = DllCall("user32.dll", "long", "SendMessageA", "long", $hwnd, "long", $msg, "long", $wp, "long", $lp) Return $ret[0] EndFunc ; API Wraper function Func SendMessageString($hwnd, $msg, $wp, $str) Local $ret ; TODO: VB Any translated to ptr ??? $ret = DllCall("user32.dll", "long", "SendMessageA", "long", $hwnd, "long", $msg, "long", $wp, "str", $str) Return $ret[0] EndFunc ; API Wraper function Func SetWindowPos($hwnd, $style, $left, $top, $width, $height, $flags) ;TODO: Verify implementation. Local $ret $ret = DllCall("user32.dll", "long", "SetWindowPos", "long", $hwnd, "long", $style, _ "long", $left, "long", $top, "long", $width, "long", $height, _ "long", $flags) If errDllCall(@error, @extended) Then Exit Return $ret[0] EndFunc Func Main() Local $GWL_HINSTANCE = -6 Local $sci Local $gui = GUICreate("MyScite", 600, 600, 10, 10) Local $hLib = LoadLibrary("SciLexer.DLL") Local $hInstance = 0 $sci = CreateWindowEx($WS_EX_CLIENTEDGE, "Scintilla", _ "TEST", BitOR($WS_CHILD, $WS_VISIBLE), 100, 100, 200, 200, _ $gui, 0, $hInstance, 0) SetWindowPos($sci, 0, 5, 5, 600 - 10, 600 - 100, 0) GUISetState(@SW_SHOW) Local $btn1 = GUICtrlCreateButton("Add", 0, 550) Local $btn2 = GUICtrlCreateButton("Append", 80, 550) GUISetState(@SW_SHOW) Sleep(1000) SciAddText($sci, "Hello I'm Scintilla..:)" & @CRLF) Sleep(1000) SciAppendText($sci, "And I'm getting hungry" & @CRLF) ;Sleep(1000) ;SciClearAll($sci) While 1 $msg = GUIGetMsg() Switch $msg Case 0 Sleep(100) Case $btn1 SciAddText($sci, "Hello I'm Scintilla..:)" & @CRLF) Case $btn2 SciAppendText($sci, "I'm getting hungry" & @CRLF) Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd EndFunc ;==>Main Func SciAddText($hwnd, $text) SendMessageString( $hwnd, $SCI_ADDTEXT, StringLen($text), $text) EndFunc Func SciAppendText($hwnd, $text) SendMessageString( $hwnd, $SCI_APPENDTEXT, StringLen($text), $text) EndFunc Func SciClearAll($hwnd) SendMessageString( $hwnd, $SCI_CLEARALL, 0, 0) EndFunc ;Run application Main() Exit Edited February 2, 2007 by Uten argumentum 1 Please keep your sig. small! Use the help file. Search the forum. Then ask unresolved questions :) Script plugin demo, Simple Trace udf, TrayMenuEx udf, IOChatter demo, freebasic multithreaded dll sample, PostMessage, Aspell, Code profiling Link to comment Share on other sites More sharing options...
WeMartiansAreFriendly Posted January 9, 2007 Share Posted January 9, 2007 hey that is awesome Don't bother, It's inside your monitor!------GUISetOnEvent should behave more like HotKeySet() Link to comment Share on other sites More sharing options...
RichardGatinho Posted January 14, 2007 Share Posted January 14, 2007 Nothing: Link to comment Share on other sites More sharing options...
RazerM Posted January 14, 2007 Share Posted January 14, 2007 You need the SciLexer.dll. You can find it in your SciTE folder. Good example Uten. My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop. Link to comment Share on other sites More sharing options...
Uten Posted January 14, 2007 Author Share Posted January 14, 2007 Nothing:Please remove the picture as it is annoyingly disturbing without providing anything. It would be much better if you provided some information about your system. Version of AutoIt. Where SciLexer.dll is located and stuff like that.@RazerM: Thanks for your kind words. Don't know if it is so good. But it is a start. Maybe I (or someone else) will add more functionality one day... Please keep your sig. small! Use the help file. Search the forum. Then ask unresolved questions :) Script plugin demo, Simple Trace udf, TrayMenuEx udf, IOChatter demo, freebasic multithreaded dll sample, PostMessage, Aspell, Code profiling Link to comment Share on other sites More sharing options...
GEOSoft Posted January 14, 2007 Share Posted January 14, 2007 Good work Uten George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
RichardGatinho Posted January 29, 2007 Share Posted January 29, 2007 No, no, no, no... api/ au3.api au3.keywords.properties SciTE.exe Link to comment Share on other sites More sharing options...
lokster Posted January 30, 2007 Share Posted January 30, 2007 How can I get the text of the Scintilla control, so it can be saved to a file? Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted January 30, 2007 Moderators Share Posted January 30, 2007 (edited) How can I get the text of the Scintilla control, so it can be saved to a file?Gary (gafrost) wrote CSnippet.exe that is in the current release of SciTe. He's provided the source and he has how he does it (_Scite...something) in there.it's in the:....AutoIt3\SciTE\Snippet folder. Edited January 30, 2007 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Uten Posted January 30, 2007 Author Share Posted January 30, 2007 @lokster,Sorry, I have not had time to work anymore with this component. But as fare as I can see form samples on the net you have to use SCI_GETTEXTLENGTH or SCI_GETLENGTH and then SCI_GETTEXT. You find the API in the scintilla docs And finally save the text returned by SCI_GETTEXT. There is also the SCI_SETSAVEPOINT call to notify scintilla that the text has been saved so it can do some maintenance and clear dirty flags. Please keep your sig. small! Use the help file. Search the forum. Then ask unresolved questions :) Script plugin demo, Simple Trace udf, TrayMenuEx udf, IOChatter demo, freebasic multithreaded dll sample, PostMessage, Aspell, Code profiling Link to comment Share on other sites More sharing options...
lokster Posted January 30, 2007 Share Posted January 30, 2007 (edited) @Uten I used your example to create more complete Scintilla+AutoIt script Look at this topic: More complete example of using Scintilla in AutoIt 10x for the help Edited January 30, 2007 by lokster 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