>>Dear Experts
>>
>>I have a textbox1 which gets input from Barcode scanner.
>>I want this textbox not to accept input from keyboard.
>>
>>Background:
>>
>>I scan barcodes of new products and save in database.
>>Some times user enters some wrong data into this textbox and save it in db.
>>I want to block user to input any data in said textbox to ensure correct data is being entered.
>>
>>While googling I found this link similar to my problem
>>
https://stackoverflow.com/questions/50464858/allow-only-barcode-scanner-and-eliminate-keyboard-input?noredirect=1&lq=1>>
>>But do no know how to make procedures workable in VFP.
>>
>>Please help
>
>If I had this requirement, I would create a DLL and subclass the thisForm.HWND to intercept all of the WM_KEYDOWN and WM_KEYUP messages, and perform a timing analysis on them when the user is on a field that has input that should only come from a remote device like a barcode scanner.
>
>If the keys are not received in immediate succession (within a few milliseconds), then ignore them on that field.
>
>If you would like this solution I can write it for you. I would create the API interface:
>
DECLARE INTEGER keyboard_intercept IN kbd.dll INTEGER nHwnd
>DECLARE INTEGER keyboard_deintercept IN kbd.dll INTEGER nHwnd
>DECLARE keyboard_only_barcode_scanner IN kbd.dll
>DECLARE keyboard_allow_all_keys IN kbd.dll
>
>Those three functions should do it for you. On the form's Init() event you would call keyboard_intercept(thisForm.HWnd). On the GotFocus() event, call keyboard_only_barcode_scanner(), and on LostFocus() call keyboard_allow_all_keys(). And on the Unload() or Destroy() event, call keyboard_deintercept(thisForm.HWnd).
>
>Let me know.
Thanks sir for helping,
Naomi Nosonovsky's solution NODEFAULT on keypress event does not work. Textbox does not accept values from keyboard or barcode scanner.
I think your codes will work fine to accept values only coming from external device.
Please help