|
|
|
|
| Welcome, Guest | Home | Search | Login | Register | |
| Author | Applescript to configure smart aliases? (Read 11250 times) | ||||||||||||||||||||||||||||||||||||||
|
cballero
1024 MB ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1176 System 7, today and forever |
on: December 02, 2023, 15:55
More bucket-list ideas here ![]() Could Applescript be used to configure, well, 'smart aliases' comes to mind; the idea would be to have icons, but really just scripts that set the Mac's color depth and resolution based on a program or game's ideal or must-have requirements. I imagine there's utilities that might do this for a program upon launch; if so, then my ask is moot. But if a script can use the program's icon, then it could make for easier launches, especially of older apps and games. The only gotcha would be the color depth and resolution once the application closes, but I do recall that some control panels handle this final step, and possibly more? Does anyone use any of these and if so, how?
|
||||||||||||||||||||||||||||||||||||||
|
Bolkonskij
|
Administrator 1024 MB ![]() ![]() ![]() ![]() ![]() Posts: 2023
Reply #1 on: December 02, 2023, 17:03
|
Hah! I think the first part of the idea is well do-able by creating a "fake application" stealing the game's icon. The "startup script" then executes a command which makes pre-defined changes to resolution and colours and then starts the real game and exits. So much for that :-) ... the difficulty lies in reverting the changes. The script would need a callback from the game ("I'm quitting - please set changes back") which isn't there? I wonder if Apple Script can process events like "on Quit of app XY" but I'm too inexperienced with AppleScript. Sounds like an interesting idea though!
|
68040
|
512 MB ![]() ![]() ![]() ![]() ![]() Posts: 950 68k - thy kingdom come, thy will be done !
Reply #2 on: December 02, 2023, 17:13
|
CE Software's QuicKeys offers the option for application specific scripts. You can either schedule them to be executed at the program's start or termination or to be available in a sub-menu or via hotkey. I use it myself extensively for UTF -> MacRoman translation and other gimmicks.
|
cballero
|
1024 MB ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1176 System 7, today and forever
Reply #3 on: December 02, 2023, 20:42
|
Exactly! ![]() So in my ideal scenario, since old apps aren't self-policing, these would solve at least the initial problem. My workaround to the quit issue would be to have a 'cleaner' script icon that would revert the finder desktop to its original settings. Ideally though, Applescript could run this cleaner script whenever an application closes.
|
MTT
|
256 MB ![]() ![]() ![]() ![]() ![]() Posts: 394 SSW7 Oldtimer
Reply #4 on: December 03, 2023, 23:57
|
Quote from: Bolkonskij: " I wonder if Apple Script can process events like "on Quit of app XY""Yes it can, you have to write a "stay alive" idle routine for the AppleScript. Here's one for cballero's bucket list -It can be used as a template for any app that requires 256 colors but can't set that in-game or restore afterwards.Copy (from 'property' down to 'end quit') and paste into AppleScript v1.1 or later: --------------------------- property idlePeriod : 2 global usualDepth tell application "Finder" copy (monitor depth) to usualDepth if (max monitor depth) < 8 then display dialog ¬ "Monitor not presently capable of running this game. ¬ It requires 256 colors." with icon 1 buttons {"Let's Split"} ¬ default button 1 else if usualDepth = 8 then select file "Games:Caesar:caesar" of startup disk open selection else set monitor depth 8 select file "Games:Caesar:caesar" of startup disk open selection end if end if end tell on idle tell application "Finder" set x to every process set y to application "caesar" if y is in x then return idlePeriod else -- caesar has quit if (max monitor depth) = usualDepth then set monitor depth (max monitor depth) else set monitor depth usualDepth end if quit me -- this exits idle, & goes to "on quit" handler end if end tell end idle on quit continue quit -- required for quitting "stay open" AS applications end quit --------------------------- For testing purposes, I needed to find a program that did not automatically adjust the color depth on opening and quitting. I found what I needed in a game called Caesar from the MG. Substitute the classic Mac path to your program/game with where I've used '"Games:Caesar:caesar" of startup disk' in the first routine and 'caesar' in the idle routine. When you compile the AppleScript (click the 'Check Syntax' button), you may be asked to locate the application you are wanting this script for. It will only occur once, if at all. Navigate to it via the dialog and select its name, click OK. The '--' two dashes in the script are used for AppleScript comments. The '¬' character represents an unbroken single line or string. The 'Option & Return' keys when in AppleScript will make this character (if parsing the text on this page into classic Mac OS doesn't go well). The 'idlePeriod : 2' property at the script beginning, informs 'idle' to check for the game 'caesar' in the 'processes' (Application menu), every 2 seconds. When you quit the game or app, idle will detect that it's no longer active and restore the display then quit itself. The script doesn't use any 'try' or 'on error' routines which could be added to make the script more fail proof, but as is, it should work OK for you. Save the AppleScript as an application with "Stay Open" and "Never Show Startup Screen" checked. You can of course add a custom icon to it if desired.
Last Edit: December 04, 2023, 00:58 by MTT
|
68040
|
512 MB ![]() ![]() ![]() ![]() ![]() Posts: 950 68k - thy kingdom come, thy will be done !
Reply #5 on: December 04, 2023, 02:15
|
You can achieve the same a lot easier with QuicKeys: Select App Tab -> Define -> Extensions -> ScreenEase -> Change Screen Depth -> Timer Option -> 0 Seconds after App Start
|
cballero
|
1024 MB ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1176 System 7, today and forever
Reply #6 on: December 05, 2023, 20:04
|
Thanks you too! ![]() Both .ook good to solve having to manually change the resolution!
|
68040
|
512 MB ![]() ![]() ![]() ![]() ![]() Posts: 950 68k - thy kingdom come, thy will be done !
Reply #7 on: December 05, 2023, 21:02
|
@cballero - Just remember to first start the target app, before opening the QuicKeys script menu. This way it automatically opens up a tab where you can define script options specific to that application. QuicKeys uses its own menu for edit/paste/copy etc. This might be a bit confusing at first but once you got used to it you'll find that it actually works a lot better than the MacOS counterpart (you can copy & paste structures/entire script blocks a.s.o.)
|
Bolkonskij
|
Administrator 1024 MB ![]() ![]() ![]() ![]() ![]() Posts: 2023
Reply #8 on: December 06, 2023, 09:02
|
Cool solutions! I think I'd prefer MTTs script because it'd allow me to have the script sitting in my game folder, disguising it with the game's icon and one would just have to double-click it and ... go! More natural unless you're already heavily invested into QuicKeys and use it anyway. (which I'm not at this point) But it's always good to have alternatives, so thanks to both of you for sharing.
|
68040
|
512 MB ![]() ![]() ![]() ![]() ![]() Posts: 950 68k - thy kingdom come, thy will be done !
Reply #9 on: December 06, 2023, 20:55
|
@Bolkonskij - Hehehe, you can insert native AppleScript sequences in QuicKeys via "Define->Extensions->Scripting Tools" QuicKeys-is-unbeatable when it comes to MacOS Desktop automation.
|
|
Pages: [1]
|
| ||||||||||
|
© 2021 System7Today.com. |





