@echo off
chcp 65001
SET admin_st4_path=powershell Start-Process 'Path\To\sublime_text.exe' -Verb runAs
SET st4_path=Path\To\Sublime\sublime_text.exe
SET st4_label_edit=Изменить в Sublime
SET st4_label_admin_edit=Изменить в Sublime от Админа
SET st4_label_admin_open=Открыть в Sublime от Админа
SET st4_label=Открыть в Sublime
rem добавить для всех типов файлов
@reg add "HKEY_CLASSES_ROOT\*\shell\Edit with Sublime Text" /t REG_SZ /v "" /d "%st4_label_edit%" /f
@reg add "HKEY_CLASSES_ROOT\*\shell\Edit with Sublime Text" /t REG_EXPAND_SZ /v "Icon" /d "%st4_path%,0" /f
@reg add "HKEY_CLASSES_ROOT\*\shell\Edit with Sublime Text\command" /t REG_SZ /v "" /d "%st4_path% \"%%1\"" /f
@reg add "HKEY_CLASSES_ROOT\*\shell\Edit with Sublime Text as Admin" /t REG_SZ /v "" /d "%st4_label_admin_edit%" /f
@reg add "HKEY_CLASSES_ROOT\*\shell\Edit with Sublime Text as Admin" /t REG_EXPAND_SZ /v "Icon" /d "%st4_path%,0" /f
@reg add "HKEY_CLASSES_ROOT\*\shell\Edit with Sublime Text as Admin" /t REG_SZ /v "Extended" /d ""
@reg add "HKEY_CLASSES_ROOT\*\shell\Edit with Sublime Text as Admin\command" /t REG_SZ /v "" /d "%admin_st4_path% \"%%1\"" /f
rem добавить для папок
@reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\Open with Sublime Text" /t REG_SZ /v "" /d "%st4_label%" /f
@reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\Open with Sublime Text" /t REG_EXPAND_SZ /v "Icon" /d "%st4_path%,0" /f
@reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\Open with Sublime Text\command" /t REG_SZ /v "" /d "%st4_path% \"%%V\"" /f
@reg add "HKEY_CLASSES_ROOT\Directory\shell\Open with Sublime Text" /t REG_SZ /v "" /d "%st4_label%" /f
@reg add "HKEY_CLASSES_ROOT\Directory\shell\Open with Sublime Text" /t REG_EXPAND_SZ /v "Icon" /d "%st4_path%,0" /f
@reg add "HKEY_CLASSES_ROOT\Directory\shell\Open with Sublime Text\command" /t REG_SZ /v "" /d "%st4_path% \"%%V\"" /f
rem добавить для папок от админа
@reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\Open Sublime Text as Admin" /t REG_SZ /v "" /d "%st4_label_admin_open%" /f
@reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\Open Sublime Text as Admin" /t REG_EXPAND_SZ /v "Icon" /d "%st4_path%,0" /f
@reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\Open Sublime Text as Admin" /t REG_SZ /v "Extended" /d "" /f
@reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\Open Sublime Text as Admin\command" /t REG_SZ /v "" /d "%admin_st4_path% \"%%V\"" /f
@reg add "HKEY_CLASSES_ROOT\Directory\shell\Open Sublime Text as Admin" /t REG_SZ /v "" /d "%st4_label_admin_open%" /f
@reg add "HKEY_CLASSES_ROOT\Directory\shell\Open Sublime Text as Admin" /t REG_EXPAND_SZ /v "Icon" /d "%st4_path%,0" /f
@reg add "HKEY_CLASSES_ROOT\Directory\shell\Open Sublime Text as Admin" /t REG_SZ /v "Extended" /d "" /f
@reg add "HKEY_CLASSES_ROOT\Directory\shell\Open Sublime Text as Admin\command" /t REG_SZ /v "" /d "%admin_st4_path% \"%%V\"" /f
pause
{"keys": ["alt+shift+-"], "command": "insert_snippet", "args": {"contents": "–"}}
var name, email, phone;
name = email = phone = 'None';
function getEmails(){
var threads = GmailApp.search('label:Заявка');
if (threads.length) {
for (var i=0; i < threads.length; i++) {
var messages = threads[i].getMessages();
for (var j=0; j < messages.length; j++) {
var message = messages[j];
message.markRead();
extractDetails(message);
}
getSheetData();
threads[i].removeLabel(GmailApp.getUserLabelByName("Заявка"));
threads[i].addLabel(GmailApp.getUserLabelByName("Обработано"));
}
} else {}
}
function extractDetails(message){
var dateTime = message.getDate();
searchInBody(message.getPlainBody());
var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
var activeSheet = SpreadsheetApp.setActiveSheet(spreadsheet.getSheetByName("Новые"));
activeSheet.appendRow([dateTime, name, email, phone]);
}
function searchInBody(mes) {
var lines, subline;
lines = mes.split("\n");
for (index = 0; index < lines.length; ++index) {
if(lines[index].indexOf('Name:') + 1) {
subline = lines[index].split(":");
name = subline[1].toString().trim();
}
if(lines[index].indexOf('Email:') + 1) {
subline = lines[index].split(":");
email = subline[1].toString().trim();
}
if(lines[index].indexOf('Phone:') + 1) {
subline = lines[index].split(":");
phone = subline[1].toString().trim().slice(1,);
}
}
}
function getSheetData() {
var re = /\S+@\S+\.\S+/;
var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
var sheet = SpreadsheetApp.setActiveSheet(spreadsheet.getSheetByName("Новые"));
var data = sheet.getRange('A2:F').getValues();
sheet.getRange('A2:F').clearContent();
data.forEach(row => {
if (row[2] !== '' && re.test(row[2])) {
sendMail();
} else {}
})
var sheet1 = SpreadsheetApp.setActiveSheet(spreadsheet.getSheetByName("Обработанные"));
var row = data.length;
var column = data[0].length;
sheet1.getRange(sheet1.getLastRow()+1, 1, row, column).setValues(data);
}
function sendMail() {
var html = 'Здравствуйте '+name+'!<br><br>Ваша заявка принята, наш специалист скоро свяжется с вами.<br><br>Спасибо за обращение.';
var recipientsTO = email;
var recipientsCC = email;
var Subject = "Ваша заявка принята";
MailApp.sendEmail({
to: recipientsTO,
cc: recipientsCC,
subject: Subject,
htmlBody: html
});
}