Be a Supporter!

a program..

  • 556 Views
  • 14 Replies
New Topic Respond to this Topic
JeremysFilms
JeremysFilms
  • Member since: Feb. 18, 2005
  • Offline.
Forum Stats
Member
Level 18
Blank Slate
a program.. 2006-07-22 19:08:10 Reply

I want a program that, while running, will return the key on the keyboard that was pressed, then it will paste in text cooresponding to that key.

Example, if I press 'a' the word apple will be put onto my clipboard and then pasted.

- What language should I use for this?
- How hard will it be to make?

CaptinChu
CaptinChu
  • Member since: Sep. 11, 2005
  • Offline.
Forum Stats
Member
Level 15
Blank Slate
Response to a program.. 2006-07-22 23:18:30 Reply

I don't think you should make it copy to clipboard. But I do know how to do that simply in C++
#include <iostream>

int main(){
char letter;

std::cout<<"Enter a letter";
std::cin>>letter;

switch (letter) {
case a:
std::cout<<"Apple";
break;
/*Fill in the rest with case whatever std::cout<<"what you want to call them" and seperating them with breaks*/
default:
std::cout<<"That either wasn't a letter or there was a program error.";
break;
}
std::cout<<"Press enter or return to continue.";
std::cin.get();
return 0;
}

Cinjection
Cinjection
  • Member since: Apr. 6, 2004
  • Offline.
Forum Stats
Member
Level 18
Blank Slate
Response to a program.. 2006-07-23 00:01:48 Reply

At 7/22/06 11:18 PM, CaptinChu wrote: solution

Or you can use ArrayLists in Java to compare. It'd be a lot less code. Have two. One for the word and the other for the letter and use the indexOf(user input); method to get the index entered char. Then use that index to get the word from word array.

Tigiot
Tigiot
  • Member since: Jul. 22, 2006
  • Offline.
Forum Stats
Member
Level 03
Blank Slate
Response to a program.. 2006-07-23 00:06:04 Reply

You could do it in Visual Basic where you have a get key function and have it recognize everytime you hit a key and output it to a label. Sorry I can't provide the code but I don't know much VB and I don't have my source for something similar off hand.

Off-Topic: Alright I don't know C+(although I want to learn) I do know that in Java and other languages a switch statement is for integers only, I find it kind of odd that they wouldn't do that as well in C+ so when people would be adapting languages it would be simpler.

Cinjection
Cinjection
  • Member since: Apr. 6, 2004
  • Offline.
Forum Stats
Member
Level 18
Blank Slate
Response to a program.. 2006-07-23 00:12:53 Reply

Using a switch statment i think is supposed to be used for only integers. I'm not C++ lets you even do that. Either way, using a switch statment is not a very effiecient way of coding this. That's a lot of coding that's not nessecary.

Another solution would be to use PHP and use thier refernce key thing. Not sure on what it's actually called. It let's you make an array with values insdead of refrences. Not sure on the syntax exactly, but it's something like this:

sexy = { "a" => "apple", "b" => "boat" ... };

and then you can go

echo sexy["a"]; // which outputs apple

Obvoisly that would be a better solution also. Granted that syntax is probably wrong(correct it someone?).

Just to show you. 1000 different ways to solve a problem.

0x41
0x41
  • Member since: Dec. 30, 2004
  • Offline.
Forum Stats
Member
Level 10
Blank Slate
Response to a program.. 2006-07-23 00:18:03 Reply

I'd have it search for the correct word from a list right after it's entered.
Here's some pseudo-code
:[[List of everything prepared in a text file or vector or whatever]]
:User inputs x
:Loop to search from list for first character to be x
:Display word from list where x was found to be the first letter

No need for 26 case statements.

Tigiot
Tigiot
  • Member since: Jul. 22, 2006
  • Offline.
Forum Stats
Member
Level 03
Blank Slate
Response to a program.. 2006-07-23 00:31:34 Reply

At 7/23/06 12:12 AM, Cinjection wrote: Another solution would be to use PHP and use thier refernce key thing. Not sure on what it's actually called. It let's you make an array with values insdead of refrences. Not sure on the syntax exactly, but it's something like this

But you forget webhosts leave their default script timeout length(60 seconds) although you could just download Xampp and change the default for yourself.

Cinjection
Cinjection
  • Member since: Apr. 6, 2004
  • Offline.
Forum Stats
Member
Level 18
Blank Slate
Response to a program.. 2006-07-23 00:38:36 Reply

At 7/23/06 12:31 AM, Tigiot wrote: But you forget webhosts leave their default script timeout length(60 seconds) although you could just download Xampp and change the default for yourself.

Yea the php solution wouldn't nesserilly work for this case. I was just pointing out that the arrays would be helpful for pulling the word given the letter. I think he needs an offline solution anyway.

JeremysFilms
JeremysFilms
  • Member since: Feb. 18, 2005
  • Offline.
Forum Stats
Member
Level 18
Blank Slate
Response to a program.. 2006-07-23 10:03:20 Reply

Um, just so you all know, I'm talking about actually pasting the text of like Apple when a is pressed, so it's on demand as soon as you click a key. So while it runs, if I type in notepad, the different letters make dif words.

Cinjection
Cinjection
  • Member since: Apr. 6, 2004
  • Offline.
Forum Stats
Member
Level 18
Blank Slate
Response to a program.. 2006-07-23 12:15:36 Reply

At 7/23/06 10:03 AM, JeremysFilms wrote: Um, just so you all know, I'm talking about actually pasting the text of like Apple when a is pressed, so it's on demand as soon as you click a key. So while it runs, if I type in notepad, the different letters make dif words.

So you want it to run in the background? Well if that's the case, I think you need hooks. And I know next to nothing on hooks.

CronoMan
CronoMan
  • Member since: Jul. 19, 2004
  • Offline.
Forum Stats
Member
Level 06
Blank Slate
Response to a program.. 2006-07-24 04:14:12 Reply

Smells like a keylogger


"no sound in ass"

JeremysFilms
JeremysFilms
  • Member since: Feb. 18, 2005
  • Offline.
Forum Stats
Member
Level 18
Blank Slate
Response to a program.. 2006-07-24 08:27:47 Reply

At 7/24/06 04:14 AM, CronoMan wrote: Smells like a keylogger

...Are you kidding me? How the hell could this be like a keylogger. I want to have words outputted when letters are typed, how the FUCK does that relate to a keylogger.

CronoMan
CronoMan
  • Member since: Jul. 19, 2004
  • Offline.
Forum Stats
Member
Level 06
Blank Slate
Response to a program.. 2006-07-24 08:59:29 Reply

At 7/24/06 08:27 AM, JeremysFilms wrote: ...Are you kidding me? How the hell could this be like a keylogger. I want to have words outputted when letters are typed, how the FUCK does that relate to a keylogger.

...In the background? ;)


"no sound in ass"

DFox
DFox
  • Member since: Aug. 9, 2003
  • Offline.
Forum Stats
Member
Level 30
Blank Slate
Response to a program.. 2006-07-24 13:44:10 Reply

At 7/24/06 04:14 AM, CronoMan wrote: Smells like a keylogger

If he wanted a keylogger, couldn't he just download a keylogger?


BBS Signature
thoughtpolice
thoughtpolice
  • Member since: Mar. 24, 2003
  • Offline.
Forum Stats
Member
Level 10
Blank Slate
Response to a program.. 2006-07-24 13:46:22 Reply

At 7/24/06 08:27 AM, JeremysFilms wrote: ...Are you kidding me? How the hell could this be like a keylogger. I want to have words outputted when letters are typed, how the FUCK does that relate to a keylogger.

They relate because the method in which many basic keyloggers work (hooks) are also the most straight forward answer to your programming problem as you can use hooks to change key output. Just because the hook translates "a" to "apple" doesn't mean it can't log "a" somewhere. Of course, this is really only a practical keylogger idea if the infected user is going to be talking to others with army callsigns or something like that. It's an unorthodox idea, but the two ideas relate at a basic level.


omg.
Playstation Network tag: muffin-noodle
the empty set