Page 1 of 1

Help with nbExecAction

PostPosted: Mon Mar 16, 2015 8:57 pm
by AsleyCruz
Hi guys!
I use this action in JavaScript:

Code: Select all
window.external.nbExecAction( 'AlertBox "Hello from HTML" "Executing action from HTML source via javascript!"' );


But, how can I use this code in VBScript?

I have tried, but nothing, maybe this is something easy for you and I will thank you in advanded.

Hope you can help me ;-) Regards

Re: Help with nbExecAction

PostPosted: Tue Mar 17, 2015 6:56 am
by Gaev
Asley Cruz:

Try this code ...
Code: Select all
window.external.nbExecAction "AlertBox " & chr(34) & "Hello from HTML" & chr(34) & " " & chr(34) & "Executing action from HTML source via vbscript" & chr(34)

Re: Help with nbExecAction

PostPosted: Tue Mar 17, 2015 12:44 pm
by AsleyCruz
Gaev wrote:Asley Cruz:

Try this code ...
Code: Select all
window.external.nbExecAction "AlertBox " & chr(34) & "Hello from HTML" & chr(34) & " " & chr(34) & "Executing action from HTML source via vbscript" & chr(34)



Hi Gaev
Many thanks but for excecuting this script I need to create an object "window".
How can I solve this? How to create an object? It says:

An object "window" is required... something like this.
Many thanks for your help.

.

Re: Help with nbExecAction

PostPosted: Tue Mar 17, 2015 4:05 pm
by Gaev
AsleyCruz:

for excecuting this script I need to create an object "window".
How can I solve this? How to create an object?
I got the impression (from reading your first post) that you were looking for a command that would work within vbscript inside an HTML document that was going to run inside a WebBrowser object ... if that is so, the suggested command should work fine ... it did in a sample pub/html document I created.

However, if you were looking to Call a vbscript directly from your publication e.g. ...
Code: Select all
Call "gkvbAlertBox"

... then try this command ...
Code: Select all
publication.nbExecAction "AlertBox " & chr(34) & "Hello" & chr(34) & " " & chr(34) & "from vbscript" & chr(34) 

Re: Help with nbExecAction

PostPosted: Tue Mar 17, 2015 5:04 pm
by AsleyCruz
Cool, Gaev... it works in WebBrowser object... no more :)
Thanks and regards!

Re: Help with nbExecAction

PostPosted: Tue Mar 17, 2015 5:29 pm
by Gaev
AsleyCruz:

I am confused by your latest response ...

Cool, Gaev... it works in WebBrowser object.
I am assuming that you had the following vbscript command inside an HTML document ... that you loaded in a WebBrowser object ...
Code: Select all
window.external.nbExecAction "AlertBox " & chr(34) & "Hello from HTML" & chr(34) & " " & chr(34) & "Executing action from HTML source via vbscript" & chr(34)
... notice that it says window.external.nbExecAction

If I want to display an AlertBox using a VBScript Function...
how is the correct way? any idea? is this possible?

But, How can I send an "AlertBox" to NeoBook using VBScript code? (Not inside an HTML document)
As per my last post, you use this command ...
Code: Select all
publication.nbExecAction "AlertBox " & chr(34) & "Hello" & chr(34) & " " & chr(34) & "from vbscript" & chr(34)
... notice that it says publication.nbExecAction ... and you place it inside a "Function defined as using vbscript" ... which you Call from a code section in your publication.

Ex: This VBScript code sends to NeoBook any result:
publication.nbSetVar "[%1]", Total
This will populate the variable defined in the first parameter (of the Call command) with the value of the vbscript variable called Total ... it has nothing to do with asking NeoBook to execute NeoBook commands from a vbscript.

Re: Help with nbExecAction

PostPosted: Tue Mar 17, 2015 5:37 pm
by AsleyCruz
Hi Gaev
Any answer you post here, worked for me...
... all I was looking for is this simple code: :x :x :x

Code: Select all
publication.nbExecAction( "AlertBox ""My Title"" ""My Message""" )


It is for my coming new tool called: "Simple Website Blocker", something like this :wink:

For using in a VBScript Function without any WebBrowser object.
I only have to say many thanks again :)

Re: Help with nbExecAction

PostPosted: Tue Mar 17, 2015 9:54 pm
by David de Argentina
Hi Ernesto,

This is working for me under XP SP3 and IE8. I guess it may work on newer OS versions and IE Versions

a) Create a new pub
b) add a button.
c) add this actions to the button:

Syntax: [ Download ] [ Hide ]
Using Neobook Syntax Highlighting
BrowserLoadFromStr "NavegadorWeb1" "<html>|<head>|</head>|<body>|<script>|function vb() {|alert([#34]this is the internal html javascript function, that calls the MyVBFunction[#34]);|window.external.nbExecAction( 'Call [#34]c:/MyVBFunction.nbf[#34]' );|}|</script>|</body>|<button onclick=[#34]vb()[#34]>Click me</button>|</body>|</html>"
 
Parsed in 0.009 seconds, using GeSHi 1.0.8.10


d) create using Notepad a text file called "MyVBFunction.nbf" at the root folder of your C drive:
with this text:

Code: Select all
{NeoBook Function}
Version=5.80
Language=VBScript
{End}
MsgBox "hello world from the VBScript function called MyVBFunction"


e) Run the program.

Tell me if this is you are searching.

Greetings from Buenos Aires,
David de Argentina

Re: Help with nbExecAction

PostPosted: Wed Mar 18, 2015 7:19 am
by AsleyCruz
Many thanks David
All this is usefull for me... it works perfectly.

I was looking for all this for a upcoming tool I am developing.
Best regards :wink: