Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 4095 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

Hi all

I need to have a script to do the following

Open up a Url (which will be a doc file) using the Url in a fileld

Once the document has downloaded and opened I need to select all, copy and then paste the text back into a filemaker field

I have done some basic scripting but never with applescript

My thinking so far is that I already have a small script to go to the url and then the word doc will download and open autmatically

So then I need to switch from filemaker to word and select and copy - then put it back into the correct field in filemaker

 

One of the problems is that I am not sure how variables work between the two applications

 

So I am guessing I need a variable for the downloaded file and a variable for the copied text

 

So a basic algorithm would be

 

Perform script (the script to Open the Url

Call applescript

switch to word

select all and copy

Close the word file

switch to filemaker

paste text into the correct filemaker field

 

 

this would be a looping script which would end when the record count = found records

 

Can someone advise if I am on the right lines here

Many thanks

 

 

 

 

Posted

Hello
Have actually written a script which seems to work would love to know if anyone thinks better way to do it

For example is there a way of setting the contents of the clipboard as a variable

Perform Script (‘hyperlink”)                     (This goes to the relevant url, the word document will then download automatically and open)
Pause script [duration (seconds): 10]

Perform AppleScript  

    tell application "Microsoft Word"                 (Makes word active then copies all the text)
        activate
    end tell
    tell application "System Events"
        keystroke "a" using command down
        keystroke "c" using command down
    end tell
    tell application "Firefox"                                    (Makes firefox active and closes the current tab - so there isn't hundreds of opened tabs on the application)
        activate
    end tell
    tell application "System Events" to tell process "firefox"
        keystroke "w" using command down
    end tell
    tell application "Microsoft Word" to close every window            (Closes the word document)
    tell application "FileMaker Pro Advanced"                                (makes Filemaker active)
        activate
    end tell

Paste [Links::textfield]                                                                 (pastes the contents of the clipboard into the correct filemaker field)
Commit Records/Requests [skip data entry validation; No dialog]


 

Posted

It's been (quite) a while since I did anything quite like this, and I don't really understand what "Microsoft Word" has to do with this.* But since you asked whether there is a simpler way to do any of this, I can tell you one simpler method to get the text of a web page. I also don’t know if any app but Safari can do this "web page as text" so directly.

 

In this test, I just used the web page that was open. You could use the FileMaker script step, Open URL to open a page (you would then need to Pause Script until it was open however). The below is just the basic, to show how Safari can give you the text.

 

I used "--" to turn off FileMaker, as it is not needed by AppleScript when run by FM (but would be need if run by AS on its own).

 

--tell application "FileMaker Pro Advanced"

tell current record of document 1

tell application "Safari"

tell window 1

set theText to text of document 1

end tell

-- close document 1

end tell

 

set cell "Text_" to theText

end tell

--end tell

 

* I do not know allot of things which I used to know. Your method, using "System Events" is another alternative.

Posted

Re: setting the contents of the clipboard as a variable

 

AppleScript can get the contents of the clipboard directly. There are two things about this. Is it text? As FM cares, in order to put it into a field. And, it's easist to put it into a field, likely a global field, which is ON the layout in FM that you're on. You cannot put it into a Variable, as FM using AS does not know what that is. This is some basic AS to get the text from the last clipboard item.

 

 

set test_text to checkClipboardContainsText()

 

if test_text is true then

set clip_test to the clipboard as text

end if

 

on checkClipboardContainsText()

try

the clipboard as text

return true

on error

return false

end try

end checkClipboardContainsText

This topic is 4095 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.