Share
Go down
Posts : 5
Join date : 2018-04-22
Location : Florida
View user profile

Paste Board feature

on Sun Apr 22, 2018 6:05 pm
Would it be possible to have a feature where anything you copy is automatically pasted into a selected sticky.  This would be very helpful when trying to take notes from the screen.  This feature is currently available in the text editor NoteTab but would be a lot more useful if I could go directly to a sticky.  Any thoughts?
Posts : 17
Join date : 2018-04-28
View user profile

Re: Paste Board feature

on Wed May 02, 2018 8:40 am
I remember that someone wrote a script to do it with stickies ( AHK ) it was only a few lines long . Unfortunately the old forum data is no longer searchable.
You could take a look at AHK to rewrite it.  ( autohotkey.com )

Greetings,
Posts : 5
Join date : 2018-04-22
Location : Florida
View user profile

Paste Board feature

on Wed May 02, 2018 1:00 pm
Thanks for the reply.  If I had time I would try auto hotkey but I also use a text editor called NoteTab light which has this feature.  Its just a little clunky to have to switch to it to copy and paste to a sticky.  I was hoping to eliminate a step.
Posts : 17
Join date : 2018-04-28
View user profile

Re: Paste Board feature

on Wed May 02, 2018 4:19 pm
Code:
 If I had time I would try auto hotkey

Maybe i did not explain that autohotkey is not an editor but a scripting language like perl or python you have to write the code to have the action you want the clipboard and sticky to do.
Greetings,
Posts : 5
Join date : 2018-04-22
Location : Florida
View user profile

Paste Board feature

on Wed May 02, 2018 11:32 pm
I researched it and that is why I stated "If I had more time", to learn, program, debug and implement.
Posts : 17
Join date : 2018-04-28
View user profile

Re: Paste Board feature

on Thu May 03, 2018 4:40 pm



Because i had some time i looked at the api provided for stickies and existing code on AHK website.

The code adds a MenuItem to a sticky " set4paste" that marks the sticky as target for pasting (sets it to blue colour) and enables the hotkeys.
There are 3 hotkeys:


  • control alt v    to paste clipboard to target
  • control alt space  to send "newline" to target
  • control alt end    to disconnect the sticky as target and disables the hotkey


My thanks to "noname" for the Code examples using the stickies api calls much appreciated!

Tested on win10 pro with ahk 1.1.28.02  32bit version ( i guess it will not work with the 64bit version)


Code:

#noenv
SetTitleMatchMode, slow
DetectHiddenWindows On
SetTitleMatchMode 2
setworkingdir:=a_scriptdir

TargetScriptTitle = ZhornSoftwareStickiesMain


OnMessage(0x4a, "Receive_WM_COPYDATA")
send_("do register",20)
if errorlevel
    {
    msgbox %errorlevel% in return code is stickies running?
    exit
    }
sleep 500
send_("do stickymenuadd set4paste set4paste",20)
return

set4paste:
  Hotkey, ^!v, On
  Hotkey, ^!end, On
  Hotkey, ^!space, On
  ToSend=get desktop %sid% colour
  send_(tosend,20)
  
  colour:=regexreplace(copyofdata,"^.+ ")
  ToSend=set desktop %sid% colour 214,214,255
  send_(tosend,20)
return


;------------ hotkey control+alt+v paste to sticky -----------------
^!v::
  ToSend=do desktop %sid% appendpaste
  send_(tosend,20)
return

;------------ hotkey control+alt+end  removes the action ------------
^!end::
  ToSend=set desktop %sid% colour %colour%
  send_(tosend,20)
  Hotkey, ^!v, Off
  Hotkey, ^!end, Off
  Hotkey, ^!space, On
return

;------------ hotkey control+alt+space  send newline character -------
^!space::
  ToSend=get desktop %sid% handle
  send_(tosend,20)
  handle:=regexreplace(CopyOfData,".+ (\d+)$","$1")
  
  ControlSend, ,`n,ahk_id %handle%
return

Receive_WM_COPYDATA(wParam, lParam)
{
 Global CopyOfData ,sid
 ID                := NumGet(lParam + 0)
 len               := NumGet(lParam + A_PtrSize)
    StringAddress     := NumGet(lParam + 2*A_PtrSize)
  
    VarSetCapacity(CopyOfData, len,0)
    CopyOfData:= StrGet(StringAddress,len,"cp0")
  
ifinstring,CopyOfData,set4paste
    {
    sid:=regexreplace(CopyOfData,".*set4paste (\w+)$","$1")
    settimer,set4paste,-20
    return true
    }
ifinstring,CopyOfData,will send
    SoundBeep


return true
}

Send_(StringToSend,IDc)
{
global TargetScriptTitle


    DetectHiddenWindows On
    SetTitleMatchMode 2

    VarSetCapacity(CopyDataStruct, 3*A_PtrSize, 0)
    
    StringToSend=api %StringToSend%
    len := StrPutVar(StringToSend, StringToSend, "cp0")+1

    NumPut(IDc          , CopyDataStruct, 0)
    NumPut(len , CopyDataStruct, 4)  
    NumPut(&StringToSend, CopyDataStruct,  

    SendMessage, 0x4a, %A_ScriptHwnd%, &CopyDataStruct,, %TargetScriptTitle%
    
  if (errorlevel="fail")
 {
  MsgBox SendMessage failed. Does the target application runs?
 
 }
  
    return  
}

StrPutVar(string, ByRef var, encoding)
{
    VarSetCapacity(var, StrPut(string, encoding) * ((encoding="UTF-16"||encoding="CP1200") ? 2 : 1))
    return StrPut(string, &var, encoding)
}



Sponsored content

Re: Paste Board feature

Back to top
Permissions in this forum:
You can reply to topics in this forum