IDE Script copy/paste issues?

Am I doing something silly here in a brand new IDE Script?

I have a class called Test sitting in the root of the project.

The SelectProjectItem(“Test”) works fine, it highlights the class. but the copy and paste just doesn’t work into the new project.

Dim ok As Boolean ok = SelectProjectItem("Test") If ok Then 'Print("Select ok") DoCommand "Copy" NewConsoleProject DoCommand "Paste" End If

“Select ok” is displayed if uncommented, so its getting in there.

Does anyone with more experience with IDE Scripting have any insights?

If you stop the script just after the ok you can see that the copy command is not enabled (but the project item is selected)

If you click on the project item the copy command will be enabled.

But if you update the location it will work

Dim ok As Boolean ok = SelectProjectItem("Test") If ok Then dim dummy as string=location DoCommand "Copy" NewConsoleProject DoCommand "Paste" End If

Many of my scripts are littered with “scrap = location” with scrap being defined as a String in the start of the script. I believe Mr. Ballman shared that little tip back in REAL Studio days on the NUG mail list.

It seems the problem is that the keyboard focus isn’t in the navigator (the class is grey, not blue) so its not picking up the class as the copy location and similarly when in the new project its pasting into the navigator search box rather than the navigator =\

Would there be a way around that issue?

[quote=371033:@JulianS]It seems the problem is that the keyboard focus isn’t in the navigator (the class is grey, not blue) so its not picking up the class as the copy location and similarly when in the new project its pasting into the navigator search box rather than the navigator =\

Would there be a way around that issue?[/quote]
Setting a variable to the “location” after you call SelectProjectItem() will do it (or does for me).

I just loaded it up on macOS to make sure it wasn’t just a windows problem.

What am I doing differently/wrong?

Notice that the Copy doesn’t work unless the Test item is blue?

Right.
The “gray selection” disables the edit commands.

You only need to “blue select” any item before run your script or add a selectWindow(0) before the code (or select window by title)

selectWindow(0) Dim ok As Boolean ok = SelectProjectItem("Test") If ok Then dim dummy as string=location DoCommand "Copy" NewConsoleProject DoCommand "Paste" End If

Ahha selectWindow(0) is the ticket, thanks Antonio and Tim!