Encoding AppleScript:使用混合字符编码搜索应用程序名称

Encoding AppleScript:使用混合字符编码搜索应用程序名称,encoding,character-encoding,applescript,Encoding,Character Encoding,Applescript,我正在写一个简单的脚本来搜索iTunesStore中的应用程序。该应用程序执行以下操作: --从用户输入读取应用程序(对话框中的文本字段) --在变量中输入应用程序名称,然后在iTunes(右上角)的搜索文本字段中输入应用程序名称 --按enter键(按键返回) 我正在努力解决的问题是: 当用户输入一个日语文本作为应用程序名称时,我需要检测它是否为日语文本,并需要在向搜索字段键入之前将键盘输入类型更改为JP 有时应用程序名称包含EN和JP字符集 有人能帮我用AppleScript检测每个字符的字

我正在写一个简单的脚本来搜索iTunesStore中的应用程序。该应用程序执行以下操作:

--从用户输入读取应用程序(对话框中的文本字段)

--在变量中输入应用程序名称,然后在iTunes(右上角)的搜索文本字段中输入应用程序名称

--按enter键(按键返回)

我正在努力解决的问题是:

当用户输入一个日语文本作为应用程序名称时,我需要检测它是否为日语文本,并需要在向搜索字段键入之前将键盘输入类型更改为JP

有时应用程序名称包含EN和JP字符集

有人能帮我用AppleScript检测每个字符的字符编码吗

谢谢并致以最良好的问候


Rahman

您可以使用itunesURL:

itunes://ax.search.itunes.apple.com/WebObjects/MZSearch.woa/wa/search?term=漢字
您还可以使用剪贴板插入文本:

try
    set old to the clipboard as record
end try
set the clipboard to "漢字"
tell application "System Events"
    keystroke "v" using command down
end tell
delay 0.1
try
    set the clipboard to old
end try
如果剪贴板为空,尝试获取它会导致错误
剪贴板
类似于
剪贴板作为文本
,但
剪贴板作为记录
还包括其他类型。模拟击键通常比单击菜单栏项目快,并且在全屏窗口或应用程序没有菜单栏时,单击菜单栏项目不起作用。没有延迟,
将剪贴板设置为old
有时会在粘贴文本之前运行

或者在这种情况下,您可以使用UI脚本:

tell application "iTunes"
    reopen
    activate
end tell
tell application "System Events" to tell process "iTunes"
    tell text field 1 of (get value of attribute "AXMainWindow")
        set value to "漢字"
        set selected to true
    end tell
    keystroke return
end tell

这太棒了!!!将值设置为“漢字" 解决了我的问题…非常感谢!!!虽然我昨天晚上睡觉时想到了剪贴板的概念,但你也提到了这个概念。至少我的想法得到了认可…哈哈。无论如何,再次感谢。
tell application "iTunes"
    reopen
    activate
end tell
tell application "System Events" to tell process "iTunes"
    tell text field 1 of (get value of attribute "AXMainWindow")
        set value to "漢字"
        set selected to true
    end tell
    keystroke return
end tell