logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
Yuichi  
#1 Posted : Saturday, November 10, 2018 2:36:11 PM(UTC)
Yuichi

Rank: Newbie

Reputation:

Groups: Approved
Joined: 9/13/2018(UTC)
Posts: 7
Poland

Example of script to translate text in browser.
Change "#auto/pl/" to your needs.


Code:
// SAVE CLIP
cliboard = saveClip();

// COPY
sp.SendKeys("^c");
sp.Sleep(50);

// RUN BROWSER OR ADD NEW TAB AND TRANSLATE
if (clip.ContainsText()) {
    var text = clip.GetText();
    var url = "https://translate.google.com/?hl=en&tab=wT#auto/pl/";
    sp.RunProgram("rundll32.exe", "url.dll,FileProtocolHandler " + url + text, "", "", true, false, false); // launch the browser through the system
}

// RETURN CLIP
returnClip(cliboard);


and here clip functions i use:
(i don't copy objects to clip so i don't have to store them)


Code:
// SAVE CLIPBOARD
function saveClip() {
    if      (clip.ContainsAudio())        { var Clip = clip.GetAudioStream();  sp.StoreNumber("savedClip", 1); }
    else if (clip.ContainsFileDropList()) { var Clip = clip.GetFileDropList(); sp.StoreNumber("savedClip", 2); }
    else if (clip.ContainsImage())        { var Clip = clip.GetImage();        sp.StoreNumber("savedClip", 3); }
    else if (clip.ContainsText())         { var Clip = clip.GetText();         sp.StoreNumber("savedClip", 4); }
    return Clip;
}

// RETURN CLIPBOARD
function returnClip(Clip) {
    switch (sp.GetStoredNumber("savedClip")) {
        case 1: clip.SetAudio(Clip);        break;
        case 2: clip.SetFileDropList(Clip); break;
        case 3: clip.SetImage(Clip);        break;
        case 4: clip.SetText(Clip);         break;
    }
    sp.DeleteStoredNumber("savedClip");
}

Edited by user Sunday, November 11, 2018 4:28:09 AM(UTC)  | Reason: Not specified

Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.