iason
Joined: 01 Nov 2005 Posts: 135
|
Posted: Sat Nov 29, 2008 6:56 pm Post subject: Fast copy-pasting between applications |
|
|
A simple idea aspirant to ease everyday copy-pasting at least for eternal beginners like me. It reduces the need of a clip manager since you can have your clips (or what else) inside files. Call it with a Hotkey, select, hit the road with Esc. Feel free to tweak shamelessly.
| Code: |
#SingleInstance force
; YOU CAN DEFINE A SPECIFIC WINDOW TO COPY FROM
; If you don't it prompts all open windows to choose
; If you do it will get you right to this one
; (which it may contain your copy-clips):
defineWindow =
Sleep, 100
WinGetActiveTitle, WorkingWindowTitle ; Retrieve working window title
clipsaved := clipboardAll ; to leave Clipboard untouched...
Sleep, 100
clipboard = ; empty clipboard
if (defineWindow)
{
WinActivate, %defineWindow%
GoSub, FinalAction
}
Winget, AllWins, list ; get all windows' IDs
Loop, %AllWins%
{
Wingettitle, WinTitle, % "ahk_id " AllWins%A_Index%
WinTitle%A_Index% = %WinTitle% ; store titles in array
}
WinCount = 0
Gui Font, s8, Tahoma
Gui Margin, 9,5
Loop %AllWins% ; list win titles in GUI
{
If WinTitle%A_Index% in ,Program Manager,%WorkingWindowTitle%
Continue ; Exclude no-name, Program manager, working win
But := WinCount + 1
Gui Add, Text, x5 gexec, % WinTitle%A_Index%
Gui Add, Button, w0 h0 gExec, % WinTitle%A_Index%
WinCount++
}
if (!WinCount) ; If no other window is open
{
MsgBox, , FastCopyPaste, Hey friend you don`'t have any other window. Exit.
WinActivate, %WorkingWindowTitle%
clipboard = clipsaved ; Restore Clipboard
Exitapp
}
Gui, Show, , FastCopyPaste
WinGetPos, , , WW, , FastCopyPaste ; Repos win if too small to show title
if (WW<500)
{
sysget, Mon, Monitorworkarea
scwidth := MonRight - MonLeft
WinMove, FastCopyPaste, , (scwidth/2)-(250), , 500
}
; show hand cursor
hCurs:=DllCall("LoadCursor","UInt",NULL,"Int",32649,"UInt")
OnMessage(0x200,"WM_MOUSEMOVE") ;cursor function
Return
; --- END OF AUTOEXEC SECTION
Exec:
WinActivate, %A_GuiControl%
FinalAction:
Sleep, 50
CoordMode, ToolTip, Screen
ToolTip, Select what you want to copy to Window •%WorkingWindowTitle%• and press Esc, 0, 0
KeyWait, Esc, D
ToolTip
send ^c
ClipWait, 0.5, 1
WinActivate, %WorkingWindowTitle%
if (!clipboard)
{
MsgBox, Nothing was selected/copied. Exit.
WinActivate, %WorkingWindowTitle%
clipboard := clipsaved ; Restore Clipboard
Exitapp
}
sleep 100
Send, ^v
clipboard := clipsaved ; Restore Clipboard
Exitapp
GuiEscape:
GuiClose:
Exitapp
Return
WM_MOUSEMOVE(wParam,lParam)
{
IfWinActive, FastCopyPaste
{
Global hCurs
MouseGetPos,,,,ctrl
ifinstring, ctrl, Static
DllCall("SetCursor","UInt",hCurs)
}
Return
}
|
_________________ help to be helped |
|