Darklord Posted December 1, 2007 Share Posted December 1, 2007 (edited) Hi, i was just writing a little script that creats a gui with some buttons and a edit in it and i wanted it to get the selection of the edit and place some bbcodes around the selection. That was working fine in the old version of autoit i think it was 3.2.8.1 and today i updated to 3.2.10.0 and now the script isnt working any more. When i select the text and try to press the button the selection is removed and the text is added to the start of the string. expandcollapse popup#include <GUIConstants.au3> #include <GuiEdit.au3> #include <String.au3> Opt("WinTitleMatchMode", 4) $Form1 = GUICreate("AllyPAgeStyler", 885, 765, 150, 132) $Edit1 = GUICtrlCreateEdit("", 10, 60, 860, 660, $WS_VSCROLL) $Button1 = GUICtrlCreateButton("[b]", 20, 20, 31, 21, 0) $Button2 = GUICtrlCreateButton("[i]", 60, 20, 31, 21, 0) $Button3 = GUICtrlCreateButton("[s]", 100, 20, 31, 21, 0) $Button4 = GUICtrlCreateButton("[center]", 140, 20, 45, 21, 0) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 inserttag("[b]", "[/b]") Case $Button2 inserttag("[i]", "[/i]") Case $Button3 inserttag("[s]", "[/s]") Case $Button4 inserttag("[center]", "[/center]") EndSwitch WEnd Func inserttag($tagS, $tagE) $aSel = _GUICtrlEdit_GetSel($Edit1) $sEdit1 = _GUICtrlEdit_GetText($Edit1) If $aSel[0] = $aSel[0] Then $sEdit1_2 = StringLeft($sEdit1, $aSel[0]) $sEdit1 = $sEdit1_2 & $tagS & $tagE & StringRight($sEdit1, StringLen($sEdit1) - $aSel[0]) _GUICtrlEdit_SetText($Edit1, $sEdit1) ControlFocus("[TITLE:AllyPAgeStyler; CLASS:AutoIt v3 GUI;]", "", "[CLASS:Edit; INSTANCE:1]") _GUICtrlEdit_SetSel($Edit1, $aSel[0] + StringLen($tagS), $aSel[0] + StringLen($tagS)) ElseIf $aSel[0] <> $aSel[1] Then $sEdit1_2 = StringLeft($sEdit1, $aSel[0]) $sEdit1_3 = StringMid($sEdit1, $aSel[0] + 1, $aSel[1] - $aSel[0]) $sEdit1 = StringReplace($sEdit1, $sEdit1_3, "") $sEdit1 = $sEdit1_2 & $tagS & $sEdit1_3 & $tagE & StringRight($sEdit1, StringLen($sEdit1) - $aSel[0]) _GUICtrlEdit_SetText($Edit1, $sEdit1) ControlFocus("[TITLE:AllyPAgeStyler; CLASS:AutoIt v3 GUI;]", "", "[CLASS:Edit; INSTANCE:1]") EndIf EndFunc;==>inserttag can anyone help me? Edited December 1, 2007 by Darklord Link to comment Share on other sites More sharing options...
Darklord Posted December 1, 2007 Author Share Posted December 1, 2007 ok i solved the problem myself Link to comment Share on other sites More sharing options...
martin Posted December 1, 2007 Share Posted December 1, 2007 ok i solved the problem myself That's pretty neat. First post gives problem. No one replies. Second post says it's fixed. Maybe you could make a third post and welcome yourself to the forums!But no, I'm going to beat you to it.Welcome. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
ludocus Posted April 22, 2008 Share Posted April 22, 2008 I have this same problem.. Can you post what you fixt? Link to comment Share on other sites More sharing options...
rasim Posted April 23, 2008 Share Posted April 23, 2008 I have this same problem.. Can you post what you fixt?Try this: expandcollapse popup#include <GUIConstants.au3> #include <GuiEdit.au3> $Form1 = GUICreate("AllyPAgeStyler", 885, 765, 150, 132) $Edit1 = GUICtrlCreateEdit("", 10, 60, 860, 660, $WS_VSCROLL) $Button1 = GUICtrlCreateButton("[b]", 20, 20, 31, 21, 0) $Button2 = GUICtrlCreateButton("[i]", 60, 20, 31, 21, 0) $Button3 = GUICtrlCreateButton("[s]", 100, 20, 31, 21, 0) $Button4 = GUICtrlCreateButton("[center]", 140, 20, 45, 21, 0) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 inserttag("[b]", "[/b]") Case $Button2 inserttag("[i]", "[/i]") Case $Button3 inserttag("[s]", "[/s]") Case $Button4 inserttag("[center]", "[/center]") EndSwitch WEnd Func inserttag($tagS, $tagE) Local $aSel $aSel = _GUICtrlEdit_GetSel($Edit1) If $aSel[0] = $aSel[1] Then Return False Local $iText = _GUICtrlEdit_GetText($Edit1) $iText = StringRegExpReplace($iText, "^.{" & $aSel[0] & "}", "") $iText = StringRegExpReplace($iText, "(^.{" & $aSel[1] - $aSel[0] & "}).*", "\1") _GUICtrlEdit_ReplaceSel($Edit1, $tagS & "" & $iText & "" & $tagE) EndFunc;==>inserttag Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now