PB.Ex WebGadget (Windows) (WebKit)

Applications, Games, Tools, User libs and useful stuff coded in PureBasic
User avatar
RSBasic
Moderator
Moderator
Posts: 1218
Joined: Thu Dec 31, 2009 11:05 pm
Location: Gernsbach (Germany)
Contact:

Re: PB.Ex WebGadget (Windows) (WebKit)

Post by RSBasic »

Good morning

Yes, that's correct. You can only call PB procedure, pass parameter (JS -> PB), but don't return a return value (PB -> JS).
Image
Image
User avatar
captain_skank
Enthusiast
Enthusiast
Posts: 636
Joined: Fri Oct 06, 2006 3:57 pm
Location: England

Re: PB.Ex WebGadget (Windows) (WebKit)

Post by captain_skank »

Morning,

First up thanks and congrats on all the work you've done recently, it is anexcellent body of work.

When i run this it displays a blank window, pauses and the quits with 'debugged executable quit unexpectedly'

I'm running it on windows 10 x64 v1809 the processor is a AMD FX8370 and i've tried with PB versions 5.70 and 5.71.

Any idea what i'm doing wrong ?

cheers
HanPBF
Enthusiast
Enthusiast
Posts: 562
Joined: Fri Feb 19, 2010 3:42 am

Re: PB.Ex WebGadget (Windows) (WebKit)

Post by HanPBF »

@RSBasic

Aha!!!! Thanks a lot for the quick answer!!!

So, the way to work here is calling procedure (PureBasic) from function (JavaScript) and let PureBasic send the answer asynchronously to JavaScript.
Which is more effort to manage but possible via exp. GUID match.

And I guess that internally there happens some messaging like calls when embedding CEF browser.

Now after this answer I still consider Your work here what it simply is: great :D

Thanks a lot!!!
Last edited by HanPBF on Tue May 21, 2019 8:42 am, edited 1 time in total.
HanPBF
Enthusiast
Enthusiast
Posts: 562
Joined: Fri Feb 19, 2010 3:42 am

Re: PB.Ex WebGadget (Windows) (WebKit)

Post by HanPBF »

@captain_skank

That happened to me when source/compiled exe was not in same folder as CEF things.
User avatar
captain_skank
Enthusiast
Enthusiast
Posts: 636
Joined: Fri Oct 06, 2006 3:57 pm
Location: England

Re: PB.Ex WebGadget (Windows) (WebKit)

Post by captain_skank »

@HanPBF

Yep your right :) sorry :oops:
HanPBF
Enthusiast
Enthusiast
Posts: 562
Joined: Fri Feb 19, 2010 3:42 am

Re: PB.Ex WebGadget (Windows) (WebKit)

Post by HanPBF »

Here is the code for JavaScript using JSON:

Code: Select all

var CEF = {
	Callbacks:{/*guid*/}
};

procedure resolveWebGadgetEx(GUID.s, P.s)	
	ExecuteWebGadgetExJavaScript(PBWebGadgetEx, "CEF.Resolves['" + GUID + "'](" + P + ")", @OutputWebGadgetEx, @ErrorOutputWebGadgetEx)	
endProcedure

CEF.call = (fun, arg={}) => {	// async call -> return value via resolve used
	let R = new Promise((resolve, reject) => {
		arg.GUID = JS.guid()
		
		CEF.Resolves[arg.GUID]	= resolve
		
		PB.call.call(null, fun, JSON.stringify(arg))
	});
	
	return R
};

CEF.callS = (fun, arg) => {		// sync call -> no return value used
	PB.call.call(null, fun, JSON.stringify(arg))
};
Here the PureBasic code to handle this (example with LibXL):

Code: Select all

structure ArgWebGadgetEx
	GUID	.s
endStructure

structure saveExcelWorkbookArgWG extends ArgWebGadgetEx	
	WB 				.i
	FilePath	.s
endStructure

procedure saveExcelWorkbookWG(*P)
	var P.s	= PeekS(*P)
	var J = ParseJSON(#PB_Any, P)
	var Arg.saveExcelWorkbookArgWG
	
	ExtractJSONStructure(JSONValue(J), @Arg, saveExcelWorkbookArgWG)
		
	var R = bool(saveExcelWorkbook(Arg\WB, Arg\FilePath) = 0)
		
	resolveWebGadgetEx(Arg\GUID, Str(R))
endProcedure

So, using it in JS could be done this way:

Code: Select all

async free(){
		CEF.callS('freeExcelWorkbook', {WB:this.Nr})  // no return value needed...
	}
	
	async save(FilePath){
		return await CEF.call('saveExcelWorkbook', {WB:this.Nr, FilePath})
	}

Last edited by HanPBF on Tue May 21, 2019 12:25 pm, edited 3 times in total.
User avatar
RSBasic
Moderator
Moderator
Posts: 1218
Joined: Thu Dec 31, 2009 11:05 pm
Location: Gernsbach (Germany)
Contact:

Re: PB.Ex WebGadget (Windows) (WebKit)

Post by RSBasic »

Nice example Image
Image
Image
User avatar
RSBasic
Moderator
Moderator
Posts: 1218
Joined: Thu Dec 31, 2009 11:05 pm
Location: Gernsbach (Germany)
Contact:

Re: PB.Ex WebGadget (Windows) (WebKit)

Post by RSBasic »

PB.Ex WebGadget 1.0.7.0 has been released.

Changelog:
  • Added: SetWebGadgetExAttribute()
  • Added: #PB_Web_Zoom for GetWebGadgetExAttribute()
  • Added: #PB_Web_Zoom for SetWebGadgetExAttribute()
Image
Image
User avatar
RSBasic
Moderator
Moderator
Posts: 1218
Joined: Thu Dec 31, 2009 11:05 pm
Location: Gernsbach (Germany)
Contact:

Re: PB.Ex WebGadget (Windows) (WebKit)

Post by RSBasic »

PB.Ex WebGadget 1.0.8.0 has been released.

Changelog:
  • Added: SetWebGadgetExSetUserAgent()
Image
Image
firace
Addict
Addict
Posts: 899
Joined: Wed Nov 09, 2011 8:58 am

Re: PB.Ex WebGadget (Windows) (WebKit)

Post by firace »

Thanks for sharing, very interesting (although I haven't had a chance to give it a try yet)
Thorium
Addict
Addict
Posts: 1271
Joined: Sat Aug 15, 2009 6:59 pm

Re: PB.Ex WebGadget (Windows) (WebKit)

Post by Thorium »

Great work, thank you for sharing.
Thorium
Addict
Addict
Posts: 1271
Joined: Sat Aug 15, 2009 6:59 pm

Re: PB.Ex WebGadget (Windows) (WebKit)

Post by Thorium »

I have a request: Please add option to change the path of the WebKit installation.
Currently it needs to be in the same directory as the application executable. It would be nice if we can specify a path, so applications can share one installation easily.
User avatar
RSBasic
Moderator
Moderator
Posts: 1218
Joined: Thu Dec 31, 2009 11:05 pm
Location: Gernsbach (Germany)
Contact:

Re: PB.Ex WebGadget (Windows) (WebKit)

Post by RSBasic »

I tested this: https://stackoverflow.com/questions/556 ... r-55683969

But it's not working. :(
Image
Image
User avatar
RSBasic
Moderator
Moderator
Posts: 1218
Joined: Thu Dec 31, 2009 11:05 pm
Location: Gernsbach (Germany)
Contact:

Re: PB.Ex WebGadget (Windows) (WebKit)

Post by RSBasic »

PB.Ex WebGadget 1.0.9.0 has been released.

Changelog:
  • Added: #PB_Web_BlockPopupMenu for SetWebGadgetExAttribute()
Image
Image
zikitrake
Addict
Addict
Posts: 833
Joined: Thu Mar 25, 2004 2:15 pm
Location: Spain

Re: PB.Ex WebGadget (Windows) (WebKit)

Post by zikitrake »

I just tried the latest version and it goes like silk!

Is it currently possible to define a proxy? (anonymous and/or with user:pass)
Post Reply