This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Orwell's profile picture

CC-copy -- Your solution to servers without HTTP API

Started by Orwell, 09 October 2012 - 01:00 PM
Orwell #1
Posted 09 October 2012 - 03:00 PM
Hi all!

After having some positive responses on my program in this thread and receiving some PM's about it, I decided to enhance it a bit and give it it's own thread on the forums.
The program reads text files (typically lua programs) and 'types' it over to the Minecraft window. You should have the Minecraft window open and have a ComputerCraft terminal open in there.
This is written in C++ and is windows only, I'm not planning on porting it to linux or mac. Both source code and binary are available as an attachment to this thread.

CC-copy is a command line program. If you don't know how to use it (for example, if you just double click it and it closes right away), ask here for help. I don't have the energy for explaining that anymore though. :P/>/> Someone else might. Usage is as follows:

CC-copy [-w <window>] [-t <interval>] [-s <startup>] [--old] file1 file2 ...

  <window> is the title of the Minecraft window. (Typically 'Minecraft' or 'Tekkit')
  <interval> is the time between key presses in milliseconds.
  <startup> is the time that the program waits after switching to the Minecraft window (in milliseconds).
  use  the parameter '--old' if you use ComputerCraft version 1.33 or lower! If you don't, text will be screwed.

If you find some bugs or have some suggestions, let me know in this thread. :)/>/>

UPDATE: CC-copy keeps indentation intact now!

PS: I didn't do the fancy titles and pictures, it's just a simple utility. Use it if you need it. ;)/>/>
TehSomeLuigi #2
Posted 09 October 2012 - 07:36 PM
I need something like this but *no linux* sadface. I'll probably write a simple program for this though.
Orwell #3
Posted 10 October 2012 - 01:04 AM
I need something like this but *no linux* sadface. I'll probably write a simple program for this though.

I'm working on a Linux version after all. I'm trying to do this without making the code messy. : )
I also updated the program to keep the formatting of the code (mostly indentation, both tabs and spaces). This works for both CC 1.32 as CC 1.43.
gknova61 #4
Posted 16 October 2012 - 08:51 AM
Would it be possible for you to add a terminate key we can press when in CMD?
CoolisTheName007 #5
Posted 16 October 2012 - 09:55 AM
Hello Orwell, I just tested your second version and carriage returns aren't being written, making the behavior of erasing previous tabs on the new line erase part of the program.
EDIT: to clarify, when editing in Notepad++, pressing return (r) conserves the indentation, eg. copies the tabs from the current line to the new line. Your script seems to be skipping the new line + copying tabs process, and jumps directly to the clean the previous line tabs, and write the new line tabs.

Your original script does get files with (no tabs in the file) correctly typed, except in case of a slightly less than ideal connection, in which it misses or 'jams' characters, typing them in no particular order.
In that case, only increasing the delay between keystrokes solves the issue, and that's only possible with your second version.

To put it simply, none of the versions will work for me.
I've attached a sample file I copied, test, and the copies made by your scripts, test_copied_version1 using your first script and test_copied_version2 using the newer one.

I also verified that these 2 characters are ignored : ´ç
But that's a minor issue compared with the previous one.

PS: I also made a very basic computercraft program to check whether or not two files match, that prints the locations of the mismatches, typechecker.txt , which I attached. Usage is typechecker fileA fileB
Orwell #6
Posted 20 October 2012 - 09:53 PM
Thank you CoolisTheName007 for the extensive testing. What version of ComputerCraft are you using? For all versions from 1.41 up to now, everything seems to work just fine. Except for the '^' (it needs a space afterwards, easily fixed). ç actually works too. only ´ doesn't work cause it's not supported by CC (it's not in the 7-bit ASCII set) :)/>/> are you using version 1.31?
Orwell #7
Posted 20 October 2012 - 10:59 PM
I'm quite certain you use CC 1.33 or lower (Tekkit?). I've identified the bugs in that version, they can't be handled in a way that still works for the newer versions of CC. So I've added the command line parameter '–old' for the people using version 1.33 or lower. The OP has been updated with the new version. I wanna thank you again for posting the elaborate bug report and tests, it really helps me out. Please post any more feedback or bug reports if you have some. : )
Cruor #8
Posted 24 October 2012 - 07:07 PM
This looks more like a utility to me, would you like for it to be moved over to that section? Quote this post or send me a pm if you do ^_^/>/>

Edit: oh, didnt see that it was you who reported that, either way, the option is still yours.
Orwell #9
Posted 24 October 2012 - 09:44 PM
This looks more like a utility to me, would you like for it to be moved over to that section? Quote this post or send me a pm if you do ^_^/>/>

Edit: oh, didnt see that it was you who reported that, either way, the option is still yours.

Yes, if you agree that it's place is in the utility section, then I'd like this thread to be moved there. : )
Naab007 #10
Posted 08 November 2012 - 09:18 PM
Nice app, Now i just have to find a C++ compiler.. what would you recommend?
CoolisTheName007 #11
Posted 12 November 2012 - 09:45 AM
Nice app, Now i just have to find a C++ compiler.. what would you recommend?
Are you going to change the program? Cause you don't need a compiler to run it.
Orwell #12
Posted 14 November 2012 - 11:28 AM
You can just download the cc-copy_bin.zip package and run the cc-copy.exe file in it from command line. If you still want to compile it for some reason, I used Dev-C++ and the MinGW32 compiler to compile the sources.
MemoryLeak21 #13
Posted 08 December 2012 - 12:54 PM
I hate to do this, but… How do I run the program from command line? I've tried researching it and have gotten… Well, zilch.
Dlcruz129 #14
Posted 11 December 2012 - 07:03 PM
I hate to do this, but… How do I run the program from command line? I've tried researching it and have gotten… Well, zilch.
What operating system do you use?
da404lewzer #15
Posted 11 December 2012 - 10:05 PM
Hey, nice app :D/>

I would love you long time if you added direct support for the turtlescript market api :rolleyes:/>

I'd even throw a link somewhere to let people know it's another way to get their scripts downloaded!
MemoryLeak21 #16
Posted 12 December 2012 - 04:29 AM
I currently use Windows 7.
Dlcruz129 #17
Posted 12 December 2012 - 06:45 PM
I currently use Windows 7.

K. Easy.
Press Start-R and type cmd.
Drag the program into the window (as if you were moving it into a folder)
It should display C:/Users/Name/…
Add the arguments to the end
Press enter.
Kingston #18
Posted 17 December 2012 - 02:54 AM
Good evening, comrades.

I'm going nuts trying to copy a code with 104 lines on Tekkit, but whenever I use CC-copy it says SYSTEM COULDN'T FIND THE SPECIFIED FILE in which I've written the code.

How should I add that parameter?

I'm using

C:\Users\ads>C:\Users\ads\Desktop\cc-copy_bin\CC-copy.exe [-w <Tekkit>] [-t <0.3>] [-s <4000>] chat.lua
dissy #19
Posted 17 December 2012 - 03:24 AM
Good evening, comrades.

I'm going nuts trying to copy a code with 104 lines on Tekkit, but whenever I use CC-copy it says SYSTEM COULDN'T FIND THE SPECIFIED FILE in which I've written the code.

How should I add that parameter?

I'm using

C:\Users\ads>C:\Users\ads\Desktop\cc-copy_bin\CC-copy.exe [-w <Tekkit>] [-t <0.3>] [-s <4000>] chat.lua

Square brackets ][ mean something is optional and can be left out.
Angle breakets >< mean something is required and must be typed.
The actual brackets should not be included, only the value it represents.

For example, [-w <window-name>] means everything between square brackets is optional, but if you DO include the -w option, the window name is now required

You want:
C:\Users\ads\Desktop\cc-copy_bin\CC-copy.exe -w Tekkit -t 0.3 -s 4000 chat.lua
Kingston #20
Posted 17 December 2012 - 03:39 AM
It still can't find the specified file. Are you sure it must be a .lua?
Orwell #21
Posted 17 December 2012 - 03:43 AM
No, it can be any extension. Run this command in the command line to see if it's not something like "chat.lua.txt": Edit: this will list all the files by their full name.

dir C:\Users\ads\Desktop\cc-copy_bin\
Also, be sure to put the lua program in that same directory.

Edit: You can also just type this in command line:

notepad C:\Users\ads\Desktop\cc-copy_bin\chat.lua
Notepad will open, then copy the content of the program into notepad and save it. After that, dissy's command should work just fine.
Kingston #22
Posted 17 December 2012 - 03:48 AM
Not working :/

Edit: Not working even after your edit, comrade Orwell.
Kingston #23
Posted 17 December 2012 - 04:00 AM
I quit.
Mr. Fang #24
Posted 21 December 2012 - 10:16 AM
Works like a charm after about 3 minutes of fiddling with it.
Orwell #25
Posted 21 December 2012 - 10:18 AM
Cool. :)/> What did you fiddle with if I may ask? I'd be happy to make it more user friendly if you have suggestions.
Mr. Fang #26
Posted 21 December 2012 - 10:59 AM
Here's what I did.
1.I placed the cc-copy.exe on my desktop
2. I opened the CMD thingy via Start+R
3. I created a .txt on my desktop named text.txt then opened it
4. Started Tekkit and opened a computercraft computer on the server that doesn't have HTTP
5. Typed "edit startup" onto my ComputerCraft Computer
6. saw this entire msg when I typed out what you asked:
"C:\Users\Fang>\desktop\CC-copy.exe -w Tekkit -t 5 -s 15 –old desktop\text.txt "
7.Ran the program (pressed enter) with my notepad open and my Tekkit open to the ComputerCraft Computer's file edit screen
8.Watched as it typed it for me
9.Checked the code and made sure it was all right…I found some things in the beginning that looked wrong but idk…I'll look later into that
10.Was done!
ti07shadow #27
Posted 01 January 2013 - 06:09 PM
Yea I have a bit of a issue with this.. When I type in

C:\Users\David\Desktop\cc-copy_bin\CC-copy.exe -w Tekkit -t 1 -s 4000 test.txt

it gives me the following

4000 test.txt
Found Tekkit Window
Couldn't open file 'test.txt'.
Done writting file
Orwell #28
Posted 01 January 2013 - 11:41 PM
Yea I have a bit of a issue with this.. When I type in

C:\Users\David\Desktop\cc-copy_bin\CC-copy.exe -w Tekkit -t 1 -s 4000 test.txt

it gives me the following

4000 test.txt
Found Tekkit Window
Couldn't open file 'test.txt'.
Done writting file
That's because the file test is not in the directory you're running the command from. Best way is to put all involved files in the same directory and cd to it. Then run the commands. Or else you can use the full path to test.txt in the command.
SteakSAUSE #29
Posted 02 January 2013 - 03:39 PM
I'm trying to use this program with the FTB MindCrack Pack, but I am unsure what the window name would be, anyone have an idea?
Orwell #30
Posted 02 January 2013 - 04:08 PM
It's just the title of the window running minecraft. :)/> I just checked, and in your case it would be "MindCrack Pack" (put it in between quotes after the -w ).
DjKiDD #31
Posted 19 January 2013 - 11:31 AM
THANK YOU!
This is an amazing help on the server I play on :P/>

I keep experiencing this same bug… it always duplicates the last character of the code being uploaded
Orwell #32
Posted 22 January 2013 - 06:38 AM
THANK YOU!
This is an amazing help on the server I play on :P/>

I keep experiencing this same bug… it always duplicates the last character of the code being uploaded
Yeh, I seem to remember that it can be fixed by putting one empty line under the code.
AkaZombie #33
Posted 10 February 2013 - 06:57 AM
It still can't find the specified file. Are you sure it must be a .lua?
Perhaps you have to drag the chat file into cmd like the CC-Copy.exe
Orwell #34
Posted 10 February 2013 - 07:16 AM
It still can't find the specified file. Are you sure it must be a .lua?
Perhaps you have to drag the chat file into cmd like the CC-Copy.exe
Chat file? :mellow:/>
superaxander #35
Posted 15 February 2013 - 03:46 AM
It still can't find the specified file. Are you sure it must be a .lua?
Perhaps you have to drag the chat file into cmd like the CC-Copy.exe
Chat file? :mellow:/>
The name of his file was chat.lua
CupricWolf #36
Posted 05 March 2013 - 01:51 AM
I notice that in

void stopEditingFile() {
    sendKey(VK_CONTROL);
    sendKey(VK_RETURN);
    sendKey(VK_CONTROL);
    sendKey(VK_RIGHT);
    sendKey(VK_RETURN);
}
you don't use the interval between each
sendKey()
. Just thought you might want to know. I couldn't save the files on my server, it types it out just fine but then sends the final key strokes much too quickly.
icecube45 #37
Posted 17 March 2013 - 11:24 AM
Hey, used this program a while ago, and it doesnt seem to work now, It will switch to the tekkit window, but nothing will happen, it will type it into any other program however
Mads #38
Posted 17 March 2013 - 08:12 PM
Where did you get the BYTE type? Is it in windows.h, or did you just typedef char BYTE; ?
Anyway, nice program. Can't test it though, I'm on Linux.
AliveGhost #39
Posted 16 July 2013 - 06:32 PM
Hey,

It all seems to be running okay, apart from it says "Couldn't open file 'desktop\mainprog'. How can I get the cmd to open it?

Cheers,
AliveGhost
Orwell #40
Posted 17 July 2013 - 08:18 AM
Hey,

It all seems to be running okay, apart from it says "Couldn't open file 'desktop\mainprog'. How can I get the cmd to open it?

Cheers,
AliveGhost
What exact command you're running? I might be able to help you better that way. The trick is to use the full path name in between quotes. E.g.:
CC-copy.exe "C:\Users\username\desktop\mainprog"
AliveGhost #41
Posted 17 July 2013 - 05:51 PM
That seems to have worked, thanks very much!