Jump to content

Magic Clip - You can define words in MS Word, but what


ioliver
 Share

Recommended Posts

Here's the code:

CODE
; Magic Clip.au3

;

; September 26, 2005

; This script will allow you to define, or Google a word or phrase in the clipboard.

ClipPut("")

While 1 ;Infinite Loop

;If WinActive("") Then ; You can use this code if you only want Magic Clip

; to work for certain applications. i.e. OpenOffice.org

$clip = ClipGet()

If $clip <> "" Then

$Magic = MsgBox(4,"Do you want to run Magic Clip?", $clip, 3)

If $Magic = 6 Then

Call ("Go")

Else

MsgBox(0, "Magic Clip", $clip & " will be available on the Clipboard for 25 seconds.", 3)

Sleep(25000)

ClipPut("")

EndIf

EndIf

;EndIf ; You can use this code if you only want Magic Clip

; to work for certain applications. i.e. OpenOffice.org

Sleep(5) ;Reduces the load this script puts on the CPU time

Wend

Func Go()

$define = MsgBox(4, "Do you want to define?", $clip, 3)

If $define = 6 Then

Run("C:\Program Files\Internet Explorer\iexplore.exe http://dictionary.reference.com/search?q=" & $clip)

ClipPut("")

Else

$google = MsgBox(4, "Do you want to Google?", $clip, 3)

If $google = 6 Then

Run("C:\Program Files\Internet Explorer\iexplore.exe http://www.google.com/search?q=" & $clip)

ClipPut("")

EndIf

EndIf

EndFunc

I just put this together. It could be better with some work, but it's kind of a concept for now.

While the script is running, you can look-up, or Google any word or pharse that you copy to the clipboard.

Let me know what you think.

Thanks,

Ian

Edited by ioliver

"Blessed be the name of the Lord" - Job 1:21Check out Search IMF

Link to comment
Share on other sites

i hate IE. why does evryone keep trying to make me use it.

also the app just kills the practial use of the clipboard IMO.

i would make it like this:

select something

hit a hotkey

back up the clip

copy the selection

look it up

put the old selection back

but thats just me.

Edited by w0uter

My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll

Link to comment
Share on other sites

i hate IE. why does evryone keep trying to make me use it.

also the app just kills the practial use of the clipboard IMO.

i would make it like this:

select something

hit a hotkey

back up the clip

copy the selection

look it up

put the old selection back

but thats just me.

Thanks Wouter,

Those are all great ideas. Do you know the command to open an URL, not using IE? I'm pretty sure there is one, but I can't remember it.

And, it does ,kind of, kill the function of the clipboard.

Thanks,

Ian

"Blessed be the name of the Lord" - Job 1:21Check out Search IMF

Link to comment
Share on other sites

or you could use a simple DOS command

_RunDOS("start *website*")

opens firefox. and if you dont have firefox itll blow up your computer

fails on urls with &'s in them.

(its option 0 in my _INetBrouwse btw ;))

My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll

Link to comment
Share on other sites

Progress...

CODE
; Magic Clip v2.au3

; Ian Oliver

; September 30, 2005

; This script will allow you to define, or Goolge a word or phrase in the clipboard.

; Notes:

; # = Windows Key; ^ = Ctrl Key

#include <GUIConstants.au3>

Dim $currentclip

Dim $newclip

Dim $newclips

HotKeySet("#z", "MagicClip")

;HotKeySet("#zd", "define") ; May be implemented later

;HotKeySet("#zg", "Google") ; May be implemented later

While 1 ; Infinite Loop - Keeps script running

Sleep(100) ; Reduces the load this script places on processor time

WEnd

Func MagicClip()

$currentclip = ClipGet()

Send("^c") ; Copy

$newclip = ClipGet()

$newclips = $newclip & "|" & $newclips

; Generated with Form Designer preview, thanks lookfar

GUICreate(" MagicClip", 404, 171, 433, 251, $WS_OVERLAPPEDWINDOW)

GUICtrlCreateLabel("Magic Clip the following word / phrase:", 8, 8, 183, 13)

$lbx_Clips = GUICtrlCreateList("", 8, 32, 185, 129, 0)

GUICtrlSetData(-1, $newclips)

$gbx_Clip = GUICtrlCreateGroup("gbx_Clip", 208, 24, 185, 105)

$rdo_Define = GUICtrlCreateRadio("Define", 216, 48, 73, 17)

GUICtrlSetState(-1, $GUI_CHECKED)

$rdo_Google = GUICtrlCreateRadio("Google", 216, 72, 73, 17)

$but_Go = GUICtrlCreateButton("Magic Clip", 264, 96, 75, 25)

$but_Cancel = GUICtrlCreateButton("Cancel", 216, 136, 75, 25)

$but_Exit = GUICtrlCreateButton("Exit", 312, 136, 75, 25)

GUICtrlSetTip($but_Exit, "Exit Magic Clip")

GUISetState(@SW_SHOW)

While 1

$msg = GuiGetMsg()

Select

Case $msg = $GUI_EVENT_CLOSE

ExitLoop

Case $msg = $but_Cancel

ExitLoop

Case $msg = $but_Exit

Call ("Quit")

Case $msg = $lbx_Clips

$text = GUICtrlRead($lbx_Clips)

MsgBox(0, "$lbx_Clips selected:", $text)

GUICtrlSetData($gbx_Clip, $lbx_Clips)

Case $msg = $but_Go

$sDefine = GUICtrlRead($rdo_Define)

$sGoogle = GUICtrlRead($rdo_Google)

If $sDefine = $GUI_CHECKED Then

Call ("define")

EndIf

If $sGoogle = $GUI_CHECKED Then

Call ("Google")

EndIf

EndSelect

WEnd

;Exit

; Run the GUI until the dialog is closed

While 1

$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop

Sleep(5) ; Reduces the load this script places on processor time

Wend

GUIDelete()

ClipPut($currentclip)

EndFunc ;==> MagicClip

Func define()

;$currentclip = ClipGet()

;Send("^c") ; Copy

;$newclip = ClipGet()

Run("C:\Program Files\Internet Explorer\iexplore.exe http://dictionary.reference.com/search?q=" & $newclip)

ClipPut($currentclip)

EndFunc ;==> define

Func Google()

;$currentclip = ClipGet()

;Send("^c") ; Copy

;$newclip = ClipGet()

Run("C:\Program Files\Internet Explorer\iexplore.exe http://www.google.com/search?q=" & $newclip)

ClipPut($currentclip)

EndFunc ;==> Google

Func Quit()

Exit

EndFunc ;==> Quit

@Wouter, I know, it still makes you use IE, and you don't like that. I'll get to that later.

@All, right now, I'm having trouble with some of the GUI functions.

1. I want the Group Box label to update when a 'word' is clicked in the list box... How can I do this?

2. My 'Cancel' button doesn't seem to work. I want the GUI to disapear, but the script to keep running.

Thanks for your help,

Comments welcome,

Ian

EDIT: Thanks lookfar for the GUI Builder, it's a big help.

Edited by ioliver

"Blessed be the name of the Lord" - Job 1:21Check out Search IMF

Link to comment
Share on other sites

Ok, here's the completed code:

CODE
; Magic Clip v2.au3

;

; September 30, 2005

; This script will allow you to define, or Goolge a word or phrase in the clipboard.

; Notes:

; # = Windows Key; ^ = Ctrl Key

#include <GUIConstants.au3>

Dim $currentclip

Dim $newclip

Dim $newclips

Dim $text

HotKeySet("#z", "MagicClip")

;HotKeySet("#zd", "define") ; May be implemented later

;HotKeySet("#zg", "Google") ; May be implemented later

While 1 ; Infinite Loop - Keeps script running

Sleep(100) ; Reduces the load this script places on processor time

WEnd

Func MagicClip()

$currentclip = ClipGet()

Send("^c") ; Copy

$newclip = ClipGet()

$newclips = $newclip & "|" & $newclips

; Generated with Form Designer preview, thanks lookfar

GUICreate(" MagicClip", 404, 171, 433, 251, $WS_OVERLAPPEDWINDOW)

GUICtrlCreateLabel("Magic Clip the following word / phrase:", 8, 8, 183, 13)

$lbx_Clips = GUICtrlCreateList("", 8, 32, 185, 129, 0)

GUICtrlSetData(-1, $newclips)

$gbx_Clip = GUICtrlCreateGroup($newclip, 208, 24, 185, 105)

$rdo_Define = GUICtrlCreateRadio("Define", 216, 48, 73, 17)

GUICtrlSetState(-1, $GUI_CHECKED)

$rdo_Google = GUICtrlCreateRadio("Google", 216, 72, 73, 17)

$but_Go = GUICtrlCreateButton("Magic Clip", 264, 96, 75, 25)

$but_Cancel = GUICtrlCreateButton("Cancel", 216, 136, 75, 25)

$but_Exit = GUICtrlCreateButton("Exit", 312, 136, 75, 25)

GUICtrlSetTip($but_Exit, "Exit Magic Clip")

GUISetState(@SW_SHOW)

While 1

$msg = GuiGetMsg()

Select

Case $msg = $GUI_EVENT_CLOSE

ExitLoop

Case $msg = $but_Cancel

ExitLoop

Case $msg = $but_Exit

Call ("Quit")

Case $msg = $lbx_Clips

$text = GUICtrlRead($lbx_Clips)

GUICtrlSetData($gbx_Clip, $text)

Case $msg = $but_Go

$sDefine = GUICtrlRead($rdo_Define)

$sGoogle = GUICtrlRead($rdo_Google)

If $sDefine = $GUI_CHECKED Then

Call ("define")

EndIf

If $sGoogle = $GUI_CHECKED Then

Call ("Google")

EndIf

EndSelect

WEnd

GUIDelete()

ClipPut($currentclip)

EndFunc ;==> MagicClip

Func define()

;$currentclip = ClipGet()

;Send("^c") ; Copy

;$newclip = ClipGet()

GUIDelete()

Run("C:\Program Files\Internet Explorer\iexplore.exe http://dictionary.reference.com/search?q=" & $text)

ClipPut($currentclip)

EndFunc ;==> define

Func Google()

;$currentclip = ClipGet()

;Send("^c") ; Copy

;$newclip = ClipGet()

GUIDelete()

Run("C:\Program Files\Internet Explorer\iexplore.exe http://www.google.com/search?q=" & $text)

ClipPut($currentclip)

EndFunc ;==> Google

Func Quit()

Exit

EndFunc ;==> Quit

It works like I want it to now.

Instructions: Once you start the script, select some text and use the shortcut Windows Key + z to run MagicClip.

Let me know what you think.

Ian

Edit: Added the instructions.

Edited by ioliver

"Blessed be the name of the Lord" - Job 1:21Check out Search IMF

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...