VBScript sendkeys, Trying to do CTRL+ALT+A

24,257

I now use powershell and it work great. With VBS, it worked once and then it stoped working. This is the code I run:

[void][reflection.assembly]::loadwithpartialname("system.windows.forms")
[system.windows.forms.sendkeys]::sendwait("^%a")

I used PS2EXE 0.5.1 to convert the script to a exe (SendKeys.exe), then I run it from this code:

Set wshShell = WScript.CreateObject("WScript.Shell")
wshShell.run "C:\Lexibar\SendKeys.exe",0

I need to run it from a vbs to avoid windows to pop. I used Vbs_To_exe to convert this one and now it work. (converting to .exe is just for security, hide my code from students)

Share:
24,257
Tommy
Author by

Tommy

Updated on February 18, 2020

Comments

  • Tommy
    Tommy about 4 years

    I'm testing Lexibar software for voice synthesis in our schoolboard. This kind of software is design to help students who have learning difficulty so I need to write a VBS file that simulate the Ctrl+Alt+A.

    I tried :

    • wshshell.sendkeys "^%{a}"
    • "^%a"
    • "^%{A}"
    • "^%A"
    • "^(%a)"
    • "^(%(a))"
    • ... (But nothing worked)

    If I try wshshell.sendkeys "^%{down}" -> the screen rotate but I am not able to send Ctrl+Alt+A.

    Is it blocked (Ctrl+Alt+Del is blocked).

    • Phylogenesis
      Phylogenesis almost 7 years
      You need to make sure you are sending the keys to the appropriate application. That is, the application needs to have keyboard focus. The other example you showed (changing screen orientation) is captured before sending to any application.
    • GTAVLover
      GTAVLover almost 7 years
      You may be able to find the Application Title of the window you want to give focus by looking at "Applications" tab in Windows Task Manager, It can be the main window or any child window of main application.
    • Tommy
      Tommy almost 7 years
      The application is Windows. It is a keys combination that activate or deactivate Lexibar. Lexibar run in background
  • Tommy
    Tommy almost 7 years
    I already tryed but it didn't worked. And about the application windows, it run in background and the key combination work on any windows
  • GTAVLover
    GTAVLover almost 7 years
    @Tommy then do you know what is the executable name of the application?
  • Tommy
    Tommy almost 7 years
    Or, is it different if I use {a} vs {A}?
  • Tommy
    Tommy almost 7 years
    The process name is Lexibar.exe, the background app is Lexibar Laucher (32 bits)
  • GTAVLover
    GTAVLover almost 7 years
    Then, as you previously mentioned, Isn't Lexibar has any window that can interact with user (You mean by background)?
  • Tommy
    Tommy almost 7 years
    There is a param page reachable by the tray icon but it don't work like normal app. When Lexibar is activate, every keyboard typing pop a Word Preacher and a voice synthesis (Word, chrome, search field in startup menu... everywhere)
  • Tommy
    Tommy over 5 years
    It don't work for Lexibar. The only way is by using Powershell