Help with using TF Library with #Include

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Tavem
Posts: 13
Joined: 14 Aug 2017, 09:02

Help with using TF Library with #Include

16 Aug 2017, 09:45

Hi,
I have been trying to install the TF Library for AHK
But none of the TF functions run, I'm not sure if I have coded something wrong or used #Include incorrectly

Code: Select all

;#Include C:\Users\User1\Documents\AutoHotkey\Lib\TF.ahk ;TF.ahk is also installed in C:\programfiles\AutoHotKey\Lib (tried it here)
F3::
WinActivate, ahk_class Chrome_WidgetWin_1
Sleep, 333
Send, {Control Down}{u}{Control Up}
Sleep, 450
Send, {Control Down}{a}{Control Up}
Sleep, 450
Send, {Control Down}{c}{Control Up}
Sleep, 200
Sleep, 500
Send, {Control Down}{w}{Control Up}
FileDelete, C:\Users\User1\Desktop\Test\Background.txt
Sleep, 500
CorrectRead := ClipBoard
Sleep, 500
FileAppend, %CorrectRead%, C:\Users\User1\Desktop\Test\Background.txt
#Include C:\Users\User1\Documents\AutoHotkey\Lib\TF.ahk ;TF.ahk is also installed in C:\programfiles\AutoHotKey\Lib
TF_ReadLines("C:\Users\User1\Desktop\Test\Background.txt",1,10)
MsgBox % TF_Readlines("C:\Users\User1\Desktop\Test\Background.txt",1,10)
Return ;no message box and when I tried to use TF_Removeblanklines nothing happened as well

;#Include C:\Users\User1\Documents\AutoHotkey\Lib\TF.ahk ;TF.ahk is also installed in C:\programfiles\AutoHotKey\Lib(Tried it here)
EDIT:Now receiving this error
Error at Line 48 in #Include tf.afk
Line Text: TF_Countlines(text)
Error: Parameters of hotkeys functions must be optional
The program will now exit


Any ideas why the library is not running?
TF.ahk
This is the TF Library File I am Using
(46.34 KiB) Downloaded 23 times
Rindis
Posts: 213
Joined: 23 Dec 2013, 13:58
Location: Norway
Contact:

Re: Help with using TF Library with #Include

17 Aug 2017, 02:45

Try placing the TF.ahk file directly in the folder where your script is, and use

Code: Select all

#Include tf.ahk
at the top of your code
Guest

Re: Help with using TF Library with #Include

17 Aug 2017, 04:33

The TF lib looks fine so should work.

If it is actually in "C:\programfiles\AutoHotKey\Lib" (are you sure you're not missing a space there between "program" and "files" ? there is no need to #include TF as AutoHotkey will automatically find it.
So remove / comment all includes, make sure TF.ahk it is EITHER in
"C:\program files\AutoHotKey\Lib"
or
"C:\Users\User1\Documents\AutoHotkey\Lib\" <- this one is easiest I suppose

Now run the script again. If there is no error message and the MsgBox is empty chances are the file you are trying to read from isn't there. Perhaps the script doesn't have the right to write to that Desktop location, try your Documents folder.

You can a MsgBox below your FileAppend command to check if writing the file was successful
MsgBox % ErrorLevel
It should show a zero (0) if OK, if something went wrong it shows one (1).

To store the result of TF_Readlines you should assign it to a variable MyVar:=TF_ReadLines(...)

TF_Removeblanklines() will by default create a copy of the source file, check if you can see a file called "Background_copy.txt" - if it isn't there, chances are background.txt didn't exist (e.g. the FileAppend command hasn't work correctly).

Notes

- if you can get it to work, you can use TF_Save() to write the file as well, it will automatically delete + create anew file so you don't have to use a FileDelete + FileAppend.
- if there is no specific reason to save to a file you can work directly with variables, so just assign the clipboard to a variable and use that like so:
MyVar:=TF_ReadLines(CorrectRead,1,10) ; not using a file but a variable

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Anput, Google [Bot], Joey5, Nerafius, RandomBoy and 154 guests