Re: Scripting Console
Re: Scripting Console
- Subject: Re: Scripting Console
- From: Bernardo Hoehl / Gessos Rutenium <email@hidden>
- Date: Wed, 22 Sep 2004 22:14:33 -0300
Greetings Johnny,
Thanks for posting.
Your tips is very cool. This is what I was looking for.
It has been a valuable lesson for me.
In the begining, I was thinking of doing something real dangerous, like "mv MyPlistFile OriginalPlistFile". (replacing the users pList file)
But your tip is far better, because it only adds the block of text I need.
I will build my App so that I expect the minimum usual screen resolution, like 800X600. Hope it works.
I think you are right also about letting the user to resize the window to its own desire. I will add a "Property WindowHasBeenResized : false" in the begining of my script and as I resize the window the first time the app runs, I set it to true, this way if the user changes the size and position of the console window, next time He/she runs my app, my script won't resize the window. The user's window setiings will remain as it was last time it was run. This is a safe way to just make sure Console window won't open on top of my window.
Thanks for this valuable lesson.
Bernardo
+++++++++++++++++++++
On 22 Sep, 2004, at 8:45 PM, Johnny AppleScript wrote:
Greetings Bernardo,
On 04/09/22 6:26 AM, "Bernardo Hoehl / Gessos Rutenium" <email@hidden> wrote:
> I am trying to to make it open Console app to display the progress of the
> process, a way of showing the GUI user that my application is working. But it
> seems to me that Console doesn't have an applescript dictionary.
>
> This is my code so far:
>
> tell application "Console"
> open "/var/log/mail.log"
> end tell
Better is to use:
tell "System Events" to ""
>
> I would like to set the console window to a specific syze and position in the
> screen, so that it won't open on top of my window, looking like just another
> window of my own program.
For this I would precede the above 'open file' command with a 'defaults write' shell script:
<x-tad-smaller>(* to get the desired coordinates in the first place, just open, set the position of, and close the desired window, then run: *)</x-tad-smaller>
<x-tad-smaller>set</x-tad-smaller><x-tad-smaller> winPrefs </x-tad-smaller><x-tad-smaller>to</x-tad-smaller><x-tad-smaller> </x-tad-smaller><x-tad-smaller>do shell script</x-tad-smaller><x-tad-smaller> "</x-tad-smaller><x-tad-smaller>defaults read ~/Library/Preferences/com.apple.console | grep /var/log/mail.log | grep NSWindow</x-tad-smaller><x-tad-smaller>"</x-tad-smaller>
<x-tad-smaller>return</x-tad-smaller><x-tad-smaller> winPrefs</x-tad-smaller>
<x-tad-smaller>set</x-tad-smaller><x-tad-smaller> qt </x-tad-smaller><x-tad-smaller>to</x-tad-smaller><x-tad-smaller> "</x-tad-smaller><x-tad-smaller>"</x-tad-smaller>
<x-tad-smaller>do shell script</x-tad-smaller><x-tad-smaller> "</x-tad-smaller><x-tad-smaller>defaults write ~/Library/Preferences/com.apple.console </x-tad-smaller><x-tad-smaller>" & qt & "</x-tad-smaller><x-tad-smaller>NSWindow Frame /var/log/mail.log</x-tad-smaller><x-tad-smaller>" & qt & "</x-tad-smaller><x-tad-smaller> </x-tad-smaller><x-tad-smaller>" & qt & "</x-tad-smaller><x-tad-smaller>676 542 400 376 0 0 1280 1002</x-tad-smaller><x-tad-smaller>" & qt</x-tad-smaller>
<x-tad-smaller>tell</x-tad-smaller><x-tad-smaller> </x-tad-smaller><x-tad-smaller> "</x-tad-smaller><x-tad-smaller>System Events</x-tad-smaller><x-tad-smaller>" </x-tad-smaller><x-tad-smaller>to</x-tad-smaller><x-tad-smaller> </x-tad-smaller><x-tad-smaller> </x-tad-smaller><x-tad-smaller> "</x-tad-smaller><x-tad-smaller>"</x-tad-smaller>
Just be aware that different users have different screen resolutions, prefs, etc.; be careful when dictating window sizes and placement; and you’d better think about letting the user give the desired placement a memory of its own, rather than you always dictating it.
HTH
JA
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden