Jump to content

Recommended Posts

Posted (edited)
Hello AutoIt,
 
I'm new to Autoit and I'm trying to play an alert sound when a barcode is scanned in while a certain window is still active.
A typical barcode scan would be something like this: "AA19-1234" followed by a carriage return/enter. My original thought was to have it within a loop, and check if the "SumatraPDF" is active and if an "Enter" is sent when a barcode is accidentally scanned. But it doesn't work when I scan a barcode, the "SumatraPDF" that displays a PDF just shrinks the PDF each time I scan in a new barcode and doesn't play the sound. However, when I manually hit the "Enter" button I do get the alert. Any help would be greatly appreciated.
 
 
#include <Misc.au3>             ;needed to use the _IsPressed function

While 1
    If WinActive("SumatraPDF") AND _IsPressed("0d") Then
        SoundPlay("error.wav")
    EndIf
WEnd
 
Edited by Yodavish
  • Developers
Posted (edited)

Not that new as this is the second time this happened with your second start of a topic. Please look and read first before posting another topic!

Moved to the appropriate forum, as the Developer General Discussion forum very clearly states:

Quote

General development and scripting discussions. If it's super geeky and you don't know where to put it - it's probably here.


Do not create AutoIt-related topics here, use the AutoIt General Help and Support or AutoIt Technical Discussion forums.

Moderation Team

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Posted

Hello AutoIt,

I'm new to Autoit and I'm trying to play an alert sound when a 1D barcode is scanned while a certain window is still active.

A typical barcode scan would be something like this: "AA19-1234" followed by a carriage return/enter. My original thought was to have it within a loop, and check if the "SumatraPDF" is active and if an "Enter" is sent when a barcode is accidentally scanned. But it doesn't work when I scan a barcode, the "SumatraPDF" window that displays a PDF just shrinks the PDF each time I scan in a new barcode and doesn't play the sound. However, when I manually hit the "Enter" button I do get the alert. Any help would be greatly appreciated.

I've even tried using the hex value for the first character of the scanned barcode "A" or hex value "41", but that doesn't work either when I scan the barcode. I'm assuming the barcode scan isn't detected at all by AutoIt? My code is below:

#include <Misc.au3> 			;needed to use the _IsPressed function

Local $hDLL = DllOpen("user32.dll")
While 1
   If WinActive("SumatraPDF") AND _IsPressed("0d",$hDLL) Then
	  SoundPlay("error.wav")
   EndIf
WEnd
Posted

 

@Jos 

I saw two different forums, (use the AutoIt General Help and Support or AutoIt Technical Discussion forums)  so I wanted to see if someone could help answer this question that's all.

  • Developers
Posted
9 minutes ago, Yodavish said:

I saw two different forums, (use the AutoIt General Help and Support or AutoIt Technical Discussion forums)  so I wanted to see if someone could help answer this question that's all.

Forumrules 1 of any forum out there is not to crosspost the same question in multiple places as that is pretty impolite toward the community and shows you are impatient. ;) 
So what is the urgency on this you can't wait for somebody to stop by and willing to offer the spare time to you?

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Posted
4 hours ago, Yodavish said:

However, when I manually hit the "Enter" button I do get the alert.

It appears that you answered your own question as to why _IsPressed() is not working.  _IsPressed() is looking for keyboard keys being pressed.  Obviously the barcode scanner is not using the keyboard to enter data.  Most likely, its driver is just sending characters directly to whatever has focus.  So using _IsPressed() will not be able to capture non-keyboard related events/characters.  You will need to find a different method of capturing scanner output or application input.  Unfortunately, I can't help you figure out a better solution because there's not enough information to work with, I don't use SumatraPDF, and I don't currently have a barcode scanner to test with.

Posted

@TheXman

Well, I tried using HotKeySet and scanned in the barcode and the message did alert. So the scan with "Enter" is correct. However, I can't get it to actually send the enter key when the viewer is not active.  SumatraPDF is just pdf viewer.

HotKeySet("{ENTER}", checkBrowser)

Func checkBrowser()
   Msgbox(0,"Debug", "Enter is detected")
   If WinActive("SumatraPDF") Then
      SoundPlay("error.wav")
   Else
      Send("{ENTER}")
   EndIf
EndFunc

 

Posted (edited)

Yes, I'm quite familiar with SumatraPDF.  I just said that I don't have it and that's because I don't use it.

Maybe I just don't understand what exactly you are trying to accomplish.  Can you explain, in different words, what it is you want to do?  Is it that you are trying to be able to tell when a barcode scan has completed?  What does SumatraPDF have to do with the task you're trying to accomplish?  I'm a bit confused.

Edited by TheXman
Posted

@TheXman

I have GUI with an input that the user can scan in a 1D barcode. The barcode is pushed to 2 separate applications, one opens the PDF in the SumatraPDF and the other in a 3rd party application where the user can perform some recording task. The user typically will not look at the screen when they are scanning (pretty standard until they start their recording task), so they want me to check if the SumatraPDF viewer is active if they accidentally scan in a barcode, if so, have it play an alert sound to alert them that they are still on the current scanned in barcode.

I hope that cleared up things.

Posted

Yes, that definitely sheds a little more light on the issue.  Unfortunately, I still don't understand enough about your process and its steps to be of any help.  Sorry, but I still can't visualize the issue and all of its steps.  Hopefully someone else may be able to.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...