|
Ok! Thank You very much for participating.
|
|
|
|
|
hi,
I am using the following code to send a string to the notepad, without direct keyboard input(using SendInput function):
//start of code
CString str(_T("D:\\sample.gho"));
INPUT key[2];
int nLeng = str.GetLength();
for(int index=0;index < nLeng;index++ )
{
::ZeroMemory(key, sizeof(key));
key[0].type = key[1].type = INPUT_KEYBOARD;
SHORT nKeyCode = VkKeyScan(str[index]);
if (VK_SHIFT & nKeyCode)
{
key[0].ki.wVk = VK_SHIFT;
key[0].ki.dwFlags = KEYEVENTF_KEYUP;
//shift key plus char
key[1].ki.wScan = str[index];
key[1].ki.dwFlags = KEYEVENTF_UNICODE ;
}
else if (VK_CAPITAL & nKeyCode)
{
key[0].ki.wVk = VK_CAPITAL;
key[0].ki.dwFlags = KEYEVENTF_KEYUP;
//capital key plus char
key[1].ki.wScan = str[index];
key[1].ki.dwFlags = KEYEVENTF_UNICODE ;
}
else
{
key[1].ki.wVk = nKeyCode;
key[1].ki.dwFlags = KEYEVENTF_UNICODE ;
}
key[0].ki.time = key[1].ki.time = 0;
key[0].ki.dwExtraInfo = key[1].ki.dwExtraInfo=0;
SendInput(2,key,sizeof(INPUT));
}
//end of code
But, unfortunately, I gets an error:
'KEYEVENTF_UNICODE' : undeclared identifier
Please help me.
Thanks in advance.
SYAMLAL
|
|
|
|
|
MSDN say, that KEYEVENTF_UNICODE used for Windows 2000/XP only.
In winuser.h you can see
#if(_WIN32_WINNT >= 0x0500)
#define KEYEVENTF_UNICODE 0x0004
#define KEYEVENTF_SCANCODE 0x0008
#endif /* _WIN32_WINNT >= 0x0500 */
So, if you are realy in Win2000 or XP...
Look in file stdafx.h.
I work in XP, and I have next line in stdafx.h :
#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0400
See? Change this on
#define _WIN32_WINNT 0x0500
#endif
May be it'll help for you
Best regards,
Baron
|
|
|
|
|
Thanks a lot.
Actually
#define KEYEVENTF_UNICODE 0x0004
#define KEYEVENTF_SCANCODE 0x0008
these lines were not present in my winuser.h file.
So I added these in that file, and the application is now working fine.
Once again,,thanx
SYAMLAL
|
|
|
|
|
hi my project is obut proming with port usb .plz explain obut it.tanks
|
|
|
|
|
Click here[^]
Nobody can give you wiser advice than yourself. - Cicero
|
|
|
|
|
Hi,
I have a text file which its contents in has to be loaded into an array. The content in the.txt file has some spaces between them and it is also a few lines long(separated by '\n'). May i know how to copy the whole file into an array?
Thank you for any help.
|
|
|
|
|
i'd suggest you to turn to C++ solutions instead of sticking to C.
by the way :
char pszBuffer[NUMBER_LONG_ENOUGH];
::fscanf(myOpenedFile, "%s", pszBuffer);
|
|
|
|
|
I can't use this method, somehow the character save in the file turns out to be in funny shapes and not the ones i input. Below is the code i used.
FILE *stream;
stream = fopen( "Result File.txt", "w+" );
char pszBuffer[500]; ::fscanf(stream, "%s", pszBuffer);
|
|
|
|
|
hey, you open the file writable, not readable...
|
|
|
|
|
sorry mistakes, just a beginner...
but if i change w to r,it still does not help. btw, i need to put it in array of characters for it to work.
|
|
|
|
|
You can use ifstream for that purpose. You can extract formatted data from the stream by using the extraction operator ( >> ).
ifstream myFile("MyFile.txt);
int iValue;
myFile >> iValue;
See here[^] for more info.
EDIT: when looking at toxcct answer, I'm wondering: your file contains only pure text that you want to load into a string or does it contain numeric values that you want to load into an array (like an integer array) ?
|
|
|
|
|
i want get characters from the file and put it in one array. Can i use getline or other functions. This array must be able to save the file content exactly because i want to use the array to save it in another file at a specified location or path.
|
|
|
|
|
Try using CString.
Regards,
Paresh.
|
|
|
|
|
#include <fstream>
#include <vector>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
ifstream f;
vector<char> vec;
f.open("test.test");
while(true)
{
char ch;
f.get(ch);
if(f.eof())
break;
if (ch != ' ' && ch != '\n')
vec.push_back(ch);
}
int size = vec.size();
char *arr = new char[size];
memset(arr, 0, size);
for (int c = 0; c < size; c++)
{
arr[c] = vec[c];
}
f.close();
delete arr;
return 0;
}
Best regards,
Baron
|
|
|
|
|
what are you trying to do with all these lines of code ?
the OP only wants to read his file in a buffer !
|
|
|
|
|
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
It seems to generate these error:
error C2146: syntax error : missing ';' before identifier 'vec'
C:\ error C2065: 'vec' : undeclared identifier
C:\: error C2228: left of '.push_back' must have class/struct/union type
C:\ : error C2228: left of '.size' must have class/struct/union type
C:\) : error C2109: subscript requires array or pointer type
Error executing cl.exe.
|
|
|
|
|
have you that:
#include <fstream>
#include <vector>
using namespace std;
Best regards,
Baron
|
|
|
|
|
sorry, forgot about html...
must be included next files :
<fstream.h> and <vector>
Best regards,
Baron
|
|
|
|
|
i tried to put #include <vector> but the same error occurs. I'm using MSVC6
|
|
|
|
|
may be <vector.h> will help you
Best regards,
Baron
|
|
|
|
|
I want to saving a drawing in client area to a bitmap file,I have refered to an article "saving a drawing to a bitmap file" in our website,but I don't know how it works.I appreciate more examples and explainations.Thanks.
|
|
|
|
|
I saw some functions such as WriteWindowToDIB,DDBToDIB(),WriteDIB() in some articles,but I can't find them in MSDN~why?~~
|
|
|
|
|
Chen-XuNuo wrote: but I don't know how it works
You're a programmer, right?
Try doing a search on CP. I'm certainly not going to do it (the search) for you.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|