Follow us on...
Follow us on Twitter Follow us on Facebook
Register
Page 3 of 3 FirstFirst 123
Results 17 to 22 of 22
  1. #17
    ejang is offline Registered User
    Join Date
    Feb 2009
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for the replication code!

    Yesterday I tried to alter an example script that replaces the text in names on my desktop. I want to be able to set it so that the script automatically sets the search parameter as both file names and folders instead of a button prompt, but I am not sure how to notate this. Basically, I am trying to strip the script of its excess error messages and user choice.

    Here is the code that I am trying to modify...

    try
    tell application "Finder" to set the source_folder to path to desktop folder as alias
    end try
    display dialog "Search and replace in:" buttons {"File Names", "Folder Names", "Both"} default button 3
    set the search_parameter to the button returned of the result

  2. #18
    ejang is offline Registered User
    Join Date
    Feb 2009
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I was sort of able to figure it out in that I could do

    set the search_parameter to the "File Names"
    or

    set the search_parameter to the "Folder Names"

    but I can't figure out how to do both.

    Also How do I get a script to click a link on a webpage? I want to make a script application that clicks a login button on the safari web browser, can somebody show me an example of how this is done?

    thanks!

  3. #19
    Mikuro's Avatar
    Mikuro is offline Crotchety UI Nitpicker
    Join Date
    Mar 2005
    Posts
    2,832
    Thanks
    8
    Thanked 74 Times in 64 Posts
    It looks like the script goes on to test search_parameter. My guess is you should say set the search_parameter to "Both". But there's probably a simpler way to do this by editing the later part of the script so that it just does what you want and doesn't bother testing search_parameter (assuming you're not using the option to search only folder or only file names).

    As for the Safari question, this is more complicated. The only way I know of doing it is to tell Safari to execute a bit of JavaScript. So the first thing to do is to figure out how to push that button with JavaScript, and then send that JavaScript snippet to Safari via AppleScript. I have a simple example of this somewhere, let me see if I can find it....

    Here we go:
    Code:
    tell application "Safari"
    	do JavaScript "
    	function x() {
    	return document.title
    	}
    	x();
    	" in tab 1 of window 1
    end tell
    That will pull the title of the active web page into your script.

    I think there's a submit() method of either buttons or forms (or both) that will do what you need, but the trickier part is finding the right form button through the script. I'm not an expert with JavaScript, so I can only point you in the right direction. It's not a simple topic. If you're really interested, check out http://www.w3schools.com/js/js_obj_htmldom.asp
    Mac mini — 1.25GHz G4, 1GB RAM — OS 10.5.8
    MacBook Pro — 2.26GHz C2D, 8GB RAM — OS 10.6.8

    Useful programs: Privoxy, Butler, ffmpegX, VLC, Perian, Tofu, Wcalc

  4. #20
    ejang is offline Registered User
    Join Date
    Feb 2009
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi,

    thanks very much!
    yeah I figured the "both" deal today by a little experimenting.

    Thanks for the javascript link!

  5. #21
    ejang is offline Registered User
    Join Date
    Feb 2009
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi once again,

    I don't think this is possible, but I just wanted to check to see if this works at all...

    I have an application that sends itself to the trash. Is there any way I can simultaneously quit that application and empty the trash at the same time? I can see how this can be done if I used a double-script file: one that opens the both of them, one that executes its process, then deleting itself. Then I can see how a timed delay can be integrated into the first script so that it empties the trash right after the second script finishes. Does anybody know how I can do this?

    Pertaining to this question, I have thought of an abstract solution, but it is extremely inefficient and I am sure there is a faster way. One way to integrate these "double" scripts is to store one on the internet, have one script download the other and then open it automatically. This should be pretty easy except I don't know how to open the resulting downloaded file, on top of selecting "open" when the internet-application confirmation prompt appears on screen.

    Thanks!

  6. #22
    somotorcycle is offline Registered User
    Join Date
    Jun 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi Mikuro,

    Thanks for all your help on this forum. You're certainly adding a valuable service.

    So I need to rename a file twice a day with one constant field and the current time stamp, e.g. s3759_20090629_0713. s3759 needs to stay constant and the date and time stamps follow in the above form.

    Will you please advise me how to change your script to provide stamps in this format? After renaming the file, I'll need to have it automatically upload via ftp to a server.

    Thanks for your help!


    Andrew

 

 
Page 3 of 3 FirstFirst 123

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •