Jump to content

GUICtrlSetBkColor - anomaly


Recommended Posts

When i use 'GUICtrlSetBkColor', my script does *really* strange things, like running the 1st 'Case' by itself, but only after clicking on, off then back on the 'drag.gif' ($GUI_WS_EX_PARENTDRAG) part of the GUI.

Here's part of the code (with 'GUICtrlSetBkColor' commented out) to show how i'm using it:

#region GUI
$GUI_BlogEditAssist = GUICreate("Blog Edit Assist", 360, 20, IniRead("config.ini", "GUI", "X-Pos", 0), IniRead("config.ini", "GUI", "Y-Pos", 0), BitOR($WS_CLIPCHILDREN,$WS_POPUP,$WS_BORDER,$WS_CLIPSIBLINGS), BitOR($WS_EX_TOPMOST,$WS_EX_WINDOWEDGE))
$Button_HeadlineFf = GUICtrlCreateButton("HDL", 0, 0, 32, 20, $BS_FLAT)
;GUICtrlSetBkColor(-1, 0xB7B7FF)
GUICtrlSetTip(-1, "Headline from Firefox to KompoZer")
$Button_QuoteFf = GUICtrlCreateButton("QTE", 32, 0, 32, 20, $BS_FLAT)
;GUICtrlSetBkColor(-1, 0xB7B7FF)
GUICtrlSetTip(-1, "Quote from Firefox to KompoZer")
$Button_Comment = GUICtrlCreateButton("CMT", 64, 0, 32, 20, $BS_FLAT)
;GUICtrlSetBkColor(-1, 0xB7B7FF)
GUICtrlSetTip(-1, "Add comment to KompoZer")
$Button_Table = GUICtrlCreateButton("TBL", 96, 0, 32, 20, $BS_FLAT)
;GUICtrlSetBkColor(-1, 0xB7B7FF)
GUICtrlSetTip(-1, "Create a table in KompoZer")
$Button_HeadlineOther = GUICtrlCreateButton("HDL", 128, 0, 32, 20, $BS_FLAT)
;GUICtrlSetBkColor(-1, 0x8888FF)
GUICtrlSetTip(-1, "Headline from any app to KompoZer")
$Button_QuoteOther = GUICtrlCreateButton("QTE", 160, 0, 32, 20, $BS_FLAT)
;GUICtrlSetBkColor(-1, 0x8888FF)
GUICtrlSetTip(-1, "Quote from any app to KompoZer")
$Button_Email = GUICtrlCreateButton("Mail", 192, 0, 32, 20, $BS_FLAT)
;GUICtrlSetBkColor(-1, 0x92FF82)
GUICtrlSetTip(-1, "Copy code and paste in T-Bird email")
$Button_Edit = GUICtrlCreateButton("Edit", 224, 0, 32, 20, $BS_FLAT)
;GUICtrlSetBkColor(-1, 0x92FF82)
GUICtrlSetTip(-1, "Edit code in PSPad")
$Button_Load = GUICtrlCreateButton("Load", 256, 0, 32, 20, $BS_FLAT)
;GUICtrlSetBkColor(-1, 0x92FF82)
GUICtrlSetTip(-1, "Load Firefox and KompoZer")
$Button_Config = GUICtrlCreateButton("Conf", 288, 0, 32, 20, $BS_FLAT)
;GUICtrlSetBkColor(-1, 0x92FF82)
GUICtrlSetTip(-1, "Settings")
$Button_ExitMain = GUICtrlCreateButton("X", 320, 0, 20, 20, $BS_FLAT)
;GUICtrlSetBkColor(-1, 0xFF8B88)
GUICtrlSetTip(-1, "Exit")
GUICtrlCreatePic("drag.gif", 340, 0, 20, 20, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS), $GUI_WS_EX_PARENTDRAG)
GUISetState(@SW_SHOW)
#endregion

Another little problem is the 'drag.gif' (3rd to last line) is getting corrupted a bit. It displays and works (dragable), but it doesn't look quit right. The actual image is 20x20.

Link to comment
Share on other sites

This code:

#include<GUIconstants.au3>
#region GUI
$GUI_BlogEditAssist = GUICreate("Blog Edit Assist", 360, 20, IniRead("config.ini", "GUI", "X-Pos", 0), IniRead("config.ini", "GUI", "Y-Pos", 0), BitOR($WS_CLIPCHILDREN,$WS_POPUP,$WS_BORDER,$WS_CLIPSIBLINGS), BitOR($WS_EX_TOPMOST,$WS_EX_WINDOWEDGE))
$Button_HeadlineFf = GUICtrlCreateButton("HDL", 0, 0, 32, 20, $BS_FLAT)
GUICtrlSetBkColor(-1, 0xB7B7FF)
GUICtrlSetTip(-1, "Headline from Firefox to KompoZer")
$Button_QuoteFf = GUICtrlCreateButton("QTE", 32, 0, 32, 20, $BS_FLAT)
GUICtrlSetBkColor(-1, 0xB7B7FF)
GUICtrlSetTip(-1, "Quote from Firefox to KompoZer")
$Button_Comment = GUICtrlCreateButton("CMT", 64, 0, 32, 20, $BS_FLAT)
GUICtrlSetBkColor(-1, 0xB7B7FF)
GUICtrlSetTip(-1, "Add comment to KompoZer")
$Button_Table = GUICtrlCreateButton("TBL", 96, 0, 32, 20, $BS_FLAT)
GUICtrlSetBkColor(-1, 0xB7B7FF)
GUICtrlSetTip(-1, "Create a table in KompoZer")
$Button_HeadlineOther = GUICtrlCreateButton("HDL", 128, 0, 32, 20, $BS_FLAT)
GUICtrlSetBkColor(-1, 0x8888FF)
GUICtrlSetTip(-1, "Headline from any app to KompoZer")
$Button_QuoteOther = GUICtrlCreateButton("QTE", 160, 0, 32, 20, $BS_FLAT)
GUICtrlSetBkColor(-1, 0x8888FF)
GUICtrlSetTip(-1, "Quote from any app to KompoZer")
$Button_Email = GUICtrlCreateButton("Mail", 192, 0, 32, 20, $BS_FLAT)
GUICtrlSetBkColor(-1, 0x92FF82)
GUICtrlSetTip(-1, "Copy code and paste in T-Bird email")
$Button_Edit = GUICtrlCreateButton("Edit", 224, 0, 32, 20, $BS_FLAT)
GUICtrlSetBkColor(-1, 0x92FF82)
GUICtrlSetTip(-1, "Edit code in PSPad")
$Button_Load = GUICtrlCreateButton("Load", 256, 0, 32, 20, $BS_FLAT)
GUICtrlSetBkColor(-1, 0x92FF82)
GUICtrlSetTip(-1, "Load Firefox and KompoZer")
$Button_Config = GUICtrlCreateButton("Conf", 288, 0, 32, 20, $BS_FLAT)
GUICtrlSetBkColor(-1, 0x92FF82)
GUICtrlSetTip(-1, "Settings")
$Button_ExitMain = GUICtrlCreateButton("X", 320, 0, 20, 20, $BS_FLAT)
GUICtrlSetBkColor(-1, 0xFF8B88)
GUICtrlSetTip(-1, "Exit")
GUICtrlCreatePic("drag.gif", 340, 0, 20, 20, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS), $GUI_WS_EX_PARENTDRAG)
GUISetState(@SW_SHOW)
#endregion
While 1
    Sleep(10)
WEnd
Gives me this result:

Posted Image

By killalltheyuppys at 2007-10-06

EDIT: I am using version 3.2.8.1 public release

Edited by danwilli
Link to comment
Share on other sites

@Valuater - i believe i'm using the latest beta (see sig), though i had the same problem with next earliest beta.

@danwilli - yeah, that's what it's supposed to look like, though there's a slight difference in your version and mine when the whole script is in tact, despite the fact the GUI code is exactly the same. I'll have to troubleshoot that as well.

I suppose i'm using 'GUICtrlSetBkColor' correctly, so here's all of the script so you can test it if you wish. WARNING: i suggest closing other apps first, as the script may try to do "funny" things. Attached is the 'drag.gif' you'll need.

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.2.9.3 (beta)
  
#ce ----------------------------------------------------------------------------


#cs >>>>>>>>>>>>>>>>>>>>>>>>>>>>>> PROBLEM WITH SCRIPT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

    script runs first 'case' when not supposed to.
    
    to invoke problem: run script > click on 'drag' section > click off of GUI > 
    now GUI won't close and may have run first 'case'.  it won't close because it's
    running the first 'case' and if apps not running, then it stalls.
    
    seems to have something to do with 'GUICtrlSetBkColor' -- commenting them out works
    
    the tab order of the buttons may have something to do with it
    
    other wierd changes affect the problem, such as playing with the 'drag.gif' control

#ce >>>>>>>>>>>>>>>>>>>>>>>>>>>>>> PROBLEM WITH SCRIPT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

#include <GUIConstants.au3>

#region GUI
$GUI_BlogEditAssist = GUICreate("Blog Edit Assist", 360, 20, IniRead("config.ini", "GUI", "X-Pos", 0), IniRead("config.ini", "GUI", "Y-Pos", 0), BitOR($WS_CLIPCHILDREN,$WS_POPUP,$WS_BORDER,$WS_CLIPSIBLINGS), BitOR($WS_EX_TOPMOST,$WS_EX_WINDOWEDGE))
$Button_HeadlineFf = GUICtrlCreateButton("HDL", 0, 0, 32, 20, $BS_FLAT)
GUICtrlSetBkColor(-1, 0xB7B7FF)
GUICtrlSetTip(-1, "Headline from Firefox to KompoZer")
$Button_QuoteFf = GUICtrlCreateButton("QTE", 32, 0, 32, 20, $BS_FLAT)
GUICtrlSetBkColor(-1, 0xB7B7FF)
GUICtrlSetTip(-1, "Quote from Firefox to KompoZer")
$Button_Comment = GUICtrlCreateButton("CMT", 64, 0, 32, 20, $BS_FLAT)
GUICtrlSetBkColor(-1, 0xB7B7FF)
GUICtrlSetTip(-1, "Add comment to KompoZer")
$Button_Table = GUICtrlCreateButton("TBL", 96, 0, 32, 20, $BS_FLAT)
GUICtrlSetBkColor(-1, 0xB7B7FF)
GUICtrlSetTip(-1, "Create a table in KompoZer")
$Button_HeadlineOther = GUICtrlCreateButton("HDL", 128, 0, 32, 20, $BS_FLAT)
GUICtrlSetBkColor(-1, 0x8888FF)
GUICtrlSetTip(-1, "Headline from any app to KompoZer")
$Button_QuoteOther = GUICtrlCreateButton("QTE", 160, 0, 32, 20, $BS_FLAT)
GUICtrlSetBkColor(-1, 0x8888FF)
GUICtrlSetTip(-1, "Quote from any app to KompoZer")
$Button_Email = GUICtrlCreateButton("Mail", 192, 0, 32, 20, $BS_FLAT)
GUICtrlSetBkColor(-1, 0x92FF82)
GUICtrlSetTip(-1, "Copy code and paste in T-Bird email")
$Button_Edit = GUICtrlCreateButton("Edit", 224, 0, 32, 20, $BS_FLAT)
GUICtrlSetBkColor(-1, 0x92FF82)
GUICtrlSetTip(-1, "Edit code in PSPad")
$Button_Load = GUICtrlCreateButton("Load", 256, 0, 32, 20, $BS_FLAT)
GUICtrlSetBkColor(-1, 0x92FF82)
GUICtrlSetTip(-1, "Load Firefox and KompoZer")
$Button_Config = GUICtrlCreateButton("Conf", 288, 0, 32, 20, $BS_FLAT)
GUICtrlSetBkColor(-1, 0x92FF82)
GUICtrlSetTip(-1, "Settings")
$Button_ExitMain = GUICtrlCreateButton("X", 320, 0, 20, 20, $BS_FLAT)
GUICtrlSetBkColor(-1, 0xFF8B88)
GUICtrlSetTip(-1, "Exit")
GUICtrlCreatePic("drag.gif", 340, 0, 20, 20, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS), $GUI_WS_EX_PARENTDRAG)
GUISetState(@SW_SHOW)
#endregion


#region before main loop
; SET AUTOIT OPTIONS
Opt("WinTitleMatchMode", 4)
Opt("SendKeyDelay", 20)
Opt("SendKeyDownDelay", 15)

; CHECK IF 'CONFIG.INI' EXISTS AND IS POPULATED
If Not FileExists(@ScriptDir & "\" & "config.ini") Then
    MsgBox(64, "Warning", 'Click the "Conf" button to configure paths to executables first!')
EndIf

; GET PATHS TO EXECUTABLES
$Get_PathKompozer = IniRead("config.ini", "PATHS", "KompoZer", "0")
$Get_PathFirefox = IniRead("config.ini", "PATHS", "Firefox", "0")
$Get_PathPspad = IniRead("config.ini", "PATHS", "PSPad", "0")
$Get_PathTbird = IniRead("config.ini", "PATHS", "Thunderbird", "0")
If $Get_PathKompozer = "0" Or $Get_PathFirefox = "0" Or $Get_PathPspad = "0" Or $Get_PathTbird = "0" Then
    MsgBox(64, "Error", "Paths to executables not defined! Click 'Conf' to configure settings.")
EndIf

; SET TRANSPARENCY
WinSetTrans($GUI_BlogEditAssist, "", IniRead("config.ini", "GUI", "Transparency", 255))

; CHECK IF FIREFOX/KOMPOZER RUNNING
If Not(WinExists("Mozilla Firefox") And WinExists("KompoZer")) Then
     MsgBox(64, "Notice", "Firefox/KompoZer not running", 2)
EndIf

; GET INI 'Remember position per app'
$Get_IniPosApp = IniRead("config.ini", "GUI", "Remember position per app", 0)

; GET INI 'OnTop'
$Get_IniOnTop = IniRead("config.ini", "GUI", "OnTop", 1)
#endregion

; MAIN LOOP
While 1

#region always running in loop
    $Msg = GUIGetMsg()
    
; GET LAST WINDOW POSITION FROM INI
    Local $Pos = WinGetPos($GUI_BlogEditAssist)

; GET WINDOW POSITIONS FOR APPS FROM INI
    If $Get_IniPosApp = 1 And WinActive("Firefox") Then
        WinMove($GUI_BlogEditAssist, "", IniRead("config.ini", "GUI", "X-Pos Firefox", 0), IniRead("config.ini", "GUI", "Y-Pos Firefox", 0))
    ElseIf $Get_IniPosApp = 1 And WinActive("KompoZer") Then
        WinMove($GUI_BlogEditAssist, "", IniRead("config.ini", "GUI", "X-Pos KompoZer", 0), IniRead("config.ini", "GUI", "Y-Pos KompoZer", 0))
    ElseIf $Get_IniPosApp = 1 And WinActive("PSPad") Then
        WinMove($GUI_BlogEditAssist, "", IniRead("config.ini", "GUI", "X-Pos PSPad", 0), IniRead("config.ini", "GUI", "Y-Pos PSPad", 0))
    EndIf

; GET WINDOW ONTOP STATE FROM INI
    If $Get_IniOnTop = 0 And WinActive("Mozilla Firefox") Or WinActive("KompoZer") Or WinActive("PSPad") Then
        WinSetOnTop($GUI_BlogEditAssist, "", 1)
    ElseIf $Get_IniOnTop = 0 Then
        WinSetOnTop($GUI_BlogEditAssist, "", 0)
    ElseIf $Get_IniOnTop = 1 Then
        WinSetOnTop($GUI_BlogEditAssist, "", 1)
    EndIf
#endregion

    Select

        Case $Msg = $Button_HeadlineFf
            WinActivate("Mozilla Firefox")
            WinWaitActive("Mozilla Firefox")
            Send("^c")          ; copy text
            $GetClip1 = ClipGet(); store text1
            Send("^l")          ; select URL
            Send("^c")          ; copy URL
            $GetClip2 = ClipGet(); store text2
            WinActivate("KompoZer")
            WinWaitActive("KompoZer")
            Send("!i h")    ; send ALT + i, then h (opens "insert", selects "HTML")
            WinWaitActive("Insert HTML")
            Opt("SendKeyDelay", 1)
            Opt("SendKeyDownDelay", 5)
            Send('<h1><a class="headline-linked" href="', 1)    ; insert HTML tags
            Send($GetClip2, 1)      ; paste text2
            Send('">', 1)           ; complete HTML tag
            Send($GetClip1, 1)      ; paste text1
            Send("</a></h1>", 1)    ; insert ending HTML tags
            Opt("SendKeyDelay", 20)
            Opt("SendKeyDownDelay", 15)
            Send("!i")      ; apply changes and close "insert HTML" window
            WinWaitActive("KompoZer")
            Send("^s")  ; save document
            WinActivate("Mozilla Firefox")

        Case $Msg = $Button_QuoteFf
            WinActivate("Mozilla Firefox")
            WinWaitActive("Mozilla Firefox")
            Send("^c")  ; copy highlighted text
            WinActivate("KompoZer")
            WinWaitActive("KompoZer")
            Send("!i h")    ; send ALT + i, then h (opens "insert", selects "HTML")
            WinWaitActive("Insert HTML")
            Opt("SendKeyDelay", 1)
            Opt("SendKeyDownDelay", 5)
            Send('<p><span class="quote">', 1)  ; insert HTML tags
            Send("^v")          ; paste clipboard
            Send("</span></p>", 1)  ; insert CSS tags
            Send("!i")          ; apply changes and close "insert HTML" window
            Opt("SendKeyDelay", 20)
            Opt("SendKeyDownDelay", 15)
            WinWaitActive("KompoZer")
            Send("^s")  ; save document
            WinActivate("Mozilla Firefox")

        Case $Msg = $Button_HeadlineOther
            GUISetState(@SW_HIDE)
            Send("^c")  ; copy text
            GUISetState(@SW_SHOW)
            WinActivate("KompoZer")
            WinWaitActive("KompoZer")
            Send("!i h")    ; send ALT + i, then h (opens "insert", selects "HTML")
            WinWaitActive("Insert HTML")
            Opt("SendKeyDelay", 1)
            Opt("SendKeyDownDelay", 5)
            Send('<h1><span class="headline-plain">', 1)        ; insert HTML tag
            Send("^v")          ; paste text
            Send('</span></h1>', 1) ; insert ending HTML tag
            Opt("SendKeyDelay", 20)
            Opt("SendKeyDownDelay", 15)
            Send("!i")      ; apply changes and close "insert HTML" window
            WinWaitActive("KompoZer")
            Send("^s")  ; save document

        Case $Msg = $Button_QuoteOther
            GUISetState(@SW_HIDE)
            Send("^c")  ; copy highlighted text
            GUISetState(@SW_SHOW)
            WinActivate("KompoZer")
            WinWaitActive("KompoZer")
            Send("!i h")    ; send ALT + i, then h (opens "insert", selects "HTML")
            WinWaitActive("Insert HTML")
            Opt("SendKeyDelay", 1)
            Opt("SendKeyDownDelay", 5)
            Send('<p><span class="quote">', 1)  ; insert HTML tags
            Send("^v")          ; paste clipboard
            Send('</span></p>', 1)  ; insert CSS tags
            Send("!i")          ; apply changes and close "insert HTML" window
            Opt("SendKeyDelay", 20)
            Opt("SendKeyDownDelay", 15)
            WinWaitActive("KompoZer")
            Send("^s")  ; save document

        Case $Msg = $Button_Comment
            WinActivate("KompoZer")
            WinWaitActive("KompoZer")
            Send("!i h")    ; send ALT + i, then h (opens "insert", selects "HTML")
            WinWaitActive("Insert HTML")
            Opt("SendKeyDelay", 1)
            Opt("SendKeyDownDelay", 5)
            Send('<p><span class="comment">comment -- DW</span></p>', 1)    ; insert HTML tags
            Opt("SendKeyDelay", 20)
            Opt("SendKeyDownDelay", 15)
            WinWaitActive("KompoZer")
            Send("^s")  ; save document

        Case $Msg = $Button_Table
            WinActivate("KompoZer")
            WinWaitActive("KompoZer")
            Send("!i h")    ; send ALT + i, then h (opens "insert", selects "HTML")
            WinWaitActive("Insert HTML")
            Opt("SendKeyDelay", 1)
            Opt("SendKeyDownDelay", 5)
            Send('<table style="width: 90%; text-align: left; margin-left: auto; margin-right: auto;" border="0" cellpadding="0" cellspacing="0"><tbody><tr><td></td></tr></tbody></table><br>', 1) ; insert table
            Opt("SendKeyDelay", 20)
            Opt("SendKeyDownDelay", 15)
            Send("!i")      ; apply changes and close "insert HTML" window
            WinWaitActive("KompoZer")
            Send("^s")  ; save document

        Case $Msg = $Button_Load
            If Not WinExists("Mozilla Firefox") Then
                WinExists("[CLASS:MozillaUIWindowClass]", "[REGEXPTITLE:Mozilla Firefox]")
                Run($Get_PathFirefox)
            EndIf
            If Not WinExists("KompoZer") Then
                Run($Get_PathKompozer)
                WinWaitActive("KompoZer")
                Send("^o")
            EndIf

        Case $Msg = $Button_Email
            If Not WinExists("PSPad") Then
                Run($Get_PathPspad)
                WinWaitActive("PSPad")
                Send("^o")  ; open file
            Else
                WinActivate("PSPad")
                WinWaitActive("PSPad")
                Send("^a")  ; select all
                Send("^c")  ; copy
                ShellExecute($Get_PathTbird, "-compose")
                WinWaitActive("Compose: (no subject)")
                Send("{TAB 2}") ; move caret to body
                Send("!i")      ; open 'insert' menu
                Send("h",1)     ; select 'HTML...'
                WinWaitActive("Insert HTML")
                Send("^v")      ; paste clipboard
                Send("!i")      ; insert HTML and close 'insert HTML' edit box
            EndIf
        
        Case $Msg = $Button_Edit
            GUISetState(@SW_HIDE); hide $GUI_BlogEditAssist so focus is on last active
            Send("^a")  ; select all from current edit window
            Send("^c")  ; copy selection
            GUISetState(@SW_SHOW)
            If Not WinExists("PSPad") Then
                Run($Get_PathPspad)
            EndIf
            WinActivate("PSPad")
            WinWaitActive("PSPad")
            Send("^n")  ; open new file
            Send("{ENTER}"); select "txt"
            Send("^v")  ; paste clipboard
        
        Case $Msg = $Button_Config
            
#region GUI settings
            $GUI_BlogEditAssistSettings = GUICreate("Settings", 442, 368, 0, 0, BitOR($WS_SYSMENU,$WS_DLGFRAME,$WS_CLIPSIBLINGS))
            GUICtrlCreateGroup("Program Locations", 8, 8, 425, 155)
            GUICtrlCreateLabel("KompoZer", 24, 32, 90, 17)
            $Input_PathKompozer = GUICtrlCreateInput(IniRead("config.ini", "PATHS", "KompoZer", ""), 130, 28, 220, 21)
            $Button_FindKompozer = GUICtrlCreateButton("Browse", 364, 28, 55, 21)
            GUICtrlCreateLabel("Firefox", 24, 64, 72, 17)
            $Input_PathFirefox = GUICtrlCreateInput(IniRead("config.ini", "PATHS", "Firefox", ""), 130, 60, 220, 21)
            $Button_FindFirefox = GUICtrlCreateButton("Browse", 364, 60, 55, 21)
            GUICtrlCreateLabel("PSPad", 24, 96, 74, 17)
            $Input_PathPspad = GUICtrlCreateInput(IniRead("config.ini", "PATHS", "PSPad", ""), 130, 92, 220, 21)
            $Button_FindPspad = GUICtrlCreateButton("Browse", 364, 92, 55, 21)
            GUICtrlCreateLabel("Thunderbird", 24, 128, 74, 17)
            $Input_PathTbird = GUICtrlCreateInput(IniRead("config.ini", "PATHS", "Thunderbird", ""), 130, 124, 220, 21)
            $Button_FindTbird = GUICtrlCreateButton("Browse", 364, 124, 55, 21)
            $GroupMisc = GUICtrlCreateGroup("Misc Settings", 8, 170, 425, 125)
            GUICtrlCreateLabel("Transparency", 24, 194, 69, 17)
            $SliderTx = GUICtrlCreateSlider(130, 194, 220, 20, BitOR($TBS_BOTH,$TBS_NOTICKS))
            GUICtrlSetLimit(-1, 255, 50)
            GUICtrlSetData(-1, IniRead("config.ini", "GUI", "Transparency", 255))
            GUICtrlCreateLabel("Always on top:", 24, 224, 100, 17)
            $Radio_OnTopForApp = GUICtrlCreateRadio("When Firefox/KompoZer/PSPad active", 136, 226, 201, 21, BitOR($BS_AUTORADIOBUTTON,$BS_PUSHLIKE))
            GUICtrlSetState(-1, $GUI_UNCHECKED)
            $Radio_OnTopAlways = GUICtrlCreateRadio("Always", 360, 226, 57, 21, BitOR($BS_AUTORADIOBUTTON,$BS_PUSHLIKE))
            GUICtrlSetState(-1, $GUI_CHECKED)
            $Checkbox_IndPos = GUICtrlCreateCheckbox("Remember window positions for each", 136, 260, 201, 17)
            $Button_ExitSettings = GUICtrlCreateButton("Exit", 8, 310, 427, 25)
            GUISetState(@SW_SHOW)
#endregion
            
#region before settins loop         
        ; GET INI SETTINGS
            $Get_IniOnTopState = IniRead("config.ini", "GUI", "OnTop", 1)
            If $Get_IniOnTopState = 0 Then
                GUICtrlSetState($Radio_OnTopForApp, $GUI_CHECKED)
            ElseIf $Get_IniOnTopState = 1 Then
                GUICtrlSetState($Radio_OnTopAlways, $GUI_CHECKED)
            EndIf
            
            $Get_IndPosState = IniRead("config.ini", "GUI", "Remember position per app", 0)
            If $Get_IndPosState = 1 Then
                GUICtrlSetState($Checkbox_IndPos, $GUI_CHECKED)
            EndIf
            
        ; DECLARE VARIABLES
            Local $Get_SliderTxState = GUICtrlRead($SliderTx)
#endregion

            ; SETTINGS LOOP
                While 1
                    
                    $Msg = GUIGetMsg()
                    
                    Switch $Msg
                    
                        Case $GUI_EVENT_CLOSE
                            GUIDelete($GUI_BlogEditAssistSettings)
                            ExitLoop

                        Case $Button_FindKompozer
                            $File = FileOpenDialog("", "", "Executables (*.exe)", 1)
                            GUICtrlSetData($Input_PathKompozer, $File, "")
                            FileChangeDir(@ScriptDir)   ; resets working dir to script dir
                            $StringCheck = StringInStr($File, "kompozer.exe")
                            If $StringCheck < 1 Then
                                MsgBox(64, "Error", "KompoZer not found!")
                            EndIf
                            $Get_PathKompozer = GUICtrlRead($Input_PathKompozer)
                            IniWrite("config.ini", "PATHS", "KompoZer", $Get_PathKompozer)
                            
                        Case $Button_FindFirefox
                            $File = FileOpenDialog("", "", "Executables (*.exe)", 1)
                            GUICtrlSetData($Input_PathFirefox, $File, "")
                            FileChangeDir(@ScriptDir)
                            $StringCheck = StringInStr($File, "firefox.exe")
                            If $StringCheck < 1 Then
                                MsgBox(64, "Error", "Firefox not found!")
                            EndIf
                            $Get_PathFirefox = GUICtrlRead($Input_PathFirefox)
                            IniWrite("config.ini", "PATHS", "Firefox", $Get_PathFirefox)
                            
                        Case $Button_FindPspad
                            $File = FileOpenDialog("", "", "Executables (*.exe)", 1)
                            GUICtrlSetData($Input_PathPspad, $File, "")
                            FileChangeDir(@ScriptDir)
                            $StringCheck = StringInStr($File, "pspad.exe")
                            If $StringCheck < 1 Then
                                MsgBox(64, "Error", "PSPad not found!")
                            EndIf
                            $Get_PathPspad = GUICtrlRead($Input_PathPspad)
                            IniWrite("config.ini", "PATHS", "PSPad", $Get_PathPspad)
                            
                        Case $Button_FindTbird
                            $File = FileOpenDialog("", "", "Executables (*.exe)", 1)
                            GUICtrlSetData($Input_PathTbird, $File, "")
                            FileChangeDir(@ScriptDir)
                            $StringCheck = StringInStr($File, "thunderbird.exe")
                            If $StringCheck < 1 Then
                                MsgBox(64, "Error", "Thunderbird not found!")
                            EndIf
                            $Get_PathTbird = GUICtrlRead($Input_PathTbird)
                            IniWrite("config.ini", "PATHS", "Thunderbird", $Get_PathTbird)
                            
                        Case $SliderTx
                            $Get_SliderTxState = GUICtrlRead($SliderTx)
                            WinSetTrans($GUI_BlogEditAssist, "", $Get_SliderTxState)
                            IniWrite("config.ini", "GUI", "Transparency", $Get_SliderTxState)
                            
                        Case $Radio_OnTopForApp
                            IniWrite("config.ini", "GUI", "OnTop", 0)
                            MsgBox(0, "Information", "Settings saved! Restart Blog Editor Asist.")
                        
                        Case $Radio_OnTopAlways
                            IniWrite("config.ini", "GUI", "OnTop", 1)
                            MsgBox(0, "Information", "Settings saved! Restart Blog Editor Asist.")
                            
                        Case $Checkbox_IndPos
                            $Get_IndPosState = GUICtrlRead($Checkbox_IndPos)
                            If $Get_IndPosState = $GUI_CHECKED And Winexists("Firefox") AND WinExists("KompoZer") And WinExists("PSPad") Then
                                IniWrite("config.ini", "GUI", "Remember position per app", 1)
                                WinSetOnTop($GUI_BlogEditAssist, "", 1)
                                WinActivate("Firefox")
                                WinWaitActive("Firefox")
                                WinSetState("Firefox", "", @SW_MAXIMIZE)
                                MsgBox(0, "Information", "Position Blog Editor Assist where desired then click 'OK'")
                                $Get_IniPosApp = WinGetPos($GUI_BlogEditAssist)
                                IniWrite("config.ini", "GUI", "X-Pos Firefox", $Get_IniPosApp[0])
                                IniWrite("config.ini", "GUI", "Y-Pos Firefox", $Get_IniPosApp[1])
                                WinActivate("KompoZer")
                                WinWaitActive("KompoZer")
                                WinSetState("KompoZer", "", @SW_MAXIMIZE)
                                MsgBox(0, "Information", "Position Blog Editor Assist where desired then click 'OK'")
                                $Get_IniPosApp = WinGetPos($GUI_BlogEditAssist)
                                IniWrite("config.ini", "GUI", "X-Pos KompoZer", $Get_IniPosApp[0])
                                IniWrite("config.ini", "GUI", "Y-Pos KompoZer", $Get_IniPosApp[1])
                                WinActivate("PSPad")
                                WinWaitActive("PSPad")
                                WinSetState("PSPad", "", @SW_MAXIMIZE)
                                MsgBox(0, "Information", "Position Blog Editor Assist where desired then click 'OK'")
                                $Get_IniPosApp = WinGetPos($GUI_BlogEditAssist)
                                IniWrite("config.ini", "GUI", "X-Pos PSPad", $Get_IniPosApp[0])
                                IniWrite("config.ini", "GUI", "Y-Pos PSPad", $Get_IniPosApp[1])
                                MsgBox(0, "Information", "Settings saved! Restart Blog Editor Asist.")
                                WinActivate($GUI_BlogEditAssistSettings)
                            ElseIf $Get_IndPosState = $GUI_CHECKED Then
                                MsgBox(64, "Error", "Firefox/KompoZer/PSPad not running!")
                            ElseIf $Get_IndPosState = $GUI_UNCHECKED Then
                                MsgBox(0, "Information", "Settings saved! Restart Blog Editor Asist.")
                                IniWrite("config.ini", "GUI", "Remember position per app", 0)
                            EndIf
                        
                        Case $Button_ExitSettings
                            GUIDelete($GUI_BlogEditAssistSettings)
                            ExitLoop
                            
                    EndSwitch
            
                WEnd

        Case $Msg = $Button_ExitMain
            Exit

    EndSelect

WEnd

; SAVE SETTINGS
Func OnAutoItExit()
    IniWrite("config.ini", "GUI", "X-Pos", $Pos[0])
    IniWrite("config.ini", "GUI", "Y-Pos", $Pos[1])
EndFunc
Link to comment
Share on other sites

I cant test this... but noted

1

Send("!i h") ; send ALT + i, then h (opens "insert", selects "HTML")

this can cause a problem, maybe it should be 2 separate send commands

2

Opt("SendKeyDelay", 1)

Opt("SendKeyDownDelay", 5)

Send('<h1><a class="headline-linked" href="', 1) ; insert HTML tags

Send($GetClip2, 1) ; paste text2

Send('">', 1) ; complete HTML tag

Send($GetClip1, 1) ; paste text1

Send("</a></h1>", 1) ; insert ending HTML tags

A. the continuous send key delays... I've never done that

B. The 1 & 5 seems very small for the time required to actually send the info

3

maybe you can use a variable and continue to add the info required and then use ControlSetText() to send 1 variable rather than multiple

... dunno, I cant do any testing

8)

NEWHeader1.png

Link to comment
Share on other sites

@Valuater - much thanks! This is my first script (first useful code i've ever written at all), so i'm grateful for the feedback. Thanks for taking the time to review it :)

Early in the code, before the main loop, i set the 'sendkey*' options to slow them a bit otherwise i have problems. This results in taking longer to send text in the edit windows, where the additional delay isn't necessary. That's why i shorten the delay before sending the text, then restore it to where it was. However... that method is dumb i think. I need to change to ClipPut or ControlSetText() or whatever. Thanks for pointing that out!

Never had a problem, that i know of, with Send("!i h"), though i think i'll take your advise and send twice as suggested.

Re: the GUICtrlSetBkColor problem, i may change to drop-down menus and dump most of the buttons as i add more functionality, so i'm not really worried about it. However, maybe the AutoIt devs should look at the "problem", if in fact it's really a problem.

Link to comment
Share on other sites

You don't need the programs to test. Just run it, click once on the 'drag.gif' area (you have to have the gif), click off of the gui to focus something else, then click the close (x) button. It won't close because it'll be trying to run the first Case. It's freaky.

Thanks for linking to the tool bars. I wanted to write my first script by referring to others as little as possible, but now it's time to look at better code :)

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