एप्लास्क्रिप्ट खोजक समस्या


1

AppleScript कोड:

on dialogBox(theMessage)
display dialog theMessage default answer "" buttons {"Cancel", "Search"} default button 2 with title "Pick a search engine"
end dialogBox

dialogBox("Google, YouTube, Wiki, Dictionary, Apple, Adobe, or Google Images")

if text returned of result = "Google" then
set search to text returned of dialogBox("Enter Google Search")
tell application "Google Chrome"
    activate
    open location "https://www.google.com/?gfe_rd=cr&ei=4fJgVJ6SM8yD8QfJjYGICA&gws_rd=ssl,cr&fg=1#q=" & search
end tell

else if text returned of result = "YouTube" then
set search to text returned of dialogBox("Enter YouTube Search")
tell application "Google Chrome"
    activate
    open location "https://www.youtube.com/results?search_query=" & search


end tell


else if text returned of result = "Wiki" then
set search to text returned of dialogBox("Enter Word")
tell application "Google Chrome"
    activate
    open location "http://en.wikipedia.org/wiki/" & search


end tell

else if text returned of result = "Dictionary" then
set search to text returned of dialogBox("Enter Word")
tell application "Google Chrome"
    activate
    open location "http://Dictionary.Reference.Com/Browse/" & search


end tell

else if text returned of result = "Apple" then
set search to text returned of dialogBox("Enter Apple Search")
tell application "Google Chrome"
    activate
    open location "http://www.apple.com/search/?q=" & search


end tell

else if text returned of result = "Adobe" then
set search to text returned of dialogBox("Enter Adobe Search")
tell application "Google Chrome"
    activate
    open location "http://www.adobe.com/cfusion/search/index.cfm?term=" & search

end tell

else if text returned of result = "Google Images" then
set search to text returned of dialogBox("Enter Image Search")
tell application "Google Chrome"
    activate
    open location "https://www.google.ca/search?site=imghp&tbm=isch&source=hp&biw=1920&bih=890&q=" & search

end tell
end if

समस्या:

शीर्ष पर, यह कहता है ("Google, YouTube, Wiki, Dictionary, Apple, Adobe, या Google Images")

मैं इसे बनाना चाहता हूं इसलिए यह अंत में एक प्रश्न चिह्न लगाता है, जैसे: ("Google, YouTube, Wiki, Dictionary, Apple, Adobe, या Google Images?"

Google छवियाँ में एक प्रश्न चिह्न है, लेकिन जब मैं टेक्स्ट बॉक्स में "Google छवियाँ" टाइप करता हूं, तो यह बंद हो जाता है। क्या कोई मेरी मदद कर सकता है इसलिए मैं प्रश्न चिह्न के साथ Google छवियां टाइप कर सकता हूं और कार्यक्रम बंद नहीं होता है?

जवाबों:


0

"Google छवियां जोड़ें ?" पाठ के लिए स्वीकार्य परिणाम वापस आ गए।

else if text returned of result is in {"Google Images", "Google Images?"} then

के बजाय:

else if text returned of result = "Google Images" then

यह आपको अपने संवाद में स्वीकार्य उत्तर के रूप में दर्ज करने की अनुमति देगा।


0

मैं आपको अपनी स्क्रिप्ट को कुछ इस तरह बदलने की सलाह दूंगा, जिससे सभी कॉपी / पेस्ट करने से बच सकें:

-- this makes it much easier to add a new search engine. The '¬' means the line is continued on the next line.
set searchEngines to { ¬
    {name:"Google", URL:"https://www.google.com/?q="}, ¬
    {name:"YouTube", URL:"https://www.youtube.com/results?search_query="}, ¬
    {name:"Wikipedia", URL:"https://en.wikipedia.org/w/index.php?title=Special%3ASearch&go=Go&search="}, ¬
    {name:"Dictionary", URL:"http://dictionary.reference.com/browse/"}, ¬
    {name:"Apple", URL:"http://www.apple.com/search/?q="}, ¬
    {name:"Adobe", URL:"http://www.adobe.com/cfusion/search/index.cfm?term="}, ¬
    {name:"Images", URL:"https://www.google.ca/search?site=imghp&tbm=isch&source=hp&biw=1920&bih=890&q="} ¬
}

set names to {}
repeat with searchEngine in searchEngines
    set end of names to name of searchEngine
end repeat
choose from list names with prompt "Select a search engine"
if result is false then -- you hit Cancel
    return
else
    set searchEngineName to item 1 of result
end if
repeat with searchEngine in searchEngines
    if name of searchEngine is searchEngineName then
        display dialog "Search " & searchEngineName & ":" buttons {"Cancel", "Search"} default button 2 default answer ""
        open location (URL of searchEngine & text returned of result)
    end if
end repeat
हमारी साइट का प्रयोग करके, आप स्वीकार करते हैं कि आपने हमारी Cookie Policy और निजता नीति को पढ़ और समझा लिया है।
Licensed under cc by-sa 3.0 with attribution required.