Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Go Back   Code Forums > Application and Web Development > Program Design and Methods
User Name
Password

Reply
 
LinkBack Thread Tools Display Modes
Old 01-08-2007, 09:37 AM   #1 (permalink)
killerk_89
Recruit
 
Join Date: Jan 2007
Posts: 6
killerk_89 is on a distinguished road
I Need Some Help On Code

Does anyone know how to make it so i can have a script that will press the x button every minute once
i use the autoit
__________________
killerk_89 is offline   Reply With Quote
Old 01-08-2007, 09:38 AM   #2 (permalink)
killerk_89
Recruit
 
Join Date: Jan 2007
Posts: 6
killerk_89 is on a distinguished road
if so can u post the code for me
__________________
killerk_89 is offline   Reply With Quote
Old 01-08-2007, 10:12 AM   #3 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,397
sde is on a distinguished road
is hardware an option? this keyboard is sweet for macro type stuff like what you are explaining. http://www.logitech.com/index.cfm/pr...ONTENTID=10717

i'm not sure about code though.
__________________
testing 1 2 3
sde is offline   Reply With Quote
Old 01-08-2007, 10:13 AM   #4 (permalink)
killerk_89
Recruit
 
Join Date: Jan 2007
Posts: 6
killerk_89 is on a distinguished road
well see its for a game where i need my character to do something with the x key every minute
__________________
killerk_89 is offline   Reply With Quote
Old 01-08-2007, 10:52 AM   #5 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,680
redhead is on a distinguished road
Write a wrapper, through which you run your game.
Have the wrapper say
  • Any key press, send unchanged to child process.
  • if no key-press within N seconds from last key press, send X-key to child process.
  • Anything returned from child, send unchanged to parent stdout/error
If it's controled stricktly through keyboard bindings, then it's not that difficult, but if it's controled through mouse-movements aswell, then it will introduce some difficulties, which you can overcome, but not without alot of trouble.
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Old 01-08-2007, 10:57 AM   #6 (permalink)
killerk_89
Recruit
 
Join Date: Jan 2007
Posts: 6
killerk_89 is on a distinguished road
kk im real new wuts a wrapper? is that macro?
__________________
killerk_89 is offline   Reply With Quote
Old 01-08-2007, 11:11 AM   #7 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,397
sde is on a distinguished road
lol, like an afk bot for wow?
__________________
testing 1 2 3
sde is offline   Reply With Quote
Old 01-08-2007, 11:13 AM   #8 (permalink)
killerk_89
Recruit
 
Join Date: Jan 2007
Posts: 6
killerk_89 is on a distinguished road
no of course not
__________________
killerk_89 is offline   Reply With Quote
Old 01-08-2007, 11:18 AM   #9 (permalink)
killerk_89
Recruit
 
Join Date: Jan 2007
Posts: 6
killerk_89 is on a distinguished road
but i mean if u have one dont mind sharing it : D
__________________
killerk_89 is offline   Reply With Quote
Old 01-08-2007, 11:24 AM   #10 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,397
sde is on a distinguished road
oh man, i nailed it! .. careful though, wow scans your running programs .. although i don't know how they could detect something custom that they have never identified before.
__________________
testing 1 2 3
sde is offline   Reply With Quote
Old 01-08-2007, 11:49 AM   #11 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,680
redhead is on a distinguished road
Since you seem to be C oriented, heres a quick example (Do note it hasn't been tested, and it lacks almost every form of error-checking):
Code:
#define WAIT_TIME 60 /* time to wait in seconds */ #define SEND_KEY 'X' /* Key to send to executed program */ void fork_child(const char* program) { int parent2child[2], child2parent[2], input, output, nwrite, status; size_t last_call = time(NULL); /* Fork child */ switch (fork()) { case -1: perror("fork"); exit(1); case 0: /* Child section */ /* * Duplicate child's stdin into parents stdin, * and child's writing end of child2parent into stdout */ if (dup2(parent2child[0], STDIN_FILENO) ==-1 || dup2(child2parent[1], STDOUT_FILENO) ==-1) { printf("Error: Child duping parent2child and child2parent.\n"); exit(1); } /* Close unused filedescriptors */ if(close(parent2child[0]) != 0) { printf("Error: Child closing parent2child[0].\n"); exit(1); } if(close(parent2child[1]) != 0) { printf("Error: Child closing parent2child[1].\n"); exit(1); } if(close(child2parent[0]) != 0) { printf("Error: Child closing child2parent[0].\n"); exit(1); } if(close(child2parent[1]) != 0) { printf("Error: Child closing child2parent[1].\n"); exit(1); } /* * All set: execute program */ execvp(program, NULL); printf("Error: Child executing program {%s}.\n", program); exit(1); default: /* Parent section */ /* Close unused fildescriptor */ if(close(child2parent[1]) != 0) { printf("Error: Child closing child2parent[1].\n"); exit(1); } if(close(parent2child[0]) != 0) { printf("Error: Parent closing parent2child[0].\n"); exit(1); } while(1) {/* get user input and send to child */ /* this is depeding on a system which is in chbreak mode */ if((input = getch()) == ERR) {/* no userinput, see if it is time to send 'x' */ if(last_call+WAIT_TIME < time(NULL)) { /* update last_call */ last_call = time(NULL); /* write 'x' to child */ if((nwrite = write(parent2child[1], (void*)SEND_KEY, 1)) < 0) { printf("Error: Parent writing to child\n"); exit(1); } } else { /* send out ERR of userinput */ if((nwrite = write(parent2child[1], (void*)SEND_KEY, 1)) < 0) { printf("Error: Parent writing to child\n"); exit(1); } } } else { /* send userinput direct to child */ /* update last_call */ last_call = time(NULL); /* send userinput */ if((nwrite = write(parent2child[1], (void*)input, 1)) < 0) { printf("Error: Parent writing to child\n"); exit(1); } } /* read return output from child and send to parents output */ if(read(child2parent[0], output, 1) < 0) { /* nothing to read from child */ /* so do whatever you want or do nothing */ ; } else { /* something to read, so send it */ putc(output); } if(waitpid(0,&status,0) <= 1) { /* some error during execution */ printf("Error: Child exited with status: %d\n", status); exit(1); } } } }
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Old 01-08-2007, 12:34 PM   #12 (permalink)
teknomage1
Jack of all trades
 
teknomage1's Avatar
 
Join Date: Feb 2005
Location: Los Angeles
Posts: 595
teknomage1 is on a distinguished road
Send a message via AIM to teknomage1
I've heard a drinking bird can be handy for this sort of thing.
__________________
Stop intellectual property from infringing on me
teknomage1 is offline   Reply With Quote
Old 01-08-2007, 12:46 PM   #13 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,397
sde is on a distinguished road
it's funny, .. i was thinking the same thing .. i just saw that episode the other night again too.
__________________
testing 1 2 3
sde is offline   Reply With Quote
Old 01-08-2007, 01:02 PM   #14 (permalink)
toe_cutter
Code Monkey
 
Join Date: Aug 2002
Location: Boston, MA
Posts: 79
toe_cutter is on a distinguished road
Send a message via ICQ to toe_cutter Send a message via AIM to toe_cutter Send a message via Yahoo to toe_cutter
Quote:
Originally Posted by teknomage1 View Post
I've heard a drinking bird can be handy for this sort of thing.
Simpsons
__________________
toe_cutter is offline   Reply With Quote
Old 01-10-2007, 03:01 AM   #15 (permalink)
DJMaze
Senior Contributor
 
DJMaze's Avatar
 
Join Date: Mar 2005
Posts: 635
DJMaze is on a distinguished road
http://msdn.microsoft.com/library/de...ostmessage.asp

Find the window and then the virtual key code to send using PostMessage.

GOOD LUCK!
__________________

UT: Ultra-kill... God like!
DJMaze is offline   Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Hey guys! Code malfunction - need experts workover groundfrog Platform/API C++ 1 06-09-2005 07:46 AM
how the servlet will integrate the LDAP code j.gohel Java 19 04-16-2005 12:55 AM
Cisco Code breaking sde Code Newbie News 0 05-21-2004 07:10 AM
Microsoft probes Windows code leak redhead Code Newbie News 0 02-13-2004 12:41 AM
An Introduction to XHTML/CSS Rie HTML / CSS 0 03-07-2003 06:50 PM


All times are GMT -8. The time now is 07:20 PM.


Powered by vBulletin Version 3.6.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2006, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting
Open Circle