XCommand (XType Help)


#1

Hi there, I’m currently trying to use XType as a replacement method for the sendKeys command, as a website I use (Discord) doesn’t really function using the other one. Here’s a simple script to test how it works and I had no success:

{
“CreationDate”: “2018-10-27”,
“Commands”: [
{
“Command”: “open”,
“Target”: “https://www.google.ca/search?hl=en-CA&ei=mzrUW_iNNoPj9AOP9qMg&q=hi&oq=hi&gs_l=psy-ab.3..0i67k1l10.3951971.3953367.0.3955857.3.3.0.0.0.0.62.123.2.3.0…0…1c.1.64.psy-ab…0.2.122.0…0j0i131k1.51.I5IxJpmcvno”,
“Value”: “”
},
{
“Command”: “click”,
“Target”: “id=rhscol”,
“Value”: “”
},
{
“Command”: “XType”,
“Target”: ““hi””,
“Value”: “”
},
{
“Command”: “XType”,
“Target”: “${KEY_ENTER}”,
“Value”: “”
}
]
}

The XType commands do not work at all, the “hi” is not typed and the enter key is not used. Is this not how the XType commands are intended to work? Am I missing something on my end? Thank you!


#2

I believe XType functions as type so you have to use locator for target, and the value would be your text.


#3

Hi, this was the example shown in the XType demo:

{
“CreationDate”: “2018-10-27”,
“Commands”: [
{
“Command”: “store”,
“Target”: “fast”,
“Value”: “!replayspeed”
},
{
“Command”: “open”,
“Target”: “https://a9t9.com/kantu/demo/xtype”,
“Value”: “”
},
{
“Command”: “comment”,
“Target”: “Send CTRL+S to open the browser save dialog”,
“Value”: “”
},
{
“Command”: “XType”,
“Target”: “${KEY_CTRL+KEY_S}”,
“Value”: “”
},
{
“Command”: “comment”,
“Target”: “Generate today’s date and time “,
“Value”: “”
},
{
“Command”: “storeEval”,
“Target”: “var d= new Date(); var m=((d.getMonth()+1)<10)?‘0’+(d.getMonth()+1):(d.getMonth()+1); d.getFullYear()+”-”+m+”-"+d.getDate();",
“Value”: “mydate”
},
{
“Command”: “storeEval”,
“Target”: “new Date().getHours()+”-" + new Date().getMinutes() + “-” + new Date().getSeconds()",
“Value”: “mytime”
},
{
“Command”: “echo”,
“Target”: “Today is ${mydate}, and the time is ${mytime}”,
“Value”: “blue”
},
{
“Command”: “comment”,
“Target”: “Wait for the dialog to appear before sending the next keystrokes”,
“Value”: “”
},
{
“Command”: “pause”,
“Target”: “2000”,
“Value”: “”
},
{
“Command”: “comment”,
“Target”: “Send the new file name to the dialog and press ENTER”,
“Value”: “blue”
},
{
“Command”: “XType”,
“Target”: “Page_saved_by_Kantu_${mydate}_${mytime}${KEY_ENTER}”,
“Value”: “”
}
]
}

So I was thinking it was the target that should be what you’re typing? Or am I mistaken? Either way I’ll try it out and see if it works, thank you


#4

Looks like I am wrong. Sorry.
But I can’t copy paste your example. Did you use <code>?


#5

Code here:
<
{
“CreationDate”: “2018-10-27”,
“Commands”: [
{
“Command”: “open”,
“Target”: “https://www.google.ca/search?hl=en-CA&ei=mzrUW_iNNoPj9AOP9qMg&q=hi&oq=hi&gs_l=psy-ab.3..0i67k1l10.3951971.3953367.0.3955857.3.3.0.0.0.0.62.123.2.3.0…0…1c.1.64.psy-ab…0.2.122.0…0j0i131k1.51.I5IxJpmcvno”,
“Value”: “”
},
{
“Command”: “click”,
“Target”: “id=rhscol”,
“Value”: “”
},
{
“Command”: “XType”,
“Target”: ““hi””,
“Value”: “”
},
{
“Command”: “XType”,
“Target”: “${KEY_ENTER}”,
“Value”: “”
}
]
}

Does it work now? Sorry I’m new to this stuff :frowning:


#6

[info]
Executing: | open | https://www.google.ca/search?hl=en-CA&ei=mzrUW_iNNoPj9AOP9qMg&q=hi&oq=hi&gs_l=psy-ab.3..0i67k1l10.3951971.3953367.0.3955857.3.3.0.0.0.0.62.123.2.3.0…0…1c.1.64.psy-ab…0.2.122.0…0j0i131k1.51.I5IxJpmcvno | |
[info]
Executing: | click | id=rhscol | |
[info]
Executing: | XType | hi | |
[info]
Executing: | XType | ${KEY_ENTER} | |
[info]
Macro completed (Runtime 3.73s)


#7

Make sure you’ve installed RealUser XModule!


#8

I’m pretty sure I do have it installed, this is what it executes it fine (no errors shown), but the “hi” does not pop up on google nor is the enter key pressed. So does the code work find on your end?

Thank you so much for your help!


#9

Yes it works perfectly.


#10

Sorry can’t be of any help on the issue.


#11

Nono, thank you so much for testing! At least I now know the problem is on my end! :blush:


#12

Hi! XType itself does not take a target as input, it “stupidly” sends keystrokes to whatever element has the focus. Therefore you must first send an XClick command to the place where the keystrokes should go to, so the right element has the focus. This is the same as if you (as human) first mouse-click in input field before you type.

This info was missing from the docs, I added it now the the XType page.


#13

Thank you so much for clarifying my problem! Appreciate it!