Created
January 20, 2022 11:28
-
-
Save OKsign/7d79354109859e3d0400a390f06422e8 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
-- user options | |
set bookmark to "off" -- "on" or "off", to run script set bookmark to "off" | |
set text_continue_reading to "off" -- "on" or "off" | |
set instruction to "on" -- "on" or "off" | |
-- end of user options | |
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 | |
if no_app is 1 then | |
tell application "System Events" | |
display dialog "Put App 'MouseTools' in Folder 'Applications'" with title "Script 31.2" | |
end tell | |
return | |
end if | |
-- get name of active app | |
tell application "System Events" | |
set activeApp to (get name of first process where it is frontmost) | |
end tell | |
-- get name of active window | |
tell application "System Events" | |
tell process activeApp | |
set mywinname to get title of front window | |
end tell | |
end tell | |
set list_done to {} | |
------------------------------------------------------- | |
-- Paste above. | |
------------------------------------------------------- | |
if bookmark is "off" then | |
set countDone to count list_done | |
if countDone = 1 or countDone > 1 then | |
display notification "Done!" with title "Script 31.2" | |
return | |
else | |
set bookmark_not_found_then_set_bookmark to the text returned of (display dialog "Bookmark Not Found | Set Bookmark = 1" default answer "" with title "Script 31.2") | |
if bookmark_not_found_then_set_bookmark is "1" then | |
set bookmark to "on" | |
else | |
return | |
end if | |
end if | |
end if | |
if bookmark is "on" and text_continue_reading is "off" then | |
if instruction is "on" then | |
display dialog "1. Select Text. | |
2. Click This Window. | |
3. Place Mouse Pointer on The Middle of Slider and Hit Return." with title "Script 31.2" | |
end if | |
tell application "System Events" | |
tell process activeApp | |
set frontmost to true | |
delay 0.5 | |
end tell | |
end tell | |
tell application "System Events" | |
set the clipboard to "" | |
delay 0.4 | |
keystroke "c" using command down | |
delay 0.7 | |
set CopT to (the clipboard as text) | |
end tell | |
-- fix " | |
set prevTIDs to AppleScript's text item delimiters | |
set AppleScript's text item delimiters to the "\"" -- search %20 | |
set the item_list to every text item of CopT -- original text | |
set AppleScript's text item delimiters to the "\\\"" -- replace | |
set CopT to the item_list as string | |
set AppleScript's text item delimiters to prevTIDs | |
set curTime to do shell script "date +%Y-%m-%d_%H.%M.%S" | |
-- mouse pos | |
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 | |
-- end - mouse pos | |
-- fix " | |
set prevTIDs to AppleScript's text item delimiters | |
set AppleScript's text item delimiters to the "\"" -- search %20 | |
set the item_list to every text item of mywinname -- original text | |
set AppleScript's text item delimiters to the "\\\"" -- replace | |
set mywinname to the item_list as string | |
set AppleScript's text item delimiters to prevTIDs | |
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 code_user to "-- " & curTime & " - Page: " & mywinname & " | |
if " & "\"" & mywinname & "\"" & " is mywinname and " & "\"" & activeApp & "\"" & " is activeApp and bookmark is \"off\" then | |
tell application \"System Events\" | |
repeat 30 times | |
key code 126 | |
end repeat | |
set position of window 1 of process activeApp to {" & pos1 & ", " & pos2 & "} | |
delay 1 | |
set size of window 1 of process activeApp to {" & siz1 & ", " & siz2 & "} | |
do shell script \"/Applications/MouseTools -x " & x_mousepos & " -y " & y_mousepos & "\" | |
delay 0.3 | |
do shell script \"/Applications/MouseTools -leftClickNoRelease\" | |
delay 0.1 | |
do shell script \"/Applications/MouseTools -releaseMouse\" | |
delay 0.5 | |
display dialog " & "\"" & CopT & "...\"" & " with title " & "\"" & "Continue Reading - Script 31.2" & "\"" & " | |
copy \"done\" to the end of list_done | |
end tell | |
end if | |
-- END | |
" | |
delay 0.5 | |
set the clipboard to code_user | |
delay 0.1 | |
display dialog "Done!" with title "Code for User - Script 31.2" | |
return | |
end tell | |
end if -- bookmark is "on" and text_continue_reading is "off" then | |
if bookmark is "on" and text_continue_reading is "on" then | |
set user_text to the text returned of (display dialog "Continue Reading" default answer "" with title "Script 31.2") | |
if instruction is "on" then | |
display dialog "Place Mouse Pointer on The Middle of Slider and Hit Return." with title "Script 31.2" | |
end if | |
-- fix " | |
set prevTIDs to AppleScript's text item delimiters | |
set AppleScript's text item delimiters to the "\"" -- search %20 | |
set the item_list to every text item of user_text -- original text | |
set AppleScript's text item delimiters to the "\\\"" -- replace | |
set user_text to the item_list as string | |
set AppleScript's text item delimiters to prevTIDs | |
set curTime to do shell script "date +%Y-%m-%d_%H.%M.%S" | |
-- mouse pos | |
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 | |
-- end - mouse pos | |
-- fix " | |
set prevTIDs to AppleScript's text item delimiters | |
set AppleScript's text item delimiters to the "\"" -- search %20 | |
set the item_list to every text item of mywinname -- original text | |
set AppleScript's text item delimiters to the "\\\"" -- replace with space (" ") | |
set mywinname to the item_list as string | |
set AppleScript's text item delimiters to prevTIDs | |
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 code_user to "-- " & curTime & " - Page: " & mywinname & " | |
if " & "\"" & mywinname & "\"" & " is mywinname and " & "\"" & activeApp & "\"" & " is activeApp and bookmark is \"off\" then | |
tell application \"System Events\" | |
repeat 30 times | |
key code 126 | |
end repeat | |
set position of window 1 of process activeApp to { " & pos1 & ", " & pos2 & "} | |
delay 1 | |
set size of window 1 of process activeApp to {" & siz1 & ", " & siz2 & "} | |
do shell script \"/Applications/MouseTools -x " & x_mousepos & " -y " & y_mousepos & "\" | |
delay 0.3 | |
do shell script \"/Applications/MouseTools -leftClickNoRelease\" | |
delay 0.1 | |
do shell script \"/Applications/MouseTools -releaseMouse\" | |
delay 0.5 | |
display dialog " & "\"" & user_text & "...\"" & " with title " & "\"" & "Continue Reading - Script 31.2" & "\"" & " | |
copy \"done\" to the end of list_done | |
end tell | |
end if | |
-- END | |
" | |
delay 0.5 | |
set the clipboard to code_user | |
delay 0.1 | |
display dialog "Done!" with title "Code for User - Script 31.2" | |
end tell | |
end if -- bookmark is "on" and text_continue_reading is "on" then | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment