Unable to write text to Notepad using System. Activities Assign

Hi all,

New member of the community here trying to learn this awesome technology! Currently going through the RPA course on Udemy by Marcelo Cruz . One of the exercises calls for creating a bot that opens Notepad and writes “Hello world!” in the notepad file. I’m having trouble writing the “Hello world!” to Notepad. here are the steps I’m taking

  1. Used OpenRPA to open notepad. I used the “select Element” button while Notepad is open to select the window. This succesfully opens notepad when I run the robot
  2. I inserted a Get Element (OpenRPA.Windows) in my workflow. I clicked on Open Selector and clicked inside the text area of Notepad.
  3. I deleted the Click Element that comes default as part of Get Element
  4. I inserted Assign activity within the Get Element and use item.Value to assign value to the text area of Notepad

When I run the bot, Notepad opens but not text appears inside Notepad.

Would appreciate your input on why this might be happening. Also please let me know if I shoud provide anything else to troubleshoot. Thank you

Welcome :blush:

A common issue with this example is notepad changes the title of the window ( and there for also the selecgbtor ) when you add text to it.
If you add a star * after the window name/title in the selector it should work again.

Thanks Allan, I appreciate you responding to my question

Is the window below what you are referring to? where should the * be added?

Below is also the code if it’s easier:

[
{
“filename”: “%ProgramFiles%\WindowsApps\Microsoft.WindowsNotepad_11.2302.26.0_x64__8wekyb3d8bbwe\Notepad\Notepad.exe”,
“processname”: “Notepad”,
“arguments”: " ",
“Selector”: “Windows”,
“search_descendants”: “True”,
“mouse_over_search”: “False”
},
{
“ClassName”: “Notepad”,
“Name”: “Notepad”,
“ControlType”: “Window”,
“FrameworkId”: “Win32”
}
]

Hey,
No in the selector for the “get element” you use for assigning text.
So on my windows 10 the selector is

[
  {
    "filename": "%windir%\\system32\\notepad.exe",
    "processname": "notepad",
    "arguments": "",
    "Selector": "Windows",
    "search_descendants": "True",
    "mouse_over_search": "False"
  },
  {
    "ClassName": "Notepad",
    "Name": "Untitled - Notepad",
    "ControlType": "Window",
    "FrameworkId": "Win32"
  },
  {
    "ClassName": "Edit",
    "Name": "Text Editor",
    "ControlType": "Document",
    "FrameworkId": "Win32"
  }
]

But as soon as i type something, the second part updates to

[
  {
    "ClassName": "Notepad",
    "Name": "*Untitled - Notepad",
    "ControlType": "Window",
    "FrameworkId": "Win32"
  },

So in openrpa selectors, * means “everything”. So it is kind of lucky for us, notepad decided to add a * when the document changes, it means this new selector can find the window weather you updated the document or not. ( you could also just remove the name part completely, then it would find any notepad window. If you know there is never more than one notepad windows open when you want to run your workflow it does not matter what the document title is )

Hi Allan,

Thanks again for getting back to me and for the explanation. Below is what mine looks like when I click on the Open Selector button in Get Element:

[
{
“filename”: “%ProgramFiles%\WindowsApps\Microsoft.WindowsNotepad_11.2302.26.0_x64__8wekyb3d8bbwe\Notepad\Notepad.exe”,
“processname”: “Notepad”,
“arguments”: “”,
“Selector”: “Windows”,
“search_descendants”: “True”,
“mouse_over_search”: “False”
},
{
“ClassName”: “Notepad”,
“Name”: “Notepad”,
“ControlType”: “Window”,
“FrameworkId”: “Win32”
},
{
“ClassName”: “Notepad”,
“Name”: “Notepad”,
“ControlType”: “Window”,
“FrameworkId”: “Win32”
}
]

It seems slightly different from yours. I tried 4 options:

  1. Replaced “Name”: in the second block of code with “*Untitled - Notepad” , but “hello world!” would still not print

2)Replaced “Name”: in the third block of code (because second and third are identical) with “*Untitled - Notepad” , but “hello world!” would still not print

  1. Replaced “Name”: in the second and third blocks of code (because second and third are identical) with “*Untitled - Notepad” , but “hello world!” would still not print

  2. Deleted the entire line “Name”: “Notepad” in the second and third blocks of code but “hello world!” would still not print

I always saved when trying each of the options above. When I run the bot Notepad always opens but still no text. Not sure what else I could try. Would you have any other ideas by any chance?

You cannot assign a text value to a window you need to select the Edit control

Sorry I’m not following. Do you mean I cannot physically modify the code that appears in the Open Selector window? I thought you said I needed to edit the “Name”: (or another field in the Selector window) with a star * ?

Sorry, I was not clear.
No, the selector you pasted in, does not select the Text field inside notepad, it selects a window. It makes no sense to assign a value to a window. You need to modify ( you can use the tree view and right click on the node you want or click the select button and select it ) to select an element of the type “edit” ( if you are on windows 10, I’m unsure if it’s the same element type on windows 11 )

You could also just click “record” again, and then record adding text to notepad, by clicking on the text area inside notepad. Then openrpa should prompt you for a text to add and only if you click Escape, will it convert it to a click

Hi Allan,

I understand. thanks for the clarification. I recorded the video below with what I’m trying

I’m using window 11, not sure if that has to do with any of the issues I’m encountering.

Really excited to learn to use the tool you built!

Thank you !
It seems notepad has change a bit since i last was on windows 11, it looks like the text area is not visible until you click it.
Could you open the selector, click sync and in the tree view expand the 3 panes and see if the text area control is under one of those?

@Allan_Zimmermann I had the same problem, and in my case I didn’t find the “textarea” by inspecting the 3 pane.
The first pane is the “tab” with title, secound pane is menu and third pane is footer. The “textarea” was never detected.

Hi Allan,

I tried doing what you suggested. Below is what I’m seeing:

Thank you

@kowts yes I think this aligns with what I saw I believe. Did you also take the Udemy course?

@Felipe_Carrillo Yes :grinning:… the course from “Marcelo”!
@Allan_Zimmermann I think this is hapenning only in windows 11, I tested in windows 10 and I was able to make it work.
On windows 11, I used other software (AkelPad) to edit a bunch of txt files and works.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.