NargalaX 8 Junior Poster in Training

I'm making a game board style program (Basically a modified monopoly with automated pieces and questions) and it is currently in the very early stages.

Right now I am making the gameboard pieces move properly etc., but once I'm finished that I will need to know how to check if an object is in the 2d area of another object.

The monopoly pieces are pictureboxes, and I will have transparent pictureboxes labeled as the designated monopoly places etc., (the board is a single image, thats why I must do that).

How could I accomplish this, simply?

NargalaX 8 Junior Poster in Training

bump

sknake commented: dont do that -1
NargalaX 8 Junior Poster in Training

Oops! Im sorry, I wrote one variable wrong in the code.

Here is a fixed version :

const string box = "****************$"+
				 "*//////////////*$"+
				 "*//////////////*$"+
				 "*//////////////*$"+
				 "*//////////////*$"+
				 "****************$"+
			
			for(int i=0; i < box.Length; i++)
				{
					if(box[i]!='/'){
					Console.ForegroundColor = ConsoleColor.Blue;
						if(box[i]=='$'){Console.ForegroundColor = ConsoleColor.Green;Console.WriteLine("/");}
						else{Console.Write(box[i]);}
					}
				else{Console.ForegroundColor = ConsoleColor.Green;Console.Write("/");}	
				
				}
NargalaX 8 Junior Poster in Training

Actually, could I use jabberwacky.com instead? Cleverbot is slower, and I like jabberwacky better anyways.

NargalaX 8 Junior Poster in Training

Hey, I would like to be able to send html requests to cleverbot, and if you've ever been there before, you would know that it is probably the most intelligent chat bot AI that can be publically used.

If you don't know what it is, just go to http://www.cleverbot.com/ and check it out!


Anyway, I would like to be able to send text to the field there on cleverbot.com, use the 'think for me' button, and use what it says back to me for my own chat bot.

Does anyone know how I could accomplish this?

Thanks!

NargalaX 8 Junior Poster in Training

I think I know what you want to do, you want to print the char '*' but make them it print in a form of a square?

Like so:

*****
*\\\\\*
*\\\\\*
*****

Where the '\'s are blank space (multi spaces are not supported here I presume)

For that you would have to use a for loop

What I would do is the following:
I would have a string showing what I would want to print, and have key charectars showing where to end the line and where to show background etc.

const string box = "****************$"+
				 "*//////////////*$"+
				 "*//////////////*$"+
				 "*//////////////*$"+
				 "*//////////////*$"+
				 "****************$"+
			
			for(int i=0; i < box.Length; i++)
				{
					if(avatar[i]!='/'){
					Console.ForegroundColor = ConsoleColor.Blue;
						if(box[i]=='$'){Console.ForegroundColor = ConsoleColor.Green;Console.WriteLine("/");}
						else{Console.Write(box[i]);}
					}
				else{Console.ForegroundColor = ConsoleColor.Green;Console.Write("/");}	
				
				}

Try that

NargalaX 8 Junior Poster in Training

Nevermind, I figured it out myself!

NargalaX 8 Junior Poster in Training

Hey,

Most of you who help in this forum have probably read my posts, and this is another one for my math bot. :)

I am using string arrays to assign to math operands, for example I would have an array such as this for a basic math equation:

5 * 2

The program will determine where any operators are, and split into an array eventually outputting this:

5,*,2.

The method I use to determine whether to assign the current string to a variable or an operator is determined by the index of the for each loop I am using.

So, for example, I would have this:

i=1;
foreach (string piece in substrings)
{
     if((i-1)%2==0){//assign to B
     }

     if(i%2==0){//assign to operator string
     }

     if(i==1|((i-1)%3)==0){//assign to A
     }
}

But so far, this code is not satisfactory to what I need it to do.
(Especially the last one, I messed it up and it doesn't work anyway so whatever)

if I have 5*2+7
The indexing is like this [1,'5'],[2,'*],[3,'2'],[4,'+'],[5,'7']

from there you can see what are numbers and what are operators, and I need the foreach code to identify from the index if it will assign the operand to an operator, A, or B using multiples, or any other system you guys may think up.

So, could someone create a foreach indexing code that will work for my needs?

Thanks.

P.S. Sorry if my explanation for …

NargalaX 8 Junior Poster in Training

Thanks everyone, but thank you especially farooqaaa, I'm now using your method and it works perfectly!

But, as I just figured out when my friend typed it in, using this method it is impossible to do equations with negative numbers.

For example, if you do a normal equation it will give this

5*2 = 5<*<2 and then splits to 5, *, 2.

But when you do negatives, it outputs

-5*2 = <-<5<*<2 and then splits to -, 5, * , 2.

How could I write this out so it will assign it to a negative value instead of an operator?

Thank you!

NargalaX 8 Junior Poster in Training

Hey,

I am using a messenging system to do math, and I am in need of help for my string splitting.

What I need it to do, is basically see if there is a '/' '*' '+' or '-' and split it from that charectar, and ALSO split it in front of that charectar.

For example, we have an equation of 5*2.

I need it to see the '*', and split it so 5 is a string, '*' is a string, and 2 is another string using an array.

Right now I have this :

string[] substrings = msg.Split(new Char [] {' ', '/', '*', '+', '-'});

but it does not work. If I inputted 5*2 into that code, it gives me this array : 5 , 2.

Thanks before hand !

NargalaX 8 Junior Poster in Training

Thanks everyone, this works method works nicely!

NargalaX 8 Junior Poster in Training

Thanks everyone, but sknake, what namespaces must I acquire before using cultureinfo, because it is 'missing an assembly reference', and I am assuming this will work with double values aswell as decimals?

EDIT: I also got "The name 'NumberStyles' does not exist in the current context (CS0103)".


Also, how would I use regex to split a string on every occurence of "\ * - +" ?

Thanks for your help guys, I appreciate it.

NargalaX 8 Junior Poster in Training

Hey, I'm making a math bot, and when you type in your equation it converts the numbers to doubles right away.

Except, when doing any equation with a decimal, the decimal is ignored.

Example

2 + 2 = 4 (No decimals, it works fine.)

2.2 + 2 = 24 (Decimal is ignored, 2.2 now equals 22.)

How would I be able to fix this?

NargalaX 8 Junior Poster in Training

Hey, I'm making a little program that will talk to you using fixed sentences etc., and I want to make it able to do math.

How would I be able to check if a string contains

+ - * /

and also contains numbers?

and then furthermore, once I have that, how would I be able to make it loop so I can also use questions such as

7 + 7 / 14

and it would give me the correct answer?

Thanks everyone

NargalaX 8 Junior Poster in Training

Thanks ddanbe,

but I do not think this is what I am looking for.

They have lots of bots, but almost all of them are a language other than C#, and if it is C#, it is not open source.

Are there any other sites you know that might help?

NargalaX 8 Junior Poster in Training

Hey everyone,

How would I go about creating a simple chat bot?

I have finally just recently got an API running for a chat application called Steam, and I can send and receive messages with this program and moderate everything that goes through, too.

So, I was hoping on getting a pre-made chat bot since creating one from scratch looks like quite the job.

If anyone could find a pre-made chat bot that just gives answers based on the input given, that would be great!!


Thanks.

NargalaX 8 Junior Poster in Training

I'm trying to make custom panels, but I can't even set the styles without getting errors

MainForm.SetStyle(System.Windows.Forms.ControlStyles.DoubleBuffer, true);
			MainForm.SetStyle(System.Windows.Forms.ControlStyles.AllPaintingInWmPaint, false);
			MainForm.SetStyle(System.Windows.Forms.ControlStyles.ResizeRedraw, true);
			MainForm.SetStyle(System.Windows.Forms.ControlStyles.UserPaint, true);
			MainForm.SetStyle(System.Windows.Forms.ControlStyles.SupportsTransparentBackColor, true);

Throws errors saying

An object reference is required for the non-static field, method, or property 'System.Windows.Forms.Control.SetStyle(System.Windows.Forms.ControlStyles, bool)' (CS0120)
NargalaX 8 Junior Poster in Training

The title basically says it all.

How would I include a DLL for use in another project?

NargalaX 8 Junior Poster in Training

How would I make the background of a form (which is usually one boring color) a dynamic gradient, measuring by size of the form and creating the gradient from there?

Thanks

NargalaX 8 Junior Poster in Training

Yeah I guess you're right, me and my friend would be working on this and we are both knowledgable in HTML and C#, so I guess this shouldn't be impossible.


FireFox runs off the Gecko engine, which I may look into, I'm not sure yet what that does for me and what it leaves out for me to do, but I'll report back here later.


Thank you!

NargalaX 8 Junior Poster in Training

I know you can make a Web Browser without using the default one .NET comes with, but how would I go about doing this?

Any tutorials or tips for this project?

Thank you!

NargalaX 8 Junior Poster in Training

Hey guys, I was just fiddling around with PixelSearch again, and found that theres a little problem.

I'll explain it with an example.

I had my C# custom window open with the PixelSearch function on it, and whenever it searches for a pixel rgb, it returns the results and then moves my cursor to that x,y position.

I had my window over an icon which contained pure red, and the pixelsearch was searching for pure red.

Even though my window covered the icon, PixelSearch still saw it, but when theres pure red on my window, it doesn't search my window, but underneath it.

Why is that?

The original link > http://www.elitepvpers.de/forum/gamehacking-coding/247732-c-pixelsearch-search-screen-pixel.html

I have not modified the PixelSearch class at all, but I was wondering why it didn't see my window.

Do I need to update what processes it sees or something?

Thank you!!

NargalaX 8 Junior Poster in Training

Pretty sure its as simple as

Application.Run(new FORMNAME();

NargalaX 8 Junior Poster in Training

I've been looking around for some good DLL Injection tutorials, because I would like to create a DLL Injector, mainly for educational purposes.

I've looked around on google for the past 20 minutes and the only things I've come up with are debates on whether its possible or not.

I saw a few that state that it is clearly possible, so now I am here to ask how I would go about creating one.

Note:: I do not want to inject C#, I want to create a C# Injector.

NargalaX 8 Junior Poster in Training

Thats my problem, the mouse hook isn't fast enough to recognise when the mouse button is released, so I'm intending to create a failsafe for it.

Is there maybe a medium level mouse hook? :)

NargalaX 8 Junior Poster in Training

I need a timer that checks every x ammount of seconds if the mousebutton is down.

How would I do this?

Oh, and it must be global. Not just on the form.

NargalaX 8 Junior Poster in Training

Nevermind, I got it to work.

:)

Thank you!

NargalaX 8 Junior Poster in Training

Must I declare both timer1 and FormTimer?

NargalaX 8 Junior Poster in Training

Is there a way to detect a variable change, and then fire an event for it?

I read the article on events tutorial in C#
http://msdn.microsoft.com/en-us/library/aa645739(VS.71).aspx

But I couldn't make sense of it, since I tried putting it in my program and it didn't work. I was trying it with a boolean value.


Thanks!

NargalaX 8 Junior Poster in Training

Hey, I would like to call a few functions from a static method, but it seems I can't.

More specifically, I would like to start or stop a timer from a static hook, called when you click your left mouse button.

Here is the code

//When you click...
    public static IntPtr HookCallback(
        int nCode, IntPtr wParam, IntPtr lParam)
    {
        if (nCode >= 0 &&
            MouseMessages.WM_LBUTTONDOWN == (MouseMessages)wParam)
        {
            MSLLHOOKSTRUCT hookStruct = (MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(MSLLHOOKSTRUCT));
            if(bool1 == true){
            	if(checkBox1.Checked == true){
				timer1.Start();
				}
            }
        }
    	if (nCode >= 0 &&
            MouseMessages.WM_LBUTTONUP == (MouseMessages)wParam)
        {
            MSLLHOOKSTRUCT hookStruct = (MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(MSLLHOOKSTRUCT));
            if(bool1 == true){
            	if(checkBox1.Checked == true){
				timer1.Stop();
				}
            }
        }
    	
        return CallNextHookEx(_hookID, nCode, wParam, lParam);
    }

The timer, checkbox and bool are all trying to be called but can't be since the method is static.

Could I change the method to be non-static? Because I've tried that, and it requires an object refrence, and when I put 'object sender' in it, it throws another error etc.

Please tell me if there is a way of doing this!

NargalaX 8 Junior Poster in Training

Thanks, This helped a lot.

NargalaX 8 Junior Poster in Training

Works perfectly. You're a genius! +REP & Solved.

NargalaX 8 Junior Poster in Training

I don't think this is what I'm looking for, sorry.

I'd like it so when I click the left mouse button on any window, it fires an event.

Sorry for being inspecific and thank you for your help!

NargalaX 8 Junior Poster in Training

Could you help me use this to fire an event when Mouse1 (Left button) is clicked?

Thank you!

NargalaX 8 Junior Poster in Training

Sorry, but how would I go about moving my cursor to a searched position . . . I don't really understand the code :\


Thank you

NargalaX 8 Junior Poster in Training

I love how when I put your code in my class, it works fine, but mine doesn't.

I think I was missing the namespace . . . Haha.

Thank you!

sknake commented: heh +10
NargalaX 8 Junior Poster in Training

Hey, I found a cool class online for finding certain colors in a designated rectangle around your mouse position.

Its optimised for speed, and supposedly works, but when I try compiling it I get around 32 errors.

Heres the code

public static Point PixelSearch(Rectangle rect, int PixelColor, int Shade_Variation)
        {
            Color Pixel_Color = Color.FromArgb(PixelColor);

            Point Pixel_Coords = new Point(-1, -1);
            Bitmap RegionIn_Bitmap = CaptureScreenRegion(rect);
            BitmapData RegionIn_BitmapData = RegionIn_Bitmap.LockBits(new Rectangle(0, 0, RegionIn_Bitmap.Width, RegionIn_Bitmap.Height), ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);

            int[] Formatted_Color = new int[3] { Pixel_Color.B, Pixel_Color.G, Pixel_Color.R }; //bgr

            unsafe
            {
                for (int y = 0; y < RegionIn_BitmapData.Height; y++)
                {
                    byte* row = (byte*)RegionIn_BitmapData.Scan0 + (y * RegionIn_BitmapData.Stride);

                    for (int x = 0; x < RegionIn_BitmapData.Width; x++)
                    {
                        if (row[x * 3] >= (Formatted_Color[0] - Shade_Variation) & row[x * 3] <= (Formatted_Color[0] + Shade_Variation)) //blue
                        {
                            if (row[(x * 3) + 1] >= (Formatted_Color[1] - Shade_Variation) & row[(x * 3) + 1] <= (Formatted_Color[1] + Shade_Variation)) //green
                            {
                                if (row[(x * 3) + 2] >= (Formatted_Color[2] - Shade_Variation) & row[(x * 3) + 2] <= (Formatted_Color[2] + Shade_Variation)) //red
                                {
                                    Pixel_Coords = new Point(x + rect.X, y + rect.Y);
                                    goto end;
                                }
                            }
                        }
                    }
                }
            }

        end:
            return Pixel_Coords;
        }

        private static Bitmap CaptureScreenRegion(Rectangle rect)
        {
            Bitmap BMP = new Bitmap(rect.Width, rect.Height, PixelFormat.Format24bppRgb);
            Graphics GFX = System.Drawing.Graphics.FromImage(BMP);
            GFX.CopyFromScreen(rect.X, rect.Y, 0, 0, rect.Size, CopyPixelOperation.SourceCopy);
            return BMP;
        }

I found it here > http://www.elitepvpers.de/forum/gamehacking-coding/247732-c-pixelsearch-search-screen-pixel.html

Unsafe code allowing is enabled.
Im using SharpDevelop as my developer.

NargalaX 8 Junior Poster in Training

Could you help me use this to fire an event when Mouse1 (Left button) is clicked?

Thank you!

NargalaX 8 Junior Poster in Training

Nevermind, found some great code and its exactly what I've been looking for.

Thank you for your help!!

SOLVED

NargalaX 8 Junior Poster in Training

To make 'custom' buttons, most people add images, such as what you said.

So, go create your button image in photoshop, save it as a .TGA (TARGA) image (This is useful since it keeps transparency), and remember where you saved it.

Then, go create your button in your developer, and go into design mode. Right click the button and go to prefrences.

Go to the Appearance area, and select background image.
Select local resource.
Browse to your picture, and add it.

It should then come up on the button!

NargalaX 8 Junior Poster in Training

I've tried this in the past, but never got it to work.

How would I set specific keys to run functions, whether I am on the current form or not?


Thanks!

NargalaX 8 Junior Poster in Training

Ok, I'm trying to get my program to search for a selected color on the screen, and then move your cursor to the x,y position of that color afterwards.

This is called a 'Color Aim Bot' or a 'Pixel Chaser'.

It needs to updated very quickly (around 25 - 50ms) and act very quickly aswell to be effective.

See where I'm going with this? :)

NargalaX 8 Junior Poster in Training

Is there a faster method of doing the same job as this?

When I try it really quickly, the program eats all my CPU and lags until finished.

NargalaX 8 Junior Poster in Training

How would I move my cursor to those coordinants then afterwards?

I tried this . . .

Cursor.Position = new System.Drawing.Point(points);

But got this error . . .

Argument '1': cannot convert from 'System.Drawing.Point[]' to 'System.Drawing.Size' (CS1503)

Any ideas?

NargalaX 8 Junior Poster in Training

How would I be able to find a certain pixel on any screen under a certain RGB, and then get its x y coordinants?


Thank you!

NargalaX 8 Junior Poster in Training

Could you just tell me a method of getting it from the client?

Please and thank you

NargalaX 8 Junior Poster in Training

Err, I wouldn't like to kill any of my critical processes, but to make one of my programs into one, so its not easy to be killed.

How would I go about doing this?

NargalaX 8 Junior Poster in Training

Why not draw a picture in photoshop or MSPaint on what you want and use the transparency key to cut off edges etc.

Once you're done the picture right click properties in design mode on your form and set the background image as the one you created and voila! You're done.

NargalaX 8 Junior Poster in Training

I need the IP used in outbound TCP IP Connections.

It shows on the server when they connect but I need to get this information on the client aswell, to tell people apart etc.

Is there a good way to get that IP?

NargalaX 8 Junior Poster in Training

How would I get an IP address?

Not the local ip, but the one people would use to connect to say a TCP IP program? :P

Thanks