Jump to content

GUI Opens Blank Page - Sometimes :-S


goss34
 Share

Go to solution Solved by Danp2,

Recommended Posts

Hi All,

Its been a while since iv been on here but so far twice this week, i wish i was better at this :-(

Ok so my problem is that i have a GUI that loads and it should load a HTML webpage in the window. For me this works 100% every time but other people using the script (compiled) they experience the GUI loading but the entire window being blank (white). If i highlight in the window you can see some of the text or if i normalise the window (it opens maximised) everything appears as normal. If i then maximise it is still fine.

It is almost like sometimes the content loads before the window, i have tried adding in a second load of the same html page which fixes it for some people but again not everyone and i am aiming for a 100% success rate. It seems to be for higher spec machines there's a higher the chance of it happening.

#include <TrayConstants.au3> ; Required for the $TRAY_EVENT_PRIMARYDOUBLE and $TRAY_EVENT_SECONDARYUP constants.
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <MsgBoxConstants.au3>
#include <IE.au3>

Opt("TrayMenuMode", 3) ; The default tray menu items will not be shown and items are not checked when selected. These are options 1 and 2 for TrayMenuMode.
Opt("TrayOnEventMode", 1) ; Enable TrayOnEventMode.

If FileExists("C:\Program Files\Company\Contact GTAS\GTAS Desktop Icon - 256x256.ico") Then
    $ProgramFiles = "C:\Program Files"
Else
    $ProgramFiles = "C:\Program Files (x86)"
EndIf

TraySetIcon($ProgramFiles & "\Company\Contact GTAS\GTAS Desktop Icon - 256x256.ico") ; Set path to icon

LaunchTray()

        While 1
            Sleep(100) ; An idle loop.
        WEnd

Func LaunchTray()

        TraySetOnEvent($TRAY_EVENT_PRIMARYUP, "TrayEvent") ; On action launch TrayEvent function
        TraySetOnEvent($TRAY_EVENT_SECONDARYUP, "TrayEvent") ; On action launch TrayEvent function
        TraySetToolTip("Need help from IT? Click Me") ; Set the tray menu tooltip
        TraySetState(1) ; Show the tray menu.

EndFunc   ;==>LaunchTray

Func TrayEvent()

Switch @TRAY_ID ; Check the last tray item identifier.

        Case $TRAY_EVENT_PRIMARYUP

            TraySetOnEvent($TRAY_EVENT_PRIMARYUP, "Dummy") ; Set the event to fire a dummy function
            TraySetOnEvent($TRAY_EVENT_SECONDARYUP, "Dummy") ; Set the event to fire a dummy function

            Local $oIE = _IECreateEmbedded()
            $Gui = GUICreate("IT Related Issue", @DesktopWidth - 25, @DesktopHeight - 25, 0, 0, $WS_MAXIMIZE + $WS_VISIBLE + $WS_OVERLAPPEDWINDOW + $WS_EX_APPWINDOW)
            GUISetIcon($ProgramFiles & "\Company\Contact GTAS\GTAS Desktop Icon - 256x256.ico")
            GUICtrlCreateObj($oIE, 05, 05, @DesktopWidth, @DesktopHeight)
            GUICtrlSetResizing(-1, $GUI_DOCKBORDERS + $WS_MAXIMIZE)
            WinSetState($Gui, "", @SW_MAXIMIZE)
            GUISetState() ;Show GUI

            _IENavigate($oIE, $ProgramFiles & "\Company\Contact GTAS\contactingGTAS.html")
            _IENavigate($oIE, $ProgramFiles & "\Company\Contact GTAS\contactingGTAS.html")

            While 1
                Local $msg = GUIGetMsg()
                Select
                    Case $msg = $GUI_EVENT_CLOSE
                        ExitLoop
                        ;_IENavigate($oIE, $ProgramFiles & "\Company\Contact GTAS\contactingGTAS.html")
                        ;_IEAction($oIE, "stop")
                EndSelect
            WEnd

            GUIDelete()

            TraySetOnEvent($TRAY_EVENT_PRIMARYUP, "TrayEvent") ; And then reset the event function
            TraySetOnEvent($TRAY_EVENT_SECONDARYUP, "TrayEvent") ; And then reset the event function

        Case $TRAY_EVENT_SECONDARYUP

            TraySetOnEvent($TRAY_EVENT_SECONDARYUP, "Dummy") ; Set the event to fire a dummy function
            TraySetOnEvent($TRAY_EVENT_PRIMARYUP, "Dummy") ; Set the event to fire a dummy function

            Local $oIE = _IECreateEmbedded()
            $Gui = GUICreate("IT Related Issue", @DesktopWidth - 25, @DesktopHeight - 25, 0, 0, $WS_MAXIMIZE + $WS_VISIBLE + $WS_OVERLAPPEDWINDOW + $WS_EX_APPWINDOW)
            GUISetIcon($ProgramFiles & "\Company\Contact GTAS\GTAS Desktop Icon - 256x256.ico")
            GUICtrlCreateObj($oIE, 05, 05, @DesktopWidth, @DesktopHeight)
            GUICtrlSetResizing(-1, $GUI_DOCKBORDERS + $WS_MAXIMIZE)
            WinSetState($Gui, "", @SW_MAXIMIZE)
            GUISetState() ;Show GUI

            _IENavigate($oIE, $ProgramFiles & "\Company\Contact GTAS\contactingGTAS.html")
            _IENavigate($oIE, $ProgramFiles & "\Company\Contact GTAS\contactingGTAS.html")

            While 1
                Local $msg = GUIGetMsg()
                Select
                    Case $msg = $GUI_EVENT_CLOSE
                        ExitLoop
                        ;_IENavigate($oIE, $ProgramFiles & "\Company\Contact GTAS\contactingGTAS.html")
                        ;_IEAction($oIE, "stop")
                EndSelect
            WEnd

            GUIDelete()

            TraySetOnEvent($TRAY_EVENT_SECONDARYUP, "TrayEvent") ; And then reset the event function
            TraySetOnEvent($TRAY_EVENT_PRIMARYUP, "TrayEvent") ; And then reset the event function

    EndSwitch

EndFunc   ;==>TrayEvent

Func Dummy()

    ConsoleWrite("Dummy" & @CRLF)

EndFunc

I fully admit this script is pushing my boundaries and i am a little out of my depth so if any response could be explained (dumbed down haha) that would be greatly appreciated.

Thank you,

Dan

Edited by goss34
Link to comment
Share on other sites

Sounds like a screen refresh issue. Instead of doubling up on the _IENavigate, have you tried:

_IEAction($oIE, "refresh")

On an unrelated matter, it appears that you are maintaining the same code twice in the TrayEvent function. You could eliminate that by moving this code to its own function or changing your Switch...Case to handle both $TRAY_EVENT_PRIMARYUP and $TRAY_EVENT_SECONDARYUP in a single case.

Link to comment
Share on other sites

Hi Danp2,

Thanks for your advice, i think i have done what you meant with regards to the unrelated matter...?

#include <TrayConstants.au3> ; Required for the $TRAY_EVENT_PRIMARYDOUBLE and $TRAY_EVENT_SECONDARYUP constants.
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <MsgBoxConstants.au3>
#include <IE.au3>

Opt("TrayMenuMode", 3) ; The default tray menu items will not be shown and items are not checked when selected. These are options 1 and 2 for TrayMenuMode.
Opt("TrayOnEventMode", 1) ; Enable TrayOnEventMode.

If FileExists("C:\Program Files\Company\Contact GTAS\GTAS Desktop Icon - 256x256.ico") Then
    $ProgramFiles = "C:\Program Files"
Else
    $ProgramFiles = "C:\Program Files (x86)"
EndIf

TraySetIcon($ProgramFiles & "\Company\Contact GTAS\GTAS Desktop Icon - 256x256.ico") ; Set path to icon

LaunchTray()

        While 1
            Sleep(100) ; An idle loop.
        WEnd

Func LaunchTray()

        TraySetOnEvent($TRAY_EVENT_PRIMARYUP, "TrayEvent") ; On action launch TrayEvent function
        TraySetOnEvent($TRAY_EVENT_SECONDARYUP, "TrayEvent") ; On action launch TrayEvent function
        TraySetToolTip("Need help from IT? Click Me") ; Set the tray menu tooltip
        TraySetState(1) ; Show the tray menu.

EndFunc   ;==>LaunchTray

Func TrayEvent()

Switch @TRAY_ID ; Check the last tray item identifier.

        Case $TRAY_EVENT_PRIMARYUP Or $TRAY_EVENT_SECONDARYUP

            TraySetOnEvent($TRAY_EVENT_PRIMARYUP, "Dummy") ; Set the event to fire a dummy function
            TraySetOnEvent($TRAY_EVENT_SECONDARYUP, "Dummy") ; Set the event to fire a dummy function

            Local $oIE = _IECreateEmbedded()
            $Gui = GUICreate("IT Related Issue", @DesktopWidth - 25, @DesktopHeight - 25, 0, 0, $WS_MAXIMIZE + $WS_VISIBLE + $WS_OVERLAPPEDWINDOW + $WS_EX_APPWINDOW)
            GUISetIcon($ProgramFiles & "\Company\Contact GTAS\GTAS Desktop Icon - 256x256.ico")
            GUICtrlCreateObj($oIE, 05, 05, @DesktopWidth, @DesktopHeight)
            GUICtrlSetResizing(-1, $GUI_DOCKBORDERS + $WS_MAXIMIZE)
            WinSetState($Gui, "", @SW_MAXIMIZE)
            GUISetState(@SW_SHOW) ;Show GUI

            _IENavigate($oIE, $ProgramFiles & "\Company\Contact GTAS\contactingGTAS.html")
            Sleep(5000)
            _IEAction($oIE, "refresh")

            While 1
                Local $msg = GUIGetMsg()
                Select
                    Case $msg = $GUI_EVENT_CLOSE
                        ExitLoop
                EndSelect
            WEnd

            GUIDelete()

            TraySetOnEvent($TRAY_EVENT_PRIMARYUP, "TrayEvent") ; And then reset the event function
            TraySetOnEvent($TRAY_EVENT_SECONDARYUP, "TrayEvent") ; And then reset the event function

    EndSwitch

EndFunc   ;==>TrayEvent

Func Dummy()

    ConsoleWrite("Dummy" & @CRLF)

EndFunc

As for the refresh i haven't used that before and added the sleep to see if i could see if it is actually refreshing the window as it doesn't appear to reload the html file, is this normal? Loading the page twice was making the window flicker as it reloaded, i was expecting to see the same behavior.

I have compiled it as above and it works for me as expected - i have sent it to my colleague with the higher spec machine to see if he continues to see the refresh problem. I will feedback tomorrow.

If you notice any more improvements please point them out as i want to be as efficient as possible.

Thank you,

Dan

Link to comment
Share on other sites

Hi Danp2,

I changed my code to the proper syntax, weirdly enough mine also worked considering it was not as it should be.

The refresh didn't work however upon playing with the original code and moving the GUISetState it now appears to be working as it should for everyone. While going through the code over and over i noticed i had some duplicate options which were probably not helping.

For reference i ended up with the full code below:

#include <TrayConstants.au3> ; Required for the $TRAY_EVENT_PRIMARYDOUBLE and $TRAY_EVENT_SECONDARYUP constants.
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <MsgBoxConstants.au3>
#include <IE.au3>

Opt("TrayMenuMode", 3) ; The default tray menu items will not be shown and items are not checked when selected. These are options 1 and 2 for TrayMenuMode.
Opt("TrayOnEventMode", 1) ; Enable TrayOnEventMode.

If FileExists("C:\Program Files\Company\Contact GTAS\GTAS Desktop Icon - 256x256.ico") Then
    $ProgramFiles = "C:\Program Files"
Else
    $ProgramFiles = "C:\Program Files (x86)"
EndIf

TraySetIcon($ProgramFiles & "\Company\Contact GTAS\GTAS Desktop Icon - 256x256.ico") ; Set path to icon

LaunchTray()

        While 1
            Sleep(100) ; An idle loop.
        WEnd

Func LaunchTray()

        TraySetOnEvent($TRAY_EVENT_PRIMARYUP, "TrayEvent") ; On action launch TrayEvent function
        TraySetOnEvent($TRAY_EVENT_SECONDARYUP, "TrayEvent") ; On action launch TrayEvent function
        TraySetToolTip("Need help from IT? Click Me") ; Set the tray menu tooltip
        TraySetState(1) ; Show the tray menu.

EndFunc   ;==>LaunchTray

Func TrayEvent()

Switch @TRAY_ID ; Check the last tray item identifier.

        Case $TRAY_EVENT_PRIMARYUP, $TRAY_EVENT_SECONDARYUP

            TraySetOnEvent($TRAY_EVENT_PRIMARYUP, "Dummy") ; Set the event to fire a dummy function
            TraySetOnEvent($TRAY_EVENT_SECONDARYUP, "Dummy") ; Set the event to fire a dummy function

            Local $oIE = _IECreateEmbedded()
            $Gui = GUICreate("IT Related Issue", @DesktopWidth - 25, @DesktopHeight - 25, 0, 0, $WS_MAXIMIZE + $WS_OVERLAPPEDWINDOW + $WS_EX_APPWINDOW)
            GUISetIcon($ProgramFiles & "\Company\Contact GTAS\GTAS Desktop Icon - 256x256.ico")
            GUICtrlCreateObj($oIE, 05, 05, @DesktopWidth, @DesktopHeight)
            GUICtrlSetResizing(-1, $GUI_DOCKBORDERS + $WS_MAXIMIZE)
            _IENavigate($oIE, $ProgramFiles & "\Company\Contact GTAS\contactingGTAS.html")
            GUISetState(@SW_SHOW) ;Show GUI

            While 1
                Local $msg = GUIGetMsg()
                Select
                    Case $msg = $GUI_EVENT_CLOSE
                        ExitLoop
                EndSelect
            WEnd

            GUIDelete()

            TraySetOnEvent($TRAY_EVENT_PRIMARYUP, "TrayEvent") ; And then reset the event function
            TraySetOnEvent($TRAY_EVENT_SECONDARYUP, "TrayEvent") ; And then reset the event function

    EndSwitch

EndFunc   ;==>TrayEvent

Func Dummy()

    ConsoleWrite("Dummy" & @CRLF)

EndFunc

Thank you very much for your help Danp2, very much appreciated.

Thanks again,

Dan

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