我有一个脚本,可引导用户扫描条形码,然后在工作表中找到条形码并在其旁边标记日期。我使用的扫描仪输入条形码的值,然后输入回车符,这样,如果我要扫描多个条形码,则输入将如下所示:
123456
123456
123456
无需我按任何按钮。我希望能够仅扫描多个项目而不必每次都按“确定”。但是Google Apps工作表不接受Enter键,可以这样做吗?
以下是我的代码示例:
var barCodeId = Browser.inputBox('Scan Barcode', ui.ButtonSet.OK_CANCEL);
if (barCodeId != 'cancel'){
try{
sheet.createTextFinder(barCodeId).findNext().offset(0, 15).activate().setValue(date);
var location = '892 ' + Browser.inputBox('Enter Location');
//used to check if the item is in the same place and colors the tile if not
colorLocation(location)
}
//creates a sheet and lists items not on inventory
catch(error){
var nonSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Not on Inventory");
if (nonSheet == null){
nonSheet = SpreadsheetApp.getActiveSpreadsheet().insertSheet();
nonSheet.setName("Not on Inventory");
createTitle(nonSheet)
}
SpreadsheetApp.setActiveSheet(nonSheet)
var location = Browser.inputBox('Enter Location');
fillInformation(barCodeId, location, date, nonSheet)
}
} else{
break;
}