Hello all,
I already have a script working with focusById(), sendText(), and sendKey(). However, I was curious if I could simply have used setText2ById() instead. The current obstacle is that the text must end with a carriage return. Does anyone have an idea how that may be possible? I've already tried (and failed at) putting an actual carriage return at the end of the text, and also a "/r/n" at the end of the text too.
setText2ById() and CR
Moderator: Martin
Re: setText2ById() and CR
Hi,
You can use \n within a string literal to create a newline, \r for a carriage return:
variable = "line1\nline2";
Regards,
Martin
You can use \n within a string literal to create a newline, \r for a carriage return:
variable = "line1\nline2";
Regards,
Martin
Re: setText2ById() and CR
Hi Martin,
I've tried that. Even tried formfeed \f. The text would appear in the appropriate field box, and even a context list of suggestions based on what was entered showed up, but the carriage return (or the execution on the text entered) does not happen. Perhaps the app is confused when data is entered directly with a setText2() or such. If I try interact manually with the app afterwards, it behaves as if no new text was entered, and the context list does the vanish as it should with any other interaction outside that list.
I've tried that. Even tried formfeed \f. The text would appear in the appropriate field box, and even a context list of suggestions based on what was entered showed up, but the carriage return (or the execution on the text entered) does not happen. Perhaps the app is confused when data is entered directly with a setText2() or such. If I try interact manually with the app afterwards, it behaves as if no new text was entered, and the context list does the vanish as it should with any other interaction outside that list.
P-chu
Re: setText2ById() and CR
Hi,
I'm confused that the carriage return does not work. Are you trying to set the text in a multi-line text field or do you want to simulate an enter key to execute an action like submit/search in the app? In the latter case you probably have to use function sendKey or press a search button or use Execute Root Command: input keyevent ENTER to simulate an enter key.
Regards,
Martin
I'm confused that the carriage return does not work. Are you trying to set the text in a multi-line text field or do you want to simulate an enter key to execute an action like submit/search in the app? In the latter case you probably have to use function sendKey or press a search button or use Execute Root Command: input keyevent ENTER to simulate an enter key.
Regards,
Martin
Re: setText2ById() and CR
Hi Martin,
It is not a multi-line text field, but there is no send/submit button either. It's the URL field in the stock web browser. (I noticed I failed to state correctly in the last sentence of my last reply, "the context list does not vanish [when I try to do anything else]."
I've been trying to avoid using sendKey(), keeping an extra URL shortcut, rooting my phone, or installing another app, all so that I can put a single shortcut with a proper name on my home screen. (The other app would have simply put another shortcut with the desired name to an existing URL shortcut too.)
It is not a multi-line text field, but there is no send/submit button either. It's the URL field in the stock web browser. (I noticed I failed to state correctly in the last sentence of my last reply, "the context list does not vanish [when I try to do anything else]."
I've been trying to avoid using sendKey(), keeping an extra URL shortcut, rooting my phone, or installing another app, all so that I can put a single shortcut with a proper name on my home screen. (The other app would have simply put another shortcut with the desired name to an existing URL shortcut too.)
P-chu