not finding barcode scanner input where expected

Hi all,

I've got barcode scanning via device camera working in Forms, :-) however I'm now working on getting it from a USB hand-held scanner on a Win10 laptop, and having trouble finding where the input is. If you have notepad (or Excel) open when you scan, the barcode just automagically appears at your cursor. I'm told to just treat it like keyboard input.

Thinking that would just be a matter of Console.readline, I tried that, but it's coming up null. I also tried getting it from the Xamarin Essentials Clipboard, but it's not there either (unless I scan into notepad and then cut/copy the text - that works, but obviously isn't the effect I'm looking for). Do I need to open a stream, or do something with focus, or...? Not sure where the input is (other than it's not in the clipboard) and how to get it. I haven't done anything with console input/output in Xamarin Forms before (other than debug statements), and there's something fundamental I'm missing (if it had been in the clipboard, then my code worked first go, :-) but unfortunately it wasn't there :-( )...

thanks,
Donald.

Answers

  • AlessandroCaliaroAlessandroCaliaro ITMember ✭✭✭✭✭

    Have you tried to have an "Entry" with the focus and read the barcode?

  • SmartmanAppsSmartmanApps AUMember ✭✭✭
    edited February 26

    @AlessandroCaliaro said:
    Have you tried to have an "Entry" with the focus and read the barcode?

    No, I was hoping to read it straight in (like I said, I was expecting it to be there in the clipboard), but I'll certainly try that suggestion if I can't work it out (I suspect that would work). Thanks!

  • SmartmanAppsSmartmanApps AUMember ✭✭✭

    I should've mentioned that I used ZXing to get the code from the device camera, if there's a way to get it to take it's input from the USB scanner instead? (as far as I can see it just defaults to the device camera, unless there's a way to override that somewhere? Not finding anything about this so far)

  • AlessandroCaliaroAlessandroCaliaro ITMember ✭✭✭✭✭

    ZXing is only for camera

  • SmartmanAppsSmartmanApps AUMember ✭✭✭

    @AlessandroCaliaro said:
    ZXing is only for camera

    I suspected as much, but thanks for confirming. I'd assumed I'd have to do it differently for the scanner, but now that's not an assumption anymore. That thread you posted looks to have some promise in it (you've obviously used some different search terms to me). I'm suspecting that reading up some more on HID might lead me somewhere. Will check it out some more tomorrow. Thanks!

  • SmartmanAppsSmartmanApps AUMember ✭✭✭
    edited March 9

    I was able to get the data by having focus on an entry, so that's at least one working method. Still would like to just do it in the back-end directly if I can find how. e.g. just using the scanner to count items (e.g. stocktake) without it placing anything in the UI. Scan the barcode initially, but then just count successive items after that.

  • Will.ItraxWill.Itrax CAMember ✭✭✭

    @SmartmanApps How did you manage to read in the scanned code? What nuget did you use? Can you share some of your code?
    We are able to scan using XZing and the camera, but now we have to use a bluetooth connected scanner and place the returned value in an Edit field. Thanks!

  • SmartmanAppsSmartmanApps AUMember ✭✭✭
    edited March 21

    @Will.Itrax said:
    @SmartmanApps How did you manage to read in the scanned code? What nuget did you use? Can you share some of your code?
    We are able to scan using XZing and the camera, but now we have to use a bluetooth connected scanner and place the returned value in an Edit field. Thanks!

    I'm using a USB handheld scanner, and no code needed (other than to make sure your entry has focus, either via code or just clicking in it) - i.e. when you pull the trigger, the barcode automatically appears where-ever you currently have focus - so can't help you there. Hopefully @AlessandroCaliaro link is of help to you.

    Oh, P.S. you have to make sure the scanner is in keyboard mode (not image mode).

Sign In or Register to comment.