DonationCoder.com forum
 
Read-only archive. This is a static copy of the DonationCoder.com forum. Reading and searching work as before; logging in, posting and private messages do not.
Archive of 2026-10-21 · About this archive · Main site

Author Topic: Clipboard to text file  (Read 10,325 times)

rgdot

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 2,197
Clipboard to text file
« on: October 25, 2016, 09:09 PM »
This I guess is not a request but a noob question  :-[

Running AHK, compiled a exe, what is missing from

#Persistent
OnClipboardChange:
FileAppend, %clipboard%, ‪C:\Users\RG\Desktop\clip1.txt
return

to keep all copied text in the text file?


skwire

  • I eat Coding Snacks for breakfast...
  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 5,297
    • Participated in NANY Challenge Seventeen Times
    • Coding Snacks
    • Superboy Coder
    • Cody Award
    • Volunteers/Staff
    • Gathering Badge
Re: Clipboard to text file
« Reply #1 on: October 26, 2016, 06:58 AM »
It works here for me.  However, you're trying to write to a UAC-protected folder so you will have to have either have admin rights or run the executable with admin rights.  Alternately, you could write to a non-UAC-protected folder.  Also, I'd add a CRLF when writing out the clipboard contents like this:

Code: ( autohotkey)
FileAppend, %clipboard%`r`n, ‪C:\Users\RG\Desktop\clip1.txt

rgdot

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 2,197
Re: Clipboard to text file
« Reply #2 on: October 26, 2016, 02:42 PM »
Desktop is UAC protected?  Moved it to Documents and doesn't work either.

Strange.

skwire

  • I eat Coding Snacks for breakfast...
  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 5,297
    • Participated in NANY Challenge Seventeen Times
    • Coding Snacks
    • Superboy Coder
    • Cody Award
    • Volunteers/Staff
    • Gathering Badge
Re: Clipboard to text file
« Reply #3 on: October 26, 2016, 06:25 PM »
Did you try running it with admin rights?

rgdot

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 2,197
Re: Clipboard to text file
« Reply #4 on: October 26, 2016, 06:39 PM »
Yes I did, not really sure what is going on, I will try other ready made scripts and see if I can get any hints. My fault for spending more time on windows again  :P

rgdot

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 2,197
Re: Clipboard to text file
« Reply #5 on: October 26, 2016, 06:43 PM »
For example something as simple as this works fine

Capslock::Shift
return

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • Coding Snacks
Re: Clipboard to text file
« Reply #6 on: October 26, 2016, 08:48 PM »
This I guess is not a request but a noob question  :-[

Running AHK, compiled a exe, what is missing from

#Persistent
OnClipboardChange:
FileAppend, %clipboard%, ‪C:\Users\RG\Desktop\clip1.txt
return

to keep all copied text in the text file?



I don't know if it makes any difference but the thing I notice where your script differs from the example is the example has a Return directly after the #Persistent directive.  Also I would probably use the A_EventInfo to find out if the clipboard data is of type text.

rgdot

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 2,197
Re: Clipboard to text file
« Reply #7 on: October 27, 2016, 02:56 AM »
I believ %Clipboard% is already Text type %ClipboardAll% would be other formats

rgdot

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 2,197
Re: Clipboard to text file
« Reply #8 on: October 27, 2016, 03:29 AM »
As expected something trivial was needed

:down:
Code: ( autohotkey)
FileAppend, %clipboard%`r`n, ‪C:\Users\RG\Desktop\clip1.txt

:up:
Code: ( autohotkey)
FileAppend, %clipboard%`r`n, %A_WorkingDir%\clip1.txt

Thanks guys :)

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • Coding Snacks
Re: Clipboard to text file
« Reply #9 on: October 27, 2016, 12:22 PM »
I believ %Clipboard% is already Text type %ClipboardAll% would be other formats

True.  Also you can test %ClipBoard% for blank.  I think there is an unwritten rule stuff cannot work the first time.  Once you get things fixed they often look pretty close to what you started with.  :)

Original address: https://www.donationcoder.com/forum/index.php?topic=43151.0