Jump to content

Default Button, not working like y'all told me to do it.


Recommended Posts

Ok, so please tell me why the send button is no longer default when i press any of the other buttons? I've tried to set it back with FOCUS but still no go. So not sure why not.

Ok, so here's the code:

#RequireAdmin
#include <zirc.au3>
#include <INet.au3>
#include <GUIConstants.au3>
#include <IE.au3>
#include <Array.au3>
#include <file.au3>
#include <Date.au3>
#include <XSkin.au3>
#include <GuiEdit.au3>
#include <GUIConstantsEx.au3>
#include <EditConstants.au3>

;-  /// Delete/Create starting configuration ///
$techs = FileOpen(@ProgramFilesDir & "\info\Chat\techs.ini", 10)
FileClose($techs)

;- /// Grab Configuration off of server ///
ToolTip("Grabing BTC Chat configuration...")
InetGet("http://myserver.com/down/techs.ini", @ProgramFilesDir & "\info\Chat\techs.ini", 1, 0)
While @InetGetActive
    Sleep(250)
WEnd
ToolTip("")

;- // Setup connection string; $server will eventually pull from config file if we ever change it //
Global $server = "irc.dal.net"
Global $port = 6667

;- /// $nick will eventually be a popup setting if blank and can be configured in the client
Global $nick = "DingleBerry"

;- /// $channel will eventually pull from the configuration file incase we ever change it
Global $channel = "#MYCHAT"

;- /// Setup constants //
$fQuery = ""
$quoteLastData = ""
$QuoteAfterHoursData = ""
$quoteAFUpDownStatus = ""
$Quotesource = ""
$quoteAFColor = ""
$quoteDelayColor = ""
$quoteAFStatus = ""
$noffset = "1"


;- /// Setup default chat color; $color will eventually be changed, however I havn't figured that one out yet ///
$color = "black"

;- /// Setup first response user; which is always system for system messages ///
$whoSent = "System"

;- // Create an embeded IE window in the application
$XT_oIE = _IECreateEmbedded()
$XT_oIE2 = _IECreateEmbedded()

;- // Create the GUI for the user interface //
$MainGui = GUICreate("Chat", 1024, 652)


;- ///////// Create Tabs /////////////////////
$ChatTab = GUICtrlCreateTab(6, 0, 1016, 626)

$tab0 = GUICtrlCreateTabItem("System")
$Obj_RCV2 = GUICtrlCreateObj($XT_oIE2, 6, 22,  1012, 596)
_IENavigate($XT_oIE2, "about:blank")
$oBody2 = _IETagNameGetCollection($XT_oIE2, "body", 0); <---------- This is new

$tab2 = GuiCtrlCreateTabItem("Chat")
$Obj_RCV = GUICtrlCreateObj($XT_oIE, 6, 22,  609, 524)
_IENavigate($XT_oIE, "about:blank")
$oBody = _IETagNameGetCollection($XT_oIE, "body", 0); <---------- This is new
$EditSend = GUICtrlCreateEdit("", 8, 550, 539, 51, $WS_VSCROLL)
$Send = GUICtrlCreateButton("Send", 550, 550, 57, 53, $BS_DEFPUSHBUTTON)
GUICtrlSetState($EditSend, $GUI_FOCUS)
$TicketList = GUICtrlCreateList("", 615, 22, 300, 400)
$UserList = GUICtrlCreateList("", 915, 22, 103, 400)
$KBList = GUICtrlCreateList("", 615, 420, 403, 201)
;- ////// END Create Tabs /////////////////////

;- ///////// Create mini buttons /////////////
$imgButton = GuiCtrlCreateButton("IMG", 8, 603, 20, 20, $BS_BITMAP)
GUICtrlSetImage(-1, "image.bmp")
$codeButton = GuiCtrlCreateButton("<>", 28, 603, 20, 20, $BS_BITMAP)
GUICtrlSetImage(-1, "code.bmp")
$linkButton = GuiCtrlCreateButton("Link", 48, 603, 20, 20, $BS_BITMAP)
GUICtrlSetImage(-1, "link.bmp")
$emailButton = GuiCtrlCreateButton("@", 68, 603, 20, 20, $BS_BITMAP)
GUICtrlSetImage(-1, "email.bmp")
$quoteButton = GuiCtrlCreateButton('""', 88, 603, 20, 20, $BS_BITMAP)
GUICtrlSetImage(-1, "quote.bmp")
;- // Show the GUI //
GUISetState(@SW_SHOW)

;- // Start TCP Connection //
TCPStartup()

;- // Connect to the server using $server, $port and $nick //
Global $sock = _IRCConnect($server, $port, $nick)

;- // Start timer //
$begin = TimerInit()

While 1
    $nMsg = GUIGetMsg()

    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            _IRCQuit($sock, "Leaving!")
            Exit
        
        case $imgButton
            $OpenTag = "[" & "img]"
            $CloseTag = "[" & "/img]"
            Replace_MySelection()
            GUICtrlSetState($EditSend, $GUI_FOCUS)
            
        Case $codeButton
            $OpenTag = "[" & "code]"
            $CloseTag = "[" & "/code]"
            Replace_MySelection()
            GUICtrlSetState($EditSend, $GUI_FOCUS)
            
        case $linkButton
            $OpenTag = "[" & "link]"
            $CloseTag = "[" & "/link]"
            Replace_MySelection()
            GUICtrlSetState($EditSend, $GUI_FOCUS)
            
        case $emailButton
            $OpenTag = "[" & "email]"
            $CloseTag = "[" & "/email]"
            Replace_MySelection()
            GUICtrlSetState($EditSend, $GUI_FOCUS)
            
        case $quoteButton
            $OpenTag = "[" & "quote]"
            $CloseTag = "[" & "/quote]"
            Replace_MySelection()
            GUICtrlSetState($EditSend, $GUI_FOCUS)
            
        Case $Send
            $msg = GUICtrlRead($EditSend)
            $msg = StringRegExpReplace($msg, "\n", "<br>"); <--- Replaces line breaks with HTML code <br>
            If $msg == "/exit" Then Exit; <--- exits the application
            If $msg == "/clr" Then; <--- Clears the screen
                _IENavigate($XT_oIE, "about:blank")
                $oBody = _IETagNameGetCollection($XT_oIE, "body", 0); <---------- This is new screen
                $msg = ""; <--- Set message to nothing
            EndIf
            If StringLeft($msg, 4) = "/me " Then; <--- Send an Action
                $msg = StringTrimLeft($msg, 4)
                _IRCSendAction($sock, $msg, $channel)
                XSkinText("[" & @HOUR & ":" & @MIN & "] *" & $nick & " " & $msg, "purple", 3)
                $msg = ""
            EndIf
            If Not $msg = "" Then _IRCSendMessage($sock, $msg, $channel); <-- Only send if $msg has contents
            If Not $msg = "" Then XSkinText("[" & @HOUR & ":" & @MIN & "] " & "<b>" & $nick & "</b>" & ": " & $msg, 3); <--- Update chat program screen
            GUICtrlSetData($EditSend, ""); <-- Reset edit box
            GUICtrlSetState($EditSend, $GUI_FOCUS); <--- Reset focus
            
        Case Else
            $recv = TCPRecv($sock, 8192); Recieve things from server
            If @error Then Exit MsgBox(1, "IRC Example", "Server has errored or disconnected"); <-- If you cant rx from server, server has died; eventually this will go to a reconnect routine, but right now it just dies.
            Local $sData = StringSplit($recv, @CRLF); Splits the messages, sometimes the server groups them
            For $i = 1 To $sData[0] Step 1; Does each message seperately
                Local $sTemp = StringSplit($sData[$i], " "); Splits the message by spaces
                If Not $sData[$i] = "" Then
                    ConsoleWrite($sData[$i] & @CRLF)
                    $noffset = 1
                    
                    $dataSYS = StringRegExp($sData[$i], '(?i)(?s):(.*?):(.*?)(?:\z)', 1, $noffset)
                    if @error = 1 Then
                    Else
                        XSkinTextSYS("[" & @HOUR & ":" & @MIN & "] " & "<b>PM: " & $dataSYS[1])
                        EndIf
                    
                    if StringInStr($sData[$i], "353 "&$nick&" @ "&$channel) Then
                        $data = StringRegExp($sData[$i], "(?i)(?s):(?:.*?):(.*?)\s(?:\z)", 1, $noffset)
                        if @error = 1 Then
                        Else
                        $names = StringSplit($data[0], " ", 1)
                            Dim $keywords[UBound($names) - 1]
                                For $dl = 1 To UBound($names) - 1
                                    $ustr = $names[$dl]
                                    If $ustr = "" Or $ustr = " " Then
                                    Else
                                        If _ArraySearch($keywords, $names[$dl]) > 0 Then
                                        Else
                                            _ArrayAdd($keywords, $names[$dl])
                                        EndIf
                                    EndIf
                                Next
                            $namesIN = _ArrayToString($keywords, " ")
                            $namesIN = StringRegExpReplace($namesIN, "\s\s", "")
                            $namesIN = StringRegExpReplace($namesIN, "\s", "|")
                            guictrlsetdata($UserList, "")
                            guictrlsetdata($UserList, $namesIN)
                        EndIf
                    ElseIf StringInStr($sData[$i], "PART "&$channel, 2, 1) Then; <--- Checks if someone parts the IRC
                        $data = StringRegExp($sData[$i], "(?i)(?s):(.*?)!(.*?)(?:\z)", 1, $noffset)
                        If @error = 1 Then
                        Else
                            XSkinText("[" & @HOUR & ":" & @MIN & "] Part: " & $data[0], "gray", 3)
                            _IRCSendNames($sock, $channel)
                        EndIf
                    ElseIf StringInStr($sData[$i], "PRIVMSG "&$nick, 0) Then; <-- Checks for PM messages
                        $data = StringRegExp($sData[$i], "(?i)(?s):(.*?)!(?:.*)PRIVMSG\s(.*?)\s:(.*?)(?:\z)", 1, $noffset)
                        If @error = 1 Then
                        Else
                                $color = "red"
                                XSkinText("[" & @HOUR & ":" & @MIN & "] " & "<b>PM: " & $data[0] & "</b>" & ": " & $data[2], $color, 3)
                                $color = "black"
                        EndIf
                    ElseIf StringInStr($sData[$i], "ACTION ") Then; <--- Checks for actions
                        $data = StringRegExp($sData[$i], '(?i)(?s):(.*?)!(?:.*?):(?:ACTION\s)(.*?)', 1, $noffset)
                        If @error = 1 Then
                        Else
                            XSkinText("[" & @HOUR & ":" & @MIN & "] *" & $data[0] & " " & $data[1], "purple", 3)
                        EndIf
                    ElseIf StringInStr($sData[$i], "Quit :", 0) Then; <--- Checks if someone quit the IRC
                        $data = StringRegExp($sData[$i], "(?i)(?s):(.*?)!(?:.*?):(.*?)(?:\z)", 1, $noffset)
                        If @error = 1 Then
                        Else
                            XSkinText("[" & @HOUR & ":" & @MIN & "] Quit:" & $data[0] & " (" & $data[1] & ")", "gray", 3)
                            _IRCSendNames($sock, $channel)
                        EndIf
                    ElseIf StringInStr($sData[$i], "JOIN :", 0) Then; <--- Checks if someone joined the IRC
                        $data = StringRegExp($sData[$i], "(?i)(?s):(.*?)!(?:.*):(.*?)(?:\z)", 1, $noffset)
                        If @error = 1 Then
                        Else
                            XSkinText("[" & @HOUR & ":" & @MIN & "] Joined: " & $data[0], "gray", 3)
                            _IRCSendNames($sock, $channel)                          
                        EndIf
                    Else
                        $data = StringRegExp($sData[$i], "(?i)(?s):(.*?)!(?:.*)PRIVMSG\s(.*?)\s:(.*?)(?:\z)", 1, $noffset); <--- Consider this the default messages and print it
                        If @error = 1 Then
                        Else
                            If $data[1] = $channel Then
                                $color = IniRead(@ProgramFilesDir & "\info\Chat\techs.ini", "Techs", $data[0], "black")
                                XSkinText("[" & @HOUR & ":" & @MIN & "] " & "<b>" & $data[0] & "</b>" & ": " & $data[2], $color, 3)
                                $color = "black"
                            EndIf
                        EndIf
                    EndIf
                ElseIf StringInStr($sData[$i], "PRIVMSG "&$channel, 0) Then
                    $data = StringRegExp($sData[$i], "(?i)(?s):(.*?)!(?:.*)PRIVMSG\s(.*?)\s:(.*?)(?:\z)", 1, $noffset)
                    If @error = 1 Then
                    Else
                        If $data[1] = $channel Then
                            $color = IniRead(@ProgramFilesDir & "\info\Chat\techs.ini", "Techs", $data[0], "black")
                            XSkinText("[" & @HOUR & ":" & @MIN & "] " & "<b>" & $data[0] & "</b>" & ": " & $data[2], $color, 3)
                            $color = "black"
                            
                        EndIf
                    EndIf
                    
                Else
                    
                    $data = StringRegExp($sData[$i], "(?i)(?s)(?:.*?):.*?:(.*?)(?:\z)", 1, $noffset)
                    If @error = 1 Then
                        $data = StringRegExp($sData[$i], "(?i)(?s)(?:.*?)\*{3}\s(.*?)(?:\z)", 1, $noffset)
                        If @error = 1 Then
                        Else
                            XSkinText($data[0], $color, 3)
                            
                        EndIf
                    Else
                        XSkinText($data[0], $color, 3)
                    EndIf
                EndIf

                If $sTemp[1] = "" Then ContinueLoop; If its empty, Continue!
                If StringInStr($sTemp[1], "PING", 0) Then _IRCPing($sTemp[2]); Checks for PING replys (There smaller then usual messages so its special!
                If $sTemp[0] <= 2 Then ContinueLoop; Useless messages for the most part
                Switch $sTemp[2]; Splits the command msg
                    Case "266"; It's what I use as an indictator to show when its done sending you info.
                        _IRCJoinChannel($sock, $channel)
                        _IRCChangeMode($sock, "+i", $nick)
                        _IRCSendNames($sock, $channel)
                EndSwitch
            Next
    EndSwitch
WEnd

;- ///////////////////////////// FUNCTION: XSkinText() ////////////////////////////////////////////////
;- //// Purpose: To send custom color messages to the screen, which are properly formated ////////////
;- //////////////////////////////////////////////////////////////////////////////////////////////////
Func XSkinText($msg = "", $color = "black", $size = "3")
    If $msg == "/clr" Then Return
    If $msg == "/exit" Then Exit
    If StringInStr($msg, "/goto:", 1) Then
        $URL = StringSplit($msg, ":")
        Return _IENavigate($XT_oIE, StringStripWS($URL[2], 8), 0)
    EndIf
    $noffset = 1
    $linktext = StringRegExp($msg, "(?i)(?s)(?:link])(.*?)(?:\[/link)", 1, $noffset)
    if @error = 1 Then
    Else
        $msg = StringReplace($msg, "[link]", '<a href="')
        $msg = StringReplace($msg, "[/link]", '" target="_blank">'&$linktext[0]&'</a>')
    EndIf
    
    $msg = StringReplace($msg, "[img]", '<img src="')
    $msg = StringReplace($msg, "[/img]", '">')
    
    $noffset = 1
    $linktext = StringRegExp($msg, '(?i)(?s)(?:email])(.*?)(?:\[/email)', 1, $noffset)
    if @error = 1 Then
    Else
    $msg = StringReplace($msg, "[email]", '<A HREF="mailto:')
    $msg = StringReplace($msg, "[/email]", '">'&$linktext[0]&'</A>')
    EndIf

    $msg = StringReplace($msg, "[quote]", '<b><font size=2 color="green">QUOTE:</font> </b><i><font size=2 color="green">')
    $msg = StringReplace($msg, "[/quote]", '</i></font>')
    
    $msg = StringReplace($msg, "[code]", '<fieldset>')
    $msg = StringReplace($msg, "[/ code]", '</fieldset>')
    
    ConsoleWrite($msg & @CRLF)
    
;- Check and replace for smilies
    $SmilieDir = @ScriptDir & "\caritas"
    
    $msg = StringReplace($msg, " :)", '&nbsp;<img src="' & $SmilieDir & '\smile.gif">')
    $msg = StringReplace($msg, " :D", '&nbsp;<img src="' & $SmilieDir & '\biggrin.gif">')
    $msg = StringReplace($msg, " :(", '&nbsp;<img src="' & $SmilieDir & '\sad.gif">')
    $msg = StringReplace($msg, " (h)", '&nbsp;<img src="' & $SmilieDir & '\cool.gif">')
    $msg = StringReplace($msg, " :|", '&nbsp;<img src="' & $SmilieDir & '\blink.gif">')
    $msg = StringReplace($msg, " :x", '&nbsp;<img src="' & $SmilieDir & '\mad.gif">')
    $msg = StringReplace($msg, " :$", '&nbsp;<img src="' & $SmilieDir & '\wub.gif">')
    $msg = StringReplace($msg, " :s", '&nbsp;<img src="' & $SmilieDir & '\huh.gif">')
    $msg = StringReplace($msg, ";)", '&nbsp;<img src="' & $SmilieDir & '\wink.gif">')
    $msg = StringReplace($msg, " >:(", '&nbsp;<img src="' & $SmilieDir & '\angry.gif">')
    $msg = StringReplace($msg, " (B)", '&nbsp;<img src="' & $SmilieDir & '\blush.gif">')
    $msg = StringReplace($msg, " ^^", '&nbsp;<img src="' & $SmilieDir & '\happy.gif">')
    $msg = StringReplace($msg, " ©", '&nbsp;<img src="' & $SmilieDir & '\closedeyes.gif">')
    $msg = StringReplace($msg, "haha", '&nbsp;<img src="' & $SmilieDir & '\laugh.gif">')
    $msg = StringReplace($msg, " (m)", '&nbsp;<img src="' & $SmilieDir & '\mellow.gif">')
    $msg = StringReplace($msg, " (o)", '&nbsp;<img src="' & $SmilieDir & '\ohmy.gif">')
    $msg = StringReplace($msg, " (n)", '&nbsp;<img src="' & $SmilieDir & '\ph34r.gif">')
    $msg = StringReplace($msg, " ®", '&nbsp;<img src="' & $SmilieDir & '\rolleyes.gif">')
    $msg = StringReplace($msg, " (s)", '&nbsp;<img src="' & $SmilieDir & '\sleep.gif">')
    $msg = StringReplace($msg, " :P", '&nbsp;<img src="' & $SmilieDir & '\tongue.gif">')
    $msg = StringReplace($msg, " :P", '&nbsp;<img src="' & $SmilieDir & '\tongue.gif">')
    $msg = StringReplace($msg, " :P", '&nbsp;<img src="' & $SmilieDir & '\tongue2.gif">')
    $msg = StringReplace($msg, " (u)", '&nbsp;<img src="' & $SmilieDir & '\unsure.gif">')
    $msg = StringReplace($msg, " :%", '&nbsp;<img src="' & $SmilieDir & '\wacko.gif">')
    $msg = StringReplace($msg, " (w)", '&nbsp;<img src="' & $SmilieDir & '\wacko.gif">')

; Start New code
    $sAppend = '<font color="' & $color & '" size=' & $size & '>' & $msg & '</font><br>'
    ConsoleWrite($sAppend & @CRLF)
    _IEDocInsertHTML($oBody, $sAppend)
    $iVisibleHeight = $XT_oIE.document.body.clientHeight
    $XT_oIE.document.parentwindow.scrollBy(0, $iVisibleHeight)
; End New code
EndFunc  ;==>XSkinText

Func XSkinTextSYS($msg = "", $color = "gray", $size = "1")
    If $msg == "/clr" Then Return
    If $msg == "/exit" Then Exit
    If StringInStr($msg, "/goto:", 1) Then
        $URL = StringSplit($msg, ":")
        Return _IENavigate($XT_oIE2, StringStripWS($URL[2], 8), 0)
    EndIf

; Start New code
    $sAppend = '<font color="' & $color & '" size=' & $size & '>' & $msg & '</font><br>'
    _IEDocInsertHTML($oBody2, $sAppend)
    $iVisibleHeight = $XT_oIE2.document.body.clientHeight
    $XT_oIE2.document.parentwindow.scrollBy(0, $iVisibleHeight)
; End New code
EndFunc  ;==>XSkinText


;- ////////////// Function: _ArrayFindAll ///////////////////
;- /////// Purpose: Find all search terms in array //////////
;- //////////////////////////////////////////////////////////
Func _ArrayFindAll($iArray, $iQuery, $iStart = 0, $iEnd = 0, $iCaseSense = 0, $fPartialSearch = True)
    Local $Rtn = ''
    While 1
        $aSrch = _ArraySearch($iArray, $iQuery, $iStart, $iEnd, $iCaseSense, $fPartialSearch)
        If $aSrch <> -1 Then
            $Rtn &= $aSrch & '|'
            $iStart = $aSrch + 1
        Else
            ExitLoop
        EndIf
    WEnd
    If $Rtn <> '' Then
        $Rtn = StringSplit(StringTrimRight($Rtn, 1), '|')
        Return $Rtn
    Else
        Return SetError(1, 1, 'No matches to your query were found')
    EndIf
EndFunc  ;==>_ArrayFindAll

Func Replace_MySelection()
    $SelectedArr = _GUICtrlEdit_GetSel($EditSend)
    $SelectedArr[0] += 1
    $count = $SelectedArr[1] - $SelectedArr[0] + 1
    If $count > 0 Then
        $allText = _GUICtrlEdit_GetText($EditSend)
        $selectedData = StringMid($allText, $SelectedArr[0], $count)
        _GUICtrlEdit_ReplaceSel($EditSend, $OpenTag & $selectedData & $CloseTag)
    EndIf
    guictrlsetstate($send, $GUI_FOCUS)
EndFunc;==>Replace_MySelection
Edited by zackrspv

-_-------__--_-_-____---_-_--_-__-__-_ ^^€ñ†®øÞÿ ë×阮§ wï†høµ† ƒë@®, wï†høµ† †ïmë, @ñd wï†høµ† @ †ïmïdï†ÿ ƒø® !ïƒë. €×阮 ñø†, bµ† ïñ§†ë@d wï†hïñ, ñ@ÿ, †h®øµghøµ† †hë 맧ëñ§ë øƒ !ïƒë.

Link to comment
Share on other sites

You may made some little example script ?

I know what's problem... wait a minute....

[quote name='dbzfanatic' post='609696' date='Nov 26 2008, 08:46 AM']This is a help forum not a "write this for me" forum.[/quote](Sorry for bad English) :)

Link to comment
Share on other sites

Look this theard

http://www.autoitscript.com/forum/index.php?showtopic=68118

You may sold this problem with hotkeyset :D:):D

I agree that i can solve the problem with hotkeyset; however I have other programs that i use the enter key for. That wouldn't be very useful for me to have it always on for the entire OS. I've reviewed the other post you sent me, and while there are some good ideas in there, right now, I do not wish to use the beta release to release to my fellow techs.

Is there not any other way to make that button stay as default? I'm sure you can see the importance here of why it needs to stay as default; it's the primary chat send key, w/o that there i might as well give up on this app lol

Thanks for the help tho, it's nice to see a friendly face around here :D

-_-------__--_-_-____---_-_--_-__-__-_ ^^€ñ†®øÞÿ ë×阮§ wï†høµ† ƒë@®, wï†høµ† †ïmë, @ñd wï†høµ† @ †ïmïdï†ÿ ƒø® !ïƒë. €×阮 ñø†, bµ† ïñ§†ë@d wï†hïñ, ñ@ÿ, †h®øµghøµ† †hë 맧ëñ§ë øƒ !ïƒë.

Link to comment
Share on other sites

Do you mean like in Winamp - F3, alweys is default button: Jump to file :D

[quote name='dbzfanatic' post='609696' date='Nov 26 2008, 08:46 AM']This is a help forum not a "write this for me" forum.[/quote](Sorry for bad English) :)

Link to comment
Share on other sites

You may also, when the default button is clicked, re-focus it so nothing else can take it! :D

Tried that:

case $imgButton
            $OpenTag = "[" & "img]"
            $CloseTag = "[" & "/img]"
            Replace_MySelection()
        GUICtrlSetState($EditSend, $GUI_FOCUS);- set focus back to the edit box (this one runs second, after the function call)


Func Replace_MySelection()
    $SelectedArr = _GUICtrlEdit_GetSel($EditSend)
    $SelectedArr[0] += 1
    $count = $SelectedArr[1] - $SelectedArr[0] + 1
    If $count > 0 Then
        $allText = _GUICtrlEdit_GetText($EditSend)
        $selectedData = StringMid($allText, $SelectedArr[0], $count)
        _GUICtrlEdit_ReplaceSel($EditSend, $OpenTag & $selectedData & $CloseTag)
    EndIf
    guictrlsetstate($send, $GUI_FOCUS);- set focus back to the send button (this one runs first)
EndFunc;==>Replace_MySelection

But unfortunately, it still stays stuck to the other button.

-_-------__--_-_-____---_-_--_-__-__-_ ^^€ñ†®øÞÿ ë×阮§ wï†høµ† ƒë@®, wï†høµ† †ïmë, @ñd wï†høµ† @ †ïmïdï†ÿ ƒø® !ïƒë. €×阮 ñø†, bµ† ïñ§†ë@d wï†hïñ, ñ@ÿ, †h®øµghøµ† †hë 맧ëñ§ë øƒ !ïƒë.

Link to comment
Share on other sites

Tried that:

case $imgButton
            $OpenTag = "[" & "img]"
            $CloseTag = "[" & "/img]"
            Replace_MySelection()
        GUICtrlSetState($EditSend, $GUI_FOCUS);- set focus back to the edit box (this one runs second, after the function call)


Func Replace_MySelection()
    $SelectedArr = _GUICtrlEdit_GetSel($EditSend)
    $SelectedArr[0] += 1
    $count = $SelectedArr[1] - $SelectedArr[0] + 1
    If $count > 0 Then
        $allText = _GUICtrlEdit_GetText($EditSend)
        $selectedData = StringMid($allText, $SelectedArr[0], $count)
        _GUICtrlEdit_ReplaceSel($EditSend, $OpenTag & $selectedData & $CloseTag)
    EndIf
    guictrlsetstate($send, $GUI_FOCUS);- set focus back to the send button (this one runs first)
EndFunc;==>Replace_MySelection

But unfortunately, it still stays stuck to the other button.

There are 2 ways to do it that I can think of.

1) whenever another button is pressed do this

GUICtrlDelete($send)
$send = GUICtrlCreateButton("dflt btn", x, y,w,h,$BS_DEFPUSHBUTTON)

2)

Send("{TAB}") the correct number of times after another button is pressed so that focus is back on the default button.

Edited by martin
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

There are 2 ways to do it that I can think of.

1) whenever another button is pressed do this

GUICtrlDelete($send)
$send = GUICtrlCreateButton("dflt btn", x, y,w,h,$BS_DEFPUSHBUTTON)

2)

Send("{TAB}") the correct number of times after another button is pressed so that focus is back on the default button.

Now THAT worked:

Func Replace_MySelection()
    $SelectedArr = _GUICtrlEdit_GetSel($EditSend)
    $SelectedArr[0] += 1
    $count = $SelectedArr[1] - $SelectedArr[0] + 1
    If $count > 0 Then
        $allText = _GUICtrlEdit_GetText($EditSend)
        $selectedData = StringMid($allText, $SelectedArr[0], $count)
        _GUICtrlEdit_ReplaceSel($EditSend, $OpenTag & $selectedData & $CloseTag)
    EndIf
    GUICtrlDelete($send)
    $Send = GUICtrlCreateButton("Send", 550, 550, 57, 53, $BS_DEFPUSHBUTTON)
EndFunc;==>Replace_MySelection

Looks kinda funny lol can actually see it regain, loose focus, but hey, who cares it worked! woot, thanks!

-_-------__--_-_-____---_-_--_-__-__-_ ^^€ñ†®øÞÿ ë×阮§ wï†høµ† ƒë@®, wï†høµ† †ïmë, @ñd wï†høµ† @ †ïmïdï†ÿ ƒø® !ïƒë. €×阮 ñø†, bµ† ïñ§†ë@d wï†hïñ, ñ@ÿ, †h®øµghøµ† †hë 맧ëñ§ë øƒ !ïƒë.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...