FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour program buffer or a keyboard buffer
Posts: 6984
Joined: Fri Oct 07, 2005 07:07 PM
program buffer or a keyboard buffer
Posted: Thu Feb 05, 2015 03:20 PM

Hello,

I try to find out how I can read a keyboard buffer.

This is what I found so far. Can someone help me to with a fivewin solution.

so if there is a command line and there is a text in it and waiting for an 'enter' to be pressed in which buffer does it stay?,in a program buffer or a keyboard buffer?

It depends on the platform, but for example on a .NET console app running on Windows, if you call Console.ReadLine() while the app has focus it is going to receive the keyboard input and store it in an application level buffer. The only time it would stay at a lower level buffer is if the system is too busy to process the input in time. At this level 'buffering' is really just a semantic concept; the system is basically at rest, the input has been processed, transformed into a UTF-8 string and stored in memory waiting to be returned to your program when the enter key is detected.

Best regards,
OttoUser avatar
Otto Posts: 2972Joined: Fri Oct 07, 2005 7:07 pm

Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: program buffer or a keyboard buffer
Posted: Thu Feb 05, 2015 06:35 PM

Hi Otto,

Please explain what you are trying to accomplish. Maybe that would help with an answer.

James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 6984
Joined: Fri Oct 07, 2005 07:07 PM
Re: program buffer or a keyboard buffer
Posted: Thu Feb 05, 2015 07:23 PM

Hello James,

I have a panel with some buttons in it.
The data I want to read comes from a keylock which is writing into the keyboard buffer.
Now when I press a key I would like to read the data.
Thanks in advance
Otto

Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: program buffer or a keyboard buffer
Posted: Thu Feb 05, 2015 10:53 PM

Otto,

Well I expect there is a windows API for this, but I don't know it.

Here is another idea though. Create an invisible GET. Send a ENTER key or TAB key to it, then read the data in the GET. The ENTER or TAB key may send the keyboard buffer into the GET.

James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 6984
Joined: Fri Oct 07, 2005 07:07 PM
Re: program buffer or a keyboard buffer
Posted: Thu Feb 05, 2015 11:03 PM
Hello James,
This is exactly what I tried this afternoon.
But it is not working properly. I will go on tomorrow.
Thank you for your help.
Best regards,
Otto



Code (fw): Select all Collapse
#include "FiveWin.ch"

function Main()
   LOCAL oDlg, oGet, oSay
   LOCAL cCad := Space(200)
   local csay := "test"
   LOCAL nNum := 0
   LOCAL dDat := Date()
   local cTest :=""

   DEFINE DIALOG oDlg TITLE "TGet from " + FWDESCRIPTION
          @ 1,2 ;
         SAY oSay ;
      PROMPT csay ;
          OF oDlg

          @ 1,6 ;
         GET oGet ;
         VAR cCad ;
          OF oDlg ;
        SIZE 60, 10 ;
  ON CHANGE ( cTest := mgetline(oget:hwnd) , iif( right( cTest, 3 ) = "out",  logfile("test.log",{ cTest}) , ) );
  // , msginfo(cTest),msginfo(cTest) ) )
   //ON CHANGE ( iif( right(cCad,3) = "1", msginfo(cCad), )  )
   //ON CHANGE ( msginfo(right(oGet:cText,3)),iif( right(cCad,3) = "OUT", (msginfo( procname() + "   " + str(procline()) + "   " + str( 1 ) ),csay := cCad, cCad := space(200) ,oSay:refresh()), ) )

  
   ACTIVATE DIALOG oDlg CENTERED
logfile("test.log",{ cTest})
return nil
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: program buffer or a keyboard buffer
Posted: Fri Feb 06, 2015 12:07 AM

Otto,

OK, we are thinking along the same lines, but you can't use bChange. I think you need to create the GET, set focus to it, then push a key to the keyboard buffer via program code like:

__keyboard( VK_RETURN )

This should empty the keyboard buffer into the GET buffer. Now read the GET buffer and you should have what was in the keyboard buffer.

You could do all this inside a function which is triggered by a button press. Then just return the result to the program and process it.

James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: program buffer or a keyboard buffer
Posted: Fri Feb 06, 2015 12:21 AM

I found a reference to a C++ program that read the keyboard buffer.

http://programmersheaven.com/discussion ... ard-buffer

Maybe one of the C programmers here could show us how to use it. Or, maybe there is already such a function in (x)Harbour?

James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 6984
Joined: Fri Oct 07, 2005 07:07 PM
Re: program buffer or a keyboard buffer
Posted: Fri Feb 06, 2015 06:55 AM
Dear James,

I am posting here a screenshot for better understanding what I want to do.

I have to change the keylock type from USB (COM) to a keyboard type.
The reason is that we work all our software remotely. This way I can support all different operating systems.
But we have no USB drivers for WINDOWS RT and also ANDROID is not well supported by the keylock type we use.
If you put a key into the lock a number is written into the keyboard buffer if you pull out the key “Out” is written into the buffer.
Now I thought to store the value in a global variable. So if you press the button “Bonieren” or “Abrechnen” which is register and bill then we read the global variable. If there is a valid code in it we bill the waiter if there is “Out” we say “please insert a key”.

BTW, this is still the application where you help me to develop class design.
Now I have to change the ECR-class.
Thank you again and best regards,
Otto
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
Re: program buffer or a keyboard buffer
Posted: Fri Feb 06, 2015 10:18 AM
James,

James Bott wrote:I found a reference to a C++ program that read the keyboard buffer.

http://programmersheaven.com/discussion ... ard-buffer

Maybe one of the C programmers here could show us how to use it. Or, maybe there is already such a function in (x)Harbour?


It's a DOS program, you can't use it on Windows, I'm afraid.

EMG
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: program buffer or a keyboard buffer
Posted: Fri Feb 06, 2015 12:14 PM

Mr Otto

Can you clarify if I understood this correctly?

1) There is one Windows PC to which a KeyLock COM device is connected. If a key is inserted the device places a number in the keyborad buffor or if the key is pulled out "Out" is placed in the keybpard buffer of that Windows PC.

2) The Application (image you posted) is run from mobiles with Windows RT OS or Android OS through Remote Desktop. In other words, this application physically resides on one Windows Server and is executed by the mobile devices remotely.

3) The Windows Server (in para-2) hosting the application and the WindowsPC (in par-1) with the keylock COM device can physically be the same computer or diferent computers on the network.

4) Now the Application the mobile devices are running should know what is the latest status of the keylock when the user presses "Register" or "Bill" ( “Bonieren” or “Abrechnen” ) and act on the basis of the latest status of the keylock.

Is this understanding correct?

If this is correct, this can be a solution:

We can have an application continuously running on the PC with COM device which continuously polls the keyboard events and keeps writing the latest even (number or 'out') at a specified place on the disk.
The Application run remotely by the mobiles is actually run on the Server which has access and can read this data when the user presses the buttons and respond accordingly.

Regards



G. N. Rao.

Hyderabad, India
Posts: 6984
Joined: Fri Oct 07, 2005 07:07 PM
Re: program buffer or a keyboard buffer
Posted: Fri Feb 06, 2015 05:24 PM

Dear Mr. Rao,
Thank you for your help.
The keylock is connected to each client PC and detected as a keyboard.

As I found no way to clear the buffer I am trying now with
oGet:KeyDown(VK_HOME)
oGet:KeyDown(VK_DELETE).
Maybe I can resolve my problem this way.
Best regards,
Otto

Continue the discussion