Copy highlighted text to specific file

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
wsimon98
Posts: 7
Joined: 29 Oct 2018, 20:26

Copy highlighted text to specific file

14 Nov 2018, 01:31

I need something basic... And I have tried many ways, and am not getting anywhere. I am wondering if it has to with the file type.
I need to be able to copy an IP address and place it to the exception.sites file for Java, preferably without removing other http://IPaddresses listed, however, it's not critical.

Here's what I thought would work, and did not.

Code: Select all

#^C::

FileAppend Http://%Clipboard%, "C:\Users\wsimon\AppData\LocalLow\Sun\Java\Deployment\security\exception.sites"

return
User avatar
Scr1pter
Posts: 1272
Joined: 06 Aug 2017, 08:21
Location: Germany

Re: Copy highlighted text to specific file

14 Nov 2018, 07:56

Can't test the code right now.
What exactly does not work?

Have you also tried it just with %Clipboard% without the Pre String?
If the target file contains simple text, I don't think the extension matters.

Have you generally used FileAppend so far?
(Just to avoid some beginner mistakes.)

Regards
Please use [code][/code] when posting code!
Keyboard: Logitech G PRO - Mouse: Logitech G502 LS - OS: Windows 10 Pro 64 Bit - AHK version: 1.1.33.09
wsimon98
Posts: 7
Joined: 29 Oct 2018, 20:26

Re: Copy highlighted text to specific file

14 Nov 2018, 09:43

I have not played with FileAppend much, but I did get something to work while waiting for the post to be approved. Here's what I ended up coming up with...

Code: Select all

#^C::

AutoTrim Off 
ClipboardOld = %ClipboardAll%
Clipboard =  
Send ^c
ClipWait 1
if ErrorLevel
    return

StringReplace, Hotstring, Clipboard, ``, ````, All  
StringReplace, Hotstring, Hotstring, `r`n, ``r, All
StringReplace, Hotstring, Hotstring, `n, ``r, All
StringReplace, Hotstring, Hotstring, %A_Tab%, ``t, All
StringReplace, Hotstring, Hotstring, `;, ```;, All
Clipboard = %ClipboardOld%  
SetTimer, MoveCarrot, 10

InputBox, Hotstring, New Exception, Is this the IP address you would like to add to exception.sites for Java?(please keep in mind that if you do not already have at least one entry as an exception, this will not work properly,,,,,,,https://%Hotstring%

if ErrorLevel <> 0 
    return

FileAppend, `n%Hotstring%, C:\Users\%A_Username%\AppData\LocalLow\Sun\Java\Deployment\security\exception.sites
Reload
Sleep 200
MsgBox, 4,, The IP address just added appears to be improperly formatted. 
IfMsgBox, Abort
return

MoveCarrot:
IfWinNotActive, New Hotstring
    return

Send {HOME}
Loop % StrLen(Hotstring) + 4
    SendInput {Right}
SetTimer, MoveCarrot, Off
return

#Hotstring R
 

#SingleInstance force
It's a modification of a script I found mixed in with another from a scripter https://www.reddit.com/r/AutoHotkey/com ... y_scripts/

But I'd really like to understand how to make a script that will add the clipboard to a file with a hotkey or even a hotstring.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: doanmvu, RSable and 389 guests