TypeError ( type(): 1st arg can't be coerced to String )

Asked by Jackson.Eyton

So I have been having the same issue regardless of the script I write or the machine I write it on. I had one script that was designed to open a webpage and download a file to a specific DIR as a specific name. However I received this error. So I changed machines and wrote a single line command to press the windows key. I still get the same result. The script and error are as follows:
Script:
type (KeyModifier.WIN)

Error:
[error] script [ *Untitled ] stopped with error in line 1
[error] TypeError ( type(): 1st arg can't be coerced to String )

Perhaps I am missing something really obvious here... Can anyone help?

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
Jackson.Eyton
Solved:
Last query:
Last reply:

This question was reopened

Revision history for this message
Jackson.Eyton (jackson-eyton) said :
#1

Something I just saw here as well, perhaps related? This is the output of my CMD window when launching the IDE:
+++ running this Java
java version "1.7.0_25"
Java(TM) SE Runtime Environment (build 1.7.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 23.25-b01, mixed mode)
+++ trying to start Sikuli IDE
+++ using: -Xms64M -Xmx512M -Dfile.encoding=UTF-8 -Dsikuli.FromCommandLine -jar
C:\Users\Admin\Downloads\sikuli-ide.jar
Aug 29, 2013 10:00:36 AM java.util.prefs.WindowsPreferences <init>
WARNING: Could not open/create prefs root node Software\JavaSoft\Prefs at root 0
x80000002. Windows RegCreateKeyEx(...) returned error code 5.

Revision history for this message
Roman Podolyan (podolyan-roman) said :
#3

http://doc.sikuli.org/region.html#Region.type
type([PSMRL], text[, modifiers])

You're missing the "text" part. First argument of "type" should be something like text or Key.CONSTANT.

This returns error:
type ('F',KeyModifier.WIN)

This works:
type ('f',KeyModifier.WIN)
wait(1)

But if you need only to call system menu, you may want to do something else.

Here is the piece of code:

    #this works and calls Windows system menu
    keyDown(Key.WIN)
    keyUp(Key.WIN)
    wait(2)
    popup('it was first way')
    wait(2)
    #this works and calls Windows system menu
    type (Key.WIN)
    wait(2)
    popup('it was second way')
    wait(2)
    #this calls Windows system menu too
    type(Key.ESC, KeyModifier.CTRL)
    wait(2)
    popup('it was third way')

Revision history for this message
RaiMan (raimund-hocke) said :
#4

@ comment #1:

Sikuli stores the Prefernces values in a persistent storage provided by Java. On Windows, this is done in the registry in the branch HKCU Software\JavaSoft\Prefs.

For some secutity reasons, this is blocked in your case - hence Sikuli crashes.

Might have something to do with admin rights.

Revision history for this message
Jackson.Eyton (jackson-eyton) said :
#5

Interesting, I'll check the permissions on that regkey, thanks RailMan.

Roman, I used the KeyModifier.WIN as thats what was indicated in the keys documentation for Sikuli here: http://doc.sikuli.org/keys.html

Perhaps this needs to be updated?

I just verified using type(Key.WIN) does indeed work. Thanks!

Revision history for this message
adityakiran1982 (adityakiran1982) said :
#6

I am trying to perform a key press action like : <<Command+Shift+"h">>.

I tried doing it this way: type(Key.CMD, KeyModifier.SHIFT , "h"). It is not working.May I know what mistake I am doing..
I tried several ways to perform this key action. I am using MAC- El Captian as well as Yosemite. It is not working in both the machines.

Revision history for this message
RaiMan (raimund-hocke) said :
#7

@adityakiran1982
what about reading the docs?

type("h", Key.CMD + Key.SHIFT)