Windows10 version 1703 : Cortana on a vfp top level form

Published on by Yousfi Benameur


the new windows 10 last version 1703 ( Fall Creators Update) have transformed cortana as a cool configurable tool.
this code *1* makes the famous cortana as a child window on a top level form.
habitually cortana is fired from the windows10 taskbar at the desktop left taskbar .
here its position changes and shows in the form area at the right.
It have the focus to type string wanting to search.if you click out its hidden and this is its normal behaviour (as menu option).
you can filter any goal search by: applications,document, web....
you can read more on its voice assist....can connect for more improvments with your microsoft account...
this tool is very performent and can search anything locally or on the web.
it may be very utile for the user.
when releasing the form, the cortana is set at its original position.Its always present.
Cortana saves always its last position.you can programmatly put it as desired.
Any search fires the Edge navigator (not the default if another is set).
this one saves 	also its postion & size.Edge have by default Bing engine search(can change it in edge by Google or another).

[Post 238]


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


*1*	
*created on 25 of october 2017
*embed Cortana on a vfp form and use it for performing searches locally or on the web.
*at the end of use ,the code restores it in its windows original position.
*cortana originally located on the taskbar can be always reached by the user (except if its masked in taskbar contextuel menu). 
*this code works and tested as well even if cortana icon is masked on taskbar.

	publi yform
	yform=newObject("yCortana")
	yform.show
	read events
	retu
	*
	DEFINE CLASS yCortana AS form
	BorderStyle = 3
	Top = 0
	Left = 272
	Height = 698
	Width = 780
	ShowWindow = 2
  alwaysonTop=.t.
  maxbutton=.f.
	Caption = "Embed Cortana on a  VFP form"
	hwindow = 0

	ADD OBJECT command1 AS commandbutton WITH ;
	AutoSize = .T., ;
	Top = 2, ;
	Left = 3, ;
	Height = 27, ;
	Width = 76, ;
	FontBold = .T., ;
	Caption = "CORTANA", ;
	MousePointer = 15, ;
	BackColor = RGB(0,255,0), ;
	Name = "Command1"

	ADD OBJECT yshp AS shape WITH ;
	Top = 8, ;
	Left = 484, ;
	Height = 765, ;
	Width = 392, ;
	Anchor = 0, ;
	Visible = .F., ;
	Name = "yShp"

	ADD OBJECT image1 AS image WITH ;
	Picture = "", ;
	Height = 58, ;
	Left = 12, ;
	MousePointer = 15, ;
	Top = 48, ;
	Width = 58, ;
	Name = "Image1"

	PROCEDURE buf2dword
	lparameters lcbuffer
	RETURN Asc(SUBSTR(lcBuffer, 1,1)) + ;
		BitLShift(Asc(SUBSTR(lcBuffer, 2,1)), 8) +;
		BitLShift(Asc(SUBSTR(lcBuffer, 3,1)), 16) +;
		BitLShift(Asc(SUBSTR(lcBuffer, 4,1)), 24)
	ENDPROC

	PROCEDURE ypos
	#DEFINE HWND_BOTTOM         1
	#DEFINE SWP_SHOWWINDOW      64
		  SetForegroundWindow(thisform.hWindow)
		  SetParent(thisform.hWindow, thisform.HWnd)
	   * positioning as user want
	   local x0,y0,x1,y1
	   x0=thisform.yshp.left
	   y0=thisform.yshp.top
	   x1=x0+thisform.yshp.width
	   y1=y0+thisform.yshp.height
	SetWindowPos(thisform.hWindow, HWND_BOTTOM, x0, y0,x1,y1,SWP_SHOWWINDOW)
	ENDPROC

	PROCEDURE Resize
	with this.yshp
	.left=thisform.width-.width
	endwith
	ENDPROC

	PROCEDURE Activate
	this.resize
	ENDPROC

	PROCEDURE Destroy
	  #DEFINE HWND_BOTTOM         1
	  #DEFINE SWP_SHOWWINDOW      64
	   *re positioning cortana in its initial position
		= SetWindowPos(thisform.hWindow, HWND_BOTTOM, 0, 70,392,837, SWP_SHOWWINDOW)
	clea events

	ENDPROC


	PROCEDURE Init
	_screen.windowstate=1
	with this
	.windowstate=2
	endwith
	ENDPROC

	PROCEDURE Load
	 DECLARE INTEGER SetForegroundWindow IN user32;
			INTEGER hWindow
	DECLARE INTEGER FindWindow IN user32;
			STRING lpClassName, STRING lpWindowName
	DECLARE INTEGER IsWindow IN user32 INTEGER hWindow
	 DECLARE INTEGER SetParent IN user32;
			INTEGER hWndChild,;
			INTEGER hWndNewParent
	 DECLARE INTEGER SetWindowPos IN user32;
			INTEGER hwnd, INTEGER hWndInsertAfter,;
			INTEGER x, INTEGER y, INTEGER cx, INTEGER cy,;
			INTEGER wFlags
			
	DECLARE INTEGER GetWindowRect IN user32;
		INTEGER hWindow,;
		STRING @lpRect
	ENDPROC


	PROCEDURE command1.Click
	Local oshell
	oshell=Newobject("wscript.shell")
	oshell.Run("ms-cortana://")
	oshell=Null
	Thisform.hWindow = FindWindow(Null, "Cortana")
	If IsWindow(Thisform.hWindow) <> 0
		Thisform.ypos()
	Endif
	ENDPROC

	Procedure image1.init
	local m.myvar
	text to m.myvar noshow
	iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAIAAADYYG7QAAAALnRFWHRDcmVhdGlvbiBUaW1lAG1lci4gMjUgb2N0LiAyMDE3IDE5OjA0OjE3ICswMTAwCSYdewAAAAd0SU1FB+EKGRIELtF13eYAAAAJcEhZcwAACxIAAAsSAdLdfvwAAAAEZ0FNQQAAsY8L/GEFAAANA0lEQVR42s1ZeXRU1Rl/62xvkpnMZJJAFrJBEpYAISxC2FyhRTmAwIEu9pyeVi169EjFHhZbsR6tHrEoFfUPrRVr4QhSUKhYDEuERBJBloSEQPZ1Jslk5s28N2/td9+bSWbGIELtqTd33rzz5nvf/d1v/25wVVWxH9Ig/t8A4gd1a6+dutRbfq6rusHd1hvwBgRekOGh2UDZrIasFKZ0XPLCKaNuG59yC5zxm1JZZZ17+75L+75oT7AlOZ2uRHsSY2Foo4ki0cYkWRJDoUDA7xv09nncrH9gRVnGY8smzCh0ff+ATpzvfuz1qmaPmp2bl5I6mqJpVVXgT3s9mgOOBoE+oij0dnc1NzXmucjt62aWTUz9fgABwV0bPq1qZCdOmuJwpSqyrCpyeGEch29Eg6ErriNTwwPuCILECbLP03Px/Nk5hYmfvnDPfwvok6r2FX8oL5hQnJmdJ4siSEUTAMnzQe+Ad9DnC7AsrkpmGhFzIqbiNGNlbImgzCSTyQzQgT8OuEi6tamx4fKF/VtvX1SafouAnnnv65f2NsyYOcdsYWRZ0pXR39/X0dGeZJbvnupaOCl5Wr7dZTORJJIQyK5nkD/b6P38vOezs54BnkxPT3c4HIqiYqpCUDQXYM9UfbFxdcHGtZNvGtCmt2u2H2wpm7cAllIUhSQplvXXXq6fNZbZvLpg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FO7e8PKwq0PTBlx3W87sNq66/wLu2szRiVTJKlnQRAJabASJnuag7ltnKUk21A4ymjTWlUQCliYN6jUdwo1TfzpK1w3dLXcgCyw4cM/KJ5lub2nf/OaCRvXTLreojc40vu4qmPls8edSYkJjBkLSxx1FARlxGkLQZsxymgxGsxgKaikF6FBUGVBEQOqyMkST6DjT61/xnFfgPP62L1Pz19UOvpbVrzxoSfoZPHGoycveVIciSYjrfUikeImfKNfsLAcNCfSP7qnhUJiT79/YbHr0HN3YDca3/lY+ELPE2/WXG7z26xmxmyIdD5xSTS6tEScg7wwyHLjsxJeeah0zoTvdI5+swfnnh3/vLy3ohXcymygDTQJ4YoImwimd31Qm0IjxYVEsJj752Y9cl/BjMLk777EzQEaGqdqe4+f762+0t/uDgxG/rVgMpAQiqD2mzbWuXBy6lBFcVPjFgH978YP7r9B/wFoAjoNQ/b3HgAAAABJRU5ErkJggg==
	endtext
	this.pictureval=strconv(m.myvar,14)
	endproc

	PROCEDURE image1.Click
	local m.myvar
	text to m.myvar pretext 7 noshow
	the new windows 10 last version 1703 have transformed cortana.
	this code makes the famous cortana as a child window on a top level form.
	habitually cortana is fired from the windows10 taskbar at the desktop left.
	here its position change and show in the form area at the right.
	It have the focus to type string wanting to search.if you click out its hidden
	and its normal behaviour.
	you an filter any search by: applications,document, web....
	you can read more on its sound assist....can connect for move improvments with
	microsoft account...
	this tool is very performent and can search anything locally or on the web.
	it may be very utile for the user.
	when releasing the form, the cortana is set at its original position.
	Cortana saves always its last position.you can programmatly put it as desired.

this code embeds Cortana on a vfp form and use it for performing searches locally or on the web.
at the end of use ,the code restores it in its windows original position.
cortana originally located on the taskbar can be always reached by the user (except if its masked in taskbar contextuel menu). 
this code works and tested as well even if cortana icon is masked on taskbar.

Any search fires the Edge navigator (not the default if another is set).
this one saves 	also its postion & size.Edge have by default bing engine search(can change it in edge by Google or another).
	endtext
	*messagebox(m.myvar,0+32+4096,"Cortana")
 Local oshell
		oshell = Createobject('WScript.Shell')
		oshell.Popup(m.myvar,0, 'Summary help', 0+32+4096)  &&4,16,48,64...
		oshell=Null
ENDPROC

	ENDDEFINE
	*
	*-- EndDefine: ycortana


Windows10 version 1703 : Cortana on a vfp top level form
Windows10 version 1703 : Cortana on a vfp top level form
Windows10 version 1703 : Cortana on a vfp top level form
Windows10 version 1703 : Cortana on a vfp top level form

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

 
In my Windows10 version 1703 , if want to hide the cortana icon:
Going to the registry (run/n regedit) and point to the key:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Search
SearchboxTaskbarMode  reg_dword     0x00000001 (1)------------cortana icon visible on taskbar
SearchboxTaskbarMode  reg_dword     0x00000000 (0)------------cortana icon hidden  on taskbar but the Cortana window exists and active.
if you run the code above Cortana works as well

this registry procedure is absolutely the same with rightclick on taskbar and go to Cortana(mask or show cortana icon on taskbar)

In principe ,mask the cortana icon to work with the code above.
In Windows 10 itself, there is no option to uninstall Cortana.



Important:All Codes above are tested on VFP9SP2 , windows 10 pro latest version 1703 .

To be informed of the latest articles, subscribe:
Comment on this post
A
Thank you - excellent programa
Reply