BetaONE will rise again!

BetaONE will rise again! (http:\\b1.hcanet.com\forum/index.php)
-   Coders Corner (http:\\b1.hcanet.com\forum/forumdisplay.php?f=57)
-   -   Project: Urban Terror Script Generator (http:\\b1.hcanet.com\forum/showthread.php?t=10631)

war59312 19th Feb 04 03:51 AM

Hey,

Anyone know hot to copy something from the clip board and enter it into a bat file some how. Like set it has a variable or something?

Thanks,
Will

Edit: Topic Title.

~*McoreD*~ 19th Feb 04 06:13 AM

Here is a sample VB6 Project.

~*McoreD*~ 19th Feb 04 06:18 AM

Here is VB.NET Code:

'Pasting from the Clipboard
Code:

               If System.Windows.Forms.Clipboard.GetDataObject.GetDataPresent( _
           System.Windows.Forms.DataFormats.Text) Then
            txtURL.Text = System.Windows.Forms.Clipboard.GetDataObject.GetData( _
            System.Windows.Forms.DataFormats.Text)
        End If

'Writing to a File
Code:

     
strBatFile = "war59312"
FileOpen(1, (Application.StartupPath & "\LogonHours.bat"), OpenMode.Output)
PrintLine(1, strBatFile)
FileClose(1)

Cheers, ;)
McoreD

war59312 19th Feb 04 08:48 PM

um ok cool

i understand that

but how the hell to do it automatic..write in the file i mean...

what i'm tyring to do is copy whats from the clipboard when the all seeing eye adds something to it and then at that to my script..understand the last part but of course than manually by running the program

and only when the all seeing eye adds something to the clipboard...the server address spicaficly... which is automaticaly copied to the clipboard when i join a server

i'm trying to make it so there is no user input needed...

u can see my other post for what i have so far

and it takes over the entire bat file it seems

thanks man,
will

~*McoreD*~ 20th Feb 04 02:20 AM

you mean getting the content from the clip board and write to *.bat file at once?

Code:

If System.Windows.Forms.Clipboard.GetDataObject.GetDataPresent( _
    System.Windows.Forms.DataFormats.Text) Then
    Dim strBatfile as String
     strBatfile = System.Windows.Forms.Clipboard.GetDataObject.GetData( _
     System.Windows.Forms.DataFormats.Text)
End If
FileOpen(1, (Application.StartupPath & "\LogonHours.bat"), OpenMode.Output)
PrintLine(1, strBatFile)
FileClose(1)

Just have them all together in one Sub.

war59312 20th Feb 04 03:53 AM

I mean in my bat file. I want to have say a variable. And have the varible set to whats in the clipboard. Of course have a different bat file that does this.

Hope you know what I mean.

So like this:

@echo off
cd C:\Minimizer
Start /MIN Minimizer.exe
CHOICE.COM /N /CY /TY,4 >NUL
cd C:\Program Files\Quake III Arena
Start /w quake3.exe +set fs_game q3ut3 +nosplash +set com_hunkmegs 128 +com_zoneMegs 32 +com_soundmegs 32 +connect "Clipboard Varible Here" /prefetch:1
cd C:\Minimizer
process -q Minimizer.exe
cls

So where it says clipboard variable here. Thats were i want to what ever is in the clip board to be entered there.

But use a differtnt bat file to put it there.

So when I double click a server in the All Seeing Eye is runs my bat file but at the same time The All Seeing Eye atuomaticly puts the server address in the clip board and then my scripts takes that in the clipboroad and adds it to my other bat file and then runs that bat file.

See what i mean? So no user inveration at all. Besdies dulbe click the server name in the all seeing eye like normal.

Thanks,
Will

~*McoreD*~ 20th Feb 04 09:45 AM

Do you mean something like this ?

~*McoreD*~ 20th Feb 04 10:05 AM

I still believe the required code is the same as before. :unsure:

Code:

       If System.Windows.Forms.Clipboard.GetDataObject.GetDataPresent(System.Windows.Forms.DataFormats.Text) Then
            Dim strServerAddress As String
            strServerAddress = System.Windows.Forms.Clipboard.GetDataObject.GetData(System.Windows.Forms.DataFormats.Text)
            Try
                Dim strFile As Stream = File.Open(Application.StartupPath + "\" + strServerAddress + ".bat", FileMode.Create, FileAccess.Write)
                Dim sw As StreamWriter
                sw = New StreamWriter(strFile)
                sw.WriteLine("@echo OFF")
                sw.WriteLine("cd " + IO.Path.GetDirectoryName(txtMinimizer.Text))
                sw.WriteLine("Start /MIN " + IO.Path.GetFileName(txtMinimizer.Text))
                sw.WriteLine("CHOICE.COM /N /CY /TY,4 >NUL")
                sw.WriteLine("cd " + txtQ3A.Text)
                sw.WriteLine("Start /w quake3.exe +set fs_game q3ut3 +nosplash +set com_hunkmegs 128 +com_zoneMegs 32 +com_soundmegs 32 +connect " + strServerAddress + " /prefetch:1")
                sw.WriteLine("cd " + IO.Path.GetDirectoryName(txtMinimizer.Text))
                sw.WriteLine("process -q " + IO.Path.GetFileName(txtMinimizer.Text))
                sw.WriteLine("cls")
                sw.Close()
            Catch ex As Exception
                Dim strMsg As String = MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.RetryCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1)
                If strMsg = DialogResult.Retry Then
                    btnCreate_Click(sender, e)
                End If
            End Try
        End If

This will take the Clipboard content as a string called strServerAddress
It will be added to the place you wanted in the bat file
And it will be saved as StrServerAddress.bat e.g. 192.168.0.1.bat

Sorry if I failed this time too.

war59312 20th Feb 04 07:33 PM

Quote:

Originally posted by ~*McoreD*~@Feb 20 2004, 04:45 AM
Do you mean something like this ?
um what excatly does this do?

make my script for you?

that would be sweet

and if you could make an installer mean it installs all the other needed files for u

that would be asome

thanks for all your help man

now goign to take a look at what you said below

um ok i see what it does now... lol...got ti working..just gives u that error if nothing in the clipboard but thats cool :)

um now its acting werid lol



oh ok wont do 207.44.182.28:27960 or something like that...

guess the : fs it up

The thing is i want the user to be able to choose this part of it:

Start /w quake3.exe +set fs_game q3ut3 +nosplash +set com_hunkmegs 128 +com_zoneMegs 32 +com_soundmegs 32 +connect Microsoft Visual Studio 6.0 /prefetch:1

Those were just my options.

oh and if possible i need it to creat the same bat file every time, like connect.bat or something because thats what the all seeing eye would be set to the entire time.

know what i mean? it needs to stay the same...

also one question the default directories look good..but does it automattically decet the folders or is it just set to that...

mean that would be cool if it actually tries to find it... u know so it u have it installed somewere

or u can just keep it the same..thats cool..anything is... since your doing all the hard work...

u the man....

and yea of course u get 100% full credit... :)

you are the man!!!

also i was thinking instead of it just creating the script it creates the script and then runs it

so then in the all seeing eye it connect to your app and the ip address of the server in the the clipboard

and then you just click say "Go!" and it creates the script and then runs it.

That would be pefect. Plus think most people would love to have a qui then command line. ;)

but i would still like for it to just make the same bat file every time or you end up with a ton of them lol

or u chould just delete it afterwords i guess

oh and btw the connect part as too look like this to work...has to be in ""

+connect "ipaddress"

so yea it does not work right now

also do u know if there is a way to make all the dos windows hidden so u never see them?

and this dont even work for some reason Start /MIN Minimizer.exe mabye u know of a way...u know so u dont have to click ok every time.

thanks,
will

war59312 20th Feb 04 07:37 PM

Quote:

Originally posted by ~*McoreD*~@Feb 20 2004, 05:05 AM
I still believe the required code is the same as before. :unsure:

Code:

       If System.Windows.Forms.Clipboard.GetDataObject.GetDataPresent(System.Windows.Forms.DataFormats.Text) Then
            Dim strServerAddress As String
            strServerAddress = System.Windows.Forms.Clipboard.GetDataObject.GetData(System.Windows.Forms.DataFormats.Text)
            Try
                Dim strFile As Stream = File.Open(Application.StartupPath + "\" + strServerAddress + ".bat", FileMode.Create, FileAccess.Write)
                Dim sw As StreamWriter
                sw = New StreamWriter(strFile)
                sw.WriteLine("@echo OFF")
                sw.WriteLine("cd " + IO.Path.GetDirectoryName(txtMinimizer.Text))
                sw.WriteLine("Start /MIN " + IO.Path.GetFileName(txtMinimizer.Text))
                sw.WriteLine("CHOICE.COM /N /CY /TY,4 >NUL")
                sw.WriteLine("cd " + txtQ3A.Text)
                sw.WriteLine("Start /w quake3.exe +set fs_game q3ut3 +nosplash +set com_hunkmegs 128 +com_zoneMegs 32 +com_soundmegs 32 +connect " + strServerAddress + " /prefetch:1")
                sw.WriteLine("cd " + IO.Path.GetDirectoryName(txtMinimizer.Text))
                sw.WriteLine("process -q " + IO.Path.GetFileName(txtMinimizer.Text))
                sw.WriteLine("cls")
                sw.Close()
            Catch ex As Exception
                Dim strMsg As String = MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.RetryCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1)
                If strMsg = DialogResult.Retry Then
                    btnCreate_Click(sender, e)
                End If
            End Try
        End If

This will take the Clipboard content as a string called strServerAddress
It will be added to the place you wanted in the bat file
And it will be saved as StrServerAddress.bat e.g. 192.168.0.1.bat

Sorry if I failed this time too.

Um very interesting. I'm still learning so if i sould lost or just way off then. lol

Anyways this part:

sw.WriteLine("Start /w quake3.exe +set fs_game q3ut3 +nosplash +set com_hunkmegs 128 +com_zoneMegs 32 +com_soundmegs 32 +connect " + strServerAddress + " /prefetch:1")

Those are just my settings. I need it so the user can do there ony setting.

Like in the program above u made that would be sweet if the user could add there options.

Or just have u know three options for hunmegs, zonemegs and soundmegs. :)

Something like that.

But damn man I really really appricate your help on this. Your a god. :)

Of and if your wondering i only have Microsoft Visual Studio 6.0 Corp. at the moment.

~*McoreD*~ 21st Feb 04 07:40 AM

Dude,

First of all, I should admit that I have never played Quake III Arena you know. :)

I provided the source code in hopes that you will be able to continue your work, but now I see you have got only VB6.

Thanks for the appreciation, I did it in my lunch hour yesterday..I will have another look today. :)

I need this thread to be educative and someone can actually learn something out of it. So I will keep explaining the bugs you pointed out.

oh ok wont do 207.44.182.28:27960 or something like that...
As I said earlier, it was taking the IP Address as the file name:
Code:

Dim strFile As Stream = File.Open(Application.StartupPath + "\" + strServerAddress + ".bat",
A file name with a colon is invalid. Therefore a filename such as 207.44.182.28:27960.bat is impossible, and hence gave that error. Oh now I see you have already mentioned it.

also one question the default directories look good..but does it automattically decet the folders or is it just set to that...
The SystemDrive will be detected by the following code. The rest are constants (they can be modified by the user though):
Code:

txtQ3A.Text = Environ("SystemDrive") + "\Program Files\Quake III Arena"
oh and btw the connect part as too look like this to work...has to be in ""
That's easy, you just have to put Chr(34) or four " marks.
Code:

"Start /w quake3.exe +set fs_game q3ut3 +nosplash +set com_hunkmegs 128 +com_zoneMegs 32 +com_soundmegs 32 +connect " + _
        """" + strServerAddress + """" + " /prefetch:1"

and this dont even work for some reason Start /MIN Minimizer.exe
That must be an error in your DOS command. I am not sure about it.

[b]Those are just my settings. I need it so the user can do there ony setting.[/b
Since I haven't played Quake II Arena and do not anything about settings, It's hard to figure out for me, which are variables and which are not. I hope you can continue from now on. :)

All the best,
McoreD

~*McoreD*~ 21st Feb 04 08:15 AM

Oh, the source code is attached in the above post. Here is the compilied exe just in case.

Once you learn the basic, you will easily code tools like this. Feel free to ask any question in Corder's Corner. :)

war59312 21st Feb 04 07:11 PM

All right cool. :)

Well I'm going to change this thing some more.

I'm trying to change it so its set by the user. So there is Combobox with different options, I guess.

Low Memory < 128Mb
Normal - < 192Mb
High < 245Mb
Very High < 320Mb

So the user picks an option and then it disaplys it under it like:

Low Memory < 128Mb

com_hunkmegs 100
com_zoneMegs 16
com_soundmegs 8

And then after you make your choice you click save.

Welll I want to save everything I guess to an ini file. Also window postion.

That way next time you launch the app it will have your settings.

But I dont know were to begin. Damn it!!! I suck at this poopie. I hate it!! lol

Think i need to buy a few books. Cant remember crap. haha

But thanks for your help. Hopefully i can figure it out. So thanks for all your help man. Its greatly appricated.

Take Care,
Will

war59312 29th Feb 04 12:37 AM

Hey,

Just one last thing.

This part.

Code:


Dim strMsg As String = MessageBox.Show("MS-DOS Batch File was successfully created. Do you want to run the file?", Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1)
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;If strMsg = DialogResult.Yes Then
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Shell(SaveFileDialog1.FileName, AppWinStyle.Hide)
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;End If

I'm trying to make it just run instead of asking. So no message box.

But having problems.

Could u just post the entire project so i can jsut load it using vb6. Since I dont know what to do with souce code.

Once I get it, it will be perfect for me.

Here is the source code. Same as u posted but edited a little. But sill has the mesage box in it since I cant get it working.

Anyways if u notice sw.WriteLine("ConsoleTool /HIDE")

Hopeing it will look for ConsoleTool.exe in:

C:\Program Files\Quake III Arena

Should so hopefully it will. Yea decided to use a third partty app to do somethings. :)

Should be the only line i have to add to the script. But since I dont know how to build it and what not then i cant test it out. Just hopeing. :)

But also for some werid reason now this is not working:

txtScript.Text = "Start /w quake3.exe +set fs_game q3ut3 +nosplash

+set com_hunkmegs 128 +com_zoneMegs 32 +com_soundmegs 32 +connect " + _
Chr(34) + txtIP.Text + Chr(34) + " /prefetch:1"

You know so it puts it like "ipaddress" but its nor working. Damn quake3 says its wrong. Really werid cause it did work. Hopefully i can find out about that.

But u can just leave it for now. If you could do this for me then it really would be pefect as you are involved. :) Then i should not needed anymore help. As of now the normal script I have wrote is working perfectly now. Just have to click a gay donkey ok button. But thats not your fault either so. Damn person who made the app did not include commadlines. :(

Also if you know how whcih i dont. Could u just add a autoload check box. That automaticly creates the script and then runs it without having to click the creat button. So right when you run the app.

If not then dont worry about. As its not a must at all. Just thought it would be a good idea. And if does not have to save it either or anything unles u can easly. If not forget it.

So really two ways of using the app u know. So you can run the app and then have to click create script that would create the script then run it. Um maybe not a good idea??? Maybe have that as an option too. Like safety windows or something. Yea that would be cool. And if it could remember your choice. Maybe? Dont know?

Thanks a ton man.

Oh yea one last thing. Think it would just be a good idea to close the app once the game is lauch, just so you dont always have to close it yourself. ;)

Really, realy really really appircated. If your not up to it or just sick of hell of me i complety understand. hehe :P

Anyways I'm still greatfull for all your help on this man. And anytime u think i can help with something just ask. I owe u. ;)

Thanks again.

Take care.
Will

~*McoreD*~ 29th Feb 04 05:04 AM

To get rid of the MessageBox, just have the code as follows: :)
Code:

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sw.WriteLine("@echo OFF")
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sw.WriteLine("ConsoleTool /HIDE")
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sw.WriteLine("cd " + Chr(34) + IO.Path.GetDirectoryName(txtMinimizer.Text) + Chr(34))
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sw.WriteLine("Start /MIN " + IO.Path.GetFileName(txtMinimizer.Text))
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sw.WriteLine("CHOICE.COM /N /CY /TY,4 >NUL")
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sw.WriteLine("cd " + Chr(34) + txtQ3A.Text + Chr(34))
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sw.WriteLine(txtScript.Text)
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sw.WriteLine("cd " + Chr(34) + IO.Path.GetDirectoryName(txtMinimizer.Text) + Chr(34))
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sw.WriteLine("process -q " + IO.Path.GetFileName(txtMinimizer.Text))
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sw.WriteLine("cls")
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sw.Close()
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Shell(SaveFileDialog1.FileName, AppWinStyle.Hide)

Since I haven't got Quake III Arena, unfortunately I cannot test the compiled application. And you cannot load the project in Visual Basic 6 because it is a .NET project. Here is my Visual Studio Solution for you anyways. Hope that would help you.

This small utility will do nothing more than outputting a MS-DOS batch file like you made:
Code:

@echo OFF
ConsoleTool /HIDE
cd "C:\Minimizer"
Start /MIN Minimizer.exe
CHOICE.COM /N /CY /TY,4 >NUL
cd "C:\Program Files\Quake III Arena"
Start /w quake3.exe +set fs_game q3ut3 +nosplash +set com_hunkmegs 128 +com_zoneMegs 32 +com_soundmegs 32 +connect "192.168.0.1" /prefetch:1
cd "C:\Minimizer"
process -q Minimizer.exe
cls

You need the correct IP address in the clip board while this application loads. Then the application while get the IP address from the clip board and use it in the necessary location of the Batch File. If the clip does not hold the IP address while the application loads, you can still click Get IP after Quake III Arena outputs the IP address to the clip board and the application will retry reading the clip board and use it. That's basically how the application works so far.

The custom scripting ability is very limited since apart from what you had in your first Batch File, I do not know anything about Quake III Arean Scripts. Can you post all the commands that is possible in Quake III Arena and the order of how to use it? For example:

Code:

C:\Documents and Settings\McoreD>tree /?
Graphically displays the folder structure of a drive or path.

TREE [drive:][path] [/F] [/A]

 &nbsp; /F &nbsp; Display the names of the files in each folder.
 &nbsp; /A &nbsp; Use ASCII instead of extended characters.

Do you want this application to autoload when you run quake3.exe? That may need some Windows Registry modifications or somethign else.

I am going to rename this thread to Project: Urban Terror Script Generator, since this thread has gone far from Copy From Clipboard.

Cheers,
McoreD

war59312 29th Feb 04 06:16 AM

All right I got you. :)

But no I wish. /? Just kills the welcome movie. hehe Thats what I use now.

I dont think it support commands lines anyways besides like memory settings. Like I'm using now in my script. That and the name of the mod. and server info. Like what port, ip address, pw, etc. to use. Thats about it.

Instead of using command line you use an autoconfig file that like it sounds is auotloaded every time by the exe and overides are settings.

But no dont care about it auotload when starting quake3. Unless u do. ;)

Think I'm going to install VisualStudio 2003 and see what happens. :)

Make that Visual Studio .NET Enterprise Architect 2003. :)

Hey um do u know what the lastest build of MSDN is? I got Oct. 2003 atm. Just wondering if u got a newer one.

Well damn it the Oct. 2003 wont install. Says its the wrong version. :(

Think i might start caring about this stuff. Hopefully might have a job in thee weeks. Own business with my father. :)

Well thanks again and good night.


Well:

C:\Documents and Settings\Will\Desktop\Urban_Terror_Script_Generato r_20040220\Form1.vb(249): 'End If' must be preceded by a matching 'If'.

Well supprised it builds. 6.0 would never build if i had an error like that...

Also about the MessageBox. Not working. :( Still asks. Why? I have no clue.

And thanks for the settings.txt one too. It works but not adding ip address.

It should be it seems to me.

txtIP.Text = System.Windows.Forms.Clipboard.GetDataObject.GetDa ta(System.Windows.Forms.DataFormats.Text)

And its set to output txtIP.Text when you run the app but its not.


All times are GMT +1. The time now is 02:34 AM.

Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.