Subscribe for automatic updates: RSS icon RSS

Login icon Sign in for full access | Help icon Help
Advanced search

Pages: [1]
  Reply  |  Print  
Author Topic: simulate keystrokes with GDC (4.0) ...  (Read 11374 times)
Benjamin G.
Posts: 130


« on: July 31, 2022, 05:26:33 pm »

Hello,

I'm looking for a way to inject "keystrokes" in a program. the problem is the following, I have an application which waits in input for a barcode, this code is sent by wifi to another application. I could write the received code in a table and with an "on timer" in the graphic application recover the value but the delay of 1 second is too long. I would like to have ideas in order to be able to "inject" this code + the "TAB" or "ENTER" key in order that the program with the input dialogue is executed...
all ideas are welcome ...
GDC type application ...
ideally if we could communicate on port 6400 of the GDC would be in my opinion ideal but I would have to know the sequence to send ...

thanks in advance

Benjamin G.
Posts: 130


« Reply #1 on: August 01, 2022, 09:15:41 pm »

Hi,

here a little schema of what we are trying to solve ...

Thank you


* Genero_Keystrokes.png (26 KB, 1300x1600 - viewed 2225 times.)
Leo S.
Four Js
Posts: 129


« Reply #2 on: August 02, 2022, 12:22:56 am »

Hi Benjamin, I wouldn't recommend simulating keystrokes ...this requires the focus being in your input program etc. and is error prone.
what you could do is extending a little bit your socket server to serve also basic http requests with a GWS server and your program doing the input could be extended with a webcomponent doing a so called long poll (or more modern: server side events).
The webcomponent hangs in a long poll at your gws server.
As soon as the socket server got input from your scanner, you finish the long poll GET of your GWS server and  the webcomponent can set the barcode data with SetData() and fire an action with gICAPI.Action() into your program doing the INPUT.
I'll try to fiddle together a demo soon.

Another possibility would be the MessageServer class, this is however only usable with native GDC and only with direct/ssh mode , not over GAS.
Using the message server allows to send function keys from one Genero program to the other.
See the docs for that: https://4js.com/online_documentation/fjs-fgl-manual-html/?path=fjs-fgl-manual#fgl-topics/c_fgl_ClassMessageServer.html

Regards, Leo
Reuben B.
Four Js
Posts: 1119


« Reply #3 on: August 02, 2022, 12:28:48 am »

My first instinct on reading the question is to ask what brand of scanner and is there any documentation for it online?

Product Consultant (Asia Pacific)
Developer Relations Manager (Worldwide)
Author of https://4js.com/ask-reuben
Contributor to https://github.com/FourjsGenero
Candy M.
Posts: 139


« Reply #4 on: August 02, 2022, 02:06:49 am »

Is there a setting to send a TAB after the bar code.  We have bar codes all throughout our ERP package and I believe you would want to send a TAB after the bar code.

Candy McCall
ONLINE Computing, Inc
Benjamin G.
Posts: 130


« Reply #5 on: August 02, 2022, 12:29:55 pm »

Hello everyone and thank you for your comments,

We use Android mobile computers with integrated barcode scanners (e.g. Unitech EA320, Zebra, ...). On these mobile computers we have JAVA or WINDEV applications (we have not yet tried to migrate to Genero ...).

The working method I describe works very well on Windows because the APIs for simulate keystrokes are easy to use and we don't have problems with loss of focus because they are kiosk applications. Sending a TAB or a CR/LF is not really a technical difficulty.

The solution of using the methods of the Message class is not possible because it uses UDP and broadcast which we do not want on our network and moreover it only allows to trigger an action and no possibility of passing characters or messages.
 
I really like the idea proposed by Leo S. because it would also open up other uses. If I understand the proposal correctly, it would be to have a webcomponent linked to the input dialog that would be listening to the socket and that could then interrupt the dialog input to process the value received. Is this correct or have I misunderstood? Unfortunately I am not so familiar with webcomponents (i understand the concept) and if Leo could guide me on how to make this type of webcomponent I would be grateful.

On the other hand, the Message class could be upgraded to be able to respond to TCP sockets events, which would be a plus in the genero input dialog in order to trigger / wake up a process remotely...

Thanks


Leo S.
Four Js
Posts: 129


« Reply #6 on: August 02, 2022, 05:00:41 pm »

Hi Benjamin, I di create a mockup for what you want to achieve.
`
abc
`
Leo S.
Four Js
Posts: 129


« Reply #7 on: August 02, 2022, 05:27:48 pm »

Sorry for my previous post, I did hit the wrong button.
I did do a little mockup, input.4gl is the program where the input should happen,srv.4gl is the http/socket server,sendcode.4gl is the mockup for sending the code via WiFi.
srv.4gl is started from input.4gl and spawns a combination of http server and socket server.
The webcomponent starts a connection to the http server and gets the result as soon as data is sent to the socket server.
The webcomponent is then able to push the data into the current dialog.
Code:
git clone https://github.com/leopatras/wc_sse.git
cd wc_sse
make run

In another terminal
Code:
fglrun sendcode 123

If there are questions to this sample let me know.
The disadvantage of this solution is:
  • you need a webcomponent
  • you need to have access to your server side from the client

In the future a new
Code:
  ON DATA_available 
trigger would be very useful to be able to get also input from a socket channel at the same time an INPUT is active.
This would avoid the need for a webcomponent and limit the communication to the server side only.
It requires however changes in the GAS protocol and the GBC.

HTH and Regards, Leo
Benjamin G.
Posts: 130


« Reply #8 on: August 02, 2022, 07:18:14 pm »

Hello Leo,

Thank you very much for the POC. I will test it. Indeed an ON DATA event would be very useful in WMS type applications because today data entry by keyboard is obsolete and fixed scanners pose a lot of maintenance and security concerns (COVID-19)

Sincerely.
Leo S.
Four Js
Posts: 129


« Reply #9 on: August 02, 2022, 10:04:14 pm »

The feature request number for ON DATA_available is #FGL-3310 btw...it's there already for almost 10 years.
If others are reading this and do poll with ON IDLE 1 or ON TIMER 1 in order to do GWS or socket connections inside dialogs :
ON data_available would make your life easier and reduce your server loads.
Use your support channels to vote for it (there isn't a high priority so far internally)
Regards, Leo
Benjamin G.
Posts: 130


« Reply #10 on: August 02, 2022, 10:18:26 pm »

Hi,

I don't know how to vote for this feature but I think that's not a "nice to have" but a real ++++ feature for genero

UP UP !!!!

regards
Reuben B.
Four Js
Posts: 1119


« Reply #11 on: August 03, 2022, 01:47:20 am »

Hi,

I don't know how to vote for this feature but I think that's not a "nice to have" but a real ++++ feature for genero

UP UP !!!!

regards

Any requests for new features is done through your local support contact.  I do have an Ask-Reuben article on new features in the pipeline that will be similar to this one https://4js.com/ask-reuben/ig-85/

Product Consultant (Asia Pacific)
Developer Relations Manager (Worldwide)
Author of https://4js.com/ask-reuben
Contributor to https://github.com/FourjsGenero
Reuben B.
Four Js
Posts: 1119


« Reply #12 on: August 03, 2022, 03:18:45 am »

Quote
We use Android mobile computers with integrated barcode scanners (e.g. Unitech EA320, Zebra, ...). On these mobile computers we have JAVA or WINDEV applications (we have not yet tried to migrate to Genero ...).

Have you considered using Genero Mobile on these devices?  This would give you the mobileScanBarCode frontcall http://4js.com/online_documentation/fjs-fgl-manual-html/#fgl-topics/c_fgl_frontcall_mobile_scanbarcode.html or access via Cordova Plugins to an external scanner http://4js.com/online_documentation/fjs-fgl-manual-html/#fgl-topics/c_fgl_program_cordova.html.

Mobile also has something that could be considered close to the proposed ON DATA in the form of ON ACTION notificationpushed http://4js.com/online_documentation/fjs-fgl-manual-html/#fgl-topics/c_fgl_mobile_push_notif_app_side.html  So where you said "I have an application which waits in input for a barcode, this code is sent by wifi to another application", if that other application can let the Push provider know, then ON ACTION notificationpushed can be fired in your 4gl

Mobile also has the concept of runOnServer http://4js.com/online_documentation/fjs-fgl-manual-html/#fgl-topics/c_fgl_frontcall_mobile_runonserver.html if you want the fglrun to be on the back-end server and just use Mobile as front-end like what a GDC does for a desktop.

Reuben

PS When iI read "I have an application which waits in input for a barcode, this code is sent by wifi to another application", I think why have another application in the mix?  Why not INPUT barcode, and enter the barcode via keyboard wedge.  The user presses the button on the scanner and does not have to do anything in the 4gl .

Product Consultant (Asia Pacific)
Developer Relations Manager (Worldwide)
Author of https://4js.com/ask-reuben
Contributor to https://github.com/FourjsGenero
Benjamin G.
Posts: 130


« Reply #13 on: August 03, 2022, 03:29:27 pm »

Hello,

I tested Leo's code and I must admit that it is a very elegant solution, 100% Genero and it works very well.

Thank you for the help and the reactivity

Regards,
Benjamin
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines