AutoHotkey Community

It is currently May 27th, 2012, 3:01 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: March 19th, 2010, 3:29 pm 
Offline

Joined: April 28th, 2007, 4:06 pm
Posts: 85
We use a data entry system here at work that utilizes barcodes. I wrote a program that lets me scan a barcode with the wand that then puts it into the retrieval program without me opening that window, opens the image and resizes it, and it usually works just fine, but, sometimes it puts this:

0)))%(!*)d01

when it should have sent this:

000059180d01

into the retrieval program.

I attempted to put a shift up into the reload portion of the program in case that was the issue, but it does not help. Not that the output really looks like the shift key is pressed, but I cannot think of anything else. Any ideas?

Code:
#SingleInstance force
SetTitleMatchMode, 2

IfWinNotExist, SAI Desktop Vault
{
   MsgBox, Please sign into the Desktop Client and then reload this program.
   ExitApp
}
Else


Gui, Add, Edit, x26 y40 w100 h20 vBarcode,
Gui, Add, Button, x26 y70 w100 h30 default, OK
Gui, Add, Text, x36 y10 w70 h20 , Scan Barcode
Gui, Show, x131 y91 h112 w164, Barcode
Return

Guiclose:
exitapp

ButtonOK:

Gui, submit


IfWinExist, - DocLanding Image Viewer
{
   WinClose
}
SendInput, {Shift Up}
ControlSend, WindowsForms10.EDIT.app.0.2004eee1, %Barcode%{Enter}, SAI Desktop Vault
WinWait, - DocLanding Image Viewer
WinMove, - DocLanding Image Viewer,, 0, 0, 597, 737
WinActivate, - EXTRA! X-treme, , LT2

+NumpadAdd::
SendInput, %Barcode%{NumpadEnter}{space}
WinClose, - DocLanding Image Viewer
Reload
Return

+F12::
SendInput, {Shift Up}
Reload


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 19th, 2010, 3:38 pm 
Offline
User avatar

Joined: March 19th, 2008, 12:43 am
Posts: 5480
Location: the tunnel(?=light)
You probably just need to replace the errant characters before they're sent:

Code:
#SingleInstance force
SetTitleMatchMode, 2

IfWinNotExist, SAI Desktop Vault
{
   MsgBox, Please sign into the Desktop Client and then reload this program.
   ExitApp
}
Else


Gui, Add, Edit, x26 y40 w100 h20 vBarcode,
Gui, Add, Button, x26 y70 w100 h30 default, OK
Gui, Add, Text, x36 y10 w70 h20 , Scan Barcode
Gui, Show, x131 y91 h112 w164, Barcode
Return

Guiclose:
exitapp

ButtonOK:

Gui, submit


IfWinExist, - DocLanding Image Viewer
{
   WinClose
}
SendInput, {Shift Up}
ControlSend, WindowsForms10.EDIT.app.0.2004eee1, % NumOnly(Barcode) "{Enter}", SAI Desktop Vault
WinWait, - DocLanding Image Viewer
WinMove, - DocLanding Image Viewer,, 0, 0, 597, 737
WinActivate, - EXTRA! X-treme, , LT2

+NumpadAdd::
SendInput, % NumOnly(Barcode) "{NumpadEnter}{space}"
WinClose, - DocLanding Image Viewer
Reload
Return

+F12::
SendInput, {Shift Up}
Reload

NumOnly(var) {
  chars:=")!@#$%^&*("
  Loop, parse, chars
    StringReplace, var, var, % A_LoopField, % A_Index-1, All
  return var
}

_________________
Image
Try Quick Search for Autohotkey or see the tutorial for newbies.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 19th, 2010, 3:40 pm 
Quote:
ControlSend, WindowsForms10.EDIT.app.0.2004eee1, {Shift Up}%Barcode%{Enter}, SAI Desktop Vault
?

What about to reconvert any non "alnum" (--> If var is [not] type) char to its 'unshifted' equivalent ?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 19th, 2010, 4:25 pm 
Offline

Joined: August 21st, 2006, 7:07 pm
Posts: 2925
Location: The Shell
If Shift down is being sent inadvertently from somewhere other than the script, sending a ShiftUp may become unreliable.

You could watch the variable containing the incoming numbers for chr(#) 33-41 and simply remap them to #'s 48-57. Because the numbers are consecutively parallel, a simple math formula can be used to convert back to digits.

A simple function that finds and displays the character differences:
Code:
num = 33,48
StringSplit, num, num, `,
maxnum = 42,58
StringSplit, maxnum, maxnum, `,

tooltip % "Char# 33 - 41: " getChar(num1,maxnum1) "`nChar# 42 - 58: " getChar(num2,maxnum2)
return

esc::exitapp

getChar(narr,mnarr){
   num := narr
   while (num < mnarr)
   {
      char .= chr(num)
      num++
   }
   return char
}
I probably could have implemented filling the arrays in the function but you get the idea ;).

BTW Seph, I love all things FF :D

_________________
Imageparadigm.shift:=(•_•)┌П┐RTFM||^.*∞


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 19th, 2010, 5:54 pm 
Offline

Joined: April 28th, 2007, 4:06 pm
Posts: 85
Quote:
If Shift down is being sent inadvertently from somewhere other than the script, sending a ShiftUp may become unreliable.


What bugs me here is that if a Shift Down is being inadvertently sent, not only can I not see where it is coming from, but I also do not understand why it affects the characters it does. The leading zero is never affected, and the d and everything to it's right is also never affected, but all of the characters in between are.

Quote:
You probably just need to replace the errant characters before they're sent:

Sinkfaze, if I am understanding this correctly, essentially your addition to the code tells the program to watch for these characters, and if it sees them, to resend the variable. If I am getting this wrong, can you let me know. I like to try and learn to do what you tell me, and this is not the first time you have got my code to work properly, so thank you.

Quote:
You could watch the variable containing the incoming numbers for chr(#) 33-41 and simply remap them to #'s 48-57. Because the numbers are consecutively parallel, a simple math formula can be used to convert back to digits.


This is going over my head. I do not doubt that it works, but I guess I do not get where you are getting these numbers from, unless, is this the ASCII assignments to these characters? Perhaps I should brush up on that... if not, would you mind explaining what is going on here? I would appreciate it.

Quote:
ControlSend, WindowsForms10.EDIT.app.0.2004eee1, {Shift Up}%Barcode%{Enter}, SAI Desktop Vault
?

I am thinking that if the other 2 shift ups do nothing, I am thinking this won't either.

Quote:
What about to reconvert any non "alnum" (--> If var is [not] type) char to its 'unshifted' equivalent ?


might try this if Sinkfaze's code fails me

Quote:
BTW Seph, I love all things FF


Me too! XIII is awesome, if you have not indulged yet

I am going to try out some stuff with what you all have told me. I will give it a couple days of testing, and if anything solves my problem, I will post the solution, just in case anyone can use the info in the future. Thank you all for the help.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 19th, 2010, 6:12 pm 
Offline
User avatar

Joined: March 19th, 2008, 12:43 am
Posts: 5480
Location: the tunnel(?=light)
Sephiroth2906 wrote:
Sinkfaze, if I am understanding this correctly, essentially your addition to the code tells the program to watch for these characters, and if it sees them, to resend the variable.


What my addition to the code does it replace all of the errant characters (if they exist) with their proper numeric characters. Try this for example:

Code:
var :=   "0)))%(!*)d01"
MsgBox % NumOnly("0)))%(!*)d01")
; or
MsgBox % NumOnly(var)

NumOnly(str) {
   chars :=   ")!@#$%^&*("
   Loop, parse, chars
      StringReplace, str, str, % A_LoopField, % A_Index-1, All
   return str
}

_________________
Image
Try Quick Search for Autohotkey or see the tutorial for newbies.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 19th, 2010, 6:28 pm 
Offline

Joined: August 21st, 2006, 7:07 pm
Posts: 2925
Location: The Shell
Sephiroth2906 wrote:
Quote:
You could watch the variable containing the incoming numbers for chr(#) 33-41 and simply remap them to #'s 48-57. Because the numbers are consecutively parallel, a simple math formula can be used to convert back to digits.

This is going over my head. I do not doubt that it works, but I guess I do not get where you are getting these numbers from, unless, is this the ASCII assignments to these characters? Perhaps I should brush up on that... if not, would you mind explaining what is going on here? I would appreciate it.
It's just a matter of parsing the incoming variable finding, each ASCII number for each character and then applying the math to force each character number to switch. A more advanced approach could use regex with less lines.

By making this a forced function, rather than a condition (which could also work if done right), it will switch regardless of what character is found. That will make it firm and much more reliable.

Unless you or someone else writes one before me, I will write something for you in a bit. I just have to run for a while. bbl..

Sephiroth2906 wrote:
Me too! XIII is awesome, if you have not indulged yet.
Hey as long as I can grow and ride choco on water I'm happy :lol:..


edit: Actually use sinkfaze's function, its perfect (as usual ;))

_________________
Imageparadigm.shift:=(•_•)┌П┐RTFM||^.*∞


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 20th, 2010, 2:01 am 
Offline
User avatar

Joined: October 7th, 2006, 8:45 am
Posts: 3330
Location: Simi Valley, CA
Shot in the dark:
Code:
SendEvent, {Blind}{Shift Up}
instead of "SendInput, {Shift Up}"

_________________
Ternary (a ? b : c) guide     TSV Table Manipulation Library
Post code inside [code][/code] tags!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 24th, 2010, 5:20 pm 
Offline

Joined: April 28th, 2007, 4:06 pm
Posts: 85
You know, I thought after the past few days everything was golden, but just now the script returned the shifted characters again, so the addition of sinkfaze's code didn't do the trick (that's a first for me :) ). So, any other ideas anyone might have would be most welcome. Again, I do not know why the leading zero and everything from the letter "d" on comes back unshifted or if it is even significant, but I am at a loss here.

I am going to throw VxE's code in there and hope, but it may be a couple of days before I can get a feel for whether or not it is working, because the stinking error is so darn infrequent and I cannot force it.

A semi-humorous, semi-sad aside,

I showed this to the elected official in charge of our office as a solution to a problem created by the new software that was purchased here. That was the first time I ever had this problem rear it's ugly head. *sigh*

Looks like I still have some work to do :)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 24th, 2010, 5:28 pm 
Offline

Joined: August 21st, 2006, 7:07 pm
Posts: 2925
Location: The Shell
Hey Seph..

Remember, sinkfaze's script was based on the static literal string
Code:
var :=   "0)))%(!*)d01"
.
You may have to convert the var to except dynamic strings if the value changes often ;).

hth

_________________
Imageparadigm.shift:=(•_•)┌П┐RTFM||^.*∞


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 24th, 2010, 6:22 pm 
Offline

Joined: April 28th, 2007, 4:06 pm
Posts: 85
TLM wrote:
Hey Seph..

Remember, sinkfaze's script was based on the static literal string
Code:
var :=   "0)))%(!*)d01"
.
You may have to convert the var to except dynamic strings if the value changes often ;).


Nah, he made a function called "numonly" inside of the control send that does this:


Code:
NumOnly(var) {
  chars:=")!@#$%^&*("
  Loop, parse, chars
    StringReplace, var, var, % A_LoopField, % A_Index-1, All
  return var
}


so that should convert any shifted character on the number row back to it's unshifted state. Sinkfaze knows his stuff :)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 24th, 2010, 7:45 pm 
Offline

Joined: August 21st, 2006, 7:07 pm
Posts: 2925
Location: The Shell
Ahh I see, I look for that function.. ok ;)

_________________
Imageparadigm.shift:=(•_•)┌П┐RTFM||^.*∞


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 25th, 2010, 4:05 pm 
Offline

Joined: April 28th, 2007, 4:06 pm
Posts: 85
Well, that didn't take very long. VxE's idea unfortunately also did not work either. Any other ideas you might be able to think of that I could try?

If it helps any, it seems to usually happen when I have not used the program for at least a few hours, say, the first time that day or when I have been performing other duties for several hours. It does not seem to make any difference if I have had the code running for all of that time inbetween.

Thanks!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 26th, 2010, 3:16 pm 
Offline

Joined: April 28th, 2007, 4:06 pm
Posts: 85
I just had the issue pop up again, and I discovered that there does not appear to be anything wrong with the variable itself, as the shift + portion of the script that resends the value has the characters come up just fine. So the issue looks like it is showing up only on the controlsend portion of the script.

Still fishing for ideas, if anyone has them

Thanks for all the help thusfar!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 26th, 2010, 5:12 pm 
Offline
User avatar

Joined: March 19th, 2008, 12:43 am
Posts: 5480
Location: the tunnel(?=light)
Put the shift up directly in the Send/ControlSend statements?

Code:
ControlSend, WindowsForms10.EDIT.app.0.2004eee1, % "{Blind}{Shift Up}" NumOnly(Barcode) "{Enter}", SAI Desktop Vault

SendInput, % "{Blind}{Shift Up}" NumOnly(Barcode) "{NumpadEnter}{space}"

_________________
Image
Try Quick Search for Autohotkey or see the tutorial for newbies.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: rbrtryn and 29 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group