Rob, You’ve been a great help so far . This works pretty good yeah. But i need to repeat it cause i have a website with this security program that has to be refreshed every 2 minutes. When im in school ( im 14 ) i can’t do this, so i want a script to do it for me. Thanks so far, and more help would be great !!
Maybe this will work when saved as a stay open application. Once launched, it should run the code every 120 seconds.
on idle
tell application "Finder" to activate
tell application "System Events"
set visible_apps to application processes whose visible is true
repeat with app_ in visible_apps
if name of app_ is not "Finder" then
set visible of app_ to false
end if
end repeat
end tell
tell application "Extra Suites" to ES move mouse {460, 515}
delay 1
tell application "Extra Suites" to ES click mouse
return 120 -- seconds
end idle
– Rob (who will be extremely mad if he finds out that this is used to break the rules at school)
Lol, Naa, I won’t run it at my school’s computer. Just at home And it’s allowed anyways. You’re the best man. Is it ok if i PM you if i need more help ?
If you run it in Script Editor, it will do nothing. It must be saved as a stay open application and then launched (the same way you launch other applications).
If there’s no chance that the computer will be used while the script is running, the following version will be more resource friendly since it doesn’t need to hide the applications every time it executes.
tell application "Finder" to activate
tell application "System Events"
set visible_apps to application processes whose visible is true
repeat with app_ in visible_apps
if name of app_ is not "Finder" then
set visible of app_ to false
end if
end repeat
end tell
tell application "Extra Suites" to ES move mouse {460, 515}
delay 1
on idle
tell application "Extra Suites" to ES click mouse
return 120 -- seconds
end idle
k Thanks man. I think this is working . What if i want to add extra mouse movements and clicks… So thesame thing but more in one serie ? Lol, I know i keep on wining but since were solving problems, might aswell solve’em all now
I would probably use something like this, where you can add more move and click commands to the idle handler (at the end of the script).
tell application "Finder" to activate
tell application "System Events"
set visible_apps to application processes whose visible is true
repeat with app_ in visible_apps
if name of app_ is not "Finder" then
set visible of app_ to false
end if
end repeat
end tell
on idle
tell application "Extra Suites"
ES move mouse {460, 515}
ES click mouse
-- more move and click commands here
end tell
return 120 -- seconds
end idle
As i’m a complete newbie, and i didnt really get what u ment in your last post, could you give me an example of this script with another move and click mouse code ? Ill insert the Co-ordinates BTW, i tried running your previous codes as an app. But it opens and disappears, and then nothing happens. is this normal ?
Here’s an example with an additional move and click command.
tell application "Finder" to activate
tell application "System Events"
set visible_apps to application processes whose visible is true
repeat with app_ in visible_apps
if name of app_ is not "Finder" then
set visible of app_ to false
end if
end repeat
end tell
on idle
tell application "Extra Suites"
ES move mouse {460, 515}
ES click mouse
ES move mouse {500, 500}
ES click mouse
end tell
return 120 -- seconds
end idle
When you save the script in Script Editor, save it as an application and make sure that “Stay Open” is enabled. This is an option in the save dialog. The dialog might/should look something like this, depending on which version of Script Editor is in use:
Hey rob, You’re the man ;). This is good. But it seems that the mouse clicks on 2 places really quick and then waits another 120 seconds. is it possible that it clicks on a certain point, waits 10 seconds, click on another point, wait 10 seconds, click on a point and then wait 120 seconds and repeat the process ?
I know it’s hard, and i understand if you’re busy doing more important things then helping a n00b like me who only needs a script to protect his website .
You can insert delays, measured in seconds, where you need them. Here’s an example.
on idle
tell application "Extra Suites"
ES move mouse {460, 515}
ES click mouse
delay 10
ES move mouse {500, 500}
ES click mouse
end tell
return 120 -- seconds
end idle
tell application "Finder" to activate
tell application "System Events"
set visible_apps to application processes whose visible is true
repeat with app_ in visible_apps
if name of app_ is not "Finder" then
set visible of app_ to false
end if
end repeat
end tell
on idle
tell application "Extra Suites"
ES move mouse {80, 669}
ES click mouse
delay 10
ES move mouse {455, 400}
ES click mouse
delay 10
ES move mouse {492, 634}
ES click mouse
end tell
return 120 -- seconds
end idle
I am looking for an easy solution to copy text from a web page (always in the same location) into to a specific location in Word and print.
tell application “Google Chrome”
activate
tell application “Google Chrome” Get id=“customer-name-first” {not sure how to execute this part}
tell application “System Events” to keystroke “c” using command down
end tell
tell application “Microsoft Word”
activate
tell application “Microsoft Word”
set findRange to find object of selection
tell findRange
execute find find text “xxx” replace with “CLIPBOARD” replace {not sure how to get the clipboard pasted here}
replace all
tell application “System Events” to keystroke “v” using command down
tell application “System Events” to keystroke “p” using command down
end tell
I don’t have Word installed on this mac and also Using safari (Safari and Chrome are pretty much the same). The code you’re looking for should look something like this:
tell application "Google Chrome"
set theText to do javascript "document.getElementbyId('customer-name-first').innerHTML;" of document 1
end tell
tell application "Microsoft Word"
set text of document 1 to theText
end