Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


[request] a command in C#
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Sat Nov 10, 2007 4:08 am    Post subject: [request] a command in C# Reply with quote

i'm looking for the command that makes that nometter what key i press it exits from the console window you know.. like "press any key to continue" and nometter what key u press it exits.. is there a command for that thing in C#?
_________________
Stylo
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Sat Nov 10, 2007 5:48 am    Post subject: Reply with quote

Using ReadLine should do the trick:

Code:

    Console.WriteLine("Press any key to exit.");
    Console.ReadLine();


EDIT:: You can also import _getch():

http://www.codeproject.com/useritems/PressAnyKeyToContinue.asp

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Sat Nov 10, 2007 7:29 am    Post subject: Reply with quote

the console.readline that's what i use right now but it's not what i was looking for cuz if i press 'X' for exemple it's not exit the console window it writes X in the console window and after i press enter it exits
i want to enter X and it exit out of the window without pressing enter after

_________________
Stylo
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Sat Nov 10, 2007 8:26 am    Post subject: Reply with quote

1qaz wrote:
the console.readline that's what i use right now but it's not what i was looking for cuz if i press 'X' for exemple it's not exit the console window it writes X in the console window and after i press enter it exits
i want to enter X and it exit out of the window without pressing enter after


I don't program in C# so I'm not sure on it, I looked it up on MSDN and according to Microsoft, thats how it should be done.

In any case, try importing _getch() instead, that should do the trick.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Sat Nov 10, 2007 8:47 am    Post subject: Reply with quote

can u give me the whole command please cuz when i write import / ing gatch() it says compiling error
_________________
Stylo
Back to top
View user's profile Send private message
lurc
Grandmaster Cheater Supreme
Reputation: 2

Joined: 13 Nov 2006
Posts: 1900

PostPosted: Sat Nov 10, 2007 9:40 am    Post subject: Reply with quote

im pretty sure you just import conio.h (i think thats the header)

Code:
#include <conio.h>

blablablah coding

_getch();

_________________
Back to top
View user's profile Send private message
samuri25404
Grandmaster Cheater
Reputation: 7

Joined: 04 May 2007
Posts: 955
Location: Why do you care?

PostPosted: Sat Nov 10, 2007 9:51 am    Post subject: Reply with quote

He's talking about C#, not C++.

Try this:

Code:

Console.WriteLine("Press any key to continue.");
Console.Read();
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Sat Nov 10, 2007 11:10 am    Post subject: Reply with quote

1qaz wrote:
can u give me the whole command please cuz when i write import / ing gatch() it says compiling error


Check the demo project out on the link I gave you above, it shows how to import it and use it. (Again, I don't program in C# so I can't make one myself.)

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Sat Nov 10, 2007 11:50 am    Post subject: Reply with quote

i have problem with sighning up to this website S:
can any1 upload this demo please?

_________________
Stylo
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Sat Nov 10, 2007 11:54 am    Post subject: Reply with quote

Sure.


The Extension 'rar' was deactivated by an board admin, therefore this Attachment is not displayed.


_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
samuri25404
Grandmaster Cheater
Reputation: 7

Joined: 04 May 2007
Posts: 955
Location: Why do you care?

PostPosted: Sat Nov 10, 2007 12:47 pm    Post subject: Reply with quote

If you wanna use getCh(), then so be it:

Code:

[DllImport("msvcrt.dll")]
public static extern int _getch();


Later on in your code:

Code:

Console.WriteLine("Press any key to continue...");
_getch();


That simple.

I would just prefer to have as little DLL Imports in a project as I can.

Edit:

Or if you actually want to get the char, and not pause it:

Code:

char c = (char)_getch();


_getch() returns an int, so when you cast it as a character, it returns an actual character.
Back to top
View user's profile Send private message
Lord._
Grandmaster Cheater Supreme
Reputation: 0

Joined: 13 Jan 2007
Posts: 1169
Location: iFun Story Owner

PostPosted: Sat Nov 10, 2007 1:07 pm    Post subject: Reply with quote

o.O Try this... (I don't really understand but if you click a button and it exit...)


Using System;

Console.WriteLine("Press any key to continue");
Console.ReadLine();
Environment(0).Exit();

Something like that...
Back to top
View user's profile Send private message
killersamurai
Expert Cheater
Reputation: 0

Joined: 10 Sep 2007
Posts: 197
Location: Colorado

PostPosted: Sat Nov 10, 2007 1:54 pm    Post subject: Reply with quote

Console.ReadKey(); is what you would want. This command is like read or readline but once a key is pressed, it will exit instead of waiting for someone to press enter.
Back to top
View user's profile Send private message
samuri25404
Grandmaster Cheater
Reputation: 7

Joined: 04 May 2007
Posts: 955
Location: Why do you care?

PostPosted: Sat Nov 10, 2007 6:02 pm    Post subject: Reply with quote

killersamurai wrote:
Console.ReadKey(); is what you would want. This command is like read or readline but once a key is pressed, it will exit instead of waiting for someone to press enter.


What's the difference between that and Console.Read(); ?
Back to top
View user's profile Send private message
killersamurai
Expert Cheater
Reputation: 0

Joined: 10 Sep 2007
Posts: 197
Location: Colorado

PostPosted: Sat Nov 10, 2007 6:22 pm    Post subject: Reply with quote

It gets the key pressed by the user and then displays it. If you don't want the key to be shown on the console, just put false.
Code:

Console.ReadKey(true);
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites