• What do you need help with? Version 1
    5,001 replies, posted
Ok, small predicament here, if you can consider it that. I'm still trying to write this text file with the path to an image. It's giving me an error saying it can't find the text file when I've specified where it is, and it's telling me it can't find it in a different place.. [code] Dim sw As New IO.StreamWriter("settings/background.txt") sw.Write(Me.PictureBox2.ImageLocation) sw.Close() [/code] You see the path is "settings/background.txt". The exception that's getting thrown is, "Could not find a part of the path 'E:\Documents and Settings\Quirk\My Documents\My Pictures\Backgrounds\settings\background.txt'." I'm probably missing something obvious..
Just a quick one. Is there any way to output keystrokes using C#, running the program in the background and sending the keystrokes to the active window? Help would be appreciated.
[QUOTE=VeryNiceGuy;24428375]Ok, small predicament here, if you can consider it that. I'm still trying to write this text file with the path to an image. It's giving me an error saying it can't find the text file when I've specified where it is, and it's telling me it can't find it in a different place.. [code] Dim sw As New IO.StreamWriter("settings/background.txt") sw.Write(Me.PictureBox2.ImageLocation) sw.Close() [/code] You see the path is "settings/background.txt". The exception that's getting thrown is, "Could not find a part of the path 'E:\Documents and Settings\Quirk\My Documents\My Pictures\Backgrounds\settings\background.txt'." I'm probably missing something obvious..[/QUOTE] That should be "settings[b]\\\[/b]background.txt", or @"settings\background.txt". [editline]10:29AM[/editline] In your streamwriter
[QUOTE=pikzen;24431015]That should be "settings[b]\\\[/b]background.txt", or @"settings\background.txt". [editline]10:29AM[/editline] In your streamwriter[/QUOTE] not \\\, just \\ [editline]01:29PM[/editline] As far as I know
[QUOTE=VeryNiceGuy;24428375]Ok, small predicament here, if you can consider it that. I'm still trying to write this text file with the path to an image. It's giving me an error saying it can't find the text file when I've specified where it is, and it's telling me it can't find it in a different place.. [code] Dim sw As New IO.StreamWriter("settings/background.txt") sw.Write(Me.PictureBox2.ImageLocation) sw.Close() [/code] You see the path is "settings/background.txt". The exception that's getting thrown is, "Could not find a part of the path 'E:\Documents and Settings\Quirk\My Documents\My Pictures\Backgrounds\settings\background.txt'." I'm probably missing something obvious..[/QUOTE] Does the directory exist? Also I would prepend Application.StartupPath to it.
[QUOTE=pikzen;24431015]That should be "settings[b]\\\[/b]background.txt", or @"settings\background.txt". [editline]10:29AM[/editline] In your streamwriter[/QUOTE] The WinAPI translates forward slashes to backslashes anyway
The servers don't seem to register on the master server. Register: [code] <?php $socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); socket_connect($socket, "hl2master.steampowered.com", 27011); socket_write($socket, "\x4D\x05", 10); $array = array(); if ($read = socket_read($socket, 10)) { for ($i = 0; $i < strlen($read); $i++) { $array[] = substr("00" . dechex(ord($read[$i])), -2) . " "; } } print_r($array); $challenge = hexdec($array[9].$array[8].$array[7].$array[6]); echo $challenge; $data = '0.\protocol\7\challenge\\'.$challenge.'\players\1\max\32\bots\0\gamedir\garrysmod\map\zambeeverse\password\0\os\w\lan\0\region\5\gameport\27015\specport\0\dedicated\1\gametype\garrysmod94,gm:zambeeverse,0\appid\4000\type\d\secure\1\version\1.0.0.96\product\garrysmod.'; echo $data; flush(); socket_write($socket, $data, strlen($data)); socket_close($socket); ?> [/code] Server: [code] <?php $port = 27015; $socket = stream_socket_server("udp://0.0.0.0:".$port, $errno, $errstr, STREAM_SERVER_BIND); if (!$socket) { die("$errstr ($errno)"); } $data = "\xff\xff\xff\xff\x49\x0f"; // Init hex $data .= "\x54\x65\x73\x74\x20\x53\x65\x72\x76\x65\x72"; // Server name hex $data .= "\x00"; // Don't touch $data .= "\x7a\x61\x6d\x62\x65\x65\x76\x65\x72\x73\x65"; // Map hex $data .= "\x00"; // Don't touch $data .= "\x67\x61\x72\x72\x79\x73\x6d\x6f\x64"; // garrysmod $data .= "\x00"; // Don't touch $data .= "\x7a\x61\x6d\x62\x65\x65\x7a"; // Gamemode hex $data .= "\x00\xa0\x0f"; // Don't touch $data .= "\x01"; // Online players hex $data .= "\x20"; // Max players hex $data .= "\x00"; // Don't touch $data .= "\x64"; // I'm a dedicated server $data .= "\x77"; // I'm on windows $data .= "\x00"; // I'm passworded (change to \x00 to not be passworded) $data .= "\x01"; // I'm secure (change to \x00 to not be secure) $data .= "\x31\x2e\x30\x2e\x30\x2e\x39\x36\x00\xb1\x87\x69\x05\x3c\x27\x33\x0b\x09\x40\x01\x67\x61\x72\x72\x79\x73\x6d\x6f\x64\x39\x36\x2c\x67\x6d\x3a"; // I have no idea what this is $data .= "\x7a\x61\x6d\x62\x65\x65\x7a"; // Gamemode (not sure what the difference is) $data .= "\x2c\x30\x00\xa0\x0f\x00\x00\x00\x00\x00\x00"; // The rest (iunno) print_r($data); flush(); do { $pkt = stream_socket_recvfrom($socket, 1024, 0, $peer); echo "$peer<br>"; flush(); stream_socket_sendto($socket, $data, 0, $peer); } while ($pkt !== false); ?> [/code] Cheers to McSimp for all his help!
[QUOTE=Shrapnel :3;24429058]Just a quick one. Is there any way to output keystrokes using C#, running the program in the background and sending the keystrokes to the active window? Help would be appreciated.[/QUOTE] [url]http://msdn.microsoft.com/en-us/library/system.windows.forms.sendkeys.send.aspx[/url] This could help you out.
Perfect, thanks a lot. :) lol smileys what a fagget.
Any recommendations on websites or books for learning C? Also same for SDL? [editline]07:19PM[/editline] Also jw but is Lua a scripting only language or can it be used on its own like python?
[QUOTE=esalaka;24431023]not \\\, just \\ [editline]01:29PM[/editline] As far as I know[/QUOTE] Either way it still throws the same exception. I'm stumped D:
[QUOTE=Richy19;24436602] Also jw but is Lua a scripting only language or can it be used on its own like python?[/QUOTE] Of course it can be used stand-alone as well. You can grab the interpreter [url=http://www.lua.org/download.html]here[/url].
I'm thinking he was asking if you can build standalone .exe's with it.
[QUOTE=VeryNiceGuy;24440683]I'm thinking he was asking if you can build standalone .exe's with it.[/QUOTE] None of these things are related to the language. What most of these tools do is just pack an interpreter with the to-be-interpreted code. There's nothing in the way of creating a compiler which emits machine-code for Python or Lua, either (see LuaJIT, and there might be something like this for Python too). For Lua, you could use this: [url]http://www.facepunch.com/showthread.php?t=700562[/url] But there are others out there, too.
[QUOTE=Richy19;24436602]Also jw but is Lua a scripting only language or can it be used on its own like python?[/QUOTE] It can, you just need lua. (That is, the Lua parser, compiler and VM binary) [editline]10:57PM[/editline] How did I miss all those poooosts D:
I still can't figure this out. I managed to realize that I was writing a blank string because I hadn't set the images location yet, so I did that. [code] Private Sub OpenFileDialog1_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles OpenFileDialog1.FileOk Form1.PictureBox2.Image = Image.FromFile(OpenFileDialog1.FileName) Form1.PictureBox2.BackColor = Color.Transparent Form1.PictureBox2.ImageLocation = OpenFileDialog1.FileName 'Testing stuff... Form1.PictureBox1.SizeMode = PictureBoxSizeMode.CenterImage Form1.PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage End Sub [/code] That works, the Picturebox's image is changed right away. On form closed for the main form, I've got this: [code] Dim sw As New IO.StreamWriter(\settings\background.txt") MsgBox(PictureBox2.ImageLocation) sw.Write(PictureBox2.ImageLocation) sw.Close() [/code] It isn't quite working..it tells me that the text file doesn't exist in the picture's location..
Firstly, that shouldn't even compile. You're missing opening quotes for your paths. Also, your paths contain the escape character \, so you're escaping those s's and b's. Use forward slashes instead. (Or \\, if you absolutely must...)
Or verbatim stings?
[QUOTE=jA_cOp;24443111]Firstly, that shouldn't even compile. You're missing opening quotes for your paths. Also, your paths contain the escape character \, so you're escaping those s's and b's. Use forward slashes instead. (Or \\, if you absolutely must...)[/QUOTE] Sorry, I wrote what I had from memory, I didn't have Visual Studio open at the moment. I think I'll just save the file onto the persons C:\ drive or something,it wrote fine when I put the path there.
[QUOTE=VeryNiceGuy;24443579]Sorry, I wrote what I had from memory, I didn't have Visual Studio open at the moment. I think I'll just save the file onto the persons C:\ drive or something,it wrote fine when I put the path there.[/QUOTE] :10bux: that your background.txt is not in C:\Users\YourUser\Documents\Visual Studio 2010\Projects\Star\Star\bin\Debug\settings
Why dont you just make it write to the same location as the .EXE
I've got a folder on my desktop called 'Star'. Inside of there is where the .exe is, and right next to it is a folder called 'Settings', which has 'background.txt' inside of it.
[QUOTE=VeryNiceGuy;24444302]I've got a folder on my desktop called 'Star'. Inside of there is where the .exe is, and right next to it is a folder called 'Settings', which has 'background.txt' inside of it.[/QUOTE] [B]S[/b]ettings or [b]s[/b]ettings ?
[QUOTE=pikzen;24444771][B]S[/b]ettings or [b]s[/b]ettings ?[/QUOTE] Windows isn't case-sensitive about paths.
[QUOTE=jA_cOp;24444799]Windows isn't case-sensitive about paths.[/QUOTE] One more thing to know then , I've always been careful with my filenames, like checking everything 4 times, and all :D
I'm 100% sure the file is where I want it to be, but it's giving me an exception because it's trying to write somewhere [B]else. [/B]It's trying to write to the picturebox2.ImageLocation for some reason.
It won't hurt for portability reasons, since UNIX-like systems will care.
How do I go about erasing parts of a vector? I created a vector to store all the spells that the player casts (since they can cast more than one spell). This is what I got for deleting them after the collide with something / are used:[code] for (int i = spells.size() - 1; i == 0; i --) if (spells[i].move(t)) spells.erase(std::remove(spells.begin(), spells.end(), i), spells.end());[/code] I can't seem to get it to work. Anyone know how to delete the instance without skrewing up the iterators?
I'm using C# and searching for files that match a pattern (string searchPattern, e.g "head*.gif"), how can I get the string at the wildcard (what replaces the *)?
This might be what you are looking for.[URL="http://msdn.microsoft.com/en-us/library/ms228595(VS.80).aspx"] http://msdn.microsoft.com/en-us/library/ms228595(VS.80).aspx[/URL]
Sorry, you need to Log In to post a reply to this thread.