Scripts discussion (2)

Discuss and announce AkelPad plugins
Locked
  • Author
  • Message
KDJ
Offline
Posts: 1949
Joined: Sat Mar 06, 2010 7:40 pm
Location: Poland

Post by KDJ »

opk44
WshShell.SendKeys("^r");

Offline
Posts: 670
Joined: Thu Jun 03, 2010 8:47 am
Location: Сочи, Хоста
Contact:

Post by Andrey_A_A »

opk44
Создай файл SendKeys.vbs

Code: Select all

' Посылает одно или несколько нажатий клавиш
' в параметрах строка выполнения нажатий
CreateObject("WScript.Shell").SendKeys WScript.Arguments(0)
и вызывай любые клавиатурные сочетания

-"Перейти на страницу вверх Page UP" Call("Scripts::Main", 1, "SendKeys.vbs", `"{PGUP}"`)
-"Ctrl +R" Call("Scripts::Main", 1, "SendKeys.vbs", `"^R"`)

Offline
Posts: 874
Joined: Sat Jan 16, 2010 2:03 pm

Post by opk44 »

1. KDJ
Thank you! Very helpful and simple!

2.
FeyFre wrote:opk44, не страдать фигней, и вызвать диалог коммандой AkelPAd.Command()
Наверное, чтобы не провоцировать такой реакции, следовало сразу объяснить свою мотивацию. Целью было написать скрипт, преобразующий макросы в скрипты (получить этакие легко редактируемые "псевдо-макросы"). Самым очевидным решением ("в лоб") представлялось перевести байт-последовательности в соответствующие им вызовы SendKeys.

3. Andrey_A_A
Спасибо за предложение. Возьму на заметку.

4. На текущий момент есть некий "прототип" скрипта по преобразованию макросов в заготовки скриптов. Он очень сырой и многого "не умеет" (например не отлавливает переключение раскладки), но благодаря подсказке KDJ делает теперь "хоть что-то".
Например: [more="результат разбора макроса объединения строк от Surveyor = "Join selected lines.macro" (см. "Plugins-Eng.chm")"]

Code: Select all

C:\Program Files\Total Commander\Plugins\exe\AkelFiles\Plugs\Macros\Join selected lines.macro
Size: 432 bytes (54 keys)
----------------------------------------
VBScript template
----------------------------------------
Dim WshShell
  Set WshShell = CreateObject("WScript.Shell")
  WshShell.SendKeys "^r"
  WshShell.SendKeys ""
  WshShell.SendKeys "n"
  WshShell.SendKeys "{TAB}"
  WshShell.SendKeys " "
  WshShell.SendKeys "{TAB}"
  WshShell.SendKeys "-"
  WshShell.SendKeys "{TAB}"
  WshShell.SendKeys "-"
  WshShell.SendKeys "{TAB}"
  WshShell.SendKeys "{+}"
  WshShell.SendKeys "{TAB}"
  WshShell.SendKeys "{UP}"
  WshShell.SendKeys "{UP}"
  WshShell.SendKeys "{UP}"
  WshShell.SendKeys "{UP}"
  WshShell.SendKeys "{DOWN}"
  WshShell.SendKeys "{DOWN}"
  WshShell.SendKeys "{DOWN}"
  WshShell.SendKeys "{TAB}"
  WshShell.SendKeys "{TAB}"
  WshShell.SendKeys "{TAB}"
  WshShell.SendKeys "{ENTER}"
  WshShell.SendKeys "{ENTER}"
  WshShell.SendKeys "{ESC}"
  WshShell.SendKeys "{HOME}"
----------------------------------------
JScript template
----------------------------------------
  var WshShell = new ActiveXObject("WScript.Shell");
  WshShell.SendKeys ("^r");
  WshShell.SendKeys ("");
  WshShell.SendKeys ("n");
  WshShell.SendKeys ("{TAB}");
  WshShell.SendKeys (" ");
  WshShell.SendKeys ("{TAB}");
  WshShell.SendKeys ("-");
  WshShell.SendKeys ("{TAB}");
  WshShell.SendKeys ("-");
  WshShell.SendKeys ("{TAB}");
  WshShell.SendKeys ("{+}");
  WshShell.SendKeys ("{TAB}");
  WshShell.SendKeys ("{UP}");
  WshShell.SendKeys ("{UP}");
  WshShell.SendKeys ("{UP}");
  WshShell.SendKeys ("{UP}");
  WshShell.SendKeys ("{DOWN}");
  WshShell.SendKeys ("{DOWN}");
  WshShell.SendKeys ("{DOWN}");
  WshShell.SendKeys ("{TAB}");
  WshShell.SendKeys ("{TAB}");
  WshShell.SendKeys ("{TAB}");
  WshShell.SendKeys ("{ENTER}");
  WshShell.SendKeys ("{ENTER}");
  WshShell.SendKeys ("{ESC}");
  WshShell.SendKeys ("{HOME}");
----------------------------------------

примеч.: для получения работоспособного кода в JS из шаблона нужна еще дополнительная коррекция слешей (замена "" на "\")

5. Будь это еще кому-то интересно... Пока скрипт не достаточно оттестирован для выкладывания в соседней теме.