open a folder when you know the full path

  1. ‹ Older
  2. 3 months ago

    Shawn B

    Aug 12 Virginia Beach
    Edited 3 months ago

    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:"
    end tell

    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.

    -image-

  3. Shawn B

    Aug 12 Virginia Beach

    functions, methods, and classes.........my head is spinning

    "......it is safer to use the Volume function and the Child method of the FolderItem class."

  4. Eli O

    is not verified Aug 12 Europe (Berlin, Germany)
    Dim sh As New Shell()
    sh.Execute("open /Users/shawn/Desktop/ATP")
  5. Shawn B

    Aug 12 Virginia Beach

    Eli, GENIUS. Thank you sooooo much. Now, can I place and position the window. (20,30,500,300)?

  6. Shawn B

    Aug 12 Virginia Beach

    what is a shell, can I read up on that somewhere

  7. Shawn B

    Aug 12 Virginia Beach

    I found this:
    link text

    but how do I get the ID of the frontmost or active Mac Finder Window

  8. Shawn B

    Aug 12 Virginia Beach

    found this, its UNIX, how do you implement into XOJO, its greek to me

    link text

  9. Beatrix W

    Aug 12 Pre-Release Testers Europe (Germany)

    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.

  10. Shawn B

    Aug 13 Virginia Beach

    Beatrix,

    here is what I currently use and it works VERY well, no issues. I just drag the script from desktop to scripts folder in XOJO. I

      dim mshell as new shell
      mshell.Execute searchqnap

    I downloaded your link, can't figure it out, here is a screenshot.

    -image-

  11. Shawn B

    Aug 13 Virginia Beach

    I found these but no one can help me use them

    xdotool getwindowpid
    xdotool windowmove
    xdotool windowsize

  12. Shawn B

    Aug 13 Virginia Beach

    link text

  13. Douglas H

    Aug 13 Pre-Release Testers, Xojo Pro

    @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.

  14. Michel B

    Aug 13 Pre-Release Testers, Xojo Pro

    Using Launch as well :

    GetFolderItem("/Users/shawn/Desktop/ATP", FolderItem.PathTypeShell).Launch
  15. Shawn B

    Aug 13 Virginia Beach

    Michel Bujardet thank you very much. 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.

  16. Michel B

    Aug 13 Pre-Release Testers, Xojo Pro
    Edited 3 months ago

    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.

  17. Tim H

    Aug 13 Pre-Release Testers Portland, OR USA

    Why would you want to do this? I don't think Xojo is the right tool for the job.

  18. Douglas H

    Aug 13 Pre-Release Testers, Xojo Pro

    @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.

  19. Michel B

    Aug 14 Pre-Release Testers, Xojo Pro
    Edited 3 months ago

    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.

  20. Douglas H

    Aug 14 Pre-Release Testers, Xojo Pro

    @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.

  21. Michel B

    Aug 14 Pre-Release Testers, Xojo Pro

    I understand perfectly well what he wants, if you care to look above, I gave him code to open a finder window. Problem is, he then asked how to move and size such window. Which in practice is not possible.

    Whatever, why am I even bothering with that ?

or Sign Up to reply!