Jump to content
Sign in to follow this  
zvvyt

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

Recommended Posts

zvvyt

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

Share this post


Link to post
Share on other sites
MikahS

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

 

Share this post


Link to post
Share on other sites
Melba23

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

 

Share this post


Link to post
Share on other sites
zvvyt

 

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

Share this post


Link to post
Share on other sites
Melba23

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

 

Share this post


Link to post
Share on other sites
zvvyt

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 :)

Share this post


Link to post
Share on other sites
zvvyt

"Följ lapp"

Is it bad that I laughed at that? :P

(it's a Swedish thing)

Well, now I can't keep it like that..! xD

Share this post


Link to post
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
Sign in to follow this  

  • Similar Content

    • UEZ
      By UEZ
      Following script shows a parent GUI with a child GUI initialized as MDICHILD.
      #include <Constants.au3> #include <GUIConstantsEx.au3> #include <GuiReBar.au3> #include <GuiScrollBars.au3> #include <GuiToolbar.au3> #include <ScreenCapture.au3> #include <ScrollBarConstants.au3> #include <WindowsConstants.au3> _GDIPlus_Startup() Global Enum $idNew = 1000, $idOpen, $idSave, $idHelper Global Const $iImageW = @DesktopWidth, $iImageH = @DesktopHeight Global Const $hBMP_ScreenCapture = _ScreenCapture_Capture("", 0, 0, $iImageW, $iImageH, False) Global Const $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hBMP_ScreenCapture) Sleep(50) Global Const $iW = 1500, $iH = 700, $SC_DRAGMOVE = 0xF012 Global Const $hGUI = GUICreate("Move child GUI within GUI", $iW, $iH) Global Const $hToolbar = _GUICtrlToolbar_Create($hGUI) Global Const $hReBar = _GUICtrlRebar_Create($hGUI, BitOR($CCS_TOP, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS)) Global Const $height_delta = 37 Global Const $idPic = GUICtrlCreatePic("", 0, $height_delta + 2, $iW, $iH) Global $hBitmap_tmp, $hHBitmap_tmp $hBitmap_tmp = _GDIPlus_BitmapCreateFromScan0($iW, $iH) Global $hGfx_Context = _GDIPlus_ImageGetGraphicsContext($hBitmap_tmp) _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR) _GUICtrlToolbar_AddButton($hToolbar, $idNew, $STD_FILENEW) _GUICtrlToolbar_AddButton($hToolbar, $idOpen, $STD_FILEOPEN) _GUICtrlToolbar_AddButton($hToolbar, $idSave, $STD_FILESAVE) _GUICtrlToolbar_AddButtonSep($hToolbar) _GUICtrlToolbar_AddButton($hToolbar, $idHelper, $STD_HELP) _GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar, "", 0) Global Const $iVSscroll = _WinAPI_GetSystemMetrics(2) Global Const $iHSscroll = _WinAPI_GetSystemMetrics(3) Global Const $iYCaption = _WinAPI_GetSystemMetrics(4) Global Const $iYFixedFrame = _WinAPI_GetSystemMetrics(8) Global Const $iXFixedFrame = _WinAPI_GetSystemMetrics(7) Global Const $iMetricsSumX = $iVSscroll + $iXFixedFrame * 2 Global Const $iMetricsSumY = $iHSscroll + $iYCaption + $iYFixedFrame _GUIScrollBars_Init($hGUI) _GUIScrollBars_SetScrollInfoMin($hGUI, $SB_HORZ, 0) _GUIScrollBars_SetScrollInfoMax($hGUI, $SB_HORZ, $iImageW - $iW + 61 + $iMetricsSumX) _GUIScrollBars_SetScrollInfoMin($hGUI, $SB_VERT, 0) _GUIScrollBars_SetScrollInfoMax($hGUI, $SB_VERT, $iImageH - $iH + $iMetricsSumY + $height_delta - 1) GUISetState(@SW_SHOW, $hGUI) Global Const $STM_SETIMAGE = 0x0172 _WinAPI_DeleteObject(GUICtrlSendMsg($idPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hBMP_ScreenCapture)) Global $IE_offset_x = 0, $IE_offset_y = 0 DrawImage($hGfx_Context, $hBitmap, $IE_offset_x, $IE_offset_y, $iW, $iH) GUIRegisterMsg($WM_HSCROLL, "WM_HSCROLL_IE") GUIRegisterMsg($WM_VSCROLL, "WM_VSCROLL_IE") Global $iPosX_Crop = 0, $iPosY_Crop = 0, $iW_crop = 200, $iH_crop = 200, $bMove_Crop = True Global $hGUI_IE_Crop = GUICreate("", $iW_crop, $iH_crop, $iPosX_Crop, $iPosY_Crop) GUISetStyle(BitOR($WS_BORDER, $WS_POPUP), $WS_EX_MDICHILD) _WinAPI_SetParent($hGUI_IE_Crop, $hGUI) WinSetTrans($hGUI_IE_Crop, "", 0xA0) Global $iLable_CropMove = GUICtrlCreateLabel("", 0, 0, $iW_crop, $iH_crop, -1, $GUI_WS_EX_PARENTDRAG) GUISetState(@SW_SHOW, $hGUI_IE_Crop) GUIRegisterMsg($WM_MOVE, "WM_MOVE_IE_GUI_Crop") ;~ GUIRegisterMsg($WM_LBUTTONDOWN, "_WM_LBUTTONDOWN") Do Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch Until False GUIRegisterMsg($WM_HSCROLL, "") GUIRegisterMsg($WM_VSCROLL, "") GUIRegisterMsg($WM_MOVE, "") GUIRegisterMsg($WM_LBUTTONDOWN, "") _WinAPI_DeleteObject($hBMP_ScreenCapture) _GDIPlus_BitmapDispose($hBitmap_tmp) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_GraphicsDispose($hGfx_Context) _GDIPlus_Shutdown() Exit Func WM_HSCROLL_IE($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg, $lParam Local $Min, $Max, $Page, $TrackPos ; Get all the horizontal scroll bar information Local $tSCROLLINFO_X = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_HORZ) $Min = DllStructGetData($tSCROLLINFO_X, "nMin") $Max = DllStructGetData($tSCROLLINFO_X, "nMax") $Page = DllStructGetData($tSCROLLINFO_X, "nPage") ; Save the position for comparison later on $IE_offset_x = DllStructGetData($tSCROLLINFO_X, "nPos") $TrackPos = DllStructGetData($tSCROLLINFO_X, "nTrackPos") #forceref $Min, $Max Local $nScrollCode = BitAND($wParam, 0x0000FFFF) Switch $nScrollCode Case $SB_LINELEFT ; user clicked left arrow DllStructSetData($tSCROLLINFO_X, "nPos", $IE_offset_x - 1) Case $SB_LINERIGHT ; user clicked right arrow DllStructSetData($tSCROLLINFO_X, "nPos", $IE_offset_x + 1) Case $SB_PAGELEFT ; user clicked the scroll bar shaft left of the scroll box DllStructSetData($tSCROLLINFO_X, "nPos", $IE_offset_x - $Page) Case $SB_PAGERIGHT ; user clicked the scroll bar shaft right of the scroll box DllStructSetData($tSCROLLINFO_X, "nPos", $IE_offset_x + $Page) Case $SB_THUMBTRACK ; user dragged the scroll box DllStructSetData($tSCROLLINFO_X, "nPos", $TrackPos) EndSwitch DllStructSetData($tSCROLLINFO_X, "fMask", $SIF_POS) _GUIScrollBars_SetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO_X) $IE_offset_x = DllStructGetData($tSCROLLINFO_X, "nPos") DrawImage($hGfx_Context, $hBitmap, $IE_offset_x, $IE_offset_y, $iW, $iH) $hHBitmap_tmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap_tmp) _WinAPI_DeleteObject(GUICtrlSendMsg($idPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBitmap_tmp)) _WinAPI_DeleteObject($hHBitmap_tmp) $bMove_Crop = False ConsoleWrite($iPosX_Crop & ", " & $iPosY_Crop & " / " & $IE_offset_x & ", " & $IE_offset_y & @CRLF) WinMove($hGUI_IE_Crop, "", -$IE_offset_x + $iPosX_Crop, -$IE_offset_y + $iPosY_Crop) ;~ DllCall("user32.dll", "bool", "MoveWindow", "hwnd", $hGUI_IE_Crop, "int", -$IE_offset_x + $iPosX_Crop, "int", -$IE_offset_y + $iPosY_Crop, "int", $iW_crop, "int", $iH_crop, "bool", True) $bMove_Crop = True Return "GUI_RUNDEFMSG" EndFunc ;==>WM_HSCROLL_IE Func WM_VSCROLL_IE($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg, $lParam Local $Min, $Max, $Page, $TrackPos ;~ ; Get all the horizontal scroll bar information Local $tSCROLLINFO_Y = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_VERT) $Min = DllStructGetData($tSCROLLINFO_Y, "nMin") $Max = DllStructGetData($tSCROLLINFO_Y, "nMax") $Page = DllStructGetData($tSCROLLINFO_Y, "nPage") ; Save the position for comparison later on $IE_offset_y = DllStructGetData($tSCROLLINFO_Y, "nPos") $TrackPos = DllStructGetData($tSCROLLINFO_Y, "nTrackPos") #forceref $Min, $Max Local $nScrollCode = BitAND($wParam, 0x0000FFFF) Switch $nScrollCode Case $SB_LINELEFT ; user clicked left arrow DllStructSetData($tSCROLLINFO_Y, "nPos", $IE_offset_y - 1) Case $SB_LINERIGHT ; user clicked right arrow DllStructSetData($tSCROLLINFO_Y, "nPos", $IE_offset_y + 1) Case $SB_PAGELEFT ; user clicked the scroll bar shaft left of the scroll box DllStructSetData($tSCROLLINFO_Y, "nPos", $IE_offset_y - $Page) Case $SB_PAGERIGHT ; user clicked the scroll bar shaft right of the scroll box DllStructSetData($tSCROLLINFO_Y, "nPos", $IE_offset_y + $Page) Case $SB_THUMBTRACK ; user dragged the scroll box DllStructSetData($tSCROLLINFO_Y, "nPos", $TrackPos) EndSwitch DllStructSetData($tSCROLLINFO_Y, "fMask", $SIF_POS) _GUIScrollBars_SetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO_Y) $IE_offset_y = DllStructGetData($tSCROLLINFO_Y, "nPos") DrawImage($hGfx_Context, $hBitmap, $IE_offset_x, $IE_offset_y, $iW, $iH) $bMove_Crop = False ConsoleWrite($iPosX_Crop & ", " & $iPosY_Crop & " / " & $IE_offset_x & ", " & $IE_offset_y & @CRLF) WinMove($hGUI_IE_Crop, "", -$IE_offset_x + $iPosX_Crop, -$IE_offset_y + $iPosY_Crop) ;~ DllCall("user32.dll", "bool", "MoveWindow", "hwnd", $hGUI_IE_Crop, "int", -$IE_offset_x + $iPosX_Crop, "int", -$IE_offset_y + $iPosY_Crop, "int", $iW_crop, "int", $iH_crop, "bool", True) $bMove_Crop = True Return "GUI_RUNDEFMSG" EndFunc ;==>WM_VSCROLL_IE Func _WM_LBUTTONDOWN($hWnd, $iMsg, $wParam, $lParam) _SendMessage($hGUI_IE_Crop, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0) EndFunc ;==>_WM_LBUTTONDOWN Func WM_MOVE_IE_GUI_Crop($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg, $wParam If $hWnd = $hGUI_IE_Crop And $bMove_Crop Then $iPosX_Crop = _WinAPI_LoWord($lParam) $iPosY_Crop = _WinAPI_HiWord($lParam) EndIf Return "GUI_RUNDEFMSG" EndFunc ;==>WM_MOVE_IE_GUI_Crop Func WM_SIZE_IE_GUI_Crop($hWnd, $iMsg, $wParam, $lParam) Return $GUI_RUNDEFMSG EndFunc ;==>WM_SIZE_IE_GUI_Crop Func DrawImage($hGfx_Context, $hBitmap, $IE_offset_x, $IE_offset_y, $iW, $iH) _GDIPlus_GraphicsDrawImageRectRect($hGfx_Context, $hBitmap, $IE_offset_x, $IE_offset_y, $iW, $iH, 0, 0, $iW, $iH) $hHBitmap_tmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap_tmp) _WinAPI_DeleteObject(GUICtrlSendMsg($idPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBitmap_tmp)) _WinAPI_DeleteObject($hHBitmap_tmp) EndFunc  
      My problem: if you move the child window at left upper corner to another place and move either H or V scrollbar the child GUI will be moved properly. BUT if you have scrolled the scrollbars to the right bottom of the image and move the child GUI to that corner, too then the child GUI jumps if you click on one of the scrollbars.
      Is there something that I didn't consider?
    • Emmhor1
      By Emmhor1
      Hi All,

      MAIN QUESTION:
      Is it possible to Call specific function within a GUI

      So I have a script with multiple functions although I don't want to use every function every time.
      My Idea is to create a simple GUI which allows me to select what functions I want to use then run the funtions by clicking a button.
      I have already made a GUI which allows me to select specific .exe's I would like to run after selection it runs the .exe one by one.
      This script is on my work laptops and cannot access it right now.
       
      Who can help me with this?
      GUIcreate
      Func1 
      Func2
      Func3
      Then have a boxes which allows me to select the specif Func.(I used GUIChecked and Unchecked in my other script)
      Then a button which executes/calls the selected functions
    • Blois
      By Blois
      Hi Guis,
       
      I need to create keyboard shortcut to navigate the tabs and activate them, but I could not use the code below:
      #include <TabConstants.au3> #include <WindowsConstants.au3> #include <GuiTab.au3> #include <GUIConstantsEx.au3> HotKeySet("^{TAB}", "_TabRight") HotKeySet("^+{TAB}", "_TabLeft") $gui = GUICreate("test",450, 300) $Tab1 = GUICtrlCreateTab(20, 24, 425, 201) $TabSheet1 = GUICtrlCreateTabItem("Tabsheet 1") $lbContagemGrupos2 = GUICtrlCreateLabel("aaaa", 50, 50) GUICtrlSetColor(-1, 0x0000FF) GUICtrlCreateTabItem("") $TabSheet2 = GUICtrlCreateTabItem(" ") $TabSheet3 = GUICtrlCreateTabItem(" ") GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd Func _TabRight() $CurPos = _GUICtrlTab_GetCurSel($Tab1) _GUICtrlTab_SetCurSel($Tab1, $CurPos + 1) $tab = "$TabSheet" & $CurPos GUICtrlSetState($TabSheet1 + $CurPos, $GUI_SHOW) Return EndFunc Func _TabLeft() $CurPos = _GUICtrlTab_GetCurSel($Tab1) _GUICtrlTab_SetCurSel($Tab1, $CurPos - 1) $tab = "$TabSheet" & $CurPos GUICtrlSetState($TabSheet1 + $CurPos, $GUI_SHOW) Return EndFunc Exit  
      can you help me?
    • Pricehacker
      By Pricehacker
      Hello again!
      I have tried searching for quite some time now but couldn´t find a single working way to change the class of your GUI that doesn´t include changing it manually after its compilation.
      First or "AutoIt v3 GUI" is a pretty boring name tbh and i would like to spice it up a bit, also, and more importantly, I would like to identify my windows by something other than its title as it will change depending on some factors and im using two different programs independently as multi threading isn't supported.
      Any help is appreciated! Thank you!
    • xtcislove
      By xtcislove
      Hello, 
      i have a Problem with  _WinAPI_SetLayeredWindowAttributes, everything is working as excepted if u are on Windows 7.

      But if u are on Windows 10 the transparent background of a control is not clickable anymore. 

      Could someone help?

      Please see example below, put cmd.jpg into the same folder as Example.au3

      Please see trigger.jpg to see which sections are not clickable in Windows 10 (the red dots, the green dots are clickable) on Windows 7 the red ones and green ones are clickable.
       
      The same problem occurs if i use 
       
       
      Example.au3


×