AutoHotkey Community

It is currently May 26th, 2012, 1:03 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: December 15th, 2007, 1:47 pm 
Offline

Joined: November 1st, 2005, 4:44 am
Posts: 135
What it does: copies something from a window and pastes to another, leaving the Clipboard untouched, an the user making 2 moves in total (1 hotkey + 1 click).

For best results please assign to a hotkey of your choise.
The script was made using only AHK recources.
Probably the idea has been already implemented. Suggestions welcome as always.

Code:
SetBatchLines, 10ms

WinGetActiveTitle, ActiveWinTitle      ; Retrieve active window title

clipsaved := clipboard    ; Leave Clipboard untouched
clipboard =               ; Empty clipboard
Sleep, 100                ; Increase reliability
Send, ^c
Sleep, 100
if (!clipboard)           ; If clipboard is empty
 {
  MsgBox, Nothing has been selected/copied.
  clipboard := clipsaved    ; Restore Clipboard
  clipsaved =             ; Unblock memory
  Return
 }

Winget, AllWins, list                ; Retrieve all open windows' IDs
 Loop, %AllWins%
 {
  Wingettitle, WinTitle, % "ahk_id " AllWins%A_Index%
  WinTitle%A_Index% = %WinTitle%     ; Store win titles in array
 }

WinCount = 0
Gui Font, s8, Tahoma
Gui Margin, 9,5
Loop %AllWins%                      ; List win titles in a GUI
 {
  If WinTitle%A_Index% in ,Program Manager,%ActiveWinTitle%
   Continue                         ; Exclude no-name, Program manager and initial window
  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, No window exists but the one you are working on.
  clipboard = clipsaved             ; Restore Clipboard
  clipsaved =                       ; Unblock memory
  Return
 }

Gui, Show, , Quick Copy From Window to Window ...

; Resize/reposition window if too small
WinGetPos, , , WW, , Quick Copy From Window to Window ...   
if (WW<300)
 {
  sysget, Mon, Monitorworkarea
  scwidth := MonRight - MonLeft
  WinMove, Quick Copy From Window to Window ..., , (scwidth/2)-(150), , 300
 }

hCurs:=DllCall("LoadCursor","UInt",NULL,"Int",32649,"UInt")
OnMessage(0x200,"WM_MOUSEMOVE")

Return

; ------- END OF AUTOEXECUTE SECTION

Exec:
WinActivate, %A_GuiControl%          ; Activate target win
Send, ^v                             ; Paste on target win
clipboard := clipsaved               ; Restore Clipboard
ExitApp
Return

GuiEscape:                           ; Dismiss on 'Esc'
GuiClose:
Exitapp
Return

WM_MOUSEMOVE(wParam,lParam)          ; Function for 'hand' cursor
{
 IfWinActive, Quick Copy From Window to Window ...
  {
   Global hCurs
   MouseGetPos,,,,ctrl
   ifinstring, ctrl, Static
   DllCall("SetCursor","UInt",hCurs)
  }
 Return
}

_________________
help to be helped


Report this post
Top
 Profile  
Reply with quote  
 Post subject: suggestion:
PostPosted: December 16th, 2007, 10:43 pm 
Use ClipWait instead of sleep


Report this post
Top
  
Reply with quote  
 Post subject: Re: suggestion:
PostPosted: December 17th, 2007, 9:54 am 
Offline

Joined: November 1st, 2005, 4:44 am
Posts: 135
JDP wrote:
Use ClipWait instead of sleep
Certainly a good idea. Trully that was my first venture, but i noticed that the script was not picking the copy reliably - i have no idea why...

_________________
help to be helped


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 17th, 2007, 3:59 pm 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
Nice! To keep non-text clipboards, use
Code:
clipsaved := clipboardALL


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 20th, 2007, 7:42 pm 
Offline

Joined: November 1st, 2005, 4:44 am
Posts: 135
Laszlo wrote:
Code:
clipsaved := clipboardALL
Thanks! I missed that...

_________________
help to be helped


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], sjc1000, Yahoo [Bot] and 46 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group