|
 |
|
 |
 |
01-08-2007, 09:37 AM
|
#1 (permalink)
|
|
Recruit
Join Date: Jan 2007
Posts: 6
|
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
__________________
|
|
|
01-08-2007, 09:38 AM
|
#2 (permalink)
|
|
Recruit
Join Date: Jan 2007
Posts: 6
|
if so can u post the code for me
__________________
|
|
|
01-08-2007, 10:13 AM
|
#4 (permalink)
|
|
Recruit
Join Date: Jan 2007
Posts: 6
|
well see its for a game where i need my character to do something with the x key every minute
__________________
|
|
|
01-08-2007, 10:52 AM
|
#5 (permalink)
|
|
Newbie
Join Date: Jun 2002
Location: Denmark
Posts: 1,680
|
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.
|
|
|
01-08-2007, 10:57 AM
|
#6 (permalink)
|
|
Recruit
Join Date: Jan 2007
Posts: 6
|
kk im real new wuts a wrapper? is that macro?
__________________
|
|
|
01-08-2007, 11:11 AM
|
#7 (permalink)
|
|
Moderator
Join Date: May 2002
Location: us.ca
Posts: 4,397
|
lol, like an afk bot for wow?
__________________
testing 1 2 3
|
|
|
01-08-2007, 11:13 AM
|
#8 (permalink)
|
|
Recruit
Join Date: Jan 2007
Posts: 6
|
no of course not
__________________
|
|
|
01-08-2007, 11:18 AM
|
#9 (permalink)
|
|
Recruit
Join Date: Jan 2007
Posts: 6
|
but i mean if u have one dont mind sharing it : D
__________________
|
|
|
01-08-2007, 11:24 AM
|
#10 (permalink)
|
|
Moderator
Join Date: May 2002
Location: us.ca
Posts: 4,397
|
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
|
|
|
01-08-2007, 11:49 AM
|
#11 (permalink)
|
|
Newbie
Join Date: Jun 2002
Location: Denmark
Posts: 1,680
|
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);
}
}
}
}
|
|
|
01-08-2007, 12:34 PM
|
#12 (permalink)
|
|
Jack of all trades
Join Date: Feb 2005
Location: Los Angeles
Posts: 595
|
I've heard a drinking bird can be handy for this sort of thing.
__________________
Stop intellectual property from infringing on me
|
|
|
01-08-2007, 12:46 PM
|
#13 (permalink)
|
|
Moderator
Join Date: May 2002
Location: us.ca
Posts: 4,397
|
it's funny, .. i was thinking the same thing  .. i just saw that episode the other night again too.
__________________
testing 1 2 3
|
|
|
01-08-2007, 01:02 PM
|
#14 (permalink)
|
|
Code Monkey
Join Date: Aug 2002
Location: Boston, MA
Posts: 79
|
Quote:
Originally Posted by teknomage1
I've heard a drinking bird can be handy for this sort of thing.
|
Simpsons 
__________________
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -8. The time now is 07:20 PM.
|
Copyright © 2000-2006, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting
Open Circle
|
 |
|