AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Fast copy-pasting between applications

 
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
iason



Joined: 01 Nov 2005
Posts: 135

PostPosted: Sat Nov 29, 2008 6:56 pm    Post subject: Fast copy-pasting between applications Reply with quote

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
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group