2
내 연결을 포함하여 인터넷의 모든 구석을 검색했지만 아직 AppleScript의 키 입력 이벤트에 대해 잘 모르는 사람은 없습니다.프린터를 추가하는 AppleScript 만들기
필자가 성취하고자하는 것은 IP 주소와 프린터의 위치와 같은 변수를 묻는 방법으로 프린터를 추가하는 AppleScript입니다. 그런 다음 스크립트는 모든 Mac에있는 AddPrinter
응용 프로그램을 엽니 다. 스크립트는 시뮬레이션 된 키 입력을 사용하여 이전에 설정된 모든 변수를 필드에 입력하고 "추가"를 클릭하여 프린터를 추가합니다.
그것은 다음과 비슷한 모습이 될 것입니다
set ip_address to text returned of (display dialog "Enter Printer Ip Adress" default answer "" buttons {"OK"} default button 1)
set printer_name to text returned of (display dialog "Enter Name of Printer" default answer "" buttons {"OK"} default button 1)
set printer_location to text returned of (display dialog "Enter Location of Printer" default answer "" buttons {"OK"} default button 1)
tell application "AddPrinter" to activate
tell application "System Events"
tell process "AddPrinter"
tell window 1 -- or “window 1”
click button "IP" of toolbar 1 -- or “button 3”
tell combo box 2 of group 2 of group 1
keystroke ip_address
end tell
delay 1
tell group 1 of group 1
set value of text field 1 to printer_name
set value of text field 2 to printer_location
-- you can't use the reserved word “location”
end tell
end tell
end tell
end tell
+1하지만'* .ppd' 경로는 특정 프레임 워크 버전을 참조하지 않도록하기 위해'/ System/Library/Frameworks/ApplicationServices.framework/Frameworks/PrintCore.framework/Resources/Generic.ppd ' 'A'). – mklement0
네, 맞습니다. –
네,하지만 제가 어떻게 위의 설정 변수를 사용하여 위의 작업을 수행 할 수 있습니다. –