Thanks for the idea Sinkfaze, but no such luck.
Here is what I have learned thusfar:
The barcode scanner is putting the ID into the edit field of the GUI correctly
The variable %barcode% contains the correct information, as I can see when I invoke the {shift}+ portion of the script to resend it.
It happens generally when the script has not been used for a few hours if it happens at all, although not necessarily when it is run for the first time in a few hours (meaning I can leave the script running but not use it for that time, and then still get the error)
When the error occurs, it does not shift the entire variable. It leaves the first digit and the last three characters untouched, and shifts those in between
So unless I am missing something, the issue has to be either the controlsend function, or there is something wrong with the program itself. Since I have not encountered this problem without using the script, nor has anyone else who uses the program in question, that leaves the function as the culprit, unless I am completely mistaken.
Here is the code as it has been modified, just in case anyone wants to take another crack at it or has any further ideas, but, otherwise, this may just be an issue I am going to have to live with.
Thank you all again for all of your help. It is truly appreciated.
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:
SendEvent, {Blind}{Shift Up}
Gui, submit
IfWinExist, - DocLanding Image Viewer
{
WinClose
}
SendEvent, {Blind}{Shift Up}
ControlSend, WindowsForms10.EDIT.app.0.2004eee1, % "{Blind}{Shift Up}" 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::
SendEvent, {Blind}{Shift Up}
Reload
NumOnly(var) {
chars:=")!@#$%^&*("
Loop, parse, chars
StringReplace, var, var, % A_LoopField, % A_Index-1, All
return var
}