topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Friday March 29, 2024, 1:20 am
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: Clipboard to text file  (Read 5955 times)

rgdot

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 2,192
    • View Profile
    • Donate to Member
Clipboard to text file
« on: October 25, 2016, 04: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

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 5,286
    • View Profile
    • Donate to Member
Re: Clipboard to text file
« Reply #1 on: October 26, 2016, 01: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 [Select]
  1. FileAppend, %clipboard%`r`n, ‪C:\Users\RG\Desktop\clip1.txt

rgdot

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

Strange.

skwire

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 5,286
    • View Profile
    • Donate to Member
Re: Clipboard to text file
« Reply #3 on: October 26, 2016, 01:25 PM »
Did you try running it with admin rights?

rgdot

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 2,192
    • View Profile
    • Donate to Member
Re: Clipboard to text file
« Reply #4 on: October 26, 2016, 01: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,192
    • View Profile
    • Donate to Member
Re: Clipboard to text file
« Reply #5 on: October 26, 2016, 01:43 PM »
For example something as simple as this works fine

Capslock::Shift
return

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • View Profile
    • Donate to Member
Re: Clipboard to text file
« Reply #6 on: October 26, 2016, 03: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,192
    • View Profile
    • Donate to Member
Re: Clipboard to text file
« Reply #7 on: October 26, 2016, 09:56 PM »
I believ %Clipboard% is already Text type %ClipboardAll% would be other formats

rgdot

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 2,192
    • View Profile
    • Donate to Member
Re: Clipboard to text file
« Reply #8 on: October 26, 2016, 10:29 PM »
As expected something trivial was needed

:down:
Code: Autohotkey [Select]
  1. FileAppend, %clipboard%`r`n, ‪C:\Users\RG\Desktop\clip1.txt

:up:
Code: Autohotkey [Select]
  1. FileAppend, %clipboard%`r`n, %A_WorkingDir%\clip1.txt

Thanks guys :)

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • View Profile
    • Donate to Member
Re: Clipboard to text file
« Reply #9 on: October 27, 2016, 07:22 AM »
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.  :)