| View previous topic :: View next topic |
| Author |
Message |
blackmorpheus Expert Cheater
Reputation: 0
Joined: 05 Apr 2008 Posts: 159
|
Posted: Sat Nov 15, 2008 6:13 am Post subject: [Solved] Windowed mode coordinates of screen |
|
|
The game i play is ran in windowed mode, and it only uses OpenGL mode in windowed mode.
I have the following code for my crosshair:
| Code: | POINT mouse;
GetCursorPos(&mouse);
ScreenToClient(hWnd, &mouse);
GLfloat winX, winY;
winX = (float)mouse.x;
winY= (float)mouse.y;
glBegin(GL_LINES);
glVertex2f(winX -5, winY);
glVertex2f(winX +5, winY);
glVertex2f(winX, winY -5);
glVertex2f(winX, winY +5);
glEnd();
|
It works fine, but somehow when my window isnt exactly in the upper left corner, the crosshair will be not exactly where i want it to be.
How can i fix that? Is there some kind of Windows function that reads the upperleft coordinates of a window ?
Ill give a screenshot
| Description: |
|
| Filesize: |
70.59 KB |
| Viewed: |
7225 Time(s) |

|
Last edited by blackmorpheus on Sat Nov 15, 2008 1:09 pm; edited 2 times in total |
|
| Back to top |
|
 |
Xeleron Grandmaster Cheater
Reputation: 0
Joined: 05 Jan 2008 Posts: 652
|
Posted: Sat Nov 15, 2008 6:16 am Post subject: Re: little problem.. |
|
|
| blackmorpheus wrote: | The game i play is ran in windowed mode, and it only uses OpenGL mode in windowed mode.
I have the following code for my crosshair:
| Code: | POINT mouse;
GetCursorPos(&mouse);
ScreenToClient(hWnd, &mouse);
GLfloat winX, winY;
winX = (float)mouse.x;
winY= (float)mouse.y;
glBegin(GL_LINES);
glVertex2f(winX -5, winY);
glVertex2f(winX +5, winY);
glVertex2f(winX, winY -5);
glVertex2f(winX, winY +5);
glEnd();
|
It works fine, but somehow when my window isnt exactly in the upper left corner, the crosshair will be not exactly where i want it to be.
How can i fix that?
Ill give a screenshot |
Is this a flash Game ?
_________________
why Hitler? why did you had to pm me that child porn?
btw Hitler, Shave your pubic hair
PM Me for Hitler's Nude pics |
|
| Back to top |
|
 |
blackmorpheus Expert Cheater
Reputation: 0
Joined: 05 Apr 2008 Posts: 159
|
Posted: Sat Nov 15, 2008 6:26 am Post subject: |
|
|
| no, its a normal game.
|
|
| Back to top |
|
 |
Xeleron Grandmaster Cheater
Reputation: 0
Joined: 05 Jan 2008 Posts: 652
|
Posted: Sat Nov 15, 2008 6:32 am Post subject: |
|
|
| blackmorpheus wrote: | | no, its a normal game. | sorry , i can't help then . i only can hack some flash game's ^^
good luck!
_________________
why Hitler? why did you had to pm me that child porn?
btw Hitler, Shave your pubic hair
PM Me for Hitler's Nude pics |
|
| Back to top |
|
 |
GMZorita Grandmaster Cheater Supreme
Reputation: 0
Joined: 21 Mar 2007 Posts: 1361
|
Posted: Sat Nov 15, 2008 6:57 am Post subject: |
|
|
Oh my bad, I'm sorry....
_________________
Gone
Last edited by GMZorita on Sat Nov 15, 2008 7:07 am; edited 1 time in total |
|
| Back to top |
|
 |
blackmorpheus Expert Cheater
Reputation: 0
Joined: 05 Apr 2008 Posts: 159
|
Posted: Sat Nov 15, 2008 7:03 am Post subject: |
|
|
I am trying to hack, this is not my own game..
I hooked some OpenGL functions..
|
|
| Back to top |
|
 |
Innovation Grandmaster Cheater
Reputation: 12
Joined: 14 Aug 2008 Posts: 617
|
Posted: Sat Nov 15, 2008 8:26 am Post subject: |
|
|
Try this:
| Code: | HANDLE hWindow = FindWindow(NULL, _T("Unreal Software's Counter-Strike 2D"));
GetWindowRect(hWindow, &Window_Coordinates);
OffsetRect(&Window_Coordinates, Window_Coordinates.X, Window_Coordinates.Y);
POINT Mouse_Coordinates;
GetCursorPos(&Mouse_Coordinates);
ScreenToClient(hWindow, &Mouse_Coordinates);
GLfloat Mouse_X = (float)(Mouse_Coordinates.x += Window_Coordinates.X);
GLfloat Mouse_Y = (float)(Mouse_Coordinates.y += Window_Coordinates.Y);
glBegin(GL_LINES);
glVertex2f(Mouse_X - 5, Mouse_Y);
glVertex2f(Mouse_X + 5, Mouse_Y);
glVertex2f(Mouse_X, Mouse_Y - 5);
glVertex2f(Mouse_X, Mouse_Y + 5);
glEnd(); |
|
|
| Back to top |
|
 |
tombana Master Cheater
Reputation: 2
Joined: 14 Jun 2007 Posts: 456 Location: The Netherlands
|
Posted: Sat Nov 15, 2008 9:15 am Post subject: |
|
|
Or just remove the ScreenToClient() and see what happens....
EDIT: Oh no sorry... I didn't look at the code correctly.
Last edited by tombana on Sat Nov 15, 2008 11:00 am; edited 1 time in total |
|
| Back to top |
|
 |
blackmorpheus Expert Cheater
Reputation: 0
Joined: 05 Apr 2008 Posts: 159
|
Posted: Sat Nov 15, 2008 10:01 am Post subject: |
|
|
tnx all, i found the answer
i didnt put HWND hWnd = FindWindow(blalbala) inside my crosshair loop
|
|
| 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: Sun Nov 16, 2008 3:17 am Post subject: |
|
|
Why constantly retrieve the hwnd?
_________________
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 |
|
 |
SXGuy I post too much
Reputation: 0
Joined: 19 Sep 2006 Posts: 3551
|
Posted: Sun Nov 16, 2008 6:39 am Post subject: |
|
|
| just get a handle then call the loop, no need to loop getting the handle.
|
|
| Back to top |
|
 |
blackmorpheus Expert Cheater
Reputation: 0
Joined: 05 Apr 2008 Posts: 159
|
Posted: Sun Nov 16, 2008 7:01 am Post subject: |
|
|
Made my crosshair red
| Code: |
void sys_glEnable (GLenum cap)
{
if(crosshair)
{
HWND hWnd = FindWindow(NULL, "Unreal Software's Counter-Strike 2D");
POINT mouse;
GetCursorPos(&mouse);
ScreenToClient(hWnd, &mouse);
GLfloat winX = (float)(mouse.x);
GLfloat winY = (float)(mouse.y);
float color[4];
glGetFloatv(GL_CURRENT_COLOR, color);
glBegin(GL_LINES);
glColor3ub(255,0,0);
glVertex2f(winX -5, winY);
glVertex2f(winX +5, winY);
glVertex2f(winX, winY -5);
glVertex2f(winX, winY +5);
glEnd();
glColor4f(color[0],color[1],color[2],color[3]);
}
(*orig_glEnable) (cap);
}
|
Where should i place the HWND hWnd = FindWindow() then?
Remember i'm rewriting opengl32 functions
|
|
| Back to top |
|
 |
Spawnfestis GO Moderator
Reputation: 0
Joined: 02 Nov 2007 Posts: 1746 Location: Pakistan
|
Posted: Sun Nov 16, 2008 7:17 am Post subject: |
|
|
| blackmorpheus wrote: | Made my crosshair red
| Code: |
void sys_glEnable (GLenum cap)
{
if(crosshair)
{
HWND hWnd = FindWindow(NULL, "Unreal Software's Counter-Strike 2D");
POINT mouse;
GetCursorPos(&mouse);
ScreenToClient(hWnd, &mouse);
GLfloat winX = (float)(mouse.x);
GLfloat winY = (float)(mouse.y);
float color[4];
glGetFloatv(GL_CURRENT_COLOR, color);
glBegin(GL_LINES);
glColor3ub(255,0,0);
glVertex2f(winX -5, winY);
glVertex2f(winX +5, winY);
glVertex2f(winX, winY -5);
glVertex2f(winX, winY +5);
glEnd();
glColor4f(color[0],color[1],color[2],color[3]);
}
(*orig_glEnable) (cap);
}
|
Where should i place the HWND hWnd = FindWindow() then?
Remember i'm rewriting opengl32 functions  |
Above the loop, inside the constructor.
_________________
CLICK TO HAX MAPLESTORAY ^ !!!! |
|
| Back to top |
|
 |
blackmorpheus Expert Cheater
Reputation: 0
Joined: 05 Apr 2008 Posts: 159
|
Posted: Mon Nov 17, 2008 1:44 pm Post subject: |
|
|
| that wouldn't matter because this function glEnable is called many times.
|
|
| Back to top |
|
 |
tombana Master Cheater
Reputation: 2
Joined: 14 Jun 2007 Posts: 456 Location: The Netherlands
|
Posted: Tue Nov 18, 2008 8:06 am Post subject: |
|
|
| Well thats the point: if you call it many times, you should make it fast. So if you remove the FindWindow, it'll be faster. And the window handle won't change, so once you have the hWnd, you don't need to get it again.
|
|
| Back to top |
|
 |
|