Sign in to follow this  
Followers 0
strate

Replace keystrokes

3 posts in this topic

#1 ·  Posted (edited)

We use a scan gun here at work for scanning barcodes. No matter what after every scan it will send a carriage return. Would it be possible to replace the carriage return with a tab?

I know I need to HotkeySet and Send. It will need to be setup so that when ever CHR(13) is sent it catches it, then sends Chr(11) instead.

The catch is I only want it to do it when it is in a certain InputBox.

While 1 
    Sleep(25)
     If ControlGetFocus ( "GUI", "" ) = $INPUT_1 Then
          HotKeySet("{Enter}", "CaptureEnter")
     Else
          HotKeySet("{Enter}", "")
     EndIf
Wend

Func CaptureEnter()
     Send("{TAB}")
EndFunc

This would work right? Could it be improved upon?

Edited by strate

INI TreeViewA bus station is where a bus stops, a train station is where a train stops. Onmy desk I have a work station...

Share this post


Link to post
Share on other sites



That looks like it will work just fine. Just make sure that $INPUT_1 is set to the ClassNameNN of your desired input box. Depending on the average time between focusing on the input and scanning something, you might be able to increase the Sleep value to something like 500 to have as little processor impact as possible.

Ah, just noticed something: The way you unset the hotkey causes a syntax error because there is no such function. Use HotKeySet("{Enter}") (without the second parameter) for that purpose.

Share this post


Link to post
Share on other sites

That looks like it will work just fine. Just make sure that $INPUT_1 is set to the ClassNameNN of your desired input box. Depending on the average time between focusing on the input and scanning something, you might be able to increase the Sleep value to something like 500 to have as little processor impact as possible.

Ah, just noticed something: The way you unset the hotkey causes a syntax error because there is no such function. Use HotKeySet("{Enter}") (without the second parameter) for that purpose.

Thank you very much.

INI TreeViewA bus station is where a bus stops, a train station is where a train stops. Onmy desk I have a work station...

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0