I'm building an app to open a lot of folders. Each button opens a different folder. (see attached screenshot) This is for work. I open the same folders all day long. I had been doing this in Applescript but know the time has come to do it in XOJO. Here is the Applescript code for what it is worth.
tell application "Finder"
open folder "Macintosh HD:Users:shawn:Desktop:ATP:"
how would do this in XOJO. I have looked the GetFolderItem (http://docs.xojo.com/index.php/GetFolderItem ) page and can't figure it out.
Why don't you use your AppleScripts in Xojo? You can either use the name of the folder as parameter in hardcoded AppleScripts or you can do AppleScripts fully dynamic with the MBS plugin (see http://www.mothsoftware.com/downloads/runAS.zip for a wrapper) or the shell. The only problem with using the shell is quoting. It's really awful but it works fine.
@Shawn B I'm building an app to open a lot of folders.
IMHO, the simplest cross-platform way in Xojo to open folders is to get a FolderItem to the path then use Launch
Dim f as FolderItem Dim dir as FolderItem dir = SpecialFolder.Desktop dirCount = dir.Count For i as Integer = 1 To dirCount f = dir.Item(i) If f <> Nil And f.Exists and f.Directory Then f.Launch End If Next
The above should open every folder on the desktop. How Launch behaves depends on what type of FolderItem you pass it. In the case of a folder, it "opens" it in that OS's normal manner. If an application, it starts the application. If another type of file (say a PDF) it starts whatever application is defined as the default program to handle that type of file, and passes it the FolderItem so it opens it.
Also notice that FolderItem.Count is a one-based array, whereas most arrays in Xojo are zero-based.
You could possibly do that with AppleScript, but since it requires a call to System Events, that will never be accepted for the MAS.
Long ago, I had done something of that nature with declare to manage where the printer dialog was placed on Windows, using GetFrontWindows and SetWindowPos. I mention it since you posted in General, not in macOS.
@Shawn B Do you know how to place the newly opened window at x20, y20 and also size the window like 500 wide 400 high, using XOJO.
It may be stating the obvious, but for Xojo application windows you set the size and placement via properties of that window, such as Width, Height, Top, Left. The problem here is you are wanting to adjust a window that is NOT part of the Xojo application. In order to do that, you need to perform platform specific calls to the OS to modify another application's window. Under most circumstances, it is not considered prudent to modify windows outside your own application. I get where you are coming from in this scenario though, since your app is the one opening these windows.
The general way to control other app's windows is via the Declare statement. A caveat here is that it not only depends on which platform you are running, but also will depend on 32-bit or 64-bit versions. You don't mention here what you need to target, and you put this thread in the General forum section. So I presume you are looking for cross-platforms ways of doing this.
Over the years, some users have created things to help use declares for a given environment. Probably the most widely used of these can be found with forums searches for "MacOSLib" or "Windows Functionality Suite"
But these originated before you had to also worry about 64-bit builds, so they are outdated. For more info, see threads like this and this . But these should also show up in any forum searches you do for the names I gave above.
Note that in your case you don't need everything these extensions have to offer, so you can cherry pick out just the parts you need and create 64-bit versions of only those declares.
Indeed, it is always a bit frustrating to have someone post in General without much explanation about the platform requirements. It is far easier when someone posts in macOS, Windows or Linux.
I would not even bother trying to control a terminal window on Mac. There are simply no declares to do so AFAIK, only AppleScript, and it is taboo if the app is to go in the MAS.
On Windows the declares are fairly simple and work flawlessly, but yet again, it seems not quite right to try and control the command prompt.
From what I understand the OP wants to do, he may look into the project Example Projects/Advanced/Shell/Interactive Shell.xojo_binary_project which enables to open your own "terminal" window in Xojo.
@Michel B I would not even bother trying to control a terminal window on Mac.
I believe he is trying to size/place multiple Finder windows, not terminal windows. You may be thinking terminal because one reply noted the Finder window can be obtained using a shell to issue the "open" command. But IMHO it makes much more sense to simply use [FolderItem].Launch and forgo the shell.