Jump to content

Dynamically created GUIs with simultaneous minimize/restore but only one "shown" window


zvvyt
 Share

Recommended Posts

Hello ya'll!

My problem is split in two, so I'll start with the first one:

What I'm having is my script with dynamically created GUIs with similar / identical names. I would like to have that undepending on how many windows I have open to only have one "window" down at the taskbar.

I guess all I need is the correct GUI style, but I can't find which one I need.

Which brings me to problem part 2 (which I also find to be the easy part):

Windows will open and close on random, so there's no set order in which they'll get closed. But I still need one "window" at the taskbar to work with as long as there's at least one window open.

In the action of one of these windows getting minimized/restored all of the windows will act simultaneously.

This will be solved with something similar: 

case $GUI_EVENT_MINIMIZE
         for $1 = 1 to Ubound($ActiveWindows) step +1
                WinSetState($ActiveWindows[$1], @SW_MINIMIZE)
        Next

And vice versa for restore.

So .. Mainly prob #1 that I need some help with, and a thought about the "always one window at taskbar"-issue.

Just point me in the right direction and I'll hopefully solve it myself ^__^'

Thanks, and have a great weekend!

zvvyt

Link to comment
Share on other sites

have a look:

Opt("TrayIconHide", 1) ; this will hide all
; or
TraySetState(2) ; will hide the tray icon

I'm not sure if this will leave you 1 tray icon for at least 1 window; I'm sure a guru will chime in ;)

To minimize all you can do the following:

WinMinimizeAll() ; this will minimize all windows
;or
Local $ShellObj = ObjCreate("Shell.Application")
$ShellObj.ToggleDesktop() ; will minimize all currently open windows -- if called again, it will bring up all windows minimized by ToggleDesktop()

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Link to comment
Share on other sites

  • Moderators

zvvyt,

To hide the button on the taskbar you need to set another GUI as the "parent" in the GUICreate call. So it sounds like you could do with a "master" GUI with all the others as children. :)

Is that enough to get you going? :huh:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

 

have a look:

Opt("TrayIconHide", 1) ; this will hide all
; or
TraySetState(2) ; will hide the tray icon

I'm not sure if this will leave you 1 tray icon for at least 1 window; I'm sure a guru will chime in ;)

I'm sorry if I were unclear, but it's not in the tray where I only want one icon, but on the taskbar where only the open windows are.

To minimize all you can do the following:

WinMinimizeAll() ; this will minimize all windows
;or
Local $ShellObj = ObjCreate("Shell.Application")
$ShellObj.ToggleDesktop() ; will minimize all currently open windows -- if called again, it will bring up all windows minimized by ToggleDesktop()

I only want to minimize the windows I've made myself, which all have about the same name.

To hide the button on the taskbar you need to set another GUI as the "parent" in the GUICreate call. So it sounds like you could do with a "master" GUI with all the others as children. :)

Is that enough to get you going? :huh:

Well, both yay and nay.

I've tried with a hidden GUI as I don't want to have another window active and primary all the GUIs in this script are made dynamically, but I couldn't get that to work.

When I try to minimize child GUIs whos parent is hidden they don't have anywhere to go, so to say. See my attachment at the bottom.

Have a look at the script in it's whole. And I'm sorry if some of the texts are hard to understand as the are in swedish, but all of the relevant text should be in proper english :)

#cs
Unlimited, controllable windows

$WinArray[n][0] = GUI winhandle
$WinArray[n][1] = Rich winhandle
$WinArray[n][2] = GUI height
$WinArray[n][3] = GUI width
$WinArray[n][4] = Rich color
$WinArray[n][5] = Rich textsize

$SaveArray[0] = GUI-name minus "LAN-notes"
$SaveArray[1] =
#ce
Opt("GUIOnEventMode", 1)
Opt("TrayMenuMode", 1 + 2)
Opt("TrayOnEventMode",1)
#include <array.au3>
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <WinAPI.au3>
#include <TrayConstants.au3>
#include <GuiRichEdit.au3>
#include <GuiMenu.au3>
#include <GuiComboBox.au3>
#include <Color.au3>

TrayCreateItem("LAN-notes")
TrayItemSetState(-1, $TRAY_DISABLE)
TrayCreateItem("")
TrayCreateItem("Ny lapp")
TrayItemSetOnEvent(-1, "New")
TrayCreateItem("")
TrayCreateItem("Följ lapp")
TrayItemSetOnEvent(-1, "LoadList")
TrayCreateItem("")
TrayCreateItem("Stäng av")
TrayItemSetOnEvent(-1,"TrayExit")
TraySetState(1)

Global Enum $idCopy = 1000, $idPaste, $idUndo, $idSelectAll, $idFontsize, $idBkColor, $idCut, $idTest

Global $WinArray[1][6], $GUI_Size[4], $Font_hFont ,$BkColor_RedInputPrev = 0, $BkColor_GreenInputPrev = 0, $BkColor_BlueInputPrev = 0, _
    $BkColor_RedInputPrevSaved = 0, $BkColor_GreenInputPrevSaved = 0, $BkColor_BlueInputPrevSaved = 0, $ColorEventsVal = 0, $BkColor_OK, $BkColor_Cancel, $FontEventsVal = 0, _
    $Font_OK, $Font_Cancel

$hWnd = GUICreate("",0,0) ;-------------------------------------------------- Hidden parentGUI
GUISetState(@SW_HIDE,-1)

Call("New")
while 1
    Sleep(10)
    $Current_GUI = WinGetHandle("[ACTIVE]")
    If _ArraySearch($WinArray,$Current_GUI) <> -1 And WinGetState($Current_GUI) = BitOR(1,2,4,8) Then
        $GUI_Size = WinGetPos($Current_GUI)
        $Current_Rich = $WinArray[_ArraySearch($WinArray,$Current_GUI)][1]
        ;$Rich_Size = GUICtrlSetPos($Current_Rich)
        If $GUI_Size[2] <> $WinArray[_ArraySearch($WinArray,$Current_GUI)][2] Or $GUI_Size[3] <> $WinArray[_ArraySearch($WinArray,$Current_GUI)][3] Then
            _WinAPI_MoveWindow($Current_Rich,0,20,$GUI_Size[2]-20,$GUI_Size[3]-60)
            $WinArray[_ArraySearch($WinArray,$Current_GUI)][2] = $GUI_Size[2]
            $WinArray[_ArraySearch($WinArray,$Current_GUI)][3] = $GUI_Size[3]
        EndIf
    EndIf
WEnd

Func New()
ReDim $WinArray[UBound($WinArray,1)+1][6]

$WinArray[UBound($WinArray,1)-1][0] = GUICreate("LAN-notes - ",200,200,Default,Default,BitOR($ws_sizebox,$WS_MINIMIZEBOX),-1,$hWnd) ;-------------------------------------------------- Dynamical childGUIs
$WinArray[UBound($WinArray,1)-1][2] = 200
$WinArray[UBound($WinArray,1)-1][3] = 200
$WinArray[UBound($WinArray,1)-1][4] = "255,255,255"
$WinArray[UBound($WinArray,1)-1][5] = 8

GUISetOnEvent($GUI_EVENT_CLOSE, "MainEvents")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "MainEvents")
GUICtrlCreateButton("+",0,0,20,20)
    GUICtrlSetTip(-1,"Skapa ny lapp")
    GUICtrlSetFont(-1,12)
    GUICtrlSetOnEvent(-1,"New")
GUICtrlCreateButton("Spara",20,0,35,20)
    GUICtrlSetOnEvent(-1,"Save")
;GUICtrlCreateButton("Test", 50,80)
    ;GUICtrlSetOnEvent(-1,"Test")
GUICtrlCreateInput("",55,0,105,20)
    GUICtrlSetState(-1,$GUI_DISABLE)
GUICtrlCreateButton("Ändra",160,0,35,20)
    GUICtrlSetOnEvent(-1,"EditProjName")
$WinArray[UBound($WinArray,1)-1][1] = _GUICtrlRichEdit_Create($WinArray[UBound($WinArray,1)-1][0], "",0,25,180,160, BitOR($ES_AUTOVSCROLL, $WS_VSCROLL, $ES_WANTRETURN,$ES_MULTILINE))
_GUICtrlRichEdit_SetFont($WinArray[UBound($WinArray,1)-1][1], 8)

Global $hMenu = _GUICtrlMenu_CreatePopup()

_GUICtrlMenu_AddMenuItem($hMenu, "Ångra", $idUndo)
_GUICtrlMenu_AddMenuItem($hMenu, "")
_GUICtrlMenu_AddMenuItem($hMenu, "Klipp ut", $idCut)
_GUICtrlMenu_AddMenuItem($hMenu, "Kopiera", $idCopy)
_GUICtrlMenu_AddMenuItem($hMenu, "Klistra in", $idPaste)
_GUICtrlMenu_AddMenuItem($hMenu, "Markera allt", $idSelectAll)
_GUICtrlMenu_AddMenuItem($hMenu, "")
_GUICtrlMenu_AddMenuItem($hMenu, "Textstorlek", $idFontsize)
_GUICtrlMenu_AddMenuItem($hMenu, "Bakgrundsfärg", $idBkColor)
_GUICtrlMenu_AddMenuItem($hMenu, "")
_GUICtrlMenu_AddMenuItem($hMenu, "Test", $idTest)

Global $wProcHandle = DllCallbackRegister("_WindowProc", "ptr", "hwnd;uint;wparam;lparam")

Global $wProcOld = _WinAPI_SetWindowLong($WinArray[UBound($WinArray,1)-1][1], $GWL_WNDPROC, DllCallbackGetPtr($wProcHandle))

GUISetState()

EndFunc

Func Test($RichTest)
    If _GUICtrlRichEdit_GetTextLength($RichTest, True, True) > 0 Then
        Local $RichPrevFontSize, $RichPrevFontSizeChange, $RichStringFonts, $RichCurrentFontSize
        For $1 = 0 To _GUICtrlRichEdit_GetTextLength($RichTest, True, True) Step +1
            _GUICtrlRichEdit_SetSel($RichTest,$1,$1)
            If $1 = 0 Then
                $RichPrevFontSize = _GUICtrlRichEdit_GetFont($RichTest)
                $RichPrevFontSizeChange = $1
                $RichStringFonts = String("<" & $RichPrevFontSize[0] & ">")
            ElseIf $1 > 0 Then
                $RichCurrentFontSize = _GUICtrlRichEdit_GetFont($RichTest)
                If $RichCurrentFontSize[0] <> $RichPrevFontSize[0] Then
                    $RichCurrentFontSizeChange = $1-1
                    If $RichPrevFontSizeChange <> 0 Then $RichPrevFontSizeChange = $RichPrevFontSizeChange-1
                    $RichStringFonts = String($RichStringFonts & _GUICtrlRichEdit_GetTextInRange($RichTest,$RichPrevFontSizeChange,$RichCurrentFontSizeChange) & "<" & $RichPrevFontSize[0] & ">" & "<" & $RichCurrentFontSize[0] & ">")
                    $RichPrevFontSize[0] = $RichCurrentFontSize[0]
                    $RichPrevFontSizeChange = $1
                EndIf
            EndIf
        Next
        If $RichPrevFontSizeChange <> 0 Then $RichPrevFontSizeChange = $RichPrevFontSizeChange-1
        $RichStringFonts = String($RichStringFonts & _GUICtrlRichEdit_GetTextInRange($RichTest,$RichPrevFontSizeChange, $1) & "<" & $RichPrevFontSize[0] & ">")
        ConsoleWrite($RichStringFonts & @CRLF)
    EndIf
EndFunc

Func MainEvents()
    Select
        Case @GUI_CtrlId = $GUI_EVENT_CLOSE
            If WinExists("LAN-notes - ") Then
                If MsgBox(4,"Stäng?","Är du säker på att du vill stänga lappen?") = 6 Then
                    For $1 = (_ArraySearch($WinArray,@GUI_WinHandle)) To (UBound($WinArray,1)-2) Step +1
                        $WinArray[$1][0] = $WinArray[$1+1][0]
                        $WinArray[$1][1] = $WinArray[$1+1][1]
                        $WinArray[$1][2] = $WinArray[$1+1][2]
                        $WinArray[$1][3] = $WinArray[$1+1][3]
                    Next
                    ReDim $WinArray[UBound($WinArray,1)-1][4]
                    GUIDelete(@GUI_WinHandle)
                EndIf
            EndIf
    EndSelect
EndFunc

Func EditProjName()
    ConsoleWrite("Edit projName" & @CRLF)
    If GUICtrlGetState(@GUI_CtrlId-1) = 144 Then
        GUICtrlSetState(@GUI_CtrlId-1,$GUI_ENABLE)
        GUICtrlSetData(@GUI_CtrlId,"Klar")
    Else
        WinSetTitle(@GUI_WinHandle,"","LAN-notes - " & GUICtrlRead(@GUI_CtrlId-1))
        GUICtrlSetState(@GUI_CtrlId-1,$GUI_DISABLE)
        GUICtrlSetData(@GUI_CtrlId,"Ändra")
    EndIf
EndFunc

Func Save()
    ConsoleWrite("--> Save" & @CRLF)
    ConsoleWrite(StringReplace(WinGetTitle(@GUI_WinHandle),"LAN-notes - ","") & @CRLF)
EndFunc

Func TrayExit()
    ConsoleWrite("TrayExit")
    If MsgBox(4,"Stäng?","Är du säker på att du vill stänga av?") = 6 Then
        DllCallbackFree($wProcHandle)
        Exit
    EndIf
EndFunc

Func _WindowProc($hWnd, $Msg, $wParam, $lParam)
    $GUI = WinActive("LAN-notes - ")
    If _ArraySearch($WinArray,$GUI) <> -1 Then
    Switch $hWnd
        Case $WinArray[_ArraySearch($WinArray,$GUI)][1]
            Switch $Msg
                Case $WM_RBUTTONUP
                    ConsoleWrite("-> Rightclick" & @LF)
                    _GUICtrlMenu_TrackPopupMenu($hMenu, $hWnd)
                    Return 0
                Case $WM_COMMAND
                    Switch $wParam
                        Case $idCut
                            ConsoleWrite("-> Cut" & @LF)
                            _GUICtrlRichEdit_Cut($WinArray[_ArraySearch($WinArray,$GUI)][1])
                        Case $idCopy
                            ConsoleWrite("-> Copy" & @LF)
                            _GUICtrlRichEdit_Copy($WinArray[_ArraySearch($WinArray,$GUI)][1])
                        Case $idPaste
                            ConsoleWrite("-> Paste" & @LF)
                            _GUICtrlRichEdit_Paste($WinArray[_ArraySearch($WinArray,$GUI)][1])
                        Case $idUndo
                            ConsoleWrite("-> Undo" & @LF)
                            _GUICtrlRichEdit_Undo($WinArray[_ArraySearch($WinArray,$GUI)][1])
                        Case $idSelectAll
                            ConsoleWrite("-> Select all" & @LF)
                            _GUICtrlRichEdit_SetSel($WinArray[_ArraySearch($WinArray,$GUI)][1],0,StringLen(_GUICtrlRichEdit_GetText($WinArray[_ArraySearch($WinArray,$GUI)][1])))
                        Case $idFontsize
                            ConsoleWrite("-> Size" &@LF)
                            $Return_Font = _Fontsize($GUI,$WinArray[_ArraySearch($WinArray,$GUI)][5])
                            ConsoleWrite($Return_Font&@CRLF)
                            If $Return_Font <> 0 Then
                                $Text_Selected = _GUICtrlRichEdit_GetSel($WinArray[_ArraySearch($WinArray,$GUI)][1])
                                If $Text_Selected[0] = $Text_Selected[1] Then
                                    _GUICtrlRichEdit_SetSel($WinArray[_ArraySearch($WinArray,$GUI)][1],0,_GUICtrlRichEdit_GetTextLength($WinArray[_ArraySearch($WinArray,$GUI)][1],True,True))
                                    _GUICtrlRichEdit_SetFont($WinArray[_ArraySearch($WinArray,$GUI)][1],$Return_Font)
                                    _GUICtrlRichEdit_SetSel($WinArray[_ArraySearch($WinArray,$GUI)][1],$Text_Selected[0],$Text_Selected[0])
                                Else
                                    _GUICtrlRichEdit_SetFont($WinArray[_ArraySearch($WinArray,$GUI)][1],$Return_Font)
                                EndIf
                            EndIf
                        Case $idBkColor
                            ConsoleWrite("-> BkColor" &@LF)
                            $Return_BkColor = _BkColor($GUI)
                            If $Return_BkColor <> 0 Then _GUICtrlRichEdit_SetBkColor($WinArray[_ArraySearch($WinArray,$GUI)][1],$Return_BkColor)
                        Case $idTest
                            ConsoleWrite("-> Test" &@LF)
                            Call("Test",$WinArray[_ArraySearch($WinArray,$GUI)][1])
                    EndSwitch
            EndSwitch
    EndSwitch
    endif
    Local $aRet = DllCall("user32.dll", "int", "CallWindowProc", "ptr", $wProcOld, _
                          "hwnd", $hWnd, "uint", $Msg, "wparam", $wParam, "lparam", $lParam)
    Return $aRet[0]
EndFunc

Func _BkColor($hGui)
    $PrevBkColors = StringSplit($WinArray[_ArraySearch($WinArray,$hGui)][4],",")
    $BkColor_RedInputPrevSaved = $PrevBkColors[1]
    $BkColor_GreenInputPrevSaved = $PrevBkColors[2]
    $BkColor_BlueInputPrevSaved = $PrevBkColors[3]
    $hGui_BkColor = GUICreate("Ställ bakgrundsfärg", 250,150,-1,-1,$WS_border, -1,$hGui)
    $BkColor_MainInput = GUICtrlCreateCombo("Vit", 90,15,70)
    If $BkColor_RedInputPrevSaved = 255 And $BkColor_GreenInputPrevSaved = 255 And $BkColor_BlueInputPrevSaved = 255 Then GUICtrlSetData(-1,"Röd|Grön|Blå|Svart|Egen","Vit")
    If $BkColor_RedInputPrevSaved = 255 And $BkColor_GreenInputPrevSaved = 0 And $BkColor_BlueInputPrevSaved = 0 Then GUICtrlSetData(-1,"Röd|Grön|Blå|Svart|Egen","Röd")
    If $BkColor_RedInputPrevSaved = 0 And $BkColor_GreenInputPrevSaved = 255 And $BkColor_BlueInputPrevSaved = 0 Then GUICtrlSetData(-1,"Röd|Grön|Blå|Svart|Egen","Grön")
    If $BkColor_RedInputPrevSaved = 0 And $BkColor_GreenInputPrevSaved = 0 And $BkColor_BlueInputPrevSaved = 255 Then GUICtrlSetData(-1,"Röd|Grön|Blå|Svart|Egen","Blå")
    If $BkColor_RedInputPrevSaved = 0 And $BkColor_GreenInputPrevSaved = 0 And $BkColor_BlueInputPrevSaved = 0 Then GUICtrlSetData(-1,"Röd|Grön|Blå|Svart|Egen","Svart")
    If ($BkColor_RedInputPrevSaved <> 0 And $BkColor_RedInputPrevSaved <> 255) Or ($BkColor_GreenInputPrevSaved <> 0 And $BkColor_GreenInputPrevSaved <> 255) Or _
        ($BkColor_BlueInputPrevSaved <> 0 And $BkColor_BlueInputPrevSaved <> 255) Then GUICtrlSetData(-1,"Röd|Grön|Blå|Svart|Egen","Egen")
    GUICtrlCreateLabel("Röd", 10,40,30)
    GUICtrlSetColor(-1, 0xFF0000)
    GUICtrlCreateLabel("Grön", 10,60,30)
    GUICtrlSetColor(-1, 0x00FF00)
    GUICtrlCreateLabel("Blå", 10,80,30)
    GUICtrlSetColor(-1, 0x0000FF)
    $BkColor_Red = GUICtrlCreateSlider(35,40,120,-1)
    GUICtrlSetLimit(-1,255)
    GUICtrlSetData(-1, $BkColor_RedInputPrevSaved)
    $BkColor_Green = GUICtrlCreateSlider(35,60,120,-1)
    GUICtrlSetLimit(-1,255)
    GUICtrlSetData(-1, $BkColor_GreenInputPrevSaved)
    $BkColor_Blue = GUICtrlCreateSlider(35,80,120,-1)
    GUICtrlSetLimit(-1,255)
    GUICtrlSetData(-1,$BkColor_BlueInputPrevSaved)
    $BkColor_RedInput = GUICtrlCreateInput($BkColor_RedInputPrevSaved,160,40,40,20,$ES_NUMBER)
    GUICtrlSetLimit(-1,255)
    $BkColor_GreenInput = GUICtrlCreateInput($BkColor_GreenInputPrevSaved,160,60,40,20,$ES_NUMBER)
    GUICtrlSetLimit(-1,255)
    $BkColor_BlueInput = GUICtrlCreateInput($BkColor_BlueInputPrevSaved,160,80,40,20,$ES_NUMBER)
    GUICtrlSetLimit(-1,255)
    $BkColor_OK = GUICtrlCreateButton("OK", 25,100,50,25)
    GUICtrlSetOnEvent(-1,"ColorEvents")
    $BkColor_Cancel = GUICtrlCreateButton("Avbryt", 75,100,50,25)
    GUICtrlSetOnEvent(-1,"ColorEvents")
    Local $BkColor_RedPrev = $BkColor_RedInputPrevSaved, $BkColor_GreenPrev = $BkColor_GreenInputPrevSaved, $BkColor_BluePrev = $BkColor_BlueInputPrevSaved, $BkColor_MainInputPrev
    $BkColor_Prev = $BkColor_RedInputPrevSaved*65536+$BkColor_GreenInputPrevSaved*256+$BkColor_BlueInputPrevSaved
    $BkColor_ExampleColor = GUICtrlCreateLabel("",210,40,30,60)
    GUICtrlSetColor(-1, $BkColor_Prev)
    GUISetState(@SW_DISABLE, $hGui)
    GUISetState(@SW_SHOW, $hGui_BkColor)
    While 1
        If _GUICtrlComboBox_GetDroppedState($BkColor_MainInput) = False Then
            If $ColorEventsVal = 1 Then
                GUIDelete($hGui_BkColor)
                GUISetState(@SW_ENABLE,$hGui)
                WinActivate($hGui)
                $ColorEventsVal = 0
                Return 0
                ExitLoop
            ElseIf $ColorEventsVal = 2 Then
                $WinArray[_ArraySearch($WinArray,$hGui)][4] = GUICtrlRead($BkColor_RedInput)&","&GUICtrlRead($BkColor_GreenInput)&","&GUICtrlRead($BkColor_BlueInput)
                Local $BkColor_ColorArray[3] = [GUICtrlRead($BkColor_RedInput), GUICtrlRead($BkColor_GreenInput), GUICtrlRead($BkColor_BlueInput)]
                $BkColor_Color = _ColorSetCOLORREF($BkColor_ColorArray)
                ConsoleWrite($BkColor_Color&@CRLF)
                GUIDelete($hGui_BkColor)
                GUISetState(@SW_ENABLE,$hGui)
                WinActivate($hGui)
                $ColorEventsVal = 0
                Return $BkColor_Color
                ExitLoop
            EndIf
        If GUICtrlRead($BkColor_MainInput) <> $BkColor_MainInputPrev Then
            ConsoleWrite(GUICtrlRead($BkColor_MainInput)&@CRLF)
            If GUICtrlRead($BkColor_MainInput) = "Vit" Then
                ConsoleWrite("Set to white"&@CRLF)
                GUICtrlSetData($BkColor_Red,255)
                $BkColor_RedPrev = 255
                GUICtrlSetData($BkColor_RedInput,255)
                $BkColor_RedInputPrev = 255
                GUICtrlSetData($BkColor_Green,255)
                $BkColor_GreenPrev = 255
                GUICtrlSetData($BkColor_GreenInput,255)
                $BkColor_GreenInputPrev = 255
                GUICtrlSetData($BkColor_Blue,255)
                $BkColor_BluePrev = 255
                GUICtrlSetData($BkColor_BlueInput,255)
                $BkColor_BlueInputPrev = 255
            EndIf
            If GUICtrlRead($BkColor_MainInput) =  "Röd" Then
                ConsoleWrite("Set to red"&@CRLF)
                GUICtrlSetData($BkColor_Red,255)
                $BkColor_RedPrev = 255
                GUICtrlSetData($BkColor_RedInput,255)
                $BkColor_RedInputPrev = 255
                GUICtrlSetData($BkColor_Green,0)
                $BkColor_GreenPrev = 0
                GUICtrlSetData($BkColor_GreenInput,0)
                $BkColor_GreenInputPrev = 0
                GUICtrlSetData($BkColor_Blue,0)
                $BkColor_BluePrev = 0
                GUICtrlSetData($BkColor_BlueInput,0)
                $BkColor_BlueInputPrev = 0
            EndIf
            If GUICtrlRead($BkColor_MainInput) =  "Grön" Then
                ConsoleWrite("Set to green"&@CRLF)
                GUICtrlSetData($BkColor_Red,0)
                $BkColor_RedPrev = 0
                GUICtrlSetData($BkColor_RedInput,0)
                $BkColor_RedInputPrev = 0
                GUICtrlSetData($BkColor_Green,255)
                $BkColor_GreenPrev = 255
                GUICtrlSetData($BkColor_GreenInput,255)
                $BkColor_GreenInputPrev = 255
                GUICtrlSetData($BkColor_Blue,0)
                $BkColor_BluePrev = 0
                GUICtrlSetData($BkColor_BlueInput,0)
                $BkColor_BlueInputPrev = 0
            EndIf
            If GUICtrlRead($BkColor_MainInput) =  "Blå" Then
                ConsoleWrite("Set to blue"&@CRLF)
                GUICtrlSetData($BkColor_Red,0)
                $BkColor_RedPrev = 0
                GUICtrlSetData($BkColor_RedInput,0)
                $BkColor_RedInputPrev = 0
                GUICtrlSetData($BkColor_Green,0)
                $BkColor_GreenPrev = 0
                GUICtrlSetData($BkColor_GreenInput,0)
                $BkColor_GreenInputPrev = 0
                GUICtrlSetData($BkColor_Blue,255)
                $BkColor_BluePrev = 255
                GUICtrlSetData($BkColor_BlueInput,255)
                $BkColor_BlueInputPrev = 255
            EndIf
            If GUICtrlRead($BkColor_MainInput) =  "Svart" Then
                ConsoleWrite("Set to black"&@CRLF)
                GUICtrlSetData($BkColor_Red,0)
                $BkColor_RedPrev = GUICtrlRead($BkColor_Red)
                GUICtrlSetData($BkColor_RedInput,0)
                $BkColor_RedInputPrev = GUICtrlRead($BkColor_RedInput)
                GUICtrlSetData($BkColor_Green,0)
                $BkColor_GreenPrev = GUICtrlRead($BkColor_Green)
                GUICtrlSetData($BkColor_GreenInput,0)
                $BkColor_GreenInputPrev = GUICtrlRead($BkColor_GreenInput)
                GUICtrlSetData($BkColor_Blue,0)
                $BkColor_BluePrev = GUICtrlRead($BkColor_Blue)
                GUICtrlSetData($BkColor_BlueInput,0)
                $BkColor_BlueInputPrev = GUICtrlRead($BkColor_BlueInput)
            EndIf
            $BkColor_MainInputPrev = GUICtrlRead($BkColor_MainInput)
        EndIf
        If GUICtrlRead($BkColor_RedInput) > 255 Then
            GUICtrlSetData($BkColor_Red,255)
            GUICtrlSetData($BkColor_RedInput,255)
            $BkColor_RedPrev = 255
            $BkColor_RedInputPrev = 255
        EndIf
        If GUICtrlRead($BkColor_GreenInput) > 255 Then
            GUICtrlSetData($BkColor_Green,255)
            GUICtrlSetData($BkColor_GreenInput,255)
            $BkColor_GreenPrev = 255
            $BkColor_GreenInputPrev = 255
        EndIf
        If GUICtrlRead($BkColor_BlueInput) > 255 Then
            GUICtrlSetData($BkColor_Blue,255)
            GUICtrlSetData($BkColor_BlueInput,255)
            $BkColor_BluePrev = 255
            $BkColor_BlueInputPrev = 255
        EndIf
        $BkColor_ZerocheckRed = StringSplit(GUICtrlRead($BkColor_RedInput),"")
        $BkColor_ZerocheckGreen = StringSplit(GUICtrlRead($BkColor_GreenInput),"")
        $BkColor_ZerocheckBlue = StringSplit(GUICtrlRead($BkColor_BlueInput),"")
        If $BkColor_ZerocheckRed[0] > 1 And $BkColor_ZerocheckRed[1] = "0" Then GUICtrlSetData($BkColor_RedInput,StringReplace(GUICtrlRead($BkColor_RedInput),"0","",1))
        If $BkColor_ZerocheckGreen[0] > 1 And $BkColor_ZerocheckGreen[1] = "0" Then GUICtrlSetData($BkColor_GreenInput,StringReplace(GUICtrlRead($BkColor_GreenInput),"0","",1))
        If $BkColor_ZerocheckBlue[0] > 1 And $BkColor_ZerocheckBlue[1] = "0" Then GUICtrlSetData($BkColor_BlueInput,StringReplace(GUICtrlRead($BkColor_BlueInput),"0","",1))
        $BkColor_ReadRed = GUICtrlRead($BkColor_Red)
        $BkColor_ReadGreen = GUICtrlRead($BkColor_Green)
        $BkColor_ReadBlue = GUICtrlRead($BkColor_Blue)
        $BkColor_ReadRedInput = GUICtrlRead($BkColor_RedInput)
        $BkColor_ReadGreenInput = GUICtrlRead($BkColor_GreenInput)
        $BkColor_ReadBlueInput = GUICtrlRead($BkColor_BlueInput)
        If $BkColor_ReadRedInput <> $BkColor_RedPrev Or $BkColor_ReadRed <> $BkColor_RedPrev Then
            If $BkColor_ReadRedInput <> $BkColor_RedPrev Then
                GUICtrlSetData($BkColor_Red,$BkColor_ReadRedInput)
                $BkColor_RedPrev = $BkColor_ReadRedInput
            ElseIf $BkColor_ReadRed <> $BkColor_RedPrev Then
                GUICtrlSetData($BkColor_RedInput,$BkColor_ReadRed)
                $BkColor_RedInputPrev = $BkColor_ReadRed
            EndIf
        EndIf

        If $BkColor_ReadGreenInput <> $BkColor_GreenPrev Or $BkColor_ReadGreen <> $BkColor_GreenPrev Then
            If $BkColor_ReadGreenInput <> $BkColor_GreenPrev Then
                GUICtrlSetData($BkColor_Green,$BkColor_ReadGreenInput)
                $BkColor_GreenPrev = $BkColor_ReadGreenInput
            ElseIf $BkColor_ReadGreen <> $BkColor_GreenPrev Then
                GUICtrlSetData($BkColor_GreenInput,$BkColor_ReadGreen)
                $BkColor_GreenInputPrev = $BkColor_ReadGreen
            EndIf
        EndIf

        If $BkColor_ReadBlueInput <> $BkColor_BluePrev Or $BkColor_ReadBlue <> $BkColor_BluePrev Then
            If $BkColor_ReadBlueInput <> $BkColor_BluePrev Then
                GUICtrlSetData($BkColor_Blue,$BkColor_ReadBlueInput)
                $BkColor_BluePrev = $BkColor_ReadBlueInput
            ElseIf $BkColor_ReadBlue <> $BkColor_BluePrev Then
                GUICtrlSetData($BkColor_BlueInput,$BkColor_ReadBlue)
                $BkColor_BlueInputPrev = $BkColor_ReadBlue
            EndIf
        EndIf

    If $BkColor_RedPrev = 255 And $BkColor_GreenPrev = 255 And $BkColor_BluePrev = 255 And GUICtrlRead($BkColor_MainInput) <> "Vit" Then _GUICtrlComboBox_SetCurSel($BkColor_MainInput,0)
    If $BkColor_RedPrev = 255 And $BkColor_GreenPrev = 0 And $BkColor_BluePrev = 0 And GUICtrlRead($BkColor_MainInput) <> "Röd" Then _GUICtrlComboBox_SetCurSel($BkColor_MainInput,1)
    If $BkColor_RedPrev = 0 And $BkColor_GreenPrev = 255 And $BkColor_BluePrev = 0 And GUICtrlRead($BkColor_MainInput) <> "Grön" Then _GUICtrlComboBox_SetCurSel($BkColor_MainInput,2)
    If $BkColor_RedPrev = 0 And $BkColor_GreenPrev = 0 And $BkColor_BluePrev = 255 And GUICtrlRead($BkColor_MainInput) <> "Blå" Then _GUICtrlComboBox_SetCurSel($BkColor_MainInput,3)
    If $BkColor_RedPrev = 0 And $BkColor_GreenPrev = 0 And $BkColor_BluePrev = 0 And GUICtrlRead($BkColor_MainInput) <> "Svart" Then _GUICtrlComboBox_SetCurSel($BkColor_MainInput,4)
    If ($BkColor_RedPrev <> 0 And $BkColor_RedPrev <> 255 And GUICtrlRead($BkColor_MainInput) <> "Egen") Or ($BkColor_GreenPrev <> 0 And $BkColor_GreenPrev <> 255 And GUICtrlRead($BkColor_MainInput) <> "Egen") Or _
        ($BkColor_BluePrev <> 0 And $BkColor_BluePrev <> 255 And GUICtrlRead($BkColor_MainInput) <> "Egen") Then _GUICtrlComboBox_SetCurSel($BkColor_MainInput,5)
    EndIf
    $BkColor =     $BkColor_RedPrev*65536+$BkColor_GreenPrev*256+$BkColor_BluePrev
    If $BkColor <> $BkColor_Prev Then
        GUICtrlSetBkColor($BkColor_ExampleColor,$BkColor)
        $BkColor_Prev = $BkColor
    EndIf
    WEnd
EndFunc

Func ColorEvents()
    switch @GUI_CtrlId
        Case $BkColor_OK
            $ColorEventsVal = 2
        Case $BkColor_Cancel
            $ColorEventsVal = 1
    EndSwitch
EndFunc

Func _Fontsize($hGui,$Font_PrevSize)
    $hGui_fontsize = GUICreate("Ställ textstorlek", 150,150,-1,-1,$WS_border,-1,$hGui)
    $Font_Input = GUICtrlCreateInput($Font_PrevSize,50,15,50)
    GUICtrlCreateUpdown(-1)
    GUICtrlSetLimit(-1, 50,8)
    $Font_ExampleLable = GUICtrlCreateLabel("Ex",60,40,100,75)
    GUICtrlSetState(-1,$gui_disable)
    GUICtrlSetFont(-1,$Font_PrevSize)
    $Font_OK = GUICtrlCreateButton("OK", 25,100,50,25)
    GUICtrlSetOnEvent(-1, "FontEvents")
    $Font_Cancel = GUICtrlCreateButton("Avbryt", 75,100,50,25)
    GUICtrlSetOnEvent(-1, "FontEvents")
    GUISetState(@SW_DISABLE, $hGui)
    GUISetState(@SW_SHOW, $hGui_fontsize)
    While 1
        If $FontEventsVal = 1 Then
            GUIDelete($hGui_fontsize)
            GUISetState(@SW_ENABLE,$hGui)
            WinActivate($hGui)
            $FontEventsVal = 0
            Return 0
            ExitLoop
        ElseIf $FontEventsVal = 2 Then
            $WinArray[_ArraySearch($WinArray,$hGui)][5] = GUICtrlRead($Font_Input)
            GUIDelete($hGui_fontsize)
            GUISetState(@SW_ENABLE,$hGui)
            WinActivate($hGui)
            ConsoleWrite(GUICtrlRead($Font_Input)&@CRLF)
            $FontEventsVal = 0
            Return $WinArray[_ArraySearch($WinArray,$hGui)][5]
            ExitLoop
        EndIf
        $Font_CurrentSize = GUICtrlRead($Font_Input)
        If $Font_CurrentSize > 50 Then GUICtrlSetData($Font_Input,50)
        If $Font_CurrentSize < 8 Then GUICtrlSetData($Font_Input,8)
        If $Font_CurrentSize <> $Font_PrevSize Then
            GUICtrlSetFont($Font_ExampleLable,GUICtrlRead($Font_Input))
            GUICtrlSetPos($Font_ExampleLable,60-(GUICtrlRead($Font_Input)/2))
            $Font_PrevSize = $Font_CurrentSize
        EndIf
    WEnd
EndFunc

Func FontEvents()
    switch @GUI_CtrlId
        Case $Font_OK
            $FontEventsVal = 2
        Case $Font_Cancel
            $FontEventsVal = 1
    EndSwitch
EndFunc

Func LoadList()

EndFunc

DllCallbackFree($wProcHandle)

fehqfLj.png

Link to comment
Share on other sites

  • Moderators

zvvyt,

Firstly, you can use the hidden, but always present, AutoIt GUI as a parent:

$hWnd = WinGetHandle(AutoItWinGetTitle())
Next, I suggest preventing the default behaviour of the GUI for button events (Opt("GUIEventOptions", 1) and then adding some code to your MainEvents function to hide the GUI instead of minimizing it:

Func MainEvents()
    Select
        Case @GUI_CtrlId = $GUI_EVENT_CLOSE
            [...]
        Case @GUI_CtrlId = $GUI_EVENT_MINIMIZE
            GUISetState(@SW_HIDE, @GUI_WinHandle)
    EndSelect
EndFunc   ;==>MainEvents
You will of course have to develop a way to get the GUI visible again when required. ;)

Finally, your script nearly always crashes on exit, but I have not yet discovered why. :(>

M23

Edit:

Found the problem - you should delete all the subclassed GUIs before freeing the replacement WndProc:

Func TrayExit()
    ConsoleWrite("TrayExit")
    If MsgBox(4, "Stäng?", "Är du säker på att du vill stänga av?") = 6 Then
        For $i = 0 To UBound($WinArray, 1) - 1
            GUIDelete($WinArray[$i][0])
        Next
        DllCallbackFree($wProcHandle)
        Exit
    EndIf
EndFunc   ;==>TrayExit
Edited by Melba23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Firstly, you can use the hidden, but always present, AutoIt GUI as a parent:

$hWnd = WinGetHandle(AutoItWinGetTitle())

Grazie! 

Next, I suggest preventing the default behaviour of the GUI for button events (Opt("GUIEventOptions", 1) and then adding some code to your MainEvents function to hide the GUI instead of minimizing it:

You will of course have to develop a way to get the GUI visible again when required. ;)

Thanks, that's the exact way of putting me on the right track I was looking for!

But then I still don't have a "window" I can use to "restore"/show the GUIs again?

I could add a hide/show-function to the tray, but that is a step off my original path..

Finally, your script nearly always crashes on exit, but I have not yet discovered why. :(>

Found the problem - you should delete all the subclassed GUIs before freeing the replacement WndProc:

That's odd, as I'm not getting a single error when I run and/or close it..

But if it was as simple and fundamental as deleting the GUIs then I'm more than happy you pointed that out :)

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

×
×
  • Create New...