Sign in to follow this  
Followers 0
friends

Help needed for GUI

2 posts in this topic

#1 ·  Posted (edited)

Please help me to check where it goes wrong.... or which command

to be used to make it work....

Scenario :

I made a "toolbar" with buttons.... I wanna make it when I press

the button, it shows up another GUI windows.

It worked fine with the first button (Printer icon), but not when press

second button. Please fix it for me... as I'm not sure where goes

wrong (command or others) ?

Thanks in advance

#include <GUIConstants.au3>

Opt ("TrayIconDebug", 1)


;+-------------------------------------------------------------------------------------------+
# << HOTKEY DECLARATION >> 
HotKeySet ("{F3}", "HideToolBar")
;+-------------------------------------------------------------------------------------------+


;+-------------------------------------------------------------------------------------------+
# << VARIABLE DECLARATION & INITIALIZATION >> 
Dim $TotalButtons = 6
Dim $BarHeight = 48
Dim $ButtonLocation = 150
Dim $ButtonWidth = 48
Dim $ButtonHeight = 48
Dim $BarWidth = $TotalButtons * $ButtonWidth + $ButtonLocation

Dim $ToolBarTransition = "show"
Dim $PrinterShown = "no"

# << DUMMY VARIABLE >> 
Dim $PrinterContent = ""
Dim $CPanelContent = ""
;+-------------------------------------------------------------------------------------------+



;+-------------------------------------------------------------------------------------------+
# << Toolbar Menu >>
$ToolBar = GUICreate ("Computer Security Control Centre", $BarWidth, $BarHeight, (@DesktopWidth - $BarWidth) / 2, 0, $WS_POPUP, $WS_EX_TOPMOST + $WS_EX_TOOLWINDOW)
;GUISetBkColor (0xE0FFFF)
GUICtrlCreatePic(@Systemdir & "\oobe\images\mslogo.jpg", 0, 0, 150, $BarHeight)
$Button1 = GUICtrlCreateButton ("Printer", $ButtonLocation, 0, $ButtonWidth, $ButtonHeight, $BS_ICON)
   GUICtrlSetImage (-1, "Shell32.dll", 16)
   GUICtrlSetTip (-1, "Button 1")
$Button2 = GUICtrlCreateButton ("Control Panel", $ButtonLocation + (1 * $ButtonWidth), 0, $ButtonWidth, $ButtonHeight, $BS_ICON)
   GUICtrlSetImage (-1, "Shell32.dll", 21)
   GUICtrlSetTip (-1, "Button 2")
$Button3 = GUICtrlCreateButton ("IE", $ButtonLocation + (2 * $ButtonWidth), 0, $ButtonWidth, $ButtonHeight, $BS_ICON)
   GUICtrlSetImage (-1, "Shell32.dll", 162)
   GUICtrlSetTip (-1, "Button 3")
$Button4 = GUICtrlCreateButton ("IE", $ButtonLocation + (3 * $ButtonWidth), 0, $ButtonWidth, $ButtonHeight, $BS_ICON)
   GUICtrlSetImage (-1, "Shell32.dll", 220)
   GUICtrlSetTip (-1, "Button 4")
$Button5 = GUICtrlCreateButton ("IE", $ButtonLocation + (4 * $ButtonWidth), 0, $ButtonWidth, $ButtonHeight, $BS_ICON)
   GUICtrlSetImage (-1, "Shell32.dll", 8)
   GUICtrlSetTip (-1, "Button 5")
$Button6 = GUICtrlCreateButton ("IE", $ButtonLocation + (5 * $ButtonWidth), 0, $ButtonWidth, $ButtonHeight, $BS_ICON)
   GUICtrlSetImage (-1, "Shell32.dll", 27)
   GUICtrlSetTip (-1, "Exit")
;+-------------------------------------------------------------------------------------------+





;+-------------------------------------------------------------------------------------------+
# << Main Process >>
GUISetState()

WHILE 1
    SLEEP (10)
    $msg = GUIGetMsg() 

    SELECT         
        CASE $msg = $Button1              
             PrinterContents()
             
         CASE $msg = $Button2             
              CPanelContents()
                     
        CASE $msg = $GUI_EVENT_CLOSE OR $msg = $button6             
             ExitLoop
             
    ENDSELECT         
WEND 

GUIDelete() 
;+-------------------------------------------------------------------------------------------+







;+-------------------------------------------------------------------------------------------+
# << Function Declaration >>
Func HideToolBar()
     IF $ToolBarTransition = "Show" THEN 
        FOR $i = 1 to $BarHeight
            WinMove ($ToolBar, "", (@DesktopWidth - $BarWidth) / 2, 0 - $i)
            SLEEP (10)
        NEXT     
        $ToolBarTransition = "hide"
        HotKeySet ("{F3}", "ShowToolBar")
        
     ENDIF 
EndFunc 
 
 
Func ShowToolBar()
     IF $ToolBarTransition = "hide" THEN 
        FOR $i = 1 to $BarHeight
            WinMove ($ToolBar, "", (@DesktopWidth - $BarWidth) / 2, -($BarHeight) + $i)
            SLEEP (10)
        NEXT     
        $ToolBarTransition = "show"
        HotKeySet ("{F3}", "HideToolBar")
     ENDIF 
EndFunc   
 
 
Func PrinterContents()
     # << Printer Button Contents >>
     IF $PrinterShown = "no" THEN    ; Check to prevent from being opened twice
        $PrinterContent = GUICreate ("Printer Contents", $BarWidth - 6, 500, (@DesktopWidth - $BarWidth) / 2, $BarHeight, $WS_POPUP+$WS_EX_TOPMOST+$WS_THICKFRAME)
        GUISetBkColor (0xE0FABF)        
        GUISetState() 
        $PrinterShown = "Yes"
     ENDIF     
EndFunc 
 
 
Func CPanelContents()
     # << CPanel Button Contents >>
     IF $PrinterShown = "no" THEN         
        $CPanelContent = GUICreate ("CPanel Contents", $BarWidth - 6, 500, (@DesktopWidth - $BarWidth) / 2, $BarHeight, $WS_POPUP+$WS_EX_TOPMOST+$WS_THICKFRAME)
        GUISetBkColor (0xE0FFFF)        
        GUISetState() 
        $PrinterShown = "yes"        
     ENDIF 
EndFunc  

;+-------------------------------------------------------------------------------------------+
Edited by friends

Share this post


Link to post
Share on other sites



I looked at your script, which took about ooo 5 seconds? And immediately found the problem which is obvious...

Func PrinterContents()
     # << Printer Button Contents >>
     IF $PrinterShown = "no" THEN   ; Check to prevent from being opened twice
        $PrinterContent = GUICreate ("Printer Contents", $BarWidth - 6, 500, (@DesktopWidth - $BarWidth) / 2, $BarHeight, $WS_POPUP+$WS_EX_TOPMOST+$WS_THICKFRAME)
        GUISetBkColor (0xE0FABF)        
        GUISetState()
        $PrinterShown = "Yes"
     ENDIF   
EndFunc

Set's $PrinterShown to "Yes".

Func CPanelContents()
     # << CPanel Button Contents >>
     IF $PrinterShown = "no" THEN        
        $CPanelContent = GUICreate ("CPanel Contents", $BarWidth - 6, 500, (@DesktopWidth - $BarWidth) / 2, $BarHeight, $WS_POPUP+$WS_EX_TOPMOST+$WS_THICKFRAME)
        GUISetBkColor (0xE0FFFF)        
        GUISetState()
        $PrinterShown = "yes"       
     ENDIF
EndFunc

OMG! IF $PrinterShown = "no" THEN... It doesn't equal "no", it equals "yes"... Therefor never going into the statement.

Click on the first button and try going to the second. Close the script then restart it, click on the second button and trying going to the first...


[u]Old Projects:[/u]A3MORGB2Hex[u]Old Functions:[/u]_TimeAdd/_TimeSub_AddComma_BubbleSort _RippleSort "He who does not understand your silence will probably not understand your words." - Elbert Hubbard.

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