 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Sephiroth2906
Joined: 28 Apr 2007 Posts: 85
|
Posted: Fri Mar 19, 2010 2:29 pm Post subject: why does my alpha numeric variable paste 0)))%(!*)d01? |
|
|
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 |
|
|
| Back to top |
|
 |
sinkfaze
Joined: 18 Mar 2008 Posts: 5043 Location: the tunnel(?=light)
|
Posted: Fri Mar 19, 2010 2:38 pm Post subject: |
|
|
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
} |
_________________ Try Quick Search for Autohotkey or see the tutorial for newbies. |
|
| Back to top |
|
 |
Murx Guest
|
Posted: Fri Mar 19, 2010 2:40 pm Post subject: |
|
|
| 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 ? |
|
| Back to top |
|
 |
TLM
Joined: 21 Aug 2006 Posts: 2926 Location: The Shell
|
Posted: Fri Mar 19, 2010 3:25 pm Post subject: |
|
|
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  _________________
paradigm.shift:=(•_•)┌П┐RTFM||^.*∞ |
|
| Back to top |
|
 |
Sephiroth2906
Joined: 28 Apr 2007 Posts: 85
|
Posted: Fri Mar 19, 2010 4:54 pm Post subject: |
|
|
| 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. |
|
| Back to top |
|
 |
sinkfaze
Joined: 18 Mar 2008 Posts: 5043 Location: the tunnel(?=light)
|
Posted: Fri Mar 19, 2010 5:12 pm Post subject: |
|
|
| 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
} |
_________________ Try Quick Search for Autohotkey or see the tutorial for newbies. |
|
| Back to top |
|
 |
TLM
Joined: 21 Aug 2006 Posts: 2926 Location: The Shell
|
Posted: Fri Mar 19, 2010 5:28 pm Post subject: |
|
|
| 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 ..
edit: Actually use sinkfaze's function, its perfect (as usual ) _________________
paradigm.shift:=(•_•)┌П┐RTFM||^.*∞ |
|
| Back to top |
|
 |
[VxE]
Joined: 07 Oct 2006 Posts: 3254 Location: Simi Valley, CA
|
|
| Back to top |
|
 |
Sephiroth2906
Joined: 28 Apr 2007 Posts: 85
|
Posted: Wed Mar 24, 2010 4:20 pm Post subject: |
|
|
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  |
|
| Back to top |
|
 |
TLM
Joined: 21 Aug 2006 Posts: 2926 Location: The Shell
|
Posted: Wed Mar 24, 2010 4:28 pm Post subject: |
|
|
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 _________________
paradigm.shift:=(•_•)┌П┐RTFM||^.*∞ |
|
| Back to top |
|
 |
Sephiroth2906
Joined: 28 Apr 2007 Posts: 85
|
Posted: Wed Mar 24, 2010 5:22 pm Post subject: |
|
|
| 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  |
|
| Back to top |
|
 |
TLM
Joined: 21 Aug 2006 Posts: 2926 Location: The Shell
|
|
| Back to top |
|
 |
Sephiroth2906
Joined: 28 Apr 2007 Posts: 85
|
Posted: Thu Mar 25, 2010 3:05 pm Post subject: |
|
|
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! |
|
| Back to top |
|
 |
Sephiroth2906
Joined: 28 Apr 2007 Posts: 85
|
Posted: Fri Mar 26, 2010 2:16 pm Post subject: |
|
|
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! |
|
| Back to top |
|
 |
sinkfaze
Joined: 18 Mar 2008 Posts: 5043 Location: the tunnel(?=light)
|
Posted: Fri Mar 26, 2010 4:12 pm Post subject: |
|
|
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}" |
_________________ Try Quick Search for Autohotkey or see the tutorial for newbies. |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|