A custom metro apps application in systray

Published on by Yousfi Benameur


This code below  builds a systray menu with some choosen  windows metro applications (available on win8.1 and win10).
with this artifact the favorite win apps can be under the hand and fired at any time.
my favorite are: meteo,news, sports,photos, my couriel gmail....(can make default custom settings in each app as language and other  parameters).
i made for this demo 4 apps in the menu but can extend as desired.
can build a simple proj (add a config.fpw only) and compile an exe.Can make this exe starts with windows also.
the windows metro apps save automaticallty their last position and dimensions(can adjust).

can read this refrence:
http://yousfi.over-blog.com/2015/02/list-and-run-windows-8-1-metro-apps.html
*tested on win10 pro and internet explorer 10 (Bing works with ie10).
*The windows  metro apps names (titles and innertexts)can be locallized(depend on languages installed).
*Some apps in win10 stay in windows store (free or $)
*All configuration parameters stay in app and can be customized usefully.

*tested on visual foxpro 9 sp2-windows 10 pro


 

 

Click on code to select [then copy] -click outside to deselect


*Begin code

**systray must be mandatory in the active folder to work otherwise mandatory must be pointed with "set path to"
*otherwise it returns error in class structure(try/catch/endtry) even if you put the location clas in define class.
*can make also an executable with this applications in systray  menu....
if !_vfp.startmode=0
on shutdown quit
endi
Clea All
Set Path To (Home(1)+"samples\solution\toledo\")

Publi m.osystray
Local m.oo
m.oo=.F.
Try
    m.osystray = Createobject("ysystray")
Catch
	m.oo=.T.
Endtry
If m.oo=.T.
	Messagebox("Systray class is absent...cancelling.. !",16+4096,1000)
	Return
Endi

_Screen.AddProperty("myvar","")
TEXT to _screen.myvar noshow
this application starts on systray and can fires some windows metro
application as  -meteo - news  -sports -Photos....
-can run on windows8.1 and windows10
ENDTEXT

Try
	With m.osystray
		.ShowBalloonTip(_Screen.myvar,"The systray balloon",0,5)
	Endwith
Catch
	Messagebox("Balloon not supported in os version!",16+4096,"error",1000)
Endtry

Read Events

Define Class ysystray As Systray Of "systray.vcx"
	IconFile = Home(1) + "Graphics\Icons\Misc\misc15.ico"
	TipText = "ysystray"
	MenuTextIsMPR = .F.
	MenuText = "1;Meteo ;2;News;3;Sports ;4;Photos;5;Exit"  &&menu integrated inside code-can add other win metro apps if available.

	Procedure ProcessMenuEvent    &&event of systray class
	Lparameters nMenuItemID
	Local m.winappName
	loshell=Newobject("wscript.shell")

	Do Case
	Case nMenuItemID = 0
* User cleared the menu. Do nothing.
	Case nMenuItemID = 1

		m.winappName="BingWeather://"
		Try
			loshell.Run(m.winappName)
		Catch
			Messagebox("An error was occured !",16+4096)
		Endtry

	Case nMenuItemID = 2
		m.winappName="BingNews://"
		Try
			loshell.Run(m.winappName)
		Catch
			Messagebox("An error was occured !",16+4096)
		Endtry
	Case nMenuItemID = 3
		m.winappName="BingSports://"
		Try
			loshell.Run(m.winappName)
		Catch
			Messagebox("An error was occured !",16+4096)
		Endtry

	Case nMenuItemID =4
    m.winappName="ms-Photos://"
    	Try
			loshell.Run(m.winappName)
		Catch
			Messagebox("An error was occured !",16+4096)
		Endtry
    case nMenuItemID =5
		This.RemoveIconFromSystray()
		Clear Events
	Endcase

	Endproc
Enddefine

*End code




 

Note that the systray balloon is a new win10 style !
Note that the systray balloon is a new win10 style !
Note that the systray balloon is a new win10 style !
Note that the systray balloon is a new win10 style !
Note that the systray balloon is a new win10 style !
Note that the systray balloon is a new win10 style !
Note that the systray balloon is a new win10 style !

Note that the systray balloon is a new win10 style !

can also execute any metro app (win8.1 and win10) with this command line.Verify the metro app syntax to make it running from window start or msdos.

 

C:\Windows\System32\cmd.exe /c start "" "ms-Photos:"

 

can make a shortcut on the desktop pointing to any metro App and running it  as these 2 photo below manually or programmatly.

Click on code to select [then copy] -click outside to deselect


*this code creates a desktop link pointing to metro photos app

Local  WshShell, strDesktop,oShellLink
WshShell =Createobject("WScript.Shell")
strDesktop = WshShell.SpecialFolders("Desktop")

oShellLink = WshShell.CreateShortcut(strDesktop + "\ymetro_Photos.lnk")
oShellLink.TargetPath ="ms-Photos://"
oShellLink.WindowStyle = 1
oShellLink.HotKey = "CTRL+SHIFT+F"
Local m.x
m.x= '['+ Home(1)+'vfp9.exe'+',0] '  && vfp icon
oShellLink.IconLocation =Eval(m.x)

oShellLink.Description = "metro Photos"
oShellLink.WorkingDirectory = strDesktop
oShellLink.Save


Messagebox("link to metro photos app created-see the desktop !",0+32+4096,"",1000)


 

manually rightclick on the desktop--new---shrtcut...and add the metro app link.The second photo is made programmatly.
manually rightclick on the desktop--new---shrtcut...and add the metro app link.The second photo is made programmatly.
manually rightclick on the desktop--new---shrtcut...and add the metro app link.The second photo is made programmatly.

manually rightclick on the desktop--new---shrtcut...and add the metro app link.The second photo is made programmatly.

if you compile an exe and want to start it with windows, simply create a shortcut linking to this exe and copy it in this windows10 folder:

C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp

Click on code to select [then copy] -click outside to deselect


Observations:
metro UI windows (8.1 &10) Apps  can be launched with a specific position and window size on desktop
this can be done by getting the window handle (the locallized title is known) .
Using classic APIs findWindow and setWindowpos do the job.

 

Click on code to select [then copy] -click outside to deselect


*Update on Friday 21 august 2015  18:56
*This is the above code updated on windows10 pro for 10 metro UI applications
*I added 6 other UI apps:Reader,Maps,Mailto,Cortana,Edge,SoundR ecorder...tested on win10 pro (some maybe dont run on win8.1).

*Begin code

**systray must be mandatory in the active folder to work otherwise mandatory must be pointed with "set path to"
*otherwise it returns error in class structure(try/catch/endtry) even if you put the location clas in define class.
*can make also an executable with this code.o win metro applications in systray  menu....
If !_vfp.StartMode=0
    On Shutdown Quit
Endi
Clea All
Set Path To (Home(1)+"samples\solution\toledo\")

Publi m.osystray
Local m.oo
m.oo=.F.
Try
	m.osystray = Createobject("ysystray")
Catch
	m.oo=.T.
Endtry
If m.oo=.T.
	Messagebox("Systray class is absent...cancelling.. !",16+4096,1000)
	Return
Endi

_Screen.AddProperty("myvar","")
TEXT to _screen.myvar noshow
this application starts on systray and can fires some windows metro
application as  -meteo - news  -sports.
-can run on windows8.1 and windows10
ENDTEXT

Try
	With m.osystray
		.ShowBalloonTip(_Screen.myvar,"The systray balloon",0,5)
	Endwith
Catch
	Messagebox("Balloon not supported in os version!",16+4096,"error",1000)
Endtry

Read Events

Define Class ysystray As Systray Of "systray.vcx"
	IconFile = Home(1) + "Graphics\Icons\Misc\misc15.ico"
	TipText = "ysystray"
	MenuTextIsMPR = .F.
	MenuText = "1;1.Meteo ;2;2.News;3;3.Sports ;4;4.Photos;5;5.Reader;6;6.maps;7;7.mailto;8;8.Cortana;9;9.Edge;10;10.Sound Recorder;11;Exit"  &&menu integrated inside code-can add other win metro apps if available.
	Procedure ProcessMenuEvent    &&event of systray class
	Lparameters nMenuItemID
	Local m.winappName
	loshell=Newobject("wscript.shell")

	Do Case
	Case nMenuItemID = 0
* User cleared the menu. Do nothing.
	Case nMenuItemID = 1
		m.winappName="BingWeather://"
		Try
			loshell.Run(m.winappName)
		Catch
			Messagebox("An error was occured !",16+4096)
		Endtry

	Case nMenuItemID = 2
		m.winappName="BingNews://"
		Try
			loshell.Run(m.winappName)
		Catch
			Messagebox("An error was occured !",16+4096)
		Endtry

	Case nMenuItemID = 3
		m.winappName="BingSports://"
		Try
			loshell.Run(m.winappName)
		Catch
			Messagebox("An error was occured !",16+4096)
		Endtry

	Case nMenuItemID =4
		m.winappName="ms-Photos://"
		Try
			loshell.Run(m.winappName)
		Catch
			Messagebox("An error was occured !",16+4096)
		Endtry

	Case nMenuItemID =5
*this code launches the modern ui reader app with shellEXECUTE API as command line parameter
&&shellexecute
		Declare Integer ShellExecute In SHELL32.Dll Integer nWinHandle,;
			STRING cOperation,;
			STRING cFileName,;
			STRING cParameters,;
			STRING cDirectory,;
			INTEGER nShowWindow

		Local m.x
		m.x=" shell:Appsfolder\Microsoft.Reader_8wekyb3d8bbwe!Microsoft.Reader"
		result = ShellExecute(0, "open", Addbs(Getenv('windir'))+"explorer.exe ",m.x,"",3)

	Case nMenuItemID =6
		m.winappName="bingmaps://"
		Try
			loshell.Run(m.winappName)
		Catch
			Messagebox("An error was occured !",16+4096)
		Endtry
	Case nMenuItemID =7
		m.winappName="mailto://"
		Try
			loshell.Run(m.winappName)
		Catch
			Messagebox("An error was occured !",16+4096)
		Endtry

	Case nMenuItemID =8
		m.winappName="ms-cortana://"
		Try
			loshell.Run(m.winappName)
		Catch
			Messagebox("An error was occured !",16+4096)
		Endtry


	Case nMenuItemID =9
		m.x="%windir%\explorer.exe shell:Appsfolder\Microsoft.MicrosoftEdge_8wekyb3d8bbwe!MicrosoftEdge"
		Try
			loshell.Run(m.x)
		Catch
			Messagebox("An error was occured !",16+4096)
		Endtry

	Case nMenuItemID =10
		m.x="%windir%\explorer.exe shell:Appsfolder\Microsoft.WindowsSoundRecorder_8wekyb3d8bbwe!App"
		Try
			loshell.Run(m.x)
		Catch
			Messagebox("An error was occured !",16+4096)
		Endtry


	Case nMenuItemID =11   &&exit
		This.RemoveIconFromSystray()
		Clear Events
	Endcase

	Endproc
Enddefine

*End code




 

A custom metro apps application in systray
A custom metro apps application in systray
A custom metro apps application in systray
A custom metro apps application in systray
A custom metro apps application in systray

*updated on thursday 3 september 2015 15:30
*this code launches the win10 godeMode ui
*it gives access to all of the operating system's control panels from within a single folder.Its very usefull for all operations on control panel.
*In fact, its real name is the Windows Master Control Panel shortcut.
*can create a desktop shortcut (new folder and name it :Godmode.{ED7BA470-8E54-465E-825C-99712043E01C}
can do this operation programmatly as shown above.


Click on code to select [then copy] -click outside to deselect


local m.x,loshell
m.x="%windir%\explorer.exe Godmode.{ED7BA470-8E54-465E-825C-99712043E01C}"
loshell=createobject("wscript.shell")
loShell.run(m.x)
loShell=null
release loshell
retu


A custom metro apps application in systray

Click on code to select [then copy] -click outside to deselect

 
 *added on september 11  2015  19h00
*this code launches the modern ui Films&video app   (windows10 pro)
*the link is cutted from a real shortcut created on desktop.

local m.x,loshell
m.x="%windir%\explorer.exe shell:Appsfolder\Microsoft.ZuneVideo_8wekyb3d8bbwe!Microsoft.ZuneVideo"
loshell=createobject("wscript.shell")
loShell.run(m.x)
retu



Click on code to select [then copy] -click outside to deselect


*this code lauches microsoft edge with a specific URl

local m.lcURL,mcmdline
m.lcURl="http://www.yousfi.over-blog.com"
m.cmdline=" run/N cmd.exe /c start microsoft-edge:"+m.lcURl
&cmdline




Click on code to select [then copy] -click outside to deselect


*can run windows powershell to extract all modern UI applications from the system
*this code extracts these Apps and redirect all to a txt file: d:\ymetroApps1.txt
*you dont find here any way to lauch these apps.only known way here is to create a link form the appsfolder (explorer shell:AppsFolder in WIN+R).

run/n0 powershell   "Get-AppxPackage > d:\ymetroApps1.txt"
inke(10)
run/n notepad d:\ymetroApps1.txt


To be informed of the latest articles, subscribe:
Comment on this post
C
This is a very inspiring post... I read each and every posing and I found it really beneficial for me... I would like to say thank you for posting this kind of article... Keep sharing with us...
Reply