 |
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
Anden100 Grandmaster Cheater
Reputation: 0
Joined: 20 Apr 2007 Posts: 668
|
Posted: Mon Apr 21, 2008 2:37 pm Post subject: convert from delphi to C++ |
|
|
How would you convert this code, from Delphi to C++?, ive got the postmessage function to work (well... it took me some time to find out i had to change "Postmessage" to "PostMessage".. forgot C++ was case sensitive...), but i dont know how to do the "for i:= 1 to Length(g) do" and the "integer(pChar(G[i]))" parts... could any1 please help me?
Code: | var
i: integer;
g: string;
begin
g:= 'asd';
for i:= 1 to Length(g) do
Postmessage(FindWindowex(FindWindow('Notepad', nil),0,nil,nil),WM_Char,integer(pChar(G[i])),1);
end; |
|
|
Back to top |
|
 |
DeletedUser14087 I post too much
Reputation: 2
Joined: 21 Jun 2006 Posts: 3069
|
Posted: Mon Apr 21, 2008 2:40 pm Post subject: |
|
|
int i;
char *g;
HWND l;
void main()
{
l = FindWindow(NULL,"Notepad");
g = "asd";
for (i = 1; strlen(g))
PostMessage(l,WM_CHAR,(int)PCHAR(g[i]),0);
}
try it
|
|
Back to top |
|
 |
Anden100 Grandmaster Cheater
Reputation: 0
Joined: 20 Apr 2007 Posts: 668
|
Posted: Mon Apr 21, 2008 2:46 pm Post subject: |
|
|
It just freezes Notepad..., well, i gtg now , sorry, but ty anyways, atleast i succeded building it this time
|
|
Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Mon Apr 21, 2008 3:26 pm Post subject: |
|
|
Code: | #include <windows.h>
int i;
char g[] = "butts";
HWND handle;
int main()
{
handle = FindWindow("Notepad", NULL);
handle = FindWindowEx(handle, NULL, "Edit", NULL);
for(i = 0; i < sizeof(g); i++){
PostMessage(handle, WM_CHAR, (WPARAM)g[i], 0);
}
return 0;
} |
|
|
Back to top |
|
 |
lurc Grandmaster Cheater Supreme
Reputation: 2
Joined: 13 Nov 2006 Posts: 1900
|
Posted: Mon Apr 21, 2008 3:50 pm Post subject: |
|
|
I made something that is exactly what you want for a friend of mine.
Ive attached the binary and source.
_________________
|
|
Back to top |
|
 |
Anden100 Grandmaster Cheater
Reputation: 0
Joined: 20 Apr 2007 Posts: 668
|
Posted: Tue Apr 22, 2008 12:02 am Post subject: |
|
|
lurc wrote: | I made something that is exactly what you want for a friend of mine.
Ive attached the binary and source. |
Gives me an error...:
Code: | 1>main.cpp
1>Linking...
1>MSVCRTD.lib(crtexe.obj) : error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup
1>C:\Documents and Settings\*****\My Documents\Visual Studio 2008\Projects\hkajd\Debug\hkajd.exe : fatal error LNK1120: 1 unresolved externals
1>Build log was saved at "file://c:\Documents and Settings\*****\My Documents\Visual Studio 2008\Projects\hkajd\hkajd\Debug\BuildLog.htm"
1>hkajd - 2 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== |
Last edited by Anden100 on Tue Apr 22, 2008 11:52 am; edited 1 time in total |
|
Back to top |
|
 |
Noz3001 I'm a spammer
Reputation: 26
Joined: 29 May 2006 Posts: 6220 Location: /dev/null
|
Posted: Tue Apr 22, 2008 3:53 am Post subject: |
|
|
You are trying to compile it in .NET?
PS, Anders, You censored out 1 of 2 instances of your name..
|
|
Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8586 Location: 127.0.0.1
|
Posted: Tue Apr 22, 2008 6:41 am Post subject: |
|
|
Start Visual Studio, choose New Project, Choose Win32 Project.
At the Win32 Application Wizard window, click on Application Settings, and choose:
- Console Application
- Check Blank Project
Then click finish.
Once Visual Studio loads, goto:
Project -> Add New Item... -> Visual C++ -> C++ File (.cpp)
Name it anything you want, preferably 'main.cpp' since its the main project file.
Example code using TCHAR:
Code: | #include <windows.h>
#include <tchar.h>
int main( int argc, TCHAR* argcv[] )
{
UNREFERENCED_PARAMETER( argc );
HWND hWndNotepadEdit = NULL;
hWndNotepadEdit = FindWindowEx( FindWindow( _T("Notepad"), NULL ), NULL, _T("Edit"), NULL );
if( INVALID_HANDLE_VALUE != hWndNotepadEdit )
for( int x=0; x<static_cast<int>(_tcslen(argcv[0])); x++ )
PostMessage( hWndNotepadEdit, WM_CHAR, (WPARAM)(char)argcv[0][x], (LPARAM)NULL );
return 0;
} |
This code will not work for Unicode character set because of how Notepad is compiled. WM_CHAR is designed to send only the given character set to a window of the same character set.
To change the character set you compile in, goto:
Project -> Properties (Hit ALT+F7 if you want) -> Configuration Properties -> General
On the right, you should see 'Character set', change the value to the right of that to 'Use Multi-byte Character Set'.
_________________
- Retired. |
|
Back to top |
|
 |
Anden100 Grandmaster Cheater
Reputation: 0
Joined: 20 Apr 2007 Posts: 668
|
Posted: Tue Apr 22, 2008 7:27 am Post subject: |
|
|
Hmm, wic, you didnt need to write a whole actual tutorial O.o, do you think i would like to know about this, without ANY knowledge in C++??, ive done those booring tutorials with calculators and so...
-----------------------
edit:
how do i change the text, that is send to Notepad?, it sends this:
"c:\Documents and Settings\ill cencor this time \My Documents\Visual Studio 2008\Projects\hkajd\Debug\hkajd.exe lolz...
Last edited by Anden100 on Tue Apr 22, 2008 11:58 am; edited 1 time in total |
|
Back to top |
|
 |
--Pillboi-- Grandmaster Cheater Supreme
Reputation: 0
Joined: 06 Mar 2007 Posts: 1383 Location: I don't understand the question. Is this a 1 to 10 thing?
|
Posted: Tue Apr 22, 2008 11:38 am Post subject: |
|
|
Anden100 wrote: | Code: | 1>C:\Documents and Settings\A*****\My Documents\Visual Studio 2008\Projects\hkajd\Debug\hkajd.exe |
|
Change your post before to get rid of your name!
_________________
Enter darkness, leave the light, Here be nightmare, here be fright...
Earth and Water, Fire and Air. Prepare to meet a creature rare.
Enter now if you dare, Enter now the dragon's lair. |
|
Back to top |
|
 |
Anden100 Grandmaster Cheater
Reputation: 0
Joined: 20 Apr 2007 Posts: 668
|
Posted: Tue Apr 22, 2008 11:53 am Post subject: |
|
|
--Pillboi-- wrote: | Anden100 wrote: | Code: | 1>C:\Documents and Settings\A*****\My Documents\Visual Studio 2008\Projects\hkajd\Debug\hkajd.exe |
|
Change your post before to get rid of your name! |
I dont really care, its my parents who wants me to..., well however, i dont think any1 would track me down and kill me, and steal all of my money, using my first name O.o
|
|
Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8586 Location: 127.0.0.1
|
Posted: Tue Apr 22, 2008 5:21 pm Post subject: |
|
|
Anden100 wrote: | Hmm, wic, you didnt need to write a whole actual tutorial O.o, do you think i would like to know about this, without ANY knowledge in C++??, ive done those booring tutorials with calculators and so...
-----------------------
edit:
how do i change the text, that is send to Notepad?, it sends this:
"c:\Documents and Settings\ill cencor this time \My Documents\Visual Studio 2008\Projects\hkajd\Debug\hkajd.exe lolz... |
It uses the default first argument in a console application, which is the executables path. The lines:
Code: | for( int x=0; x<static_cast<int>(_tcslen(argcv[0])); x++ )
PostMessage( hWndNotepadEdit, WM_CHAR, (WPARAM)(char)argcv[0][x], (LPARAM)NULL ); |
This is what you want to edit.
_________________
- Retired. |
|
Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
|