phpdesktop icon indicating copy to clipboard operation
phpdesktop copied to clipboard

Splash screen during app launch / custom background color for window

Open GoogleCodeExporter opened this issue 11 years ago • 11 comments

An option in settings.json to set an image for a splash screen. This is to prevent user seeing a blank window with white background during application launch while loading start page. CEF callbacks OnLoadingState/OnLoadEnd should be used to determine when web page loading has completed.

It would be nice to be able to set a default backround color for the window, so that white background flicker does not occur during F5 refresh.

Topic for reference: https://groups.google.com/d/topic/phpdesktop/WfIDVZfNAk0/discussion

Original issue reported on code.google.com by [email protected] on 20 Nov 2014 at 6:06

GoogleCodeExporter avatar Aug 28 '15 11:08 GoogleCodeExporter

I think PHP-Desktop should make use of manifest.json (https://www.w3.org/TR/appmanifest/) for things like splash screen

ZanderBrown avatar Apr 16 '16 22:04 ZanderBrown

A splash screen would indeed be a very nice feature. Is there any workarounds at the moment?

siran avatar Jan 11 '17 18:01 siran

@siran I can only suggest googling "javascript loading splash" or similar.

cztomczak avatar Jan 11 '17 20:01 cztomczak

@cztomczak your suggestion might work. Yet I don't know what is happening under the hood while the app is loading... is JS available?

siran avatar Jan 22 '17 23:01 siran

A possible workaround is to create an application launcher in other programming/scripting language which will show a splash screen then calls the main phpdesktop exe. Basically you just place the main folder of phpdesktop in a folder, like in the ff. directory structure.

ApplicationFolder 
    |__AppLauncher.exe
       |__ phpdesktopfolder
           |__phpdesktop-chrome.exe
	   |__logo.jpg
   

For AppLauncher, I use the following autohotkey script

/*initially, run minimized*/
Run, phpdesktop\phpdesktop-chrome.exe,, Min 

/*
*wait for 3 seconds for the phpdesktop window  to be created
*main_window_title is the same as the window title set in the settings.json
*/
WinWait, main_window_title, , 3 
WinHide 

SplashImage, phpdesktopfolder\logo.jpg, b fs18, Loading...
Sleep, 4000
SplashImage, Off
WinShow
WinMaximize
WinWaitClose

/* run any other script like,cleanup etc. after phpdesktop-chrome.exe is closed*/
MsgBox Bye 

Admittedly, this splashscreen will be basically just eye-candy and will not ensure that your php application has already loaded once it is displayed.

jal617b avatar Mar 24 '17 03:03 jal617b

My two cents:

About this issue I 'solved' it using AutoIt tool.

With this tool I can write a script that

  1. launches the app
  2. shows a splash screen
  3. detects when the app writes a control file
  4. when the file is detected (the app is running) the splash screen is hidden and the control file deleted

This results in a non-eye-candy splash screen.

Downside: if app fails to start, splash screen is not hidden.

Maybe the splash screen can be also hidden with a timer.

My script is something like:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPIFiles.au3>

; Change this variable to the full path and filename of the program's executable
$sExec="myexe.exe"

;this empty filename gets created when the app is running. 
$sFilePath="relative\path\to\splash.off"

If _WinAPI_FileExists( $sFilePath ) Then 
    FileDelete($sFilePath)
EndIf

Run($sExec)
$hWait=GUICreate("Loading ...",450,300,-1,-1,BitOR($WS_BORDER,$WS_POPUP),$WS_EX_TOPMOST)
GUICtrlCreatePic("relative\path\to\splash.jpg", 0, 0, 450, 300)
GUISetState(@SW_SHOW)

While 1
    sleep(500);
    If _WinAPI_FileExists( $sFilePath ) Then 
        FileDelete($sFilePath)
        ExitLoop    
    EndIf
WEnd

GUIDelete($hWait)

siran avatar Mar 26 '17 19:03 siran

You can tweak up the solution a little bit. Use this AutoIt Script, the following splash.ini and the attached index.php file. Now you have a dynamic solution for all your applications with a nice fading Splash :)

Autoit:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPIFiles.au3>
#include <Process.au3>

; Change this variable to the full path and filename of the program's executable $sExec=IniRead("splash.ini","SplashConfig","Filename","file.exe")

;this empty filename gets created when the app is running. $sFilePath=IniRead("splash.ini","SplashConfig","DisableFile","splash.off")

If _WinAPI_FileExists( $sFilePath ) Then FileDelete($sFilePath) EndIf

$Process=Run($sExec, "", @SW_HIDE) $hWait=GUICreate("Loading...",450,300,-1,-1,BitOR($WS_BORDER,$WS_POPUP),$WS_EX_TOPMOST) GUICtrlCreatePic(IniRead("splash.ini","SplashConfig","SplashFilename","splash.jpg"), 0, 0, 450, 300) GUISetState(@SW_HIDE) ;fade-in DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hWait, "int", 500, "long", 0x00080000)

While 1 sleep(500); If _WinAPI_FileExists( $sFilePath ) Then FileDelete($sFilePath) ExitLoop EndIf WEnd

;fade-out DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hWait, "int", 1000, "long", 0x00090000) GUIDelete($hWait)

;this gets the list of windows to sort through Dim $ProcList = WinList () ;browses through all of the items in the array returned For $i = 1 To $ProcList[0][0] If WinGetProcess ( $ProcList[$i][1] ) = $Process Then WinSetState($ProcList[$i][0],"",@SW_SHOW) EndIf Next

splash.ini:

[SplashConfig]
Filename=phpdesktop-chrome.exe
DisableFile=www/splash.off
SplashFilename=splash.jpg

index.php:

$file = 'splash.off';
file_put_contents($file, "", FILE_APPEND | LOCK_EX);

zap0xfce2 avatar Jul 05 '17 13:07 zap0xfce2

amazing works guys with Autoit and sharing scripts! hats off!

yeomann avatar Mar 18 '18 22:03 yeomann

Hi @zap0xfce2... I did not understand which script goes inside the splash.off file.

astherweb avatar Jul 26 '18 00:07 astherweb

@astherweb The splash.off file is just a empty file :) Read the AutoIt Script at line 11 & 12 to understand what is happening there.

zap0xfce2 avatar Oct 14 '18 15:10 zap0xfce2

You can tweak up the solution a little bit. Use this AutoIt Script, the following splash.ini and the attached index.php file. Now you have a dynamic solution for all your applications with a nice fading Splash :)

Autoit:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPIFiles.au3>
#include <Process.au3>
; Change this variable to the full path and filename of the program's executable
$sExec=IniRead("splash.ini","SplashConfig","Filename","file.exe")
;this empty filename gets created when the app is running.
$sFilePath=IniRead("splash.ini","SplashConfig","DisableFile","splash.off")
If _WinAPI_FileExists( $sFilePath ) Then
FileDelete($sFilePath)
EndIf
$Process=Run($sExec, "", @SW_HIDE)
$hWait=GUICreate("Loading...",450,300,-1,-1,BitOR($WS_BORDER,$WS_POPUP),$WS_EX_TOPMOST)
GUICtrlCreatePic(IniRead("splash.ini","SplashConfig","SplashFilename","splash.jpg"), 0, 0, 450, 300)
GUISetState(@SW_HIDE)
;fade-in
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hWait, "int", 500, "long", 0x00080000)
While 1
sleep(500);
If _WinAPI_FileExists( $sFilePath ) Then
FileDelete($sFilePath)
ExitLoop
EndIf
WEnd
;fade-out
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hWait, "int", 1000, "long", 0x00090000)
GUIDelete($hWait)
;this gets the list of windows to sort through
Dim $ProcList = WinList ()
;browses through all of the items in the array returned
For $i = 1 To $ProcList[0][0]
If WinGetProcess ( $ProcList[$i][1] ) = $Process Then
WinSetState($ProcList[$i][0],"",@SW_SHOW)
EndIf
Next

splash.ini:

[SplashConfig]
Filename=phpdesktop-chrome.exe
DisableFile=www/splash.off
SplashFilename=splash.jpg

index.php:

$file = 'splash.off';
file_put_contents($file, "", FILE_APPEND | LOCK_EX);

This is actually helpful in 2022

HashenUdara avatar Aug 29 '22 06:08 HashenUdara