Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 11/23/2014 in all areas

  1. I was needing to enable and disable a network connection. I google and find a good C++ example using interfaces. so I ported to Autoit (ObjCreateInterface ) Global Const $NCME_DEFAULT = 0 Global Const $S_OK = 0 Global Const $sCLSID_ConnectionManager = '{BA126AD1-2166-11D1-B1D0-00805FC1270E}' Global Const $sIID_INetConnectionManager = '{C08956A2-1CD3-11D1-B1C5-00805FC1270E}' Global Const $sIID_IEnumNetConnection = '{C08956A0-1CD3-11D1-B1C5-00805FC1270E}' Global Const $sIID_INetConnection = '{C08956A1-1CD3-11D1-B1C5-00805FC1270E}' Global Const $sINetConnectionManager = "EnumConnections hresult(int;ptr*)" Global Const $sTag_IEnumNetConnection = "Next hresult(int;ptr*;ulong*)" Global Const $sTag_INetConnection = "Connect hresult();Disconnect hresult();Delete hresult();Duplicate hresult(wstr;ptr*);GetProperties hresult(ptr)" Global Const $sTag_NETCON_PROPERTIES = "byte guidId[16];ptr pszwName;ptr pszwDeviceName;dword Status;dword MediaType;dword dwCharacter;byte clsidThisObject[16];byte clsidUiObject[16]" Func NetWorkEnableDisable($sNetWorkName, $bEnable_Disable = true) Local $hResult = 0 Local $iCount = 0 Local $pIEnumNetConnection = 0 Local $oIEnumNetConnection = 0 Local $pConnection = 0 Local $tNETCON_PROPERTIES = 0 Local $tName = 0 Local $sNetName = "" Local $tDeviceName = 0 Local $oConnection = 0 Local $pPROPERTIES = 0 Local $tPtr = 0 Local $iState=0 Local $oNetCManager = ObjCreateInterface($sCLSID_ConnectionManager, $sIID_INetConnectionManager, $sINetConnectionManager) If IsObj($oNetCManager) Then ConsoleWrite("$oNetCManager:" & IsObj($oNetCManager) & @CRLF) $oNetCManager.EnumConnections($NCME_DEFAULT, $pIEnumNetConnection) If $pIEnumNetConnection Then ConsoleWrite("$pIEnumNetConnection: " & $pIEnumNetConnection & @CRLF) $oIEnumNetConnection = ObjCreateInterface($pIEnumNetConnection, $sIID_IEnumNetConnection, $sTag_IEnumNetConnection) If IsObj($oIEnumNetConnection) Then ConsoleWrite("$oIEnumNetConnection: " & IsObj($oIEnumNetConnection) & @CRLF) While ($oIEnumNetConnection.Next(1, $pConnection, $iCount) = $S_OK) ConsoleWrite("$pConnection: " & $pConnection & " $iCount: " & $iCount & @CRLF) $oConnection = ObjCreateInterface($pConnection, $sIID_INetConnection, $sTag_INetConnection) If IsObj($oConnection) Then $tNETCON_PROPERTIES = DllStructCreate($sTag_NETCON_PROPERTIES) $tPtr = DllStructCreate("ptr Pointer") ConsoleWrite("$oConnection: " & IsObj($oConnection) & @CRLF) $hResult = $oConnection.GetProperties(DllStructGetPtr($tPtr)) If SUCCEEDED($hResult) Then $tNETCON_PROPERTIES = DllStructCreate($sTag_NETCON_PROPERTIES, $tPtr.Pointer) $tName = DllStructCreate("wchar[260]", $tNETCON_PROPERTIES.pszwName) $sNetName = DllStructGetData($tName, 1) If $bEnable_Disable Then If $sNetName = $sNetWorkName Then If SUCCEEDED($oConnection.Connect()) Then DllCall("netshell.dll", "none", "NcFreeNetconProperties", "ptr", DllStructGetPtr($tNETCON_PROPERTIES)) Return True EndIf EndIf Else If $sNetName = $sNetWorkName Then If SUCCEEDED($oConnection.Disconnect()) Then DllCall("netshell.dll", "none", "NcFreeNetconProperties", "ptr", DllStructGetPtr($tNETCON_PROPERTIES)) Return True EndIf EndIf EndIf DllCall("netshell.dll", "none", "NcFreeNetconProperties", "ptr", DllStructGetPtr($tNETCON_PROPERTIES)) $tPtr = 0 $tName = 0 $tNETCON_PROPERTIES = 0 $oConnection = 0 Else Return False EndIf Else Return False EndIf WEnd Else Return False EndIf Else Return False EndIf Else Return False EndIf EndFunc ;==>NetWorkEnableDisable Func SUCCEEDED($hr) Return ($hr >= 0) EndFunc ;==>SUCCEEDED Saludos
    1 point
  2. $xml = "<channels><channel ID='2' url='http://videe.com/index.php/channel/3a9a071' name='Guest1588664 live from Android' quality='best'/> <channel ID='3' url='http://videe.com/index.php/channel/ea579cc92d' name='boulon live' quality='best'/> <channel ID='4' url='http://videe.com/index.php/channel/290a3a52b' name='frank11262' quality='best'/> <channel ID='5' url='http://videe.com/index.php/channel/ab6c066e' name='REAL MADRID # LIVERPOOL 19:45 gmt' quality='best'/> </channels>" $oXML = ObjCreate("Microsoft.XMLDOM") $oXML.loadXML($xml) $oChannels = $oXML.selectNodes("//channel") For $oChannel In $oChannels ConsoleWrite($oChannel.getAttribute("name") & @crlf) ConsoleWrite($oChannel.getAttribute("url") & @crlf) Next
    1 point
  3. Spider001

    transfer to autoit

    that example from kylomas is verry good. I'am busy to understand it and what all things do and how. Give me some time and when i'am feeling i'am not going forward again i come back to here with the code i already have on that time. thanks for your post kylomas
    1 point
  4. The fancybox is just a some html within a div. Find the div and then locate the desired button within it. If you need further help, post a link to a website and your sample script to show what you've tried thus far.
    1 point
  5. You didn't specify, so I assume you are using IE. The following should work as long as the website is using a recent version of fancybox: Local $result = $oIE.document.parentwindow.eval('$.fancybox.isOpen;') MsgBox(0, "Result", $result)
    1 point
  6. SmOke_N

    Analyse math calculations

    And yet more... had to format those strings that didn't have all the brackets correctly ... and this stupid string obsession is over... if you find the errors, you fix'em Global $ga_Equation[] = [ _ "(8 + (7 * 4) - (3 *(2 / 7)))", _ "8 + 7 * 4 - 3 * 2 / 7", _ "8 + 7 * (4 - 3) * 2 / 7"] Global $ga_Arr = 0 For $i = 0 To UBound($ga_Equation) - 1 $ga_Arr = _getMathBreakDown($ga_Equation[$i]) _simpleArray2Cons($ga_Arr, 1) ConsoleWrite("----" & @CRLF) Next Func _getMathBreakDown($s_str) Local $s_ret = $s_str Local $s_hold = $s_str Local $s_tmp = __formatMathBreakDown($s_str) If $s_tmp <> $s_str Then $s_ret &= @LF & $s_tmp $s_str = $s_tmp EndIf While 1 $s_tmp = __getParenthesisItems($s_str) If @error Then ExitLoop $s_str = StringRegExpReplace($s_str, "\Q" & $s_tmp & "\E", Execute($s_tmp), 1) $s_ret &= @LF & $s_str WEnd Local $a_ret StringRegExpReplace($s_str, "[\*\-\+\^/]", "") If @extended > 1 Or $s_ret = $s_str Then ; we don't want to assume how they want to process ; the numbers sent, so parenthesis are their responsibility ; however, if they sent something with no parenthesis ; it might be fun to show them what the break down is like ; from the programs translator ; Order: ; ^, /, *, +, - ; recursion fun!!! :) $a_ret = _getMathBreakDown(_setParenthesisMathItems($s_str)) $s_ret = $s_hold <> $s_str ? $s_hold & @LF & $s_str : $s_str For $i = 1 To UBound($a_ret) - 1 If StringLen($a_ret[$i]) Then $s_ret &= @LF & $a_ret[$i] Next $s_str = $a_ret[UBound($a_ret)-1] EndIf If Not StringRegExp($s_str, "^(\d+\.?\d*|\d*\.?\d+)\z") Then $s_ret &= @LF & Execute($s_str) EndIf $a_ret = StringSplit($s_ret, @LF) Return $a_ret EndFunc Func _setParenthesisMathItems($s_str) Local Const $a_items[] = ["^","/","*","+","-"] Local $s_tmp = $s_str Local $a_ret[100][2], $a_tmp, $i_cc = 0 For $i = 0 To UBound($a_items) - 1 $a_tmp = __setParenthesisMathItems($s_str, $a_items[$i]) If Not @error Then If Mod($i_cc + 1, 100) = 0 Then ReDim $a_ret[$i_cc + 101][2] EndIf For $n = 0 To UBound($a_tmp) - 1 $a_ret[$i_cc][0] = $a_tmp[$n][0] $a_ret[$i_cc][1] = $a_tmp[$n][1] $i_cc += 1 Next EndIf Next ReDim $a_ret[$i_cc][2] If $s_str = $s_tmp Then ; error??? Return SetError(1, 0, $s_tmp) EndIf For $i = UBound($a_ret) - 1 To 0 Step - 1 $s_str = StringReplace($s_str, $a_ret[$i][0], $a_ret[$i][1], 1, 1) Next Return $s_str EndFunc Func __setParenthesisMathItems(ByRef $s_str, $s_item) Local Const $a_items[] = ["^","/","*","+","-"] Local Const $a_repitems[] = ["p","d","m","a","s"] Local $s_repl = "" For $i = 0 To UBound($a_items) - 1 If $s_item = $a_items[$i] Then $s_repl = "rep" & $a_repitems[$i] ExitLoop EndIf Next StringReplace($s_str, $s_item, "") Local $n_items = @extended If Not $n_items Then Return SetError(1, 0, 0) EndIf Local $a_temp = 0, $s_last, $a_reg, $n_ub Local $i_cc = 0, $s_repn = "", $s_tmp = $s_str While 1 $a_reg = StringRegExp($s_str, "((?:\d*\.?\d+|\d+\.?\d*|rep.\d+)\s*\" & $s_item & "\s*)", 3) If @error Then ExitLoop $n_ub = UBound($a_reg) - 1 $a_temp = StringRegExp($s_str, "(\Q" & $a_reg[$n_ub] & "\E(?:\d*\.?\d+|\d+\.?\d*|rep.\d+))", 3) If @error Then ExitLoop $s_str = StringReplace($s_str, $a_temp[0], $s_repl & StringFormat("%04d", $i_cc), -1, 1) $s_repn &= "(" & $a_temp[0] & ")|" & $s_repl & StringFormat("%04d", $i_cc) & @LF $i_cc += 1 WEnd If $s_str = $s_tmp Then Return SetError(2, 0, 0) EndIf Local $a_split = StringSplit(StringTrimRight($s_repn, 1), @LF, 2) Local $a_ret[UBound($a_split)][2], $i_cc = 0 For $i = 0 To UBound($a_split) - 1 $a_tmp = StringSplit($a_split[$i], "|") $a_ret[$i][0] = $a_tmp[2] $a_ret[$i][1] = $a_tmp[1] Next Return $a_ret EndFunc Func __getParenthesisItems($s_str) StringReplace($s_str, "(", "") Local $n_parenthesis = @extended If Not $n_parenthesis Then Return SetError(1, 0, 0) EndIf StringReplace($s_str, ")", "") If @extended <> $n_parenthesis Then Return SetError(1, 0, 0) EndIf Local $s_tmp Local $i_lftpos = 0, $i_rgtpos = 0 $i_lftpos = StringInStr($s_str, "(", 0, $n_parenthesis) $s_tmp = StringTrimLeft($s_str, $i_lftpos - 1) $i_rgtpos = StringInStr($s_tmp, ")", 0, 1) Return StringMid($s_str, $i_lftpos, $i_rgtpos) EndFunc Func __formatMathBreakDown($s_str) $s_str = StringStripWS($s_str, 7) Local $s_change = $s_str, $s_out Local $i_cc = 0, $i_ub Local $a_tmp, $a_tmp2, $a_split If StringInStr($s_str, "(", 1, 1) Then While 1 $s_tmp = __getParenthesisItems($s_change) If @error Then ExitLoop $s_change = StringReplace($s_change, $s_tmp, "rep" & StringFormat("%04d", $i_cc)) $s_out &= $s_tmp & "|" & "rep" & StringFormat("%04d", $i_cc) & @LF $i_cc += 1 WEnd $a_tmp = StringSplit(StringTrimRight($s_out, 1), @LF) Dim $a_tmp2[UBound($a_tmp) - 1][2] $i_ub = UBound($a_tmp2) For $i = 1 To UBound($a_tmp) - 1 $a_split = StringSplit($a_tmp[$i], "|") $a_tmp2[$i - 1][0] = $a_split[2] $a_tmp2[$i - 1][1] = $a_split[1] Next StringRegExpReplace($a_tmp2[$i_ub-1][1], "[\*\-\+\^/]", "") If @extended > 1 Then $a_tmp2[$i_ub - 1][1] = _setParenthesisMathItems( _ StringRegExpReplace($a_tmp2[$i_ub - 1][1], "\(|\)", "")) EndIf For $i = UBound($a_tmp2) - 1 To 0 Step -1 $s_change = StringReplace($s_change, $a_tmp2[$i][0], $a_tmp2[$i][1]) Next Return $s_change EndIf Return _setParenthesisMathItems($s_str) EndFunc Func _simpleArray2Cons(ByRef $a_arr, $n_istart = 0, $n_jstart = 0) Local $n_ub1 = UBound($a_arr) If $n_ub1 = 0 Then Return SetError(1) Local $n_ub2 = UBound($a_arr, 2) Local $s_toconsole If $n_ub2 Then For $i = $n_istart To $n_ub1 - 1 For $j = $n_jstart To $n_ub2 - 1 $s_toconsole &= "[" & $i & "][" & $j & "] = " & $a_arr[$i][$j] & @CRLF Next ConsoleWrite($s_toconsole) $s_toconsole = "" Next Return EndIf For $i = $n_istart To $n_ub1 - 1 $s_toconsole &= "[" & $i & "] = " & $a_arr[$i] & @CRLF Next ConsoleWrite($s_toconsole) EndFunc
    1 point
  7. SmOke_N

    Analyse math calculations

    Well, I went cross-eyed with the regex, and went back old school. I can see it breaking if the math fails (if values exceed scope). Global $ga_Equation[4] = [ _ "(8 + (7 * ((3 / 4) * (5 / (2 ^ (4 ^ 2))))))", _ "8 + 7 * 3 / 4 * 5 / 2 ^ 2 ^ 2", _ "8 + (7 * ((3 / 4) * (5 / (4 ^ 2))))", _ "8 + 7 * 4 - 3 *2 / 7 + 2^3"] Global $ga_Arr = 0 For $i = 0 To UBound($ga_Equation) - 1 $ga_Arr = _getMathBreakDown($ga_Equation[$i]) _simpleArray2Cons($ga_Arr, 1) ConsoleWrite("----" & @CRLF) Next Func _getMathBreakDown($s_str) Local $s_ret = $s_str While 1 $s_tmp = __getParenthesisItems($s_str) If @error Then ExitLoop $s_str = StringRegExpReplace($s_str, "\Q" & $s_tmp & "\E", Execute($s_tmp), 1) $s_ret &= @LF & $s_str WEnd Local $a_ret If $s_ret = $s_str Then ; we don't want to assume how they want to process ; the numbers sent, so parenthesis are their responsibility ; however, if they sent something with no parenthesis ; it might be fun to show them what the break down is like ; from the programs translator ; Order: ; ^, /, *, +, - ; recursion fun!!! :) $a_ret = _getMathBreakDown(_setParenthesisMathItems($s_str)) $s_ret = $s_str For $i = 1 To UBound($a_ret) - 1 If StringLen($a_ret[$i]) Then $s_ret &= @LF & $a_ret[$i] Next $s_str = $a_ret[UBound($a_ret)-1] EndIf If Not StringRegExp($s_str, "^(\d+\.?\d*|\d*\.?\d+)\z") Then $s_ret &= @LF & Execute($s_str) EndIf $a_ret = StringSplit($s_ret, @LF) Return $a_ret EndFunc Func _setParenthesisMathItems($s_str) Local Const $a_items[] = ["^","/","*","+","-"] Local $s_tmp = $s_str Local $a_ret[100][2], $a_tmp, $i_cc = 0 For $i = 0 To UBound($a_items) - 1 $a_tmp = __setParenthesisMathItems($s_str, $a_items[$i]) If Not @error Then If Mod($i_cc + 1, 100) = 0 Then ReDim $a_ret[$i_cc + 101][2] EndIf For $n = 0 To UBound($a_tmp) - 1 $a_ret[$i_cc][0] = $a_tmp[$n][0] $a_ret[$i_cc][1] = $a_tmp[$n][1] $i_cc += 1 Next EndIf Next ReDim $a_ret[$i_cc][2] If $s_str = $s_tmp Then ; error??? Return SetError(1, 0, $s_tmp) EndIf For $i = UBound($a_ret) - 1 To 0 Step - 1 $s_str = StringReplace($s_str, $a_ret[$i][0], $a_ret[$i][1], 1, 1) Next Return $s_str EndFunc Func __setParenthesisMathItems(ByRef $s_str, $s_item) Local Const $a_items[] = ["^","/","*","+","-"] Local Const $a_repitems[] = ["p","d","m","a","s"] Local $s_repl = "" For $i = 0 To UBound($a_items) - 1 If $s_item = $a_items[$i] Then $s_repl = "rep" & $a_repitems[$i] ExitLoop EndIf Next StringReplace($s_str, $s_item, "") Local $n_items = @extended If Not $n_items Then Return SetError(1, 0, 0) EndIf Local $a_temp = 0, $s_last, $a_reg, $n_ub Local $i_cc = 0, $s_repn = "", $s_tmp = $s_str While 1 $a_reg = StringRegExp($s_str, "((?:\d*\.?\d+|\d+\.?\d*|rep.\d+)\s*\" & $s_item & "\s*)", 3) If @error Then ExitLoop $n_ub = UBound($a_reg) - 1 $a_temp = StringRegExp($s_str, "(\Q" & $a_reg[$n_ub] & "\E(?:\d*\.?\d+|\d+\.?\d*|rep.\d+))", 3) If @error Then ExitLoop $s_str = StringReplace($s_str, $a_temp[0], $s_repl & $i_cc, -1, 1) $s_repn &= "(" & $a_temp[0] & ")|" & $s_repl & $i_cc & @LF $i_cc += 1 WEnd If $s_str = $s_tmp Then Return SetError(2, 0, 0) EndIf Local $a_split = StringSplit(StringTrimRight($s_repn, 1), @LF, 2) Local $a_ret[UBound($a_split)][2], $i_cc = 0 For $i = 0 To UBound($a_split) - 1 $a_tmp = StringSplit($a_split[$i], "|") $a_ret[$i][0] = $a_tmp[2] $a_ret[$i][1] = $a_tmp[1] Next Return $a_ret EndFunc Func __getParenthesisItems($s_str) StringReplace($s_str, "(", "") Local $n_parenthesis = @extended If Not $n_parenthesis Then Return SetError(1, 0, 0) EndIf StringReplace($s_str, ")", "") If @extended <> $n_parenthesis Then Return SetError(1, 0, 0) EndIf Local $s_tmp Local $i_lftpos = 0, $i_rgtpos = 0 $i_lftpos = StringInStr($s_str, "(", 0, $n_parenthesis) $s_tmp = StringTrimLeft($s_str, $i_lftpos - 1) $i_rgtpos = StringInStr($s_tmp, ")", 0, 1) Return StringMid($s_str, $i_lftpos, $i_rgtpos) EndFunc Func _simpleArray2Cons(ByRef $a_arr, $n_istart = 0, $n_jstart = 0) Local $n_ub1 = UBound($a_arr) If $n_ub1 = 0 Then Return SetError(1) Local $n_ub2 = UBound($a_arr, 2) Local $s_toconsole If $n_ub2 Then For $i = $n_istart To $n_ub1 - 1 For $j = $n_jstart To $n_ub2 - 1 $s_toconsole &= "[" & $i & "][" & $j & "] = " & $a_arr[$i][$j] & @CRLF Next ConsoleWrite($s_toconsole) $s_toconsole = "" Next Return EndIf For $i = $n_istart To $n_ub1 - 1 $s_toconsole &= "[" & $i & "] = " & $a_arr[$i] & @CRLF Next ConsoleWrite($s_toconsole) EndFunc
    1 point
  8. I can help you write some code but I need a working website to test it on. Can you provide the web address or another one like it? Edit - I made this for a guy on the forums that taked am html file and gets all the specific links from it and puts it into an array: #include <array.au3> #include <File.au3> #include <String.au3> Global $temp Global $aArray[0] $temp = FileRead(@ScriptDir & '\Syncron Solutions - User.htm');get your url and put it here $aArray = _StringBetween($temp,'<li class="duallist-item"','">',1);Change the info in the () to the common start and end of the string _ArrayDisplay($aArray)
    1 point
  9. I avoid using globals in include files like the plague, but if global variables are required, they should be named to be unique to the include. I sometimes go through a process of updateing a downloaded UDF to rename its global variables before I use it. Unfortunately, I also end up needing to rename some functions to avoid duplicates as well. Global $MYUDF_MyVar and Func _MYUDF_MyFunc() isn't that tough to do, is it?
    1 point
  10. wolf9228

    BBCODE TO HTML

    All Files BBCode.zip In this example is convert BBCode to HTML language BBCode.au3 #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <File.au3> Func GetCoordinatesOfBBCode($BBCodeText) Local $OpenSquare = "(?:\[)" , $ClosSquare = "(?:\])" Local $nOffset = 1,$uOffset = 0,$CodeArray[7] Local $nRtArray = StringRegExp($BBCodeText,$OpenSquare,3,1) if (@error) Then Return SetError(1,0,0) Local $UBound = UBound($nRtArray) For $i = 1 To $UBound StringRegExp($BBCodeText,$OpenSquare,1,$nOffset) If @error = 0 Then $nOffset = @extended StringRegExp($BBCodeText,$ClosSquare,1,$nOffset) If @error = 0 Then $uOffset = @extended Local $nLen = (($uOffset - $nOffset) - 1), $EqualString = "" Local $CodeName = StringStripWS(StringMid($BBCodeText,$nOffset,$nLen),3),$nCodeName = $CodeName $CodeName = StringUpper($CodeName) $IsEquals = StringInStr($CodeName,"=") if ($IsEquals) Then $EqualString = StringStripWS(StringMid($nCodeName,$IsEquals + 1,-1),3) $CodeName = StringStripWS(StringMid($CodeName,1,$IsEquals - 1),3) EndIf $IsSlash = StringInStr($CodeName,"/") if ($IsSlash) Then ContinueLoop Select Case StringCompare($CodeName,"EMAIL") == 0 Case StringCompare($CodeName,"URL") == 0 Case StringCompare($CodeName,"IMG") == 0 Case StringCompare($CodeName,"NOPARSE") == 0 Case StringCompare($CodeName,"LEFT") == 0 Case StringCompare($CodeName,"CENTER") == 0 Case StringCompare($CodeName,"RIGHT") == 0 Case StringCompare($CodeName,"FONT") == 0 Case StringCompare($CodeName,"SIZE") == 0 Case StringCompare($CodeName,"COLOR") == 0 Case StringCompare($CodeName,"U") == 0 Case StringCompare($CodeName,"I") == 0 Case StringCompare($CodeName,"B") == 0 Case Else ContinueLoop EndSelect Local $wnOffset = $uOffset,$wuOffset = 0 For $j = $i To $UBound StringRegExp($BBCodeText,$OpenSquare,1,$wnOffset) If @error = 0 Then $wnOffset = @extended StringRegExp($BBCodeText,$ClosSquare,1,$wnOffset) If @error = 0 Then $wuOffset = @extended Local $wnLen = (($wuOffset - $wnOffset) - 1) Local $wCodeName = StringStripWS(StringMid($BBCodeText,$wnOffset,$wnLen),3) $IsSlash = StringInStr($wCodeName,"/") if Not($IsSlash) Then ContinueLoop $wCodeName = StringUpper(StringStripWS(StringMid($wCodeName,$IsSlash + 1,-1),3)) Select Case StringCompare($wCodeName,"EMAIL") == 0 Case StringCompare($wCodeName,"URL") == 0 Case StringCompare($wCodeName,"IMG") == 0 Case StringCompare($wCodeName,"NOPARSE") == 0 Case StringCompare($wCodeName,"LEFT") == 0 Case StringCompare($wCodeName,"CENTER") == 0 Case StringCompare($wCodeName,"RIGHT") == 0 Case StringCompare($wCodeName,"FONT") == 0 Case StringCompare($wCodeName,"SIZE") == 0 Case StringCompare($wCodeName,"COLOR") == 0 Case StringCompare($wCodeName,"U") == 0 Case StringCompare($wCodeName,"I") == 0 Case StringCompare($wCodeName,"B") == 0 Case Else ContinueLoop EndSelect if StringCompare($wCodeName,$CodeName) = 0 Then $nTest = True ;[BBCode].....[/BBCode] $CodeArray[0] = $CodeName ;Name Of BBCode $CodeArray[1] = $nOffset ;position Of First Open Square Bracket ; [BBCode $CodeArray[2] = $uOffset ;position Of First Clos Square Bracket ; BBCode] $CodeArray[3] = $wnOffset ;position Of Next Open Square Bracket ; [/BBCode $CodeArray[4] = $wuOffset ;position Of Next Clos Square Bracket ; /BBCode] $CodeArray[5] = (($wnOffset - $uOffset) - 1) ; The length of the middle string ]...String...[ $CodeArray[6] = $EqualString ;String after the equals sign Return SetError(0,$UBound,$CodeArray) EndIf Else ExitLoop EndIf Else ExitLoop EndIf Next Else ExitLoop EndIf Else ExitLoop EndIf Next Return SetError(2,0,0) EndFunc Func BBCodeToHtml($BBCodeText,$ProgressBar = 0) $BBCodeText = StringReplace($BBCodeText,"&", "&amp;") $BBCodeText = StringReplace($BBCodeText,"<", "&lt;") $BBCodeText = StringReplace($BBCodeText,">", "&gt;") $BBCodeText = StringReplace($BBCodeText,'"', "&quot;") $BBCodeText = StringReplace($BBCodeText,"'", "&#039;"); $BBCodeText = StringReplace($BBCodeText,@CR,'<br />' & @CR) if ($ProgressBar) Then GUICtrlSetData($progressbar,0) Local $iProg = 0 ,$CodeArray = 0 , $Prog = 0 While 1 $CodeArray = GetCoordinatesOfBBCode($BBCodeText) if @error Then ExitLoop if Not($Prog) Then $Prog = @extended / 2 if ($ProgressBar) Then GUICtrlSetData($ProgressBar,(100 / $Prog) * (($iProg + 1))) Local $CodeName = $CodeArray[0] Local $PonA = $CodeArray[2] Local $PonB = $CodeArray[3] Local $MidLen = $CodeArray[5] Local $EqualString = $CodeArray[6] Local $StaA = ($CodeArray[1] - 1) Local $EndA = $CodeArray[2] Local $StaB = ($CodeArray[3] - 1) Local $EndB = $CodeArray[4] Select Case StringCompare($CodeName,"EMAIL") == 0 if $EqualString == "" Then $AStr = StringMid($BBCodeText,1,$StaA - 1) $BStr = StringMid($BBCodeText,$EndA,$MidLen) $CStr = StringMid($BBCodeText,$EndB,-1) $BBCodeText = $AStr & '<a href="mailto:' & $BStr & '">' & $BStr & '</a><br />' & $CStr Else $AStr = StringMid($BBCodeText,1,$StaA - 1) $BStr = StringMid($BBCodeText,$EndA,$MidLen) $CStr = StringMid($BBCodeText,$EndB,-1) $BBCodeText = $AStr & '<a href="mailto:' & $EqualString & '">' & $BStr & '</a><br />' & $CStr EndIf Case StringCompare($CodeName,"URL") == 0 if $EqualString == "" Then $AStr = StringMid($BBCodeText,1,$StaA - 1) $BStr = StringMid($BBCodeText,$EndA,$MidLen) $CStr = StringMid($BBCodeText,$EndB,-1) $BBCodeText = $AStr & '<a href="' & $BStr & '" target="_self">' & $BStr & '</a><br />' & $CStr Else $AStr = StringMid($BBCodeText,1,$StaA - 1) $BStr = StringMid($BBCodeText,$EndA,$MidLen) $CStr = StringMid($BBCodeText,$EndB,-1) $BBCodeText = $AStr & '<a href="' & $EqualString & '" target="_self">' & $BStr & '</a><br />' & $CStr EndIf Case StringCompare($CodeName,"IMG") == 0 $AStr = StringMid($BBCodeText,1,$StaA - 1) $BStr = StringMid($BBCodeText,$EndA,$MidLen) $CStr = StringMid($BBCodeText,$EndB,-1) if FileExists($BStr) Then $BStr = "file:///" & StringReplace(StringReplace($BStr,"\","/")," ","%20") $BBCodeText = $AStr & '<img src="' & $BStr & '" border="0" alt="" />' & $CStr Case StringCompare($CodeName,"NOPARSE") == 0 $AStr = StringMid($BBCodeText,1,$StaA - 1) $BStr = StringMid($BBCodeText,$EndA,$MidLen) $CStr = StringMid($BBCodeText,$EndB,-1) $BStr = StringReplace($BStr,"[","&#91;") $BStr = StringReplace($BStr,"]","&#93;") $BBCodeText = $AStr & '<div class="desc">' & $BStr & '</div>' & $CStr Case StringCompare($CodeName,"LEFT") == 0 $AStr = StringMid($BBCodeText,1,$StaA - 1) $BStr = StringMid($BBCodeText,$EndA,$MidLen) $CStr = StringMid($BBCodeText,$EndB,-1) $BBCodeText = $AStr & '<div align="left">' & $BStr & '</div>' & $CStr Case StringCompare($CodeName,"CENTER") == 0 $AStr = StringMid($BBCodeText,1,$StaA - 1) $BStr = StringMid($BBCodeText,$EndA,$MidLen) $CStr = StringMid($BBCodeText,$EndB,-1) $BBCodeText = $AStr & '<div align="center">' & $BStr & '</div>' & $CStr Case StringCompare($CodeName,"RIGHT") == 0 $AStr = StringMid($BBCodeText,1,$StaA - 1) $BStr = StringMid($BBCodeText,$EndA,$MidLen) $CStr = StringMid($BBCodeText,$EndB,-1) $BBCodeText = $AStr & '<div align="right">' & $BStr & '</div>' & $CStr Case StringCompare($CodeName,"FONT") == 0 $AStr = StringMid($BBCodeText,1,$StaA - 1) $BStr = $EqualString $CStr = StringMid($BBCodeText,$EndA,$MidLen) $DStr = StringMid($BBCodeText,$EndB,-1) $BBCodeText = $AStr & '<font face=' & $BStr & '>' & $CStr & '</font>' & $DStr Case StringCompare($CodeName,"SIZE") == 0 $AStr = StringMid($BBCodeText,1,$StaA - 1) $BStr = $EqualString $CStr = StringMid($BBCodeText,$EndA,$MidLen) $DStr = StringMid($BBCodeText,$EndB,-1) $BBCodeText = $AStr & '<font size=' & $BStr & '>' & $CStr & '</font>' & $DStr Case StringCompare($CodeName,"COLOR") == 0 $AStr = StringMid($BBCodeText,1,$StaA - 1) $BStr = $EqualString $CStr = StringMid($BBCodeText,$EndA,$MidLen) $DStr = StringMid($BBCodeText,$EndB,-1) $BBCodeText = $AStr & '<font color=' & $BStr & '>' & $CStr & '</font>' & $DStr Case StringCompare($CodeName,"U") == 0 $AStr = StringMid($BBCodeText,1,$StaA - 1) $BStr = StringMid($BBCodeText,$EndA,$MidLen) $CStr = StringMid($BBCodeText,$EndB,-1) $BBCodeText = $AStr & '<u>' & $BStr & '</u>' & $CStr Case StringCompare($CodeName,"I") == 0 $AStr = StringMid($BBCodeText,1,$StaA - 1) $BStr = StringMid($BBCodeText,$EndA,$MidLen) $CStr = StringMid($BBCodeText,$EndB,-1) $BBCodeText = $AStr & '<i>' & $BStr & '</i>' & $CStr Case StringCompare($CodeName,"B") == 0 $AStr = StringMid($BBCodeText,1,$StaA - 1) $BStr = StringMid($BBCodeText,$EndA,$MidLen) $CStr = StringMid($BBCodeText,$EndB,-1) $BBCodeText = $AStr & '<b>' & $BStr & '</b>' & $CStr Case Else $AStr = StringMid($BBCodeText,1,$StaA - 1) $BStr = StringMid($BBCodeText,$StaA,($EndB - $StaA)) $CStr = StringMid($BBCodeText,$EndB,-1) $BStr = StringReplace($BStr,"[","&#91;") $BStr = StringReplace($BStr,"]","&#93;") $BBCodeText = $AStr & $BStr & $CStr EndSelect $iProg += 1 WEnd if ($ProgressBar) Then GUICtrlSetData($progressbar,0) Return $BBCodeText EndFunc Func ViewFunc($BBCodeText,$hGUI = 0) $HtmlText = '<html>' & @CRLF $HtmlText &= "<head>" & @CRLF $HtmlText &= "</head>" & @CRLF $HtmlText &= "<body>" & @CRLF $HtmlText &= $BBCodeText & @CRLF $HtmlText &= "</body>" & @CRLF $HtmlText &= "</html>" & @CRLF $oIE = ObjCreate("Shell.Explorer.2") if Not IsObj($oIE) Then Return SetError(1,0,False) $BStr = _TempFile(@TempDir & "\", "prefix_", ".htm", Default) $FileOpen = FileOpen($BStr,2) if @error Then Return SetError(2,0,False) FileWrite($FileOpen,$HtmlText) $TrayWnd = WinGetHandle("[CLASS:Shell_TrayWnd]") $Pos = WinGetPos($TrayWnd) $BBCodeGui = GUICreate("View", @DesktopWidth, @DesktopHeight - $Pos[3] - 30,0, 0) GUISetBkColor(15790320) GUISetFont(12, 400, 0, "MS Sans Serif") $GUIActiveX = GUICtrlCreateObj($oIE, 0, 30, @DesktopWidth - 10, (@DesktopHeight - ($Pos[3] + 70))) $Close = GUICtrlCreateButton("Close", (@DesktopWidth - 120) / 2,2,120,25) GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") if ($hGUI) Then GUISwitch($BBCodeGui) FileClose($FileOpen) $BStr = "file:///" & StringReplace(StringReplace($BStr,"\","/")," ","%20") $oIE.navigate($BStr) GUISetState() $oIE.document.execCommand("Refresh") While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Or $msg = $Close if ($hGUI) Then GUIDelete($BBCodeGui) GUISwitch($hGUI) ExitLoop Else Exit EndIf EndSelect WEnd Return True EndFunc Example.au3 #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <SendMessage.au3> #include <GuiRichEdit.au3> #include <ButtonConstants.au3> #include <ComboConstants.au3> #include <StaticConstants.au3> #include <Color.au3> #include "BBCode.au3" $hGUI = GUICreate("Forums Editor",650, 335,@DesktopWidth - (650), 0) GUISetBkColor(15790320) $iButton1 = GUICtrlCreateButton( "B" ,5,5 ,75 ,25 , $BS_CENTER + $BS_BOTTOM + $WS_GROUP) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $iButton2 = GUICtrlCreateButton( "I" ,90,5 ,75 ,25 , $BS_CENTER + $BS_BOTTOM + $WS_GROUP) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $iButton3 = GUICtrlCreateButton( "U" ,175,5 ,75 ,25 , $BS_CENTER + $BS_BOTTOM + $WS_GROUP) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $iButton4 = GUICtrlCreateButton( "LEFT" ,260,5 ,80 ,25 , $BS_CENTER + $BS_BOTTOM + $WS_GROUP) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $iButton5 = GUICtrlCreateButton( "CENTER" ,350,5 ,85 ,25 , $BS_CENTER + $BS_BOTTOM + $WS_GROUP) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $iButton6 = GUICtrlCreateButton( "RIGHT" ,445,5 ,80 ,25 , $BS_CENTER + $BS_BOTTOM + $WS_GROUP) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $iButton7 = GUICtrlCreateButton( "Color" ,535,5 ,80 ,25 , $BS_CENTER + $BS_BOTTOM + $WS_GROUP) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $Combo1 = GUICtrlCreateCombo("",85, 40,160,25,BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL,$WS_BORDER), BitOR($WS_EX_CLIENTEDGE,$WS_EX_STATICEDGE)) GUICtrlSetFont(-1, 11, 800, 0, "MS Sans Serif") Dim $Font = "" $Font &= "Arial|" $Font &= "Arial Black|" $Font &= "Monotype Koufi|" $Font &= "DecoType Naskh Special|" $Font &= "Arial Narrow|" $Font &= "Book Antiqua|" $Font &= "Century Gothic|" $Font &= "Comic Sans MS|" $Font &= "Courier New|" $Font &= "Fixedsys|" $Font &= "Franklin Gothic Medium|" $Font &= "Garamond|" $Font &= "Georgia|" $Font &= "Impact|" $Font &= "Lucida Console|" $Font &= "Lucida Sans Unicode|" $Font &= "Microsoft Sans Serif|" $Font &= "Palatino Linotype|" $Font &= "System|" $Font &= "Tahoma|" $Font &= "Times New Roman|" $Font &= "Trebuchet MS|" $Font &= "Verdana|Fonts" GUICtrlSetData(-1,$Font,"Fonts") $Combo2 = GUICtrlCreateCombo("", 5, 40,70,25,BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL,$WS_BORDER), BitOR($WS_EX_CLIENTEDGE,$WS_EX_STATICEDGE)) GUICtrlSetFont(-1, 11, 800, 0, "MS Sans Serif") Dim $iFontSize = "" $iFontSize &= "1|" $iFontSize &= "2|" $iFontSize &= "3|" $iFontSize &= "4|" $iFontSize &= "5|" $iFontSize &= "6|" $iFontSize &= "7|" $iFontSize &= "8|" $iFontSize &= "9|" $iFontSize &= "10|" $iFontSize &= "11|" $iFontSize &= "12|" $iFontSize &= "13|" $iFontSize &= "14|" $iFontSize &= "15|Sizes" GUICtrlSetData(-1,$iFontSize,"Sizes") $iButton8 = GUICtrlCreateButton( "NOPARSE" ,500,40 ,115 ,25 , $BS_CENTER + $BS_BOTTOM + $WS_GROUP) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $iButton9 = GUICtrlCreateButton( "EMAIL" ,255,40 ,110 ,25 , $BS_CENTER + $BS_BOTTOM + $WS_GROUP) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $iButton10 = GUICtrlCreateButton( "Image" ,375,40 ,115 ,25 , $BS_CENTER + $BS_BOTTOM + $WS_GROUP) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $progressbar = GUICtrlCreateProgress(5, 70, 633, 10) $iButton11 = GUICtrlCreateButton("View" ,7,295 ,100,30 , $BS_CENTER + $BS_BOTTOM + $WS_GROUP) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $dwStyle = $WS_VSCROLL + $ES_AUTOVSCROLL + $ES_MULTILINE + $WS_BORDER $EditText = "[CENTER][COLOR=#FF0000][FONT=Impact][SIZE=13]Wolf9228[/SIZE][/FONT][/COLOR][/CENTER]" $hRichEdit = _GUICtrlRichEdit_Create($hGUI,$EditText,7,85,635 ,200 ,$dwStyle) Dim $aiInput[3] = [244, 244, 244] $aiRGB = _ColorSetRGB($aiInput) _GUICtrlRichEdit_SetBkColor($hRichEdit, $aiRGB) $tag_charformat = "int cbSize;DWORD dwMask;DWORD dwEffects;LONG yHeight;LONG yOffset;" & _ "int crTextColor;BYTE bCharSet;BYTE bPitchAndFamily;char szFaceName[32]" $CHARFORMAT = DllStructCreate($tag_charformat) DllStructSetData($CHARFORMAT,"cbSize",DllStructGetSize($CHARFORMAT)) DllStructSetData($CHARFORMAT,"dwMask",$CFM_SIZE) DllStructSetData($CHARFORMAT,"yHeight",14 * 20) _SendMessage($hRichEdit, $EM_SETCHARFORMAT, $SCF_DEFAULT,DllStructGetPtr($CHARFORMAT)) $CHARFORMAT = DllStructCreate($tag_charformat) DllStructSetData($CHARFORMAT,"cbSize",DllStructGetSize($CHARFORMAT)) DllStructSetData($CHARFORMAT,"dwMask",$CFM_FACE) DllStructSetData($CHARFORMAT,"szFaceName",'Arial') _SendMessage($hRichEdit,$EM_SETCHARFORMAT, $SCF_DEFAULT,DllStructGetPtr($CHARFORMAT)) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE _GUICtrlRichEdit_Destroy($hRichEdit) ExitLoop Case $msg = $Combo1 if ("Fonts" == GUICtrlRead($Combo1)) Then _WinAPI_SetFocus($hRichEdit) ContinueLoop EndIf Add_CodeA("FONT=" & GUICtrlRead($Combo1)) Case $msg = $Combo2 if ("Sizes" == GUICtrlRead($Combo2)) Then _WinAPI_SetFocus($hRichEdit) ContinueLoop EndIf Add_CodeA("SIZE=" & GUICtrlRead($Combo2)) _WinAPI_SetFocus($hRichEdit) Case $msg = $iButton1 Add_CodeA("B") _WinAPI_SetFocus($hRichEdit) Case $msg = $iButton2 Add_CodeA("I") _WinAPI_SetFocus($hRichEdit) Case $msg = $iButton3 Add_CodeA("U") _WinAPI_SetFocus($hRichEdit) Case $msg = $iButton4 Add_CodeA("LEFT") _WinAPI_SetFocus($hRichEdit) Case $msg = $iButton5 Add_CodeA("CENTER") _WinAPI_SetFocus($hRichEdit) Case $msg = $iButton6 Add_CodeA("RIGHT") _WinAPI_SetFocus($hRichEdit) Case $msg = $iButton7 if Not _GUICtrlRichEdit_IsTextSelected($hRichEdit) Then _WinAPI_SetFocus($hRichEdit) $Pos = WinGetPos($hGUI) $Text = "You must select the text" $Form1 = GUICreate("MSG", 372, 77, $Pos[0],$Pos[1] + (($Pos[3] / 2) - (77 / 2))) GUISetBkColor(15790320) $Label1X = GUICtrlCreateLabel($Text, 5, 5, 360, 30, _ BitOR($SS_CENTER,$SS_CENTERIMAGE,$WS_BORDER)) GUICtrlSetFont(-1, 13, 800, 0, "MS Sans Serif") GUICtrlSetBkColor(-1, 0xFFFFFF) $Button1X = GUICtrlCreateButton("OK", (372 / 2) - (169 / 2), 42, 169, 30, $WS_GROUP) GUICtrlSetFont(-1, 15, 800, 0, "Arial") GUISetState(@SW_SHOW,$Form1) GUISwitch($Form1) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE , $Button1X ExitLoop EndSwitch WEnd GUIDelete($Form1) GUISwitch($hGUI) _WinAPI_SetFocus($hRichEdit) Else $Color = _ChooseColor(2, 0x0080C0, 2, $hGUI) if Not @error Then Add_CodeA("COLOR=#" & StringTrimLeft($Color,2)) EndIf EndIf _WinAPI_SetFocus($hRichEdit) Case $msg = $iButton8 Add_CodeA("NOPARSE") _WinAPI_SetFocus($hRichEdit) Case $msg = $iButton9 Add_EmailCode() _WinAPI_SetFocus($hRichEdit) Case $msg = $iButton10 Add_ImageCode() _WinAPI_SetFocus($hRichEdit) Case $msg = $iButton11 $BBCodeText = _GUICtrlRichEdit_GetText($hRichEdit) _WinAPI_SetFocus($hRichEdit) $BBCodeText = BBCodeToHtml($BBCodeText,$progressbar) ViewFunc($BBCodeText,$hGUI) EndSelect WEnd Exit Func Add_CodeA($CodeStr) $Pos = WinGetPos($hGUI) _WinAPI_SetFocus($hRichEdit) if _GUICtrlRichEdit_IsTextSelected($hRichEdit) Then $Array = _GUICtrlRichEdit_GetSel($hRichEdit) _GUICtrlRichEdit_SetSel($hRichEdit,$Array[0],$Array[0]) $StringSplit1 = StringSplit("[" & $CodeStr & "]","") For $i = 1 To $StringSplit1[0] _SendMessage($hRichEdit,$WM_CHAR, AscW($StringSplit1[$i]),0) Next _GUICtrlRichEdit_SetSel($hRichEdit,$Array[1] + $StringSplit1[0],$Array[1] + $StringSplit1[0]) $position = StringInStr($CodeStr,"=") if ($position) Then $CodeStr = StringMid($CodeStr,1,($position - 1)) $StringSplit2 = StringSplit("[/" & $CodeStr & "]","") For $i = 1 To $StringSplit2[0] _SendMessage($hRichEdit,$WM_CHAR, AscW($StringSplit2[$i]),0) Next _GUICtrlRichEdit_SetSel($hRichEdit,$Array[0],$Array[1] + $StringSplit1[0] + $i) Else $Text = "You must select the text" $Form1 = GUICreate("MSG", 372, 77, $Pos[0],$Pos[1] + (($Pos[3] / 2) - (77 / 2))) GUISetBkColor(15790320) $Label1X = GUICtrlCreateLabel($Text, 5, 5, 360, 30, _ BitOR($SS_CENTER,$SS_CENTERIMAGE,$WS_BORDER)) GUICtrlSetFont(-1, 13, 800, 0, "MS Sans Serif") GUICtrlSetBkColor(-1, 0xFFFFFF) $Button1X = GUICtrlCreateButton("OK", (372 / 2) - (169 / 2), 42, 169, 30, $WS_GROUP) GUICtrlSetFont(-1, 15, 800, 0, "Arial") GUISetState(@SW_SHOW,$Form1) GUISwitch($Form1) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE , $Button1X ExitLoop EndSwitch WEnd GUIDelete($Form1) GUISwitch($hGUI) EndIf _WinAPI_SetFocus($hRichEdit) EndFunc Func Add_EmailCode() $Pos = WinGetPos($hGUI) Local $URText = "SendEmail" , $UrTest = False $Array = _GUICtrlRichEdit_GetSel($hRichEdit) if _GUICtrlRichEdit_IsTextSelected($hRichEdit) Then $URText = _GUICtrlRichEdit_GetSelText($hRichEdit) $UrTest = True EndIf $Form3 = GUICreate("Email", 320, 150, $Pos[0],$Pos[1] + (($Pos[3] / 2) - (150 / 2))) GUISetBkColor(15790320) $Input1 = GUICtrlCreateInput($URText, 5, 35,310, 23,BitOR($ES_CENTER,$ES_AUTOHSCROLL)) GUICtrlSetFont(-1, 13, 800, 0, "MS Sans Serif") GUICtrlSetState(-1, $GUI_DISABLE) $Label1 = GUICtrlCreateLabel("Email Text", 5, 5, 310, 25, _ BitOR($SS_CENTER,$SS_CENTERIMAGE,$WS_BORDER)) GUICtrlSetFont(-1, 13, 800, 0, "MS Sans Serif") GUICtrlSetBkColor(-1, 0xFFFFFF) GUICtrlSetState(-1, $GUI_DISABLE) $Input2 = GUICtrlCreateInput("oman9228@hotmail.com", 5, 35 + 63,310, 23,BitOR($ES_CENTER,$ES_AUTOHSCROLL)) GUICtrlSetFont(-1, 13, 800, 0, "MS Sans Serif") $Label2 = GUICtrlCreateLabel("Email Url", 5, 5 + 63, 310, 25, _ BitOR($SS_CENTER,$SS_CENTERIMAGE,$WS_BORDER)) GUICtrlSetFont(-1, 13, 800, 0, "MS Sans Serif") GUICtrlSetBkColor(-1, 0xFFFFFF) $Checkbox1 = GUICtrlCreateCheckbox("Advanced", 5, 126, 150, 23, BitOR($BS_CHECKBOX,$BS_AUTOCHECKBOX,$BS_CENTER,$WS_TABSTOP,$WS_BORDER)) GUICtrlSetFont(-1, 13, 800, 0, "MS Sans Serif") GUICtrlSetBkColor(-1, 0xFFFFFF) GUICtrlSetState(-1, $GUI_UNCHECKED) $Button1 = GUICtrlCreateButton("Ok", 160, 126,150, 23, $WS_GROUP) GUICtrlSetFont(-1, 13, 800, 0, "MS Sans Serif") GUISetState(@SW_SHOW) GUISwitch($Form3) if $UrTest Then GUICtrlSetState($Label1, $GUI_DISABLE) GUICtrlSetState($Input1, $GUI_DISABLE) GUICtrlSetState($Checkbox1, $GUI_CHECKED) GUICtrlSetState($Checkbox1, $GUI_DISABLE) EndIf While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE GUIDelete($Form3) GUISwitch($hGUI) ExitLoop Case $Checkbox1 if BitAND(GUICtrlRead($Checkbox1), $GUI_CHECKED) = $GUI_CHECKED Then GUICtrlSetState($Label1, $GUI_ENABLE) GUICtrlSetState($Input1, $GUI_ENABLE) Else GUICtrlSetState($Label1, $GUI_DISABLE) GUICtrlSetState($Input1, $GUI_DISABLE) EndIf Case $Button1 if BitAND(GUICtrlRead($Checkbox1), $GUI_CHECKED) = $GUI_CHECKED Then $CodeStr = '[email=' & GUICtrlRead($Input2) & ']' & GUICtrlRead($Input1) Else $CodeStr = '[email]' & GUICtrlRead($Input2) EndIf GUIDelete($Form3) GUISwitch($hGUI) $StringSplit1 = StringSplit($CodeStr,"") For $i = 1 To $StringSplit1[0] _SendMessage($hRichEdit,$WM_CHAR, AscW($StringSplit1[$i]),0) Next _GUICtrlRichEdit_SetSel($hRichEdit,$Array[1] + $StringSplit1[0],$Array[1] + $StringSplit1[0]) $StringSplit2 = StringSplit('[/email]',"") For $i = 1 To $StringSplit2[0] _SendMessage($hRichEdit,$WM_CHAR, AscW($StringSplit2[$i]),0) Next _GUICtrlRichEdit_SetSel($hRichEdit,$Array[0],$Array[1] + $StringSplit1[0] + $i) ExitLoop EndSwitch WEnd EndFunc Func Add_ImageCode() _WinAPI_SetFocus($hRichEdit) $Pos = WinGetPos($hGUI) Local $var = "", $error = 0 Local $URText = "Image Url" , $UrTest = False if _GUICtrlRichEdit_IsTextSelected($hRichEdit) Then $URText = _GUICtrlRichEdit_GetSelText($hRichEdit) $UrTest = True EndIf $Array = _GUICtrlRichEdit_GetSel($hRichEdit) $Form3 = GUICreate("Image File", 320, 235,$Pos[0],$Pos[1] + (($Pos[3] / 2) - (235 / 2))) GUISetBkColor(15790320) $Input1 = GUICtrlCreateInput("http://www.microsoft.com/windows/Framework/images/win_logo.png", 5, 35,310, 23,BitOR($ES_CENTER,$ES_AUTOHSCROLL)) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $Button1 = GUICtrlCreateButton("FileOpenDialog", 5, 34,310, 26,$WS_GROUP) GUICtrlSetFont(-1, 13, 800, 0, "MS Sans Serif") $Label1 = GUICtrlCreateLabel("Image Url", 5, 5, 310, 25, _ BitOR($SS_CENTER,$SS_CENTERIMAGE,$WS_BORDER)) GUICtrlSetFont(-1, 13, 800, 0, "MS Sans Serif") GUICtrlSetBkColor(-1, 0xFFFFFF) $Input2 = GUICtrlCreateInput("http://www.microsoft.com/windows/default.aspx", 5, 95,310, 23,BitOR($ES_CENTER,$ES_AUTOHSCROLL)) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $Label2 = GUICtrlCreateLabel("Url", 5, 65, 310, 25, _ BitOR($SS_CENTER,$SS_CENTERIMAGE,$WS_BORDER)) GUICtrlSetFont(-1, 13, 800, 0, "MS Sans Serif") GUICtrlSetBkColor(-1, 0xFFFFFF) $Input3 = GUICtrlCreateInput($URText, 5, 153,310, 23,BitOR($ES_CENTER,$ES_AUTOHSCROLL)) GUICtrlSetFont(-1, 13, 800, 0, "MS Sans Serif") $Label3 = GUICtrlCreateLabel("Url Text", 5, 123, 310, 25, _ BitOR($SS_CENTER,$SS_CENTERIMAGE,$WS_BORDER)) GUICtrlSetFont(-1, 13, 800, 0, "MS Sans Serif") GUICtrlSetBkColor(-1, 0xFFFFFF) $Checkbox1 = GUICtrlCreateCheckbox("Image File", 5, 181, 150, 23, BitOR($BS_CHECKBOX,$BS_AUTOCHECKBOX,$BS_CENTER,$WS_TABSTOP,$WS_BORDER)) GUICtrlSetFont(-1, 13, 800, 0, "MS Sans Serif") GUICtrlSetBkColor(-1, 0xFFFFFF) GUICtrlSetState(-1, $GUI_UNCHECKED) $Checkbox2 = GUICtrlCreateCheckbox("Image Url", 160, 181,150, 23, BitOR($BS_CHECKBOX,$BS_AUTOCHECKBOX,$BS_CENTER,$WS_TABSTOP,$WS_BORDER)) GUICtrlSetFont(-1, 13, 800, 0, "MS Sans Serif") GUICtrlSetBkColor(-1, 0xFFFFFF) $Checkbox3 = GUICtrlCreateCheckbox("Advanced", 5, 209, 150, 23, BitOR($BS_CHECKBOX,$BS_AUTOCHECKBOX,$BS_CENTER,$WS_TABSTOP,$WS_BORDER)) GUICtrlSetFont(-1, 13, 800, 0, "MS Sans Serif") GUICtrlSetBkColor(-1, 0xFFFFFF) GUICtrlSetState(-1, $GUI_UNCHECKED) $Button2 = GUICtrlCreateButton("OK", 160, 208,150, 25, $WS_GROUP) GUICtrlSetFont(-1, 13, 800, 0, "MS Sans Serif") GUISetState(@SW_SHOW) GUISwitch($Form3) if $UrTest = False Then GUICtrlSetState($Label2, $GUI_DISABLE) GUICtrlSetState($Input2, $GUI_DISABLE) GUICtrlSetState($Label3, $GUI_DISABLE) GUICtrlSetState($Input3, $GUI_DISABLE) Else GUICtrlSetState($Checkbox3,$GUI_CHECKED) GUICtrlSetState($Checkbox3,$GUI_DISABLE) GUICtrlSetState($Input3,$GUI_DISABLE) EndIf GUICtrlSetState($Checkbox2,$GUI_CHECKED) GUICtrlSetState($Button1, $GUI_HIDE) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE GUIDelete($Form3) GUISwitch($hGUI) ExitLoop Case $Checkbox3 if BitAND(GUICtrlRead($Checkbox3), $GUI_CHECKED) = $GUI_CHECKED Then GUICtrlSetState($Label2, $GUI_ENABLE) GUICtrlSetState($Input2, $GUI_ENABLE) GUICtrlSetState($Label3, $GUI_ENABLE) GUICtrlSetState($Input3, $GUI_ENABLE) Else GUICtrlSetState($Label2, $GUI_DISABLE) GUICtrlSetState($Input2, $GUI_DISABLE) GUICtrlSetState($Label3, $GUI_DISABLE) GUICtrlSetState($Input3, $GUI_DISABLE) EndIf Case $Checkbox1 if BitAND(GUICtrlRead($Checkbox1), $GUI_CHECKED) = $GUI_CHECKED Then GUICtrlSetState($Checkbox2, $GUI_UNCHECKED) GUICtrlSetData($Label1,"FileOpenDialog") GUICtrlSetState($Input1, $GUI_HIDE) GUICtrlSetState($Button1, $GUI_SHOW) Else GUICtrlSetState($Checkbox2,$GUI_CHECKED) GUICtrlSetData($Label1,"Image Url") GUICtrlSetState($Input1, $GUI_SHOW) GUICtrlSetState($Button1, $GUI_HIDE) EndIf Case $Checkbox2 if BitAND(GUICtrlRead($Checkbox2), $GUI_CHECKED) = $GUI_CHECKED Then GUICtrlSetState($Checkbox1, $GUI_UNCHECKED) GUICtrlSetData($Label1,"Image Url") GUICtrlSetState($Input1, $GUI_SHOW) GUICtrlSetState($Button1, $GUI_HIDE) Else GUICtrlSetState($Checkbox1,$GUI_CHECKED) GUICtrlSetData($Label1,"FileOpenDialog") GUICtrlSetState($Input1, $GUI_HIDE) GUICtrlSetState($Button1, $GUI_SHOW) EndIf Case $Button1 $var = FileOpenDialog("FileOpenDialog", @MyDocumentsDir & "\", "Images (*.jpg;*.bmp;*.gif;*.png)", 1 + 4 ) Case $Button2 if ($var == "") And BitAND(GUICtrlRead($Checkbox1), $GUI_CHECKED) = $GUI_CHECKED Then $Form1 = GUICreate("MSG", 372, 77, $Pos[0],$Pos[1] + (($Pos[3] / 2) - (77 / 2))) GUISetBkColor(15790320) $Label1X = GUICtrlCreateLabel("You must select the image file", 5, 5, 360, 30, _ BitOR($SS_CENTER,$SS_CENTERIMAGE,$WS_BORDER)) GUICtrlSetFont(-1, 13, 800, 0, "MS Sans Serif") GUICtrlSetBkColor(-1, 0xFFFFFF) $Button1X = GUICtrlCreateButton("OK", (372 / 2) - (169 / 2), 42, 169, 30, $WS_GROUP) GUICtrlSetFont(-1, 15, 800, 0, "Arial") GUISetState(@SW_SHOW,$Form1) GUISwitch($Form1) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE , $Button1X ExitLoop EndSwitch WEnd GUIDelete($Form1) GUISwitch($Form3) ContinueLoop EndIf Local $ImagePtch = $var if BitAND(GUICtrlRead($Checkbox2), $GUI_CHECKED) = $GUI_CHECKED Then $ImagePtch = GUICtrlRead($Input1) if BitAND(GUICtrlRead($Checkbox3), $GUI_CHECKED) = $GUI_CHECKED Then $CodeStr = '[url=' & GUICtrlRead($Input2) & '] [img]' & $ImagePtch & '[/img] [/url] (' & GUICtrlRead($Input3) & ')' Else $CodeStr = '[img]' & $ImagePtch & '[/img]' EndIf GUIDelete($Form3) GUISwitch($hGUI) _WinAPI_SetFocus($hRichEdit) $StringSplit1 = StringSplit($CodeStr,"") For $i = 1 To $StringSplit1[0] _SendMessage($hRichEdit,$WM_CHAR, AscW($StringSplit1[$i]),0) Next _GUICtrlRichEdit_SetSel($hRichEdit,$Array[0],$Array[0] + $i) ExitLoop EndSwitch WEnd EndFunc
    1 point
  11. JohnOne

    Any udf to record sound?

    This works for me WIN 7 32 $sExe = "C:\Windows\system32\soundrecorder.exe /file C:\Users\john\Desktop\sndrectest\wav.wav /duration 00:00:30" Run($sExe)
    1 point
×
×
  • Create New...