0

私はさまざまな UNIX コマンドをいじっていて、ダイアログを表示するためにこれに出くわしました。

osascript -e 'tell app "System Events" to display dialog "Hello World"'

ダイアログの位置を変更したい。ほとんどのコマンドでは、man commandそのコマンドに対して何かを行う方法を理解するために使用できます。ただし、man osascriptダイアログ ボックスの位置を変更する方法はわかりません。コマンドを変更して、ダイアログを別の場所に配置するにはどうすればよいですか?

4

2 に答える 2

3

First, to get help with applescript just open the AppleScript Editor application and look under the help menu. The applescript language guide is in there and other tools. Also under the file menu is "Open Dictionary" which will show you the specific commands for applications.

To see the information about display dialog, open the dictionary of StandardAdditions and use the search field to find the command.

To answer your question, no, you cannot specify the location of a "display dialog" window. There are no parameters in that command for positioning the window, as you'll see in the dictionary. In addition, no other commands will help you either because you can't issue other commands while the dialog window is open because the code pauses while the window is open waiting for a response from the dialog window (like when you press the OK button).

If you need to set the position of a window to display information to a user then you'll need to use some other dialog tool other than "display dialog". You could create your own window in cocoa or google for some alternatives like cocoaDialog, SKProgressBar, and Notification Center.

于 2013-07-06T06:32:29.037 に答える
1

これについては回り道があり、いくつかのシナリオで役立つ場合があります。次のことを試してください。

on displayMessage(msg)
tell application "Finder"
   activate
   set c to (count windows)
   ignoring application responses
       display dialog msg with icon note
   end ignoring
end tell

tell application "System Events"
   tell application process "Finder"
       repeat until ((count windows) > c)
           delay 0.2
       end repeat
       set position of window 1 to {0, 22}
   end tell
end tell
end displayMessage

displayMessage("I'm over here!")

この小さなスクリプトの功績は、こちらの投稿にあります。

これを自分で実装したところ、呼び出されているアプリケーション (Finder例では ) がcount windowコマンドをサポートしているかどうか (または、API サポートがまったくないかどうか) に限定されていることがわかりました。

2013年から質問をドラッグしたことに気づきました.OPに役立つ場合、または同様の質問を持つ他の誰かに役立つ場合に備えて、この回答をここに投稿しています。

于 2015-03-08T00:23:04.537 に答える