Page 1 of 1

hpwRemote action

PostPosted: Sun Mar 19, 2017 2:21 pm
by fkapnist
RE: This is a free text string to be sent to the listener app.
It is the job of the listener app to make something with it.
When the string is received it is stored in [hpwRemoteListenerMessage]
Then a optional action in [hpwRemoteListenerAction] is fired.



I got as far as successfully sending a text string between apps. But I don't know how to put the string into an Action command. I am using windowhandle to identify the main app because the Title changes when running.

I cannot find any further information about [hpwRemoteListenerAction]... It does not seem to be included in the hpwRemote plugin....

Any help will be appreciated.

.

Re: hpwRemote action

PostPosted: Mon Mar 20, 2017 12:20 pm
by HPW
Hello,

Sample hpwSendToListener.exe launch hpwListener.exe and you can send the textstring to the listener.
In the hpwListener.exe Startup Action you can find:
Code: Select all
SetVar "[hpwRemoteListenerAction]" "Setvar [#34][#91]TextEntry1[#93][#34] [#34][#91]hpwRemoteListenerMessage[#93][#34]"

This load the code into the variable. It tells the Action what to do with the incoming message.
Hope this helps.

Regards

Re: hpwRemote action

PostPosted: Tue Mar 21, 2017 3:23 am
by fkapnist
HPW wrote:Hello,

Sample hpwSendToListener.exe launch hpwListener.exe and you can send the textstring to the listener.
In the hpwListener.exe Startup Action you can find:
Code: Select all
SetVar "[hpwRemoteListenerAction]" "Setvar [#34][#91]TextEntry1[#93][#34] [#34][#91]hpwRemoteListenerMessage[#93][#34]"

This load the code into the variable. It tells the Action what to do with the incoming message.
Hope this helps.

Regards


Got it. Thanks! I have a main app and a monitor app in the system tray to see if the main app is working and responding. I put the above code in both apps and now I have 2-way communication! But I still don't know how to turn a text string into an Action event. Any simple code example of a text string turning into a Neobok Action? Where and when does that happen?

I want the monitor app not to just get a text string but to remotely "Call" a function in the main app.
What for example would be the hpwRemote syntax for something like Call "HelloWorld"


:?:

.

Re: hpwRemote action

PostPosted: Tue Mar 21, 2017 6:53 am
by mishem
Write down the received line in the file and cause it from the file.
For example:

Code: Select all
SetVar "[HelloWorld]" "AlertBox [#34][#34] [#34]Hello World![#34]"
FileWrite "[TempDir]HelloWorld" "All" "[HelloWorld]"
Call "[TempDir]HelloWorld"

Re: hpwRemote action

PostPosted: Tue Mar 21, 2017 9:15 am
by HPW
Hello,
Code: Select all
Call [#34]HelloWorld[#34]

When you understand how the neobook Interpreter evaluates his script the first time and whats get stored in the variable, you can do it by hand.

As an help you can use the wizard of hpwUtilitySetVar and choose one of the defined Action vars.
The wizard offers a button to the full Screen Action Editor. There you can edit your code.
When you leave the Editor, your code gets transformed to a valid string for the setvar-action.
Then copy the string into your action-variable.

Nice to have would be the same wizard in a hpwRemoteSetvar command.

Another Option to store your Action code in a offsreen TextEntryObject and simply call the Content-variable.

Regards

Re: hpwRemote action

PostPosted: Tue Mar 21, 2017 9:37 am
by fkapnist
HPW wrote:Hello,
Code: Select all
Call [#34]HelloWorld[#34]

When you understand how the neobook Interpreter evaluates his script the first time and whats get stored in the variable, you can do it by hand.

As an help you can use the wizard of hpwUtilitySetVar and choose one of the defined Action vars.
The wizard offers a button to the full Screen Action Editor. There you can edit your code.
When you leave the Editor, your code gets transformed to a valid string for the setvar-action.
Then copy the string into your action-variable.

Nice to have would be the same wizard in a hpwRemoteSetvar command.

Another Option to store your Action code in a offsreen TextEntryObject and simply call the Content-variable.

Regards


I am still a bit confused... I can now send any text string from "App A" to a TextEntryObject in "App B." So far so good. But the text string is static... Call [#34]HelloWordl[#34] does not do anything. The TextEntryObject does indeed change with every new text string received but Neobook ignores its own "Text Change" tab and does not run the Action. I do not want to click on anything to run the Action. I want it to run automatically by itself as soon as the text string changes


:roll:

I looked through the hpwUtility.pub but I am not sure what you mean by wizard and I could not find a button to the full Screen Action Editor. What I simply want to do is get "App B" to automatically run an Action when it receives a text string from remote "App A" without having the user click on a button etc...

I just found the hpwUtilitySetVar wizard in the plugin Insert Action tab. it has a drop down menu with many variables to choose from.... Very interesting.
But I want to remotely trigger an Action from one app textstring sent to another without a user click or any intervention....


.

Re: hpwRemote action

PostPosted: Tue Mar 21, 2017 11:05 am
by HPW
Hello,

You should have a look at the other sample Pubs hpwSender and hpwReceive.
The Sender starts the Receiver and can play free text-Actions in the Receiver.

Seems more the right function for your wishes.

Regards

Re: hpwRemote action

PostPosted: Tue Mar 21, 2017 11:50 am
by fkapnist
HPW wrote:Hello,

You should have a look at the other sample Pubs hpwSender and hpwReceive.
The Sender starts the Receiver and can play free text-Actions in the Receiver.

Seems more the right function for your wishes.

Regards


I have stored the target app WinHandle in a file "[AppDataPath]handle-b.txt"
I have also put these lines in the Startup:

Code: Select all
hpwRemoteCreateListener
SetVar "[hpwRemoteListenerAction]" "Setvar [#34][#91]TextEntryRL1[#93][#34] [#34][#91]hpwRemoteListenerMessage[#93][#34]"


and now this works okay:

Code: Select all
FileToVar "[AppDataPath]handle-b.txt" "[var-b]"
hpwRemotePlayActionHandle "[var-b]" "[TextEntryRS1]" "0"


It sends whatever text is in "[TextEntryRS1]" to the target app.

But if I put this line in the Startup what more does it need to work? (It asks for a password)

Code: Select all
hpwRemoteCreateReceiver ""


And then neither of these lines will run the AlertBox Action that I want

Code: Select all
hpwRemotePlayActionHandle "[var-b]" "AlertBox [#34][#34] [#34]ok2[#34]" "0"
hpwRemotePlayActionHandle "[#91]var-b[#93]" "AlertBox [#34][#34] [#34]ok2[#34]" "0"



So what needs to be changed?

Thanks for the help

:?:
.

Re: hpwRemote action

PostPosted: Tue Mar 21, 2017 12:07 pm
by HPW
Helo,

Code: Select all
hpwRemoteCreateReceiver "YourOwnPassword"


You choose a password to make the connection a bit secure. See it as a open port. (based on windows messaging) Only your 2 apps know the password.
With that password you make sure that it accept only messages which starts with that password on the first line of the message.

Regards

Re: hpwRemote action

PostPosted: Tue Mar 21, 2017 12:50 pm
by fkapnist
HPW wrote:Helo,

Code: Select all
hpwRemoteCreateReceiver "YourOwnPassword"


You choose a password to make the connection a bit secure. See it as a open port. (based on windows messaging) Only your 2 apps know the password.
With that password you make sure that it accept only messages which starts with that password on the first line of the message.

Regards


When I put that line of code in the Startup my application always crashes. I wonder why?

:?:
.

Re: hpwRemote action

PostPosted: Tue Mar 21, 2017 2:04 pm
by HPW
Hello,

Does Sample hpwReceive.pub work for you?
What does you see in the Debugger?
Other code in Startup?

Regards

Re: hpwRemote action

PostPosted: Thu Mar 23, 2017 4:16 pm
by fkapnist
HPW wrote:Hello,

Does Sample hpwReceive.pub work for you?
What does you see in the Debugger?
Other code in Startup?

Regards



I moved the following line to another part of the Receiver Startup script and now it works.

hpwRemoteCreateReceiver "Secretword"

Thank you.

:)