Sign in to follow this  
Followers 0
jennico

StringRegExp and whitespace

23 posts in this topic

hi there,

i am using StringRegExpGUI.au3 from helpfile.

StringRegExp(testscript,pattern,3)oÝ÷ Úl­zËlr¸©¶+]¡ë'¢Ùæ§Êǧ±æ®¶­sb4WFôC5w&W%õW6Tç6× ¤÷BgV÷C´×W7DFV6Æ&Uf'2gV÷C²Â ¢6æ6ÇVFRfÇC´Ö62æS2fwC°¢6æ6ÇVFRgV÷C´wV&6VFBæS2gV÷C°  ¥tÕôäõDeôWfVçG2b33c¶væDuTÂb33c´×6tBÂb33c·u&ÒÂb33c¶Å&Ò ¤gVæ2ôÖâ Æö6Âb33c¶×6rÂb33c¶wVÂb33c¶'WGFöà  b33c¶wVÒuT7&VFRgV÷Cµ&6VFBW×ÆRgV÷C²ÂSÂSSÂÓÂÓÂ&Dõ"b33cµu5ôÔäÔ¤T$õÂb33cµu5ô4DôâÂb33cµu5õõUÂb33cµu5õ54ÔTåRÂb33cµu5õ4¤T$õ  b33c¶õ&6VFBÒôuT7G&Å&6VFD7&VFRb33c¶wVÂÂÂCÂC#Â&Dõ"b33c´U5õtåE$UEU$âÂb33cµu5ô45$ôÄÂÂb33c´U5õ5Tä´TâÂb33c´U5ôÕTÅDÄäRÂb33cµu5õe45$ôÄÂÂb33c´U5ôUDõe45$ôÄ  b33c¶'WGFöâÒuT7G&Ä7&VFT'WGFöâgV÷C´WBgV÷C²ÂÂCcÂÂ#R  uT&Vv7FW$×6rb33cµtÕôäõDeÂgV÷CµtÕôäõDeôWfVçG2gV÷C² vÆR b33c¶×6rÒuTvWD×6r  6VÆV7@  66Rb33c¶×6rÒb33c´uTôUdTåEô4Äõ4R÷"b33c¶×6rÒb33c¶'WGFöà  VæE6VÆV7@ tVæ@¤VæDgVæ2³ÓÒfwCµôÖà ¤gVæ2tÕôäõDeôWfVçG2b33c¶væDuTÂb33c´×6tBÂb33c·u&ÒÂb33c¶Å&Ò b&DäBb33c¶VåöÆæµö×6rÂb33cµtÕôÄ%UEDôäDõtâÒb33cµtÕôÄ%UEDôäDõtâFVà¤VæDgVæ2³ÓÒfwCµtÕôäõDeôWfVçG0oÝ÷ Ú,ÛhëZªëk,"¶¥Ø^¡Ç.®·§që(~Ø^~éܶ*'ªê-Âiè¶'òz÷§¶Ê®¢Û(¯zÚwZW±¦·¬²*'²ØZ¶f­razv¦{ꮢڮ¢ÓßÚ®¢Ýý~àº+¶Þ½éí²ayÊ+­ç-¥«mz¹â±«­¢+Ø ý¤¥Ýµ}¹½Ñ¥å}Ù¹ÑÍlÀäÈì ÀäÈìÅÕ½ÐítoÝ÷ Ù»­mëpÁéߺw-çjgÚ®¢Ú®¢×·²y©ÝËbXZ½ëh~)ݶ¬~éܶ*'{kzË"¢vî·ZµëÞ®'h«yëÞ®(§±êí¶±º.¦('¢·°+^²y«­¢+Ø ý¤¥]µ}¹½Ñ¥å}Ù¹ÑÌ ýà¥lÀäÈì ÀäÈìÅÕ½ÐíoÝ÷ Ù«­¢+Ø ý¤¤ ýà¥]µ}¹½Ñ¥å}Ù¹ÑÍlÀäÈì ÀäÈìÅÕ½ÐíoÝ÷ Ú(¶Ø^±©­ë.Ö¬mçè­éèµø§v)ඨqË«­éÜy«­¢+Ù]5}9=Q%e}Ù¹ÑÌ ÀÌØí¡]¹U$°ÀÌØí5Í%°ÀÌØíÝAÉ´°ÀÌØí±AÉ´¤

why and what can i do instead ?

j.


Spoiler

I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.OixB7.jpgDon't forget this IP: 213.251.145.96

 

Share this post


Link to post
Share on other sites



rereading my post, i have to explain why i need the "(" or '"' at the end:

i want to filter out functions that might use the same name, but with more letters, like:

"WM_NOTIFY_Events_Ex ( $hWndGUI, $MsgID, $wParam, $lParam)"

this should not be found.

j.


Spoiler

I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.OixB7.jpgDon't forget this IP: 213.251.145.96

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

(?i)\Wwm_notify_events\s*\(

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

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Use \h*? for possibly existing horizontal whitespace muttley

#include <Array.au3>

$string = 'GUISetOnEvent(123,"WM_Notify_events") '&@CRLF&' WM_NOTIFY_Events ( $hWndGUI, $MsgID, $wParam, $lParam)'

$r = StringRegExp($string,'(?i)\Wwm_notify_events\h*?[("]',3)

_ArrayDisplay($r)

//Edit: @Smoke_N: \W is good :) Didn't know it exists :(, but for white4space \h is better or linefeed matches, too. Edited by ProgAndy

*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

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

smoke:

thx, your code does not catch trailing '"', but works a little bit different:

(?i)\Wwm_notify_events\s*[\(\"]

seems that \W does it, but why ?

andy: thx, but i want to ignore whitespace not match. i tried that.

j.

yes, \W is good but mysterious. in my case i cannot include linefeeds, so it is better.

and: why (?x) does not do anything ?

Edited by jennico

Spoiler

I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.OixB7.jpgDon't forget this IP: 213.251.145.96

 

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

smoke:

thx, your code does not catch trailing '"', but works a little bit different:

(?i)\Wwm_notify_events\s*[\(\"]

seems that \W does it, but why ?

andy: thx, but i want to ignore whitespace not match. i tried that.

j.

yes, \W is good but mysterious. in my case i cannot include linefeeds, so it is better.

What exactly are you trying to do here? I mean, if you know the name, makes it kind of a senseless expression to make as far as I can tell anyway.

Edit:

If it's for occurrences:

$s_string = 'GUISetOnEvent(123,"WM_Notify_events") '&@CRLF&' WM_NOTIFY_Events ( $hWndGUI, $MsgID, $wParam, $lParam)'
StringRegExpReplace($s_string,"(?s)(?i)\W(wm_notify_events)\W", "")
MsgBox(64, "Occurrences", "There are " & @extended & " occurrences")
Should be all that you need. Edited 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.

Share this post


Link to post
Share on other sites

Use \h*? for possibly existing horizontal whitespace muttley

//Edit: @Smoke_N: \W is good :) Didn't know it exists :(, but for white4space \h is better or linefeed matches, too.

Why in the world would you use horizontal spaces (CR / LF / HTab) in this situation?

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.

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

no, i don't know the name of the fuction. it will be a variable (array) in the script. just made a name for testing purposes.

at the end i want to replace all instances of a certain function name with a different name.

just like that: find all occurrences of the function 'whatever' and replace it with 'whatever_Ex', while whatever MUST be a function and nothing else. characteristical for a function is ALWAYS a trailing '(', but might be with spaces OR, more complicated, the function name in quotation marks as it appears in guiregistermsg.

all this i need for my script 'FreeStyle', linked in my signature (please take a look at it, Smoke !).

supposed to be a preprocessor and script assistant tool.

j.

Edited by jennico

Spoiler

I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.OixB7.jpgDon't forget this IP: 213.251.145.96

 

Share this post


Link to post
Share on other sites

no, i don't know the name of the fuction. it will be a variable (array) in the script. just made a name for testing purposes.

at the end i want to replace all instances of a certain function name with a different name.

just like that: find all occurrences of the function 'whatever' and replace it with 'whatever_Ex', while whatever MUST be a function and nothing else. characteristical for a function is ALWAYS a trailing '(', but might be with spaces OR, more complicated, the function name in quotation marks as it appears in guiregistermsg.

all this i need for my script 'FreeStyle', linked in my signature (please take a look at it, Smoke !).

supposed to be a preprocessor and script assistant tool.

j.

http://www.autoitscript.com/forum/index.ph...st&p=552586 (Instead of "" for replace, just put what you want to change it to muttley )

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.

Share this post


Link to post
Share on other sites

yes thx this helps me a lot.

i'll have to do the same with Global Constants, as far as i see, your code also works for variables:

(?i)\W\$button\W

seems to find all occurrences of $button and NOT $buttons.

so very nice ! thx again

j.


Spoiler

I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.OixB7.jpgDon't forget this IP: 213.251.145.96

 

Share this post


Link to post
Share on other sites

yes thx this helps me a lot.

i'll have to do the same with Global Constants, as far as i see, your code also works for variables:

(?i)\W\$button\W

seems to find all occurrences of $button and NOT $buttons.

so very nice ! thx again

j.

I just wrote something that pulled all the constants and their values out for GEOsoft I believe.... It's fairly in depth, and even gets the values of those that have things such as BitOr/BitAnd/other variables in it as a value.

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.

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

I just wrote something that pulled all the constants and their values out for GEOsoft I believe.... It's fairly in depth, and even gets the values of those that have things such as BitOr/BitAnd/other variables in it as a value.

muttley ha ! geosoft told me yesterday that he is working on the same thing and he wanted to inform me when he got it working, but i had no patience. funny.

j.

by the way, FreeStyle does it already, but somewhat slow without stringregexp. !!! it pulls out all constants, values and functions out of the include directory. even enums, steps, bitors or anything, and recursively for things like '$vdm_first+1024' will be converted to digits/hex.

Edited by jennico

Spoiler

I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.OixB7.jpgDon't forget this IP: 213.251.145.96

 

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

muttley ha ! geosoft told me yesterday that he is working on the same thing and he wanted to inform me when he got it working, but i had no patience. funny.

j.

by the way, FreeStyle does it already, but somewhat slow without stringregexp. !!! it pulls out all constants, values and functions out of the include directory. even enums, steps, bitors or anything, and recursively for things like '$vdm_first+1024' will be converted to digits/hex.

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

Share this post


Link to post
Share on other sites

now you gave me something to chew on ! muttley

i also succeeded in managing the continuation lines and even ignoring comments as well as block comments.

i am still stuck with duplicates (there are lots of functions with identical names, and even some global constants, which should be avoided).

j.


Spoiler

I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.OixB7.jpgDon't forget this IP: 213.251.145.96

 

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

@ SmOke_N

i tested your script with "Rich_Edit_Example.au3".

your script returns 16 or 17 variables depending on au3 version.

17 = 
$WS_MINIMIZEBOX = 0x00020000
$WS_CAPTION = 0x00C00000
$WS_POPUP = 0x80000000
$WS_SYSMENU = 0x00080000
$WS_SIZEBOX = 0x00040000
$ES_WANTRETURN = 4096
$WS_HSCROLL = 0x00100000
$ES_SUNKEN = 16384
$ES_MULTILINE = 4
$WS_VSCROLL = 0x00200000
$ES_AUTOVSCROLL = 64
$GUI_DOCKAUTO = 0x0001
$WM_NOTIFY = 0x004E
$GUI_EVENT_CLOSE = -3
$GUI_EVENT_RESIZED = -12
$WM_LBUTTONDOWN = 0x0201
$GUI_RUNDEFMSG = 'GUI_RUNDEFMSG'

seems that your script skips some constants...... ??

j.

Rich_Edit_Example.au3

Edited by jennico

Spoiler

I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.OixB7.jpgDon't forget this IP: 213.251.145.96

 

Share this post


Link to post
Share on other sites

#16 ·  Posted (edited)

ah, maybe because you limit search to "*Constants*.au3". but constants may be in all include files....

will try again

j.

edit : with "*.au3" better now, but with two errors concerning *fmt constants.

46 = 
$WS_MINIMIZEBOX = 0x00020000
$WS_CAPTION = 0x00C00000
$WS_POPUP = 0x80000000
$WS_SYSMENU = 0x00080000
$WS_SIZEBOX = 0x00040000
$ES_WANTRETURN = 4096
$WS_HSCROLL = 0x00100000
$ES_SUNKEN = 16384
$ES_MULTILINE = 4
$WS_VSCROLL = 0x00200000
$ES_AUTOVSCROLL = 64
$GUI_DOCKAUTO = 0x0001
$EM_SETEVENTMASK = 0x00000445
$ENM_REQUESTRESIZE = 0x40000
$ENM_LINK = 0x4000000
$ENM_DROPFILES = 0x100000
$ENM_KEYEVENTS = 0x10000
$ENM_MOUSEEVENTS = 0x20000
$EM_AUTOURLDETECT = 0x0000045B
$WM_NOTIFY = 0x004E
$GUI_EVENT_CLOSE = -3
$DebugIt = 1
$GUI_EVENT_RESIZED = -12
$EM_REQUESTRESIZE = 0x00000441
$EM_SETBKGNDCOLOR = 0x00000443
$nmhdr = "int;int;int"
$NMHDR_fmt = "int;int;int"
$EN_ALIGNLTR = 0X710
$EN_ALIGNRTL = 0X711
$EN_CORRECTTEXT = 0X705
$EN_DRAGDROPDONE = 0X70c
$EN_DROPFILES = 0X703
$EN_IMECHANGE = 0X707
$EN_LINK = 0X70b
$ENLINK_fmt = !===========================================================
+===========================================================
-->Unloading Library (Handle): 
+===========================================================

$WM_LBUTTONDOWN = 0x0201
$EN_MSGFILTER = 0X700
$msgfilter_fmt = !===========================================================
+===========================================================
-->Unloading Library (Handle): 
+===========================================================

$EN_OBJECTPOSITIONS = 0X70a
$EN_OLEOPFAILED = 0X709
$EN_PROTECTED = 0X704
$EN_REQUESTRESIZE = 0X701
$EN_SAVECLIPBOARD = 0X708
$EN_SELCHANGE = 0X702
$EN_STOPNOUNDO = 0X706
$GUI_RUNDEFMSG = 'GUI_RUNDEFMSG'
Edited by jennico

Spoiler

I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.OixB7.jpgDon't forget this IP: 213.251.145.96

 

Share this post


Link to post
Share on other sites

#17 ·  Posted (edited)

Where is $EN anything at? I can't find it... If it is in a standard format it should be fine.

Edit:

Must be a later beta or something, I don't have it in 3.2.13.1.

Edi2:

BTW, I just don't have enlink_fmt

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

Share this post


Link to post
Share on other sites

#18 ·  Posted (edited)

I think I see the error... but don't have a string file to test it on... see if this revision works (With your changes to *.au3 of course):

Edit: Had to re-attach

Edit2:

Nope, did extra work for nothing I see... damn can't even read my own code in the state I'm in... brb

Edit3:

I don't really understand how that error is coming about if it is simply a string to begin with. Now if it's variables together that make up the string, I can see where the error is coming from.

Try this and see if it fixes it:

#include <array.au3>
#include <file.au3>

Local $a_all = _GetConstants("C:\AU3\dummy.au3", "C:\Program Files\AutoIt3\Beta\Include")
_ArrayDisplay($a_all, "[0] = var, [1] = value")

Func _GetConstants($s_au3_read, $s_include_dir)
    If FileExists($s_au3_read) = 0 Then Return SetError(1, 0, "")
    If FileExists($s_include_dir) = 0 Then Return SetError(2, 0, "")
    
    Local $a_include_array = _ListIncludeValArray($s_include_dir)
    If IsArray($a_include_array) = 0 Then Return SetError(3, 0, "")
    
    Local $a_vars = StringRegExp(FileRead($s_au3_read), "(?s)\$\w+", 3)
    If IsArray($a_vars) = 0 Then Return SetError(4, 0, "")
    
    _ArrayUnique($a_vars)
    
    Local $n_ubound = UBound($a_vars), $i_add, $icc, $ncc
    Local $a_includes[$n_ubound + 1][2]
    
    For $ncc = 0 To $n_ubound - 1
        For $icc = 1 To $a_include_array[0][0]
            If StringInStr($a_include_array[$icc][1], "," & $a_vars[$ncc] & ",") Then
                $i_add += 1
                $a_includes[$i_add][0] = $a_include_array[$icc][0]
                $a_includes[$i_add][1] = $a_vars[$ncc]
                ExitLoop
            EndIf
        Next
    Next
    
    If $i_add = 0 Then Return SetError(5, 0, "")
    
    ReDim $a_includes[$i_add + 1][2]
    $a_includes[0][0] = $i_add
    
    $i_add = 0
    Local $s_read, $a_sre, $a_recurse, $s_value = "", $a_split
    Local $a_values[$a_includes[0][0] + 1][2]
    
    For $icc = 1 To $a_includes[0][0]
        ; Merge continuation lines as well read the file
        $s_read = StringRegExpReplace(FileRead($a_includes[$icc][0]), "_\s*\r\n\s*", "")
        $a_sre = StringRegExp($s_read, "(?i)Global\s+Const\s+" & _
                    StringReplace($a_includes[$icc][1], "$", "\$") & _
                    "\s*=\s*(.+?)(?:\s*\r\n|\z)", 1)
        If IsArray($a_sre) = 0 Then ContinueLoop
        If StringInStr($a_sre[0], "$") Then
            $s_value = _RunInclude_GetValue($a_includes[$icc][0], $a_includes[$icc][1])
            $a_sre[0] = $s_value
        EndIf
        $i_add += 1
        $a_values[$i_add][0] = $a_includes[$icc][1]
        $a_values[$i_add][1] = $a_sre[0]
    Next
    
    If $i_add = 0 Then Return SetError(5, 0, "")
    
    ReDim $a_values[$i_add + 1][2]
    $a_values[0][0] = $i_add
    Return $a_values
EndFunc

Func _ListIncludeValArray($s_include_dir, $s_mask = "*Constants*.au3")
    $s_include_dir = StringRegExpReplace($s_include_dir, "\\+\z", "") & "\"
    Local $a_files = _FileListToArray($s_include_dir, $s_mask)
    If IsArray($a_files) = 0 Then Return SetError(1, 0, 0)
    
    Local $a_vals[$a_files[0] + 1][2], $i_add, $icc
    Local $s_hold, $s_path, $s_read, $a_sre, $ncc
    For $icc = 1 To $a_files[0]
        $s_path = $s_include_dir & $a_files[$icc]
        $s_read = FileRead($s_path)
        $a_sre = StringRegExp($s_read, "(?s)(?i)Global\s+Const\s+(\$\w+)", 3)
        If IsArray($a_sre) Then
            For $ncc = 0 To UBound($a_sre) - 1
                $s_hold &= $a_sre[$ncc] & ","
            Next
            $i_add += 1
            $a_vals[$i_add][0] = $s_path
            $a_vals[$i_add][1] = "," & $s_hold
            $s_hold = ""
        EndIf
    Next
    ReDim $a_vals[$i_add + 1][2]
    $a_vals[0][0] = $i_add
    Return $a_vals
EndFunc

Func _RunInclude_GetValue($s_include, $s_var)
    Local $s_string = $s_include, $s_std
    If FileExists($s_string) Then $s_string = FileRead($s_string)
    Local $s_write = "#NoTrayIcon" & @CRLF & $s_string & @CRLF
    $s_write &= "Local $___a_include_split__, $___a_include_value_get__" & @CRLF & _
            "Local $___i_include__" & @CRLF & _
            "If VarGetType(" & $s_var & ") = ""String"" Then" & @CRLF & _
            "   If StringInStr(" & $s_var & ", " & "'""'" & ") = 0 Then" & @CRLF & _
            "       If StringRegExp(" & $s_var & ", ""\r|\n"") Then" & @CRLF & _
            "           $___a_include_split__ = StringSplit(StringStripCR(" & $s_var & "), @LF)" & @CRLF & _
            "           For $___i_include__ = 1 To $___a_include_split__[0]" & @CRLF & _
            "               $___a_include_value_get__ &= " & "'""'" & " & $___a_include_split__[$___i_include__] & " & "'""' & @CRLF &" & ' " _"' & @CRLF & _
            "           Next" & @CRLF & _
            "           $___a_include_value_get__ = StringTrimRight($___a_include_value_get__, 4)" & @CRLF & _
            "       Else" & @CRLF & _
            "           $___a_include_value_get__ = " & "'""'" & " & " & $s_var & " & '""'" & @CRLF & _
            "       EndIf" & @CRLF & _
            "   Else" & @CRLF & _
            "       If StringRegExp(" & $s_var & ",  " & '"' & "\r|\n" & '"' & ") Then" & @CRLF & _
            "           $___a_include_split__ = StringSplit(StringStripCR(" & $s_var & "), @LF)" & @CRLF & _
            "           For $___i_include__ = 1 To $___a_include_split__[0]" & @CRLF & _
            "               $___a_include_value_get__ &= " & '"''"' & " & $___a_include_split__[$___i_include__] & " & '"''"' & " & @CRLF &" & ' " _"' & @CRLF & _
            "           Next" & @CRLF & _
            "           $___a_include_value_get__ = StringTrimRight($___a_include_value_get__, 4)" & @CRLF & _
            "       Else" & @CRLF & _
            "           $___a_include_value_get__ = " & '"''"' & " & " & $s_var & " & " & '"''"' & @CRLF & _
            "       EndIf" & @CRLF & _
            "   EndIf" & @CRLF & _
            "Else" & @CRLF & _
            "   $___a_include_value_get__ = " & $s_var & @CRLF & _
            "EndIf" & @CRLF & _
            "ConsoleWrite($___a_include_value_get__)"
    
    Local $s_temp = @TempDir & "\au3_constant_convert_file.au3"
    FileClose(FileOpen($s_temp, 2))
    FileWrite($s_temp, $s_write)

    Local $i_pid = Run('"' & @AutoItExe & '" /AutoIt3ExecuteScript "' & $s_temp & '"', "", @SW_HIDE, 6)
    $s_std = StdoutRead($i_pid)
    
    FileDelete($s_temp)
    
    If $s_std Then
        If StringIsInt($s_std) Then Return "0x" & Hex(Int($s_std), 8)
        Return $s_std
    EndIf
    
    Return SetError(2, 0, "")
EndFunc

Func _ArrayUnique(ByRef $aArray, $vDelim = '', $iBase = 0, $iCase = 0)
    If Not IsArray($aArray) Then Return SetError(1, 0, 0)
    If $vDelim = '' Then $vDelim = Chr(1)
    Local $sHold = ""
    For $iCC = $iBase To UBound($aArray) - 1
        If Not StringInStr($vDelim & $sHold, $vDelim & $aArray[$iCC] & $vDelim, $iCase) Then
            $sHold &= $aArray[$iCC] & $vDelim
        EndIf
    Next
    $sHold = StringTrimRight($sHold, StringLen($vDelim))
    If $sHold And $iBase = 1 Then
        $aArray = StringSplit($sHold, $vDelim)
        Return SetError(0, 0, $aArray)
    ElseIf $sHold And $iBase = 0 Then
        $aArray = StringRegExp($sHold & $vDelim, "(?s)(.+?)" & $vDelim, 3)
        Return SetError(0, 0, $aArray)
    EndIf
    Return SetError(2, 0, 0)
EndFunc
Edited 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.

Share this post


Link to post
Share on other sites

taken from an old GuiRichEdit.au3 (well not so old, but a nice one !)

Global Const $msgfilter_fmt = $NMHDR_fmt & ";uint;int;int"
Global Const $ENLINK_fmt = $NMHDR_fmt & ";uint;int;int;" & $charrange_fmt

there has to be some recursing done.

the entire au3:

[autoit]#include-once

#include <GUIConstants.au3>

#include <Misc.au3>

#include <Memory.au3>

#include <EditConstants.au3>

Global Const $DebugIt = 1

Global Const $WM_NOTIFY = 0x4E

;~ Global Const $WM_USER = 0x400

Global Const $RICHEDIT_CLASS10A = "RICHEDIT"

Global Const $RICHEDIT_CLASS = $RICHEDIT_CLASS10A

Global Const $RICHEDIT_CLASSA = "RichEdit20A"

Global Const $RICHEDIT_CLASSW = "RichEdit20W"

Global Const $ICC_STANDARD_CLASSES = 0x4000

Global Const $ST_DEFAULT = 0

Global Const $ST_KEEPUNDO = 1

Global Const $ST_SELECTION = 2

; pitch and family

;~ If Not IsDeclared("DEFAULT_PITCH") Then Global Const $DEFAULT_PITCH = 0

Global Const $FIXED_PITCH = 1

Global Const $VARIABLE_PITCH = 2

Global Const $FF_DECORATIVE = 80

;~ If Not IsDeclared("FF_DONTCARE") Then Global Const $FF_DONTCARE = 0

Global Const $FF_ROMAN = 16

Global Const $FF_SWISS = 32

Global Const $FF_MODERN = 48

Global Const $FF_SCRIPT = 64

Global Const $FW_DONTCARE = 0

Global Const $FW_THIN = 100

Global Const $FW_EXTRALIGHT = 200

Global Const $FW_ULTRALIGHT = 200

Global Const $FW_LIGHT = 300

Global Const $FW_NORMAL = 400

Global Const $FW_REGULAR = 400

Global Const $FW_MEDIUM = 500

Global Const $FW_SEMIBOLD = 600

Global Const $FW_DEMIBOLD = 600

Global Const $FW_BOLD = 700

Global Const $FW_EXTRABOLD = 800

Global Const $FW_ULTRABOLD = 800

Global Const $FW_HEAVY = 900

Global Const $FW_BLACK = 900

; char sets

Global Const $ANSI_CHARSET = 0

Global Const $DEFAULT_CHARSET = 1

Global Const $SYMBOL_CHARSET = 2

Global Const $MAC_CHARSET = 77

Global Const $SHIFTJIS_CHARSET = 128

Global Const $HANGEUL_CHARSET = 129

Global Const $GB2312_CHARSET = 134

Global Const $CHINESEBIG5_CHARSET = 136

Global Const $GREEK_CHARSET = 161

Global Const $TURKISH_CHARSET = 162

Global Const $VIETNAMESE_CHARSET = 163

Global Const $BALTIC_CHARSET = 186

Global Const $RUSSIAN_CHARSET = 204

Global Const $OEM_CHARSET = 255

Global Const $CFU_UNDERLINENONE = 0

Global Const $CFU_UNDERLINE = 1

Global Const $CFU_UNDERLINEWORD = 2

Global Const $CFU_UNDERLINEDOUBLE = 3

Global Const $CFU_UNDERLINEDOTTED = 4

; code pages

Global Const $CP_ACP = 0 ; use system default

Global Const $CP_37 = 37

Global Const $CP_273 = 273

Global Const $CP_277 = 277

Global Const $CP_278 = 278

Global Const $CP_280 = 280

Global Const $CP_284 = 284

Global Const $CP_285 = 285

Global Const $CP_290 = 290

Global Const $CP_297 = 297

Global Const $CP_423 = 423

Global Const $CP_500 = 500

Global Const $CP_875 = 875

Global Const $CP_930 = 930

Global Const $CP_931 = 931

Global Const $CP_932 = 932

Global Const $CP_933 = 933

Global Const $CP_935 = 935

Global Const $CP_936 = 936

Global Const $CP_937 = 937

Global Const $CP_939 = 939

Global Const $CP_949 = 949

Global Const $CP_950 = 950

Global Const $CP_1027 = 1027

Global Const $CP_5026 = 5026

Global Const $CP_5035 = 5035

Global Const $CFM_ALLCAPS = 0x80

Global Const $CFM_ANIMATION = 0x40000

Global Const $CFM_BACKCOLOR = 0x4000000

Global Const $CFM_BOLD = 0x1

Global Const $CFM_CHARSET = 0x8000000

Global Const $CFM_COLOR = 0x40000000

Global Const $CFM_DISABLED = 0x2000

Global Const $CFM_EMBOSS = 0x800

Global Const $CFM_FACE = 0x20000000

Global Const $CFM_HIDDEN = 0x100

Global Const $CFM_IMPRINT = 0x1000

Global Const $CFM_ITALIC = 0x2

Global Const $CFM_KERNING = 0x100000

Global Const $CFM_LCID = 0x2000000

Global Const $CFM_LINK = 0x20

Global Const $CFM_OFFSET = 0x10000000

Global Const $CFM_OUTLINE = 0x200

Global Const $CFM_PROTECTED = 0x10

Global Const $CFM_REVAUTHOR = 0x8000

Global Const $CFM_REVISED = 0x4000

Global Const $CFM_SHADOW = 0x400

Global Const $CFM_SIZE = 0x80000000

Global Const $CFM_SMALLCAPS = 0x40

Global Const $CFM_SPACING = 0x200000

Global Const $CFM_STRIKEOUT = 0x8

Global Const $CFM_STYLE = 0x80000

Global Const $CFM_SUBSCRIPT = BitOR(0x10000, 0x20000)

Global Const $CFM_SUPERSCRIPT = $CFM_SUBSCRIPT

Global Const $CFM_UNDERLINE = 0x4

Global Const $CFM_UNDERLINETYPE = 0x800000

Global Const $CFM_WEIGHT = 0x400000

Global Const $CFE_ALLCAPS = $CFM_ALLCAPS

Global Const $CFE_AUTOBACKCOLOR = $CFM_BACKCOLOR

Global Const $CFE_AUTOCOLOR = 0x40000000

Global Const $CFE_BOLD = 0x1

Global Const $CFE_DISABLED = $CFM_DISABLED

Global Const $CFE_EMBOSS = $CFM_EMBOSS

Global Const $CFE_HIDDEN = $CFM_HIDDEN

Global Const $CFE_IMPRINT = $CFM_IMPRINT

Global Const $CFE_ITALIC = 0x2

Global Const $CFE_LINK = 0x20

Global Const $CFE_OUTLINE = $CFM_OUTLINE

Global Const $CFE_PROTECTED = 0x10

Global Const $CFE_REVISED = $CFM_REVISED

Global Const $CFE_SHADOW = $CFM_SHADOW

Global Const $CFE_SMALLCAPS = $CFM_SMALLCAPS

Global Const $CFE_STRIKEOUT = 0x8

Global Const $CFE_SUBSCRIPT = 0x10000

Global Const $CFE_SUPERSCRIPT = 0x20000

Global Const $CFE_UNDERLINE = 0x4

;~ Global Const $CFM_EFFECTS = BitOR($CFM_BOLD, $CFM_ITALIC, $CFM_UNDERLINE, $CFM_COLOR, $CFM_STRIKEOUT, $CFE_PROTECTED, $CFM_LINK)

;~ Global Const $CFM_ALL = BitOR($CFM_EFFECTS, $CFM_SIZE, $CFM_FACE, $CFM_OFFSET, $CFM_CHARSET)

Global Const $SCF_DEFAULT = 0x0

Global Const $SCF_SELECTION = 0x1

Global Const $SCF_WORD = 0x2

Global Const $SCF_ALL = 0x4

Global Const $SCF_USEUIRULES = 0x8

Global Const $SCF_ASSOCIATEFONT = 0x10

Global Const $SCF_NOKBUPDATE = 0x20

; RichEdit Messages

Global Const $EM_AUTOURLDETECT = ($WM_USER + 91)

Global Const $EM_CANPASTE = ($WM_USER + 50)

Global Const $EM_CANREDO = ($WM_USER + 85)

Global Const $EM_DISPLAYBAND = ($WM_USER + 51)

Global Const $EM_EXGETSEL = ($WM_USER + 52)

Global Const $EM_EXLIMITTEXT = ($WM_USER + 53)

Global Const $EM_EXLINEFROMCHAR = ($WM_USER + 54)

Global Const $EM_EXSETSEL = ($WM_USER + 55)

Global Const $EM_FINDTEXT = ($WM_USER + 56)

Global Const $EM_FINDTEXTEX = ($WM_USER + 79)

Global Const $EM_FINDTEXTEXW = ($WM_USER + 124)

Global Const $EM_FINDTEXTW = ($WM_USER + 123)

Global Const $EM_FINDWORDBREAK = ($WM_USER + 76)

Global Const $EM_FORMATRANGE = ($WM_USER + 57)

Global Const $EM_GETAUTOURLDETECT = ($WM_USER + 92)

Global Const $EM_GETBIDIOPTIONS = ($WM_USER + 201)

Global Const $EM_GETCHARFORMAT = ($WM_USER + 58)

Global Const $EM_GETEDITSTYLE = ($WM_USER + 205)

Global Const $EM_GETEVENTMASK = ($WM_USER + 59)

Global Const $EM_GETIMECOLOR = ($WM_USER + 105)

Global Const $EM_GETIMECOMPMODE = ($WM_USER + 122)

Global Const $EM_GETIMEMODEBIAS = ($WM_USER + 127)

Global Const $EM_GETIMEOPTIONS = ($WM_USER + 107)

Global Const $EM_GETLANGOPTIONS = ($WM_USER + 121)

Global Const $EM_GETOPTIONS = ($WM_USER + 78)

Global Const $EM_GETPARAFORMAT = ($WM_USER + 61)

Global Const $EM_GETPUNCTUATION = ($WM_USER + 101)

Global Const $EM_GETREDONAME = ($WM_USER + 87)

Global Const $EM_GETSCROLLPOS = ($WM_USER + 221)

Global Const $EM_GETSELTEXT = ($WM_USER + 62)

Global Const $EM_GETTEXTEX = ($WM_USER + 94)

Global Const $EM_GETTEXTLENGTHEX = ($WM_USER + 95)

Global Const $EM_GETTEXTMODE = ($WM_USER + 90)

Global Const $EM_GETTEXTRANGE = ($WM_USER + 75)

Global Const $EM_GETTYPOGRAPHYOPTIONS = ($WM_USER + 203)

Global Const $EM_GETUNDONAME = ($WM_USER + 86)

Global Const $EM_GETWORDBREAKPROCEX = ($WM_USER + 80)

Global Const $EM_GETWORDWRAPMODE = ($WM_USER + 103)

Global Const $EM_GETZOOM = ($WM_USER + 224)

Global Const $EM_HIDESELECTION = ($WM_USER + 63)

Global Const $EM_PASTESPECIAL = ($WM_USER + 64)

Global Const $EM_RECONVERSION = ($WM_USER + 125)

Global Const $EM_REDO = ($WM_USER + 84)

Global Const $EM_REQUESTRESIZE = ($WM_USER + 65)

Global Const $EM_SELECTIONTYPE = ($WM_USER + 66)

Global Const $EM_SETBIDIOPTIONS = ($WM_USER + 200)

Global Const $EM_SETBKGNDCOLOR = ($WM_USER + 67)

Global Const $EM_SETCHARFORMAT = ($WM_USER + 68)

Global Const $EM_SETEDITSTYLE = ($WM_USER + 204)

Global Const $EM_SETEVENTMASK = ($WM_USER + 69)

Global Const $EM_SETFONTSIZE = ($WM_USER + 223)

Global Const $EM_SETIMECOLOR = ($WM_USER + 104)

Global Const $EM_SETIMEMODEBIAS = ($WM_USER + 126)

Global Const $EM_SETIMEOPTIONS = ($WM_USER + 106)

Global Const $EM_SETLANGOPTIONS = ($WM_USER + 120)

Global Const $EM_SETOLECALLBACK = ($WM_USER + 70)

Global Const $EM_SETOPTIONS = ($WM_USER + 77)

Global Const $EM_SETPALETTE = ($WM_USER + 93)

Global Const $EM_SETPARAFORMAT = ($WM_USER + 71)

Global Const $EM_SETPUNCTUATION = ($WM_USER + 100)

Global Const $EM_SETSCROLLPOS = ($WM_USER + 222)

Global Const $EM_SETTARGETDEVICE = ($WM_USER + 72)

Global Const $EM_SETTEXTEX = ($WM_USER + 97)

Global Const $EM_SETTEXTMODE = ($WM_USER + 89)

Global Const $EM_SETTYPOGRAPHYOPTIONS = ($WM_USER + 202)

Global Const $EM_SETUNDOLIMIT = ($WM_USER + 82)

Global Const $EM_SETWORDBREAKPROCEX = ($WM_USER + 81)

Global Const $EM_SETWORDWRAPMODE = ($WM_USER + 102)

Global Const $EM_SETZOOM = ($WM_USER + 225)

Global Const $EM_SHOWSCROLLBAR = ($WM_USER + 96)

Global Const $EM_STOPGROUPTYPING = ($WM_USER + 88)

Global Const $EM_STREAMIN = ($WM_USER + 73)

Global Const $EM_STREAMOUT = ($WM_USER + 74)

Global Const $EN_ALIGNLTR = 0X710

Global Const $EN_ALIGNRTL = 0X711

Global Const $EN_CORRECTTEXT = 0X705

Global Const $EN_DRAGDROPDONE = 0X70c

Global Const $EN_DROPFILES = 0X703

Global Const $EN_IMECHANGE = 0X707

Global Const $EN_LINK = 0X70b

Global Const $EN_MSGFILTER = 0X700

Global Const $EN_OBJECTPOSITIONS = 0X70a

Global Const $EN_OLEOPFAILED = 0X709

Global Const $EN_PROTECTED = 0X704

Global Const $EN_REQUESTRESIZE = 0X701

Global Const $EN_SAVECLIPBOARD = 0X708

Global Const $EN_SELCHANGE = 0X702

Global Const $EN_STOPNOUNDO = 0X706

Global Const $ENM_CHANGE = 0x1

Global Const $ENM_CORRECTTEXT = 0x400000

Global Const $ENM_DRAGDROPDONE = 0x10

Global Const $ENM_DROPFILES = 0x100000

Global Const $ENM_IMECHANGE = 0x800000

Global Const $ENM_KEYEVENTS = 0x10000

Global Const $ENM_LINK = 0x4000000

Global Const $ENM_MOUSEEVENTS = 0x20000

Global Const $ENM_OBJECTPOSITIONS = 0x2000000

Global Const $ENM_PROTECTED = 0x200000

Global Const $ENM_REQUESTRESIZE = 0x40000

Global Const $ENM_SCROLL = 0x4

Global Const $ENM_SCROLLEVENTS = 0x8

Global Const $ENM_SELCHANGE = 0x80000

Global Const $ENM_UPDATE = 0x2

Global Const $ES_DISABLENOSCROLL = 0x2000

Global Const $ES_EX_NOCALLOLEINIT = 0x1000000

Global Const $ES_NOIME = 0x80000

Global Const $ES_SELFIME = 0x40000

Global Const $ES_SUNKEN = 0x4000

;~ Global Const $ES_NUMBER = 0x2000

;~ Global Const $ES_PASSWORD = 0x20

;~ Global Const $ES_READONLY = 0x800

;~ Global Const $ES_RIGHT = 0x2

;~ Global Const $ES_WANTRETURN = 0x1000

Global Const $WM_LBUTTONDBLCLK = 0x203

Global Const $WM_LBUTTONDOWN = 0x201

Global Const $WM_LBUTTONUP = 0x202

Global Const $WM_MOUSEMOVE = 0x200

Global Const $WM_RBUTTONDBLCLK = 0x206

Global Const $WM_RBUTTONDOWN = 0x204

Global Const $WM_RBUTTONUP = 0x205

Global Const $WM_SETCURSOR = 0x20

; structure formats

Global Const $LF_FACESIZE = 32

Global Const $MAX_TAB_STOPS = 32

Global Const $NMHDR_fmt = "int;int;int"

;~ HWND hwndFrom;

;~ UINT idFrom;

;~ UINT code;

Global Const $Rect_fmt = "int;int;int;int"

Global Const $bidioptions_fmt = "uint;int;int"

;~ UINT cbSize;

;~ WORD wMask;

;~ WORD wEffects

Global Const $charformat_fmt = "uint;dword;dword;int;int;int;byte;byte;char[" & $LF_FACESIZE & "]"

;~ UINT cbSize;

;~ DWORD dwMask;

;~ DWORD dwEffects;

;~ LONG yHeight;

;~ LONG yOffset;

;~ COLORREF crTextColor;

;~ BYTE bCharSet;

;~ BYTE bPitchAndFamily;

;~ TCHAR szFaceName[LF_FACESIZE];

Global Const $charformat2_fmt = "uint;dword;dword;int;int;int;byte;byte;char[" & $LF_FACESIZE & "];int;short;int;byte;byte;byte;byte"

;~ UINT cbSize;

;~ DWORD dwMask;

;~ DWORD dwEffects;

;~ LONG yHeight;

;~ LONG yOffset;

;~ COLORREF crTextColor;

;~ BYTE bCharSet;

;~ BYTE bPitchAndFamily;

;~ TCHAR szFaceName[LF_FACESIZE];

;~ WORD wWeight;

;~ SHORT sSpacing;

;~ COLORREF crBackColor;

;~ LCID lcid;

;~ DWORD dwReserved;

;~ SHORT sStyle;

;~ WORD wKerning;

;~ BYTE bUnderlineType;

;~ BYTE bAnimation;

;~ BYTE bRevAuthor;

;~ BYTE bReserved1;

Global Const $charrange_fmt = "int;int"

;~ LONG cpMin;

;~ LONG cpMax;

Global Const $COMPCOLOR_fmt = "int;int;dword"

;~ COLORREF crText;

;~ COLORREF crBackground;

;~ DWORD dwEffects

;~ editstream {

;~ DWORD_PTR dwCookie;

;~ DWORD dwError;

;~ EDITSTREAMCALLBACK pfnCallback

Global Const $encorrecttext_fmt = $NMHDR_fmt & ";" & $charrange_fmt & ";int"

;~ NMHDR nmhdr;

;~ CHARRANGE chrg;

;~ WORD seltyp;

Global Const $endropfiles_fmt = $NMHDR_fmt & ";int;int;int"

;~ NMHDR nmhdr;

;~ HANDLE hDrop;

;~ LONG cp;

;~ BOOL fProtected

Global Const $ENLINK_fmt = $NMHDR_fmt & ";uint;int;int;" & $charrange_fmt

;~ NMHDR nmhdr;

;~ UINT msg;

;~ WPARAM wParam;

;~ LPARAM lParam;

;~ CHARRANGE chrg

Global Const $enlowfirtf_fmt = $NMHDR_fmt & ";ptr"

;~ NMHDR nmhdr;

;~ CHAR *szControl

Global Const $ENOLEOPFAILED_fmt = $NMHDR_fmt & ";int;int;int"

;~ NMHDR nmhdr;

;~ LONG iob;

;~ LONG lOper;

;~ HRESULT hr;

Global Const $enprotected_fmt = $NMHDR_fmt & ";uint;int;int;" & $charrange_fmt

;~ NMHDR nmhdr;

;~ UINT msg;

;~ WPARAM wParam;

;~ LPARAM lParam;

;~ CHARRANGE chrg

Global Const $ENSAVECLIPBOARD_fmt = $NMHDR_fmt & ";int;int"

;~ NMHDR nmhdr;

;~ LONG cObjectCount;

;~ LONG cch;

;~ Global Const $findtext_fmt = $charrange_fmt & ";ptr"

Global Const $findtext_fmt = $charrange_fmt & ";char[128]"

;~ CHARRANGE chrg;

;~ LPCTSTR lpstrText;

Global Const $findtextex_ftm = $charrange_fmt & ";char[128];" & $charrange_fmt

;~ CHARRANGE chrg;

;~ LPCTSTR lpstrText;

;~ CHARRANGE chrgText

Global Const $formatrange_fmt = "int;int;" & $Rect_fmt & ";" & $Rect_fmt & ";" & $charrange_fmt

;~ HDC hdc;

;~ HDC hdcTarget;

;~ RECT rc;

;~ RECT rcPage;

;~ CHARRANGE chrg

Global Const $gettextex_fmt = "dword;dword;uint;char;int"

;~ DWORD cb;

;~ DWORD flags;

;~ UINT codepage;

;~ LPCSTR lpDefaultChar;

;~ LPBOOL lpUsedDefChar

Global Const $gettextlengthex_fmt = "dword;uint"

;~ DWORD flags;

;~ UINT codepage;

;~ tagHyphenateInfo {

;~ SHORT cbSize;

;~ SHORT dxHyphenateZone;

;~ PFNHYPHENATEPROC pfnHyphenate

Global Const $tagKHYPH_fmt = "int;int;int;int;int;int;int"

;~ khyphNil,

;~ khyphNormal,

;~ khyphAddBefore,

;~ khyphChangeBefore,

;~ khyphDeleteBefore,

;~ khyphChangeAfter,

;~ khyphDelAndChange

Global Const $hyphresult_fmt = $tagKHYPH_fmt & ";int;char"

;~ KHYPH khyph;

;~ LONG ichHyph;

;~ WCHAR chHyph

Global Const $imecomptext_fmt = "int;dword"

;~ LONG cb;

;~ DWORD flags;

Global Const $msgfilter_fmt = $NMHDR_fmt & ";uint;int;int"

;~ NMHDR nmhdr;

;~ UINT msg;

;~ WPARAM wParam;

;~ LPARAM lParam

Global Const $objectpositions_fmt = $NMHDR_fmt & ";int;int"

;~ NMHDR nmhdr;

;~ LONG cObjectCount;

;~ LONG *pcpPositions

Global Const $paraformat_fmt = "uint;dword;int;int;int;int;int;int;short;int[" & $MAX_TAB_STOPS & "]"

;~ UINT cbSize;

;~ DWORD dwMask;

;~ WORD wNumbering;

;~ WORD wReserved;

;~ LONG dxStartIndent;

;~ LONG dxRightIndent;

;~ LONG dxOffset;

;~ WORD wAlignment;

;~ SHORT cTabCount;

;~ LONG rgxTabs[MAX_TAB_STOPS];

Global Const $paraformat_fmt2 = "uint;dword;int;int;int;int;int;int;short;int;int;int;int;short;byte;byte;int;int;int;int;int;int;int;int"

;~ UINT cbSize;

;~ DWORD dwMask;

;~ WORD wNumbering;

;~ WORD wEffects;

;~ LONG dxStartIndent;

;~ LONG dxRightIndent;

;~ LONG dxOffset;

;~ WORD wAlignment;

;~ SHORT cTabCount;

;~ LONG rgxTabs[MAX_TAB_STOPS];

;~ LONG dySpaceBefore;

;~ LONG dySpaceAfter;

;~ LONG dyLineSpacing;

;~ SHORT sStyle;

;~ BYTE bLineSpacingRule;

;~ BYTE bOutlineLevel;

;~ WORD wShadingWeight;

;~ WORD wShadingStyle;

;~ WORD wNumberingStart;

;~ WORD wNumberingStyle;

;~ WORD wNumberingTab;

;~ WORD wBorderSpace;

;~ WORD wBorderWidth;

;~ WORD wBorders;

Global Const $punctuation_fmt = "uint;ptr"

;~ UINT iSize;

;~ LPSTR szPunctuation

;~ Global $reobject_fmt = "dword;int;int; {

;~ DWORD cbStruct;

;~ LONG cp;

;~ CLSID clsid;

;~ LPOLEOBJECT poleobj;

;~ LPSTORAGE pstg;

;~ LPOLECLIENTSITE polesite;

;~ SIZEL sizel;

;~ DWORD dvaspect;

;~ DWORD dwFlags;

;~ DWORD dwUser

Global Const $repastespecial_fmt = "dword;dword"

;~ DWORD dwAspect;

;~ DWORD_PTR dwParam

Global Const $reqresize_fmt = $NMHDR_fmt & ";" & $Rect_fmt

;~ NMHDR nmhdr;

;~ RECT rc;

Global Const $selchange_fmt = $NMHDR_fmt & ";" & $charrange_fmt & ";int"

;~ NMHDR nmhdr;

;~ CHARRANGE chrg;

;~ WORD seltyp;

Global Const $settextex_fmt = "dword;uint"

;~ DWORD flags;

;~ UINT codepage

Global Const $textrange_fmt = $charrange_fmt & ";ptr"

;~ CHARRANGE chrg;

;~ LPSTR lpstrText

Global Const $tagLOGFONT_fmt = "int;int;int;int;int;byte;byte;byte;byte;byte;byte;byte;byte;char[" & $LF_FACESIZE & "]"

;~ LONG lfHeight;

;~ LONG lfWidth;

;~ LONG lfEscapement;

;~ LONG lfOrientation;

;~ LONG lfWeight;

;~ BYTE lfItalic;

;~ BYTE lfUnderline;

;~ BYTE lfStrikeOut;

;~ BYTE lfCharSet;

;~ BYTE lfOutPrecision;

;~ BYTE lfClipPrecision;

;~ BYTE lfQuality;

;~ BYTE lfPitchAndFamily;

;~ TCHAR lfFaceName[LF_FACESIZE];

Global $h_lib

; Cleanup

Func OnAutoItExit()

If $DebugIt Then _DebugPrint("Unloading Library (Handle): " & $h_lib)

$h_lib = DllCall("kernel32.dll", "long", "FreeLibrary", "long", $h_lib)

If Not @error Then

If $DebugIt Then _DebugPrint("Libarary Unloaded")

EndIf

EndFunc ;==>OnAutoItExit

;===============================================================================

;

; Description: _GUICtrlRichEditCreate

; Parameter(s): $h_Gui - Handle to parent window

; $x - The left side of the control

; $y - The top of the control

; $width - The width of the control

; $height - The height of the control

; $v_styles - styles to apply to the control (Optional) for multiple styles bitor them.

; $v_exstyles - extended styles to apply to the control (Optional) for multiple styles bitor them.

; Requirement:

; Return Value(s): Returns hWhnd if successful, or 0 with error set to 1 otherwise.

; User CallTip: _GUICtrlRichEditCreate($h_Gui, $x, $y, $width, $height, [, $v_styles = -1[, $v_exstyles = -1]]) Creates RichEdit Control.

; Author(s): Gary Frost (gafrost (custompcs@charter.net))

; Note(s):

;===============================================================================

Func _GUICtrlRichEditCreate(ByRef $h_Gui, $x, $y, $width, $height, $v_styles = -1, $v_exstyles = -1)

Local $h_RichEdit, $style

If Not IsHWnd($h_Gui) Then $h_Gui = HWnd($h_Gui)

$style = BitOR($WS_CHILD, $WS_VISIBLE, $WS_CLIPSIBLINGS)

If $v_styles <> -1 Then $style = BitOR($style, $v_styles)

If $v_exstyles = -1 Then $v_exstyles = 0

;~ Local $stICCE = DllStructCreate('dword;dword')

;~ DllStructSetData($stICCE, 1, DllStructGetSize($stICCE))

;~ DllStructSetData($stICCE, 2, $ICC_STANDARD_CLASSES)

$h_lib = DllCall("kernel32.dll", "long", "LoadLibrary", "str", "RichEd20.dll")

If Not @error Then $h_lib = $h_lib[0]

If $DebugIt Then _DebugPrint("Libarary Loaded (Handle): " & $h_lib)

$h_RichEdit = DllCall("user32.dll", "long", "CreateWindowEx", "long", $v_exstyles, _

"str", $RICHEDIT_CLASSA, "str", "", _

"long", $style, "long", $x, "long", $y, "long", $width, "long", $height, _

"hwnd", $h_Gui, "long", 0, "hwnd", $h_Gui, "long", 0)

If Not @error Then

Return $h_RichEdit[0]

Else

SetError(1)

EndIf

Return 0

EndFunc ;==>_GUICtrlRichEditCreate

;===============================================================================

;

; Description: _GUICtrlRichEditSetText

; Parameter(s): $h_RichEdit - Handle to the control

; $s_Text - Text to put into the control

; Requirement:

; Return Value(s): If the operation is setting all of the text and succeeds, the return value is 1.

; If the operation is setting the selection and succeeds, the return value is the number of bytes or characters copied.

; If the operation fails, the return value is zero.

; User CallTip: _GUICtrlRichEditSetText($h_Gui, $s_Text) Put text into the RichEdit Control.

; Author(s): Gary Frost (gafrost (custompcs@charter.net))

; Note(s):

;===============================================================================

Func _GUICtrlRichEditSetText(ByRef $h_RichEdit, $s_Text = "")

If Not IsHWnd($h_RichEdit) Then $h_RichEdit = HWnd($h_RichEdit)

Local $lResult, $settext_struct

$settext_struct = DllStructCreate($settextex_fmt)

DllStructSetData($settext_struct, 1, $ST_DEFAULT)

DllStructSetData($settext_struct, 2, $CP_ACP)

Return _SendMessage($h_RichEdit, $EM_SETTEXTEX, DllStructGetPtr($settext_struct), $s_Text, 0, "ptr", "str")

EndFunc ;==>_GUICtrlRichEditSetText

Func _GUICtrlRichEditInsertText(ByRef $h_RichEdit, $s_Text = "")

If Not IsHWnd($h_RichEdit) Then $h_RichEdit = HWnd($h_RichEdit)

Local $lResult, $settext_struct

$settext_struct = DllStructCreate($settextex_fmt)

DllStructSetData($settext_struct, 1, $ST_SELECTION)

DllStructSetData($settext_struct, 2, $CP_ACP)

Return _SendMessage($h_RichEdit, $EM_SETTEXTEX, DllStructGetPtr($settext_struct), $s_Text, 0, "ptr", "str")

EndFunc ;==>_GUICtrlRichEditInsertText

Func _GUICtrlRichEditAppendText(ByRef $h_RichEdit, $s_Text = "")

If Not IsHWnd($h_RichEdit) Then $h_RichEdit = HWnd($h_RichEdit)

Local $lResult, $settext_struct

Local $i_index = _GUICtrlRichEditLineIndex($h_RichEdit, _GUICtrlRichEditGetLineCount($h_RichEdit) - 1)

;~ If @error Then Return SetError($EC_ERR, $EC_ERR, "")

Local $length = _GUICtrlRichEditLineLength($h_RichEdit, $i_index) + $i_index

_GUICtrlRichEditSetSel($h_RichEdit, $length, $length)

$settext_struct = DllStructCreate($settextex_fmt)

DllStructSetData($settext_struct, 1, $ST_SELECTION)

DllStructSetData($settext_struct, 2, $CP_ACP)

Return _SendMessage($h_RichEdit, $EM_SETTEXTEX, DllStructGetPtr($settext_struct), $s_Text, 0, "ptr", "str")

EndFunc ;==>_GUICtrlRichEditAppendText

Func _GUICtrlRichEditGetText(ByRef $h_RichEdit, $start, $end)

If Not IsHWnd($h_RichEdit) Then $h_RichEdit = HWnd($h_RichEdit)

Local $sBuffer_pointer, $TextRange_ptr

Local $Memory_pointer, $struct_MemMap

Local $i_Size, $string_Memory_pointer

Local $buf_struct = DllStructCreate("char[4096]")

$sBuffer_pointer = DllStructGetPtr($buf_struct)

Local $TextRange_Struct = DllStructCreate($textrange_fmt)

$TextRange_ptr = DllStructGetPtr($TextRange_Struct)

$i_Size = DllStructGetSize($TextRange_Struct)

DllStructSetData($TextRange_Struct, 1, $start)

DllStructSetData($TextRange_Struct, 2, $end)

$Memory_pointer = _MemInit ($h_RichEdit, $i_Size + 4096, $struct_MemMap)

If @error Then

_MemFree ($struct_MemMap)

Return SetError(-1, -1, "")

EndIf

$string_Memory_pointer = $Memory_pointer + 4096

DllStructSetData($TextRange_Struct, 3, $string_Memory_pointer)

_MemWrite ($struct_MemMap, $TextRange_ptr)

If @error Then

_MemFree ($struct_MemMap)

Return SetError(-1, -1, "")

EndIf

Local $lResult = _SendMessage($h_RichEdit, $EM_GETTEXTRANGE, 0, $Memory_pointer)

If @error Then

_MemFree ($struct_MemMap)

Return SetError(-1, -1, "")

EndIf

_MemRead ($struct_MemMap, $string_Memory_pointer, $sBuffer_pointer, 4096)

If @error Then

_MemFree ($struct_MemMap)

Return SetError(-1, -1, "")

EndIf

_MemFree ($struct_MemMap)

If @error Then Return SetError(-1, -1, "")

;~ MsgBox(0, "Rich Edit Get Text", "Chars Copied: " & $lResult & @CRLF & "Chars: " & DllStructGetData($buf_struct, 1))

Return DllStructGetData($buf_struct, 1)

EndFunc ;==>_GUICtrlRichEditGetText

;===============================================================================

;

; Description: _GUICtrlRichEditGetSel

; Parameter(s): $h_RichEdit - controlID

; Requirement: None

; Return Value(s): Array containing the starting and ending selected positions, first element ($array[0]) contains the number of elements

; If an error occurs, the return value is $EC_ERR.

; User CallTip: _GUICtrlRichEditGetSel($h_RichEdit) Retrieves the starting and ending character positions of the current selection in an edit control. (required: <GuiRichEdit.au3>)

; Author(s): Gary Frost (custompcs at charter dot net)

; Note(s): $array[1] contains the starting position

; $array[2] contains the ending position

;

;===============================================================================

Func _GUICtrlRichEditGetSel($h_RichEdit)

;~ If Not _IsClassName ($h_Edit, "Edit") Then Return SetError($EC_ERR, $EC_ERR, $EC_ERR)

If Not IsHWnd($h_RichEdit) Then $h_RichEdit = HWnd($h_RichEdit)

Local $ptr1 = "int", $ptr2 = "int", $i_ret

Local $wparam = DllStructCreate($ptr1)

Local $a_sel

If @error Then Return SetError($EC_ERR, $EC_ERR, $EC_ERR)

Local $lparam = DllStructCreate($ptr2)

If @error Then Return SetError($EC_ERR, $EC_ERR, $EC_ERR)

;~ If IsHWnd($h_Edit) Then

$i_ret = _SendMessage($h_RichEdit, $EM_GETSEL, DllStructGetPtr($wparam), DllStructGetPtr($lparam))

;~ Else

;~ $i_ret = GUICtrlSendMsg($h_Edit, $EM_GETSEL, DllStructGetPtr($wparam), DllStructGetPtr($lparam))

;~ EndIf

If ($i_ret == -1) Then Return SetError($EC_ERR, $EC_ERR, $EC_ERR)

$a_sel = StringSplit(DllStructGetData($wparam, 1) & "," & DllStructGetData($lparam, 1), ",")

Return $a_sel

EndFunc ;==>_GUICtrlRichEditGetSel

;===============================================================================

;

; Description: _GUICtrlRichEditSetSel

; Parameter(s): $h_RichEdit - controlID

; $i_start - Specifies the starting character position of the selection.

; $i_end - Specifies the ending character position of the selection.

; Requirement: None

; Return Value(s): None

; User CallTip: _GUICtrlRichEditSetSel($h_RichEdit, $i_start, $i_end) Selects a range of characters in an edit control. (required: <GuiRichEdit.au3>)

; Author(s): Gary Frost (custompcs at charter dot net)

; Note(s): The start value can be greater than the end value.

; The lower of the two values specifies the character position of the first character in the selection.

; The higher value specifies the position of the first character beyond the selection.

;

; The start value is the anchor point of the selection, and the end value is the active end.

; If the user uses the SHIFT key to adjust the size of the selection, the active end can move but the anchor point remains the same.

;

; If the $i_start is 0 and the $i_end is


Spoiler

I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.OixB7.jpgDon't forget this IP: 213.251.145.96

 

Share this post


Link to post
Share on other sites

#20 ·  Posted (edited)

i neither can see where these values come from, it seems to be a comment...

edit: ...consolewrite ?

j.

Edited by jennico

Spoiler

I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.OixB7.jpgDon't forget this IP: 213.251.145.96

 

Share this post


Link to post
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
Sign in to follow this  
Followers 0