Created
October 1, 2020 08:51
-
-
Save OKsign/e57217cfedbeed9f72c719eac58a0227 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Download cliclick > https://www.bluem.net/en/projects/cliclick/ | |
-- Download MouseTools > http://www.hamsoftengineering.com/codeSharing/MouseTools/MouseTools.html | |
-- Put cliclick and MouseTools in Applications folder | |
----------------------------------------------------------------- | |
set theFile to (path to applications folder as text) & "MouseTools" | |
tell application "Finder" | |
if not (exists file theFile) then | |
set no_app to 1 | |
else | |
set no_app to 0 | |
end if | |
end tell | |
set theFile to (path to applications folder as text) & "cliclick" | |
tell application "Finder" | |
if not (exists file theFile) then | |
set no_app_2 to 1 | |
else | |
set no_app_2 to 0 | |
end if | |
end tell | |
if no_app is 1 or no_app_2 is 1 then | |
tell application "System Events" | |
display dialog "Put App 'MouseTools' and 'cliclick' in Folder 'Applications'" with title "script 30.3" | |
end tell | |
return | |
end if | |
set uchoice to the text returned of (display dialog "Bring App to Front, Set Size and Position = 1, Mouse = 2" default answer "" with title "script 30.3") | |
if uchoice is not "" then | |
if uchoice is "1" then | |
tell application "System Events" | |
set activeApp to (get name of first process where it is frontmost) | |
end tell | |
tell application "System Events" | |
set ppp to get position of window 1 of process activeApp | |
delay 0.03 | |
set sss to get size of window 1 of process activeApp | |
delay 0.02 | |
set pos1 to (item 1 of ppp) | |
set pos2 to (item 2 of ppp) | |
set siz1 to (item 1 of sss) | |
set siz2 to (item 2 of sss) | |
set activate_app_set_sizepos to "-- bring app to front, set size pos | |
set list_use to {" & pos1 & ", " & pos2 & ", " & siz1 & ", " & siz2 & ", " & "\"" & activeApp & "\"" & "} | |
tell application \"System Events\" | |
tell process (item 5 of list_use) | |
set frontmost to true | |
delay 0.3 | |
end tell | |
end tell | |
tell application \"System Events\" | |
set position of window 1 of process (item 5 of list_use) to {item 1 of list_use, item 2 of list_use} | |
delay 0.03 | |
set size of window 1 of process (item 5 of list_use) to {item 3 of list_use, item 4 of list_use} | |
end tell | |
delay 0.7 | |
-- end - bring app to front, set size pos" | |
delay 0.5 | |
set the clipboard to activate_app_set_sizepos | |
end tell | |
display notification "Done" with title "Code for User" | |
return | |
end if -- uchoice is "2" then | |
if uchoice is "2" then | |
set uchoice to the text returned of (display dialog "Left Click = 1, Right Click = 2" default answer "" with title "script 30.3") | |
if uchoice is "1" then -- left click | |
set curmousepos to do shell script "/Applications/MouseTools -location" | |
set prevTIDs to AppleScript's text item delimiters | |
set AppleScript's text item delimiters to the return | |
set x_mousepos to text item 1 of curmousepos | |
set y_mousepos to text item 2 of curmousepos | |
set AppleScript's text item delimiters to prevTIDs | |
set the clipboard to "-- left click | |
do shell script \"/Applications/MouseTools -x " & x_mousepos & " -y " & y_mousepos & "\" | |
delay 0.3 | |
do shell script \"/Applications/cliclick c:.\" | |
delay 0.5 | |
-- end - left click" | |
display notification "Done" with title "Code for User" | |
return | |
end if | |
if uchoice is "2" then -- right click | |
set curmousepos to do shell script "/Applications/MouseTools -location" | |
set prevTIDs to AppleScript's text item delimiters | |
set AppleScript's text item delimiters to the return | |
set x_mousepos to text item 1 of curmousepos | |
set y_mousepos to text item 2 of curmousepos | |
set AppleScript's text item delimiters to prevTIDs | |
set the clipboard to "-- right click | |
do shell script \"/Applications/MouseTools -x " & x_mousepos & " -y " & y_mousepos & "\" | |
delay 0.3 | |
do shell script \"/Applications/MouseTools -controlKey -leftClick\" | |
delay 0.5 | |
-- end - right click" | |
display notification "Done" with title "Code for User" | |
end if | |
end if | |
end if -- uchoice is not "" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment