Zhorn Software
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Go down
avatar
Gene95
Posts : 52
Join date : 2018-04-22
Location : New York

Paste Board feature Empty Paste Board feature

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?
avatar
Guest
Guest

Paste Board feature Empty Re: Paste Board feature

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,
avatar
Gene95
Posts : 52
Join date : 2018-04-22
Location : New York

Paste Board feature Empty Paste Board feature

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.
avatar
Guest
Guest

Paste Board feature Empty Re: Paste Board feature

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,
avatar
Gene95
Posts : 52
Join date : 2018-04-22
Location : New York

Paste Board feature Empty Paste Board feature

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.
avatar
Guest
Guest

Paste Board feature Empty Re: Paste Board feature

Thu May 03, 2018 4:40 pm
Paste Board feature RGUpEcA


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)
}



avatar
lccd
Posts : 4
Join date : 2018-11-13

Paste Board feature Empty Re: Paste Board feature

Tue Nov 13, 2018 8:15 am
Sooyke wrote:

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)
}





It seems missing something here

Line 96:     NumPut(&StringToSend, CopyDataStruct,
avatar
Guest
Guest

Paste Board feature Empty Re: Paste Board feature

Tue Nov 13, 2018 8:44 am
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

  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



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)
}



You are right , the complete line must  be    NumPut(&StringToSend, CopyDataStruct , 8  ) .It is only tested with ahk 32bit .

I guess the "  8 ) "  turned into Cool emoticon and i just deleted that without realising it was part of the code  !


Last edited by Sooyke on Tue Nov 13, 2018 11:44 am; edited 2 times in total (Reason for editing : character 8 ) turned into emoticon!)
avatar
lccd
Posts : 4
Join date : 2018-11-13

Paste Board feature Empty Re: Paste Board feature

Wed Nov 14, 2018 7:51 am
Sooyke wrote:

You are right , the complete line must  be    NumPut(&StringToSend, CopyDataStruct , 8  ) .It is only tested with ahk 32bit .

I guess the "  8 ) "  turned into Cool emoticon and i just deleted that without realising it was part of the code  !

Thank you, it works on my 32bit AHK in Win10, but not in 64bit AHK. Cool

Just wondering, what is the cause for the error on 64bit version AHK? Is it AHK's side problem?
avatar
Guest
Guest

Paste Board feature Empty Re: Paste Board feature

Wed Nov 14, 2018 12:29 pm
The CopyDataStruct uses A_Prtsize in the send command and this is either 4 (32-bit) or 8 (64-bit). Stickies is 32bit the offset it is looking at would be wrong if A_Prtsize returns 8 with ahk64.
avatar
lccd
Posts : 4
Join date : 2018-11-13

Paste Board feature Empty Re: Paste Board feature

Wed Nov 14, 2018 3:30 pm
Sooyke wrote:The CopyDataStruct uses A_Prtsize in the send command and this is either 4 (32-bit) or 8 (64-bit). Stickies is 32bit the offset it is looking at would be wrong if A_Prtsize returns 8 with ahk64.

Okay...it is totally out of my knowledge, I will stick with 32 bit AHK.

Thank you for your code, I spent a long time to search a code work with Stickies.
avatar
Guest
Guest

Paste Board feature Empty Re: Paste Board feature

Thu Nov 15, 2018 8:58 am
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

  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

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,"Uptr")
    NumPut(len , CopyDataStruct, A_PtrSize) 
    NumPut(&StringToSend, CopyDataStruct, 2*A_PtrSize) 

    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)
}



This should work on 64bit ahk  ( and i tested it on 32bit too ).I hope nothing else is broken now.......... Wink
avatar
lccd
Posts : 4
Join date : 2018-11-13

Paste Board feature Empty Re: Paste Board feature

Sun Nov 18, 2018 4:58 pm
Sooyke wrote:This should work on 64bit ahk  ( and i tested it on 32bit too ).I hope nothing else is broken now.......... Wink

Thank you for updating the 64bit version.
Works great on my Win10, AHK 64bit . Laughing
Sponsored content

Paste Board feature Empty Re: Paste Board feature

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