|
Excellent answer, David. My 5 vote to you.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Hi, I have some problem with sending keystroke/keystroks to a full screen game (Counter Strike Source, if it matter). What I want to do is simply send a lot of keystroke, for example so your character jump automatics while you hold down a key.
I have try to use keybd_event and SendInput, neither of them seems to work the way I want them to. Both work with menus and chat windows but have no effect in gameplay. So I can press for example 'y' and open the chat window and then let the program write there but it can't open it by itself, or no keys like jump(blankspace) and forward(w) works neither (in gameplay).
My SendKey function look like this,
void SinKey(WORD keyCode)
{
INPUT key;
key.type = INPUT_KEYBOARD;
key.ki.wVk = keyCode;
key.ki.dwFlags = 0;
key.ki.time = 0;
key.ki.wScan = 0;
key.ki.dwExtraInfo = 0;
SendInput(1,&key,sizeof(INPUT));
key.ki.dwExtraInfo = KEYEVENTF_KEYUP;
SendInput(1,&key,sizeof(INPUT));
}
and my keybd_event function look like this.
void keyPress(unsigned char keyCode)
{
keybd_event( keyCode, 0x45, KEYEVENTF_EXTENDEDKEY, 0 );
keybd_event( keyCode, 0x45, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0 );
}
As I said, both work in menus and for example noteopad but not in games.
Have this something with directx to do?
If you have any idea/ideas or even better a solution please let me know .
Thanks for all help I can get.
edit: pls reply in the forum becouse the email address I have here has ceased to function.
edit2: I have got a tip to use spy++ and I working on it. I will also add the solution here as soon as I find one.
modified on Thursday, June 11, 2009 7:05 PM
|
|
|
|
|
Hello!
You can use Spy++ to see what is going on under the hood when those messages are being sent to the game. Also, is the game yours or someone else (the source code is with you or not?) If you have the source for the game, you can write the keyboard events that occurs in the game to a log file and check if the correct key strokes are received or not.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Hi, thanks for your awnser.
Unfortunately, I don't have the source code available. But I will definitely give Spy++ a try, good idea.
|
|
|
|
|
Hello,
I am creating a linked list. I have found that the best way to develop the linked list is to have the head and tail in another structure. My products struct will be nested inside this structure. And I should be passing the list to the function for adding and deleting. I find this concept confusing.
I have implemented the initialize, add, and clean_up. However, I am not sure that I have done that correctly.
When I add a product to the list I declare some memory using calloc. But I am thinking shouldn't I be declaring the memory for the product instead. I am really confused about this adding.
Many thanks for any suggestions,
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define PRODUCT_NAME_LEN 128
typedef struct product_data
{
int product_code;
char product_name[PRODUCT_NAME_LEN];
int product_cost;
struct product_data_t *next;
}product_data_t;
typedef struct list
{
product_data_t *head;
product_data_t *tail;
}list_t;
void add(list_t *list, int code, char name[], int cost);
void initialize(list_t *list);
void clean_up(list_t *list);
int main(void)
{
list_t *list = NULL;
initialize(list);
add(list, 10, "Dell Inspiron", 1500);
clean_up(list);
getchar();
return 0;
}
void add(list_t *list, int code, char name[], int cost)
{
list = calloc(1, sizeof(list_t));
if(!list)
{
fprintf(stderr, "Cannot allocated memory");
exit(1);
}
if(list)
{
list->head->product_code = code;
list->head->product_cost = cost;
strncpy(list->head->product_name, name, sizeof(list->head->product_name));
list->head->product_name[127] = '/0';
}
}
void initialize(list_t *list)
{
list = NULL;
list = NULL;
}
void clean_up(list_t *list)
{
list_t *temp = NULL;
while(list)
{
temp = list->head;
list->head = list->head->next;
free(temp);
}
list = NULL;
list = NULL;
temp = NULL;
}
|
|
|
|
|
Me think you don't need the list structure, you only need the product_data structure.
in your code, you only need a pointer to the first element in the list.
This signature was proudly tested on animals.
|
|
|
|
|
steve_rm wrote: Many thanks for any suggestions,
Compare what you have to:
typedef struct product_data
{
int product_code;
char product_name[PRODUCT_NAME_LEN];
int product_cost;
product_data *next;
} product_data_t;
typedef struct list
{
product_data_t *head;
product_data_t *tail;
} list_t;
void add(list_t *l, int code, char name[], int cost)
{
product_data_t *node;
node = new product_data_t;
node->product_code = code;
node->product_cost = cost;
strcpy(node->product_name, name);
node->next = NULL;
if (l->head == NULL)
l->head = node;
if (l->tail != NULL)
l->tail->next = node;
l->tail = node;
}
void clean_up( list_t *l )
{
while (l->head != NULL)
{
product_data_t *node = l->head;
l->head = node->next;
delete node;
node = NULL;
}
}
void main(void)
{
list_t l;
l.head = NULL;
l.tail = NULL;
add(&l, 10, "Dell Inspiron", 1500);
add(&l, 11, "Dell Inspirona", 1501);
add(&l, 12, "Dell Inspironb", 1502);
add(&l, 13, "Dell Inspironc", 1503);
clean_up(&l);
}
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Hello,
Thanks for the source. However, I had done it a similar way like that. However, I changed to having the list_t structure as I have been informed that is not good practice to have the head and tail as global and should be contained in a structure. I think this makes it more generic.
That was why I was having some problems with my source code.
Thanks,
|
|
|
|
|
A few small changes will correct that.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
steve_rm wrote: I am creating a linked list.
Is there some reason you are not using the STL list?
|
|
|
|
|
Hello,
The reason I am not using the STL list, is I am practicing C programming and wanted to get up to speed on both pointers and lists.
Thanks,
|
|
|
|
|
steve_rm wrote: ...I am practicing C programming and wanted to get up to speed on both pointers and lists.
So did you ever get a grasp on this topic?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Please help,
I have a problem trying to set the text parameter of my CRichEditCtrl ::SetWindowText(my param)
When i write my string directly as param it work correct but when i make it a variable it not work
|
|
|
|
|
Showing some code wouldn't hurt your chances of getting an answer.
Steve
|
|
|
|
|
this the part of my code :
CString m_strShowText;
m_RichReportUserImport.SetWindowText(m_strShowText); // This dont work
long nCountLine = m_RichReportUserImport.GetLineCount();
m_RichReportUserImport.LineScroll(nCountLine - 4, 0);
...
but when i write like that it work normaly:
m_RichReportUserImport.SetWindowText("this is a test");
long nCountLine = m_RichReportUserImport.GetLineCount();
m_RichReportUserImport.LineScroll(nCountLine - 4, 0);
...
So, can you help me ?
|
|
|
|
|
If you have a CString member variable you could use UpdateData(FALSE) . Some people say UpdateData() should not be used but it always worked for me.
|
|
|
|
|
ok it work but it display a part only of the string and not the all.so what can i do?
|
|
|
|
|
khaliloenit wrote: part only of the string
You'll have to be a bit more specific. It might have to do with the "LineScroll" function you are using or maybe the styles of your control are not correct (ES_MULTILINE comes to mind).
|
|
|
|
|
I am creating a program for a children's ATM for the local kids museum, and I'm having problems sending data to the machine (over RS232). I am using a .dll supplied by the manufacturer that is used to interface the dispenser with a computer. I think the problem is in sending the hex characters to the machine. I open the port fine (according to the generated log file), but then I send and don't recieve the ACK. I'm pretty sure that it is just not sending for some reason. here is the pertinent part of the code. thanks for any help
#include "stdafx.h"
#include
typedef struct
{
unsigned int uiPort; //communication port
unsigned char ucDataBits; //Data bit
unsigned char ucParity; //Parity bit
unsigned char ucStopBits; //Stop bit
unsigned long dwBaudRate; //Baud Rate
HWND hwnd; //Parent window handle
unsigned char ucCommandType; //command type(1: ezCDM-1000 )
}SETINFO;
typedef unsigned int (*EZLINKOPEN)(SETINFO* setInfo);
typedef unsigned int (*EZLINKCLOSE)(void);
typedef unsigned int (*EZLINKPATH)(PCHAR pcMessage);
typedef unsigned int (*EZLINKSEND)(DWORD dwCmdExcuteTime, PUCHAR pcMessage, UINT uiCmdSize);
typedef unsigned int (*EZLINKRCV)(PUCHAR pcMessage, UINT *piRspSize);
int _tmain(int argc, _TCHAR* argv[])
{
//Loading dll------------------------------------------------------------------------------------------
HINSTANCE hdll = NULL;
hdll = LoadLibrary(TEXT("ezlink")); //load the dll
if (hdll == NULL)
{
printf("Didn't load dll\n"); //tell me if it failed
}
//Mapping the dll's functions--------------------------------------------------------------------------------
EZLINKOPEN ezLinkOpen;
EZLINKCLOSE ezLinkClose;
EZLINKPATH ezLinkPath;
EZLINKSEND ezLinkSend;
EZLINKRCV ezLinkRcv;
ezLinkOpen = (EZLINKOPEN)GetProcAddress(hdll,"ezLinkOpen");
ezLinkClose = (EZLINKCLOSE)GetProcAddress(hdll,"ezLinkClose");
ezLinkPath = (EZLINKPATH)GetProcAddress(hdll,"ezLinkPath");
ezLinkSend = (EZLINKSEND)GetProcAddress(hdll,"ezLinkSend");
ezLinkRcv = (EZLINKRCV)GetProcAddress(hdll,"ezLinkRcv");
//handle the error
if(!ezLinkOpen) //end program if dll mapping fails fails
{
FreeLibrary(hdll);
printf("Failed to map open function!\n");
return -1;
}
else //otherwise, lets send some commands
{
unsigned int result;
//Setting the log path--------------------------------------------------------------------------------------------
char message[] = "C:\\Documents and Settings\\august brower\\My Documents\\Visual Studio 2008\\Projects\\cash machine";
result = ezLinkPath((PCHAR) &message);
printf("Result of Path: '%i'\n", result);
//Opening the port---------------------------------------------------------------------------------------------------
SETINFO pSetInfo;
pSetInfo.uiPort =3;
pSetInfo.ucDataBits = 8;
pSetInfo.ucParity = 2;
pSetInfo.ucStopBits = 0;
pSetInfo.dwBaudRate = 9600;
pSetInfo.hwnd = GetActiveWindow();
pSetInfo.ucCommandType = 1;
result = ezLinkOpen(&pSetInfo);
printf("Result of Open: '%i'\n", result);
unsigned char response[20] ;
UINT *rspSize;
rspSize = (PUINT)malloc(sizeof(UINT));
//Sending commands
unsigned char command[6] = {0x01,0x30,0x02,0x50,0x03,0x60};
unsigned char command9[1] = {0x06};
unsigned char command1[12] = {0x01,0x30,0x02,0x4B,0x42,0x32,0x42,0x32,0x42,0x32,0x03,0x0B};
unsigned char command2[7] = {0x01,0x30,0x02,0x42,0x21,0x03,0x53};
PUCHAR cassette; //check cassette
PUCHAR ack; //acknowledge
PUCHAR bill; //set bill dimensions
PUCHAR dispense; //dispense 1 bill
cassette = command;
ack = command9;
bill= command1;
dispense=command2;
//--get cassette info-------------------------------------------------
result = ezLinkSend(4000,cassette;message,6);
printf("Result of Send: '%i'\n", result);
result = ezLinkRcv(response,rspSize);
printf("Result of Receive: '%i'\n", result);
result = ezLinkRcv(response,rspSize);
printf("Result of Receive: '%i'\n", result);
result = ezLinkSend(4000,ack,1);
printf("Result of Send: '%i'\n", result);
|
|
|
|
|
August Brower wrote: result = ezLinkSend(4000,cassette;message,6);
What is this (it looks pretty ugly, with that semicolon...)?
You know, without knowing proper command format (probably you've some documentation about) we can give little help to you.
BTW: please use <pre> tags (or code block button) to enclose code snippets.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
By looking at following code statements,
unsigned char response[20] ;
UINT *rspSize;
rspSize = (PUINT)malloc(sizeof(UINT));
result = ezLinkRcv(response,rspSize);
it seems like problem with rspSize, rspSize doesn't match with response memory allocatin i.e. 20. I suggest you to try out giving hard-coded 20 instead of rspSize to know exact problem and then after implement generalized logic.
|
|
|
|
|
How to debug a DLL () running on the remote server using Visual studio 2005
|
|
|
|
|
|
Here are some of the steps that mey helps you,
> Run msvsmon.exe located under "Program Files\Microsoft Visual Studio 8\Common7\IDE\Remote Debugger\x86" on the remote machine where EXE is running.
> Then change the Tools->Options in msvsmon.exe according to your requirements.
> On machine where VS2005 is running, Debug->Attach to Process: Transport-Remote, Qualifier-machine-name:port. Click on Refresh, that will give you list of processes running on remote machine.
Hope this helps.
|
|
|
|
|
On my server visual studio 8 is not installed, It was installed only on my development machine,
how can I go ahead
|
|
|
|
|