 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
rousni
Joined: 23 Mar 2006 Posts: 41
|
Posted: Thu Nov 08, 2007 11:48 am Post subject: Changing the clipboard from within the OnClipboardChange |
|
|
Is there any way to change the clipboard from within the label named OnClipboardChange (especially by: Clipboard = %Clipboard%) without launching repeatedly the same label?
Thanks |
|
| Back to top |
|
 |
engunneer
Joined: 30 Aug 2005 Posts: 6772 Location: Pacific Northwest, US
|
Posted: Thu Nov 08, 2007 7:51 pm Post subject: |
|
|
no - any change, even made by ahk, will launch the label again. you can always make logic involving a oneshot flag or other indicator to skip the second action. _________________
Unless otherwise noted, all code is untested.
Common Answers: 1.(Loops, Viruses, etc.) 2. Search 3.RTFM |
|
| Back to top |
|
 |
Serenity
Joined: 08 Nov 2004 Posts: 1010
|
Posted: Sun Aug 31, 2008 12:47 am Post subject: |
|
|
| engunneer wrote: | | you can always make logic involving a oneshot flag or other indicator to skip the second action. |
I tried this method but it has only reduced the number of loops, I still get duplicate entries in the clipboard and tooltip. Is there is a better way to implement it?
| Code: | #SingleInstance Force
#Persistent
OnClipboardChange:
; Thread, NoTimers, True ; helps reduce some of the repeats a little
; Critical ; makes it worse!!!
; SetBatchLines,-1 ; default 10ms works better
if c > 1 ; already running so ignore
{
return
}
else
{
ifwinactive, ahk_class MozillaUIWindowClass
{
c++
wingetactivetitle, title
title := RegExReplace( title, " -[\w ]+$" )
if a_eventinfo = 1 ; text
{
if clipboard contains http:// ; deal with urls first
{
if clipboard contains http://msdn.microsoft.com/en-us/library/
{
if clipboard not contains `r`n
{
link := clipboard
clipboard := title . "`n" . link
tooltip % title . "`n" . link
}
}
if clipboard contains http://www.autohotkey.com/forum/viewtopic.php ; clean up forum urls
{
if clipboard not contains `r`n
{
str := title . "`n" . RegExReplace( clipboard, "\&\w(.*)" )
clipboard := str
tooltip % str
}
}
}
}
c =
}
}
settimer, tooltip, -1000
return
tooltip:
tooltip
return |
_________________ "Anything worth doing is worth doing slowly." - Mae West
 |
|
| Back to top |
|
 |
SKAN
Joined: 26 Dec 2005 Posts: 5887
|
Posted: Sun Aug 31, 2008 2:30 am Post subject: |
|
|
| Serenity wrote: | | Is there is a better way to implement it? |
There might be a way with default method.. but here is a different method on how to Turn On/Off Clipboard monitoring.
| Code: | Gui +LastFound
DllCall( "SetClipboardViewer", UInt,WinExist() ), OnMessage( 0x308, "OnClipboardChange" )
Return ; // end of auto-execute section
OnClipboardChange() { ; The Clipboard Monitor
SetTimer, Mozilla, -1
; No return value required
}
Mozilla:
IfWinNotActive, ahk_class MozillaUIWindowClass
Return
OnMessage( 0x308, "" ) ; Turn Off
WinGetActiveTitle, Title
Title := RegExReplace( Title, "(- \w+ \w+$)" )
If Clipboard contains http://msdn.microsoft.com/en-us/library/
If Clipboard not contains `r`n
{
link := Clipboard
Clipboard := Title . "`n" . link
Tooltip % Title . "`n" . link
SetTimer, Tooltip, -2000
}
OnMessage( 0x308, "OnClipboardChange" ) ; Turn On
Return
Tooltip:
Tooltip
Return |
Edit: WM_DRAWCLIPBOARD = 0x308 _________________ SKAN - Suresh Kumar A N |
|
| Back to top |
|
 |
Serenity
Joined: 08 Nov 2004 Posts: 1010
|
Posted: Sun Aug 31, 2008 11:52 am Post subject: |
|
|
SKAN, Thank you!! I'm so happy now this is working.  _________________ "Anything worth doing is worth doing slowly." - Mae West
 |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|