tell application "System Events"
set {name:theApp, bundle identifier:theIdentifier} to (get 1st application process whose frontmost is true)
end tell
I want to process something related to the current application. I want to save the result of the processing in a variable. (say for example, I want the third character of the name of the application. Though, what I actually want is really important)
I want to somehow make that variable a property so that the processing need not be done again for the same application.
Is that possible? Or is there an alternative way of doing it instead of using property?
(I don’t want to create text files to save the result of processing)
I don’t know exactly what you mean, but of course you can define properties, for example
property theApp : missing value
property theIdentifier : missing value
if theApp is missing value and theIdentifier is missing value then
tell application "System Events"
set {name:theApp, bundle identifier:theIdentifier} to (get 1st application process whose frontmost is true)
end tell
end if
Its best if I ask you to write a script which does this:
Get the third character of the name of the current application (ofcourse, the script will have to be run after assigning it a shortcut or from the Script Menu. Otherwise, the current app will always be Script Editor)
However, the script must not process the name again to get the third character of the name if it has already done it for that application before. It should directly retrieve the value.