Windows: MS VisualStudio: type("4", KEY_ALT) not working?

Asked by Beth Griffin

I am working on a script testing a plugin to MS Visual Studio. So far, using "type()" to send hotkeys has worked just fine (e.g. type( "B", KEY_ALT + KEY_SHIFT)).

So I want to send the hotkeys for switching focus to the Locals view in Visual Studio:

switchApp("My Project (Debugging) - Microsoft Visual Studio")
type( "4", KEY_ALT)

I've also tried it as:
type(4, KEY_ALT)
type(Key.4, KEY_ALT)

But Sikuli doesn't like any of them:

[log] App.focus DataTypesVS10 (Debugging) - Microsoft Visual Studio(0) #0
[error] Stopped [error] An error occurs at line 43 [error] Error message:
Traceback (most recent call last):
 File "C:\Users\bgriffin.AMD\AppData\Local\Temp\sikuli-tmp4884278211712740274.py", line 43, in
    SetFocusLocals()
  File "C:\Users\bgriffin.AMD\Documents\VisualStudioLib.sikuli\VisualStudioLib.py", line 116, in SetFocusLocals
  type( Key.4, KEY_ALT )
  File "C:\Program Files (x86)\Sikuli X\sikuli-script.jar\Lib\sikuli\Region.py", line 59, in find
  Line 77, in file C:\Users\bgriffin.AMD\AppData\Local\Temp\sikuli-tmp4884278211712740274.py

Manually, "ALT+4" works fine. Not the Numpad "4", but the keypad "4".

In the Sikuli IDE, "type("4", KEY_ALT)" behaves odd; I expected KEY_ALT to display in brown, just like all the other KEY_* keywords, but it displays in black. The other two ways I tried (4, Key.4) cause KEY_ALT to display in brown, but don't work.

Looking at the documentation, it appears the using type("4", KEY_ALT) should work.

What should I be doing here?

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
Last query:
Last reply:
Revision history for this message
Best RaiMan (raimund-hocke) said :
#1

this is correct and should work:
type("4", KEY_ALT)

may be, you have to click somewhere before.

just ignore the fact, that KEY_ALT is black - seems to be a regex error in the IDE's word coloring.
want to see it brown:
type(str(4), KEY_ALT)
which is equivalent to the above.

Revision history for this message
Beth Griffin (beth-griffin) said :
#2

Using "str(4)" worked.

Revision history for this message
Beth Griffin (beth-griffin) said :
#3

Thanks RaiMan, that solved my question.