fvestrgenrl (09-17-2010),GodHack2 (09-15-2010),hilolo (09-24-2010),markoj (09-15-2010),NOOB (04-22-2011),Nubzgetkillz (11-27-2010),S0aD (03-07-2011),Solify (09-17-2010),tahha (09-24-2010),Turbulence (03-22-2011),whit (09-15-2010),why06 (09-15-2010)
I actually used this code in my menu base a while back and for those of you who are tired of using the arrow keys to move your menu, here's a fresh change of pace.
I wrote this code for the release whit made of Gellin's and Hans' bases. It can be adapted to other bases but you should do that yourself.
We start with some global variables, declared in the global scope.
We got 2 POINT structures, pos for taking in the mouse cordinates, and dragOffset for holding.Code:POINT pos, dragOffset; bool dragging=false; int width, height;
Then we have a bool dragging that just is used to tell weather or not we're dragging the menu.
Finally, we have the width and height variables. These AREN'T DEFINED and should be setup and changed according to your hack's needs.
Then we use this handy function, courtesy of crash or whoever he got it from. This is just used to determine if the mouse is within a rectangle formed by a pair of points.
Finally we got the meat of the code which should be put in your main thread or in your hooked function or w/e. I put in a bunch of comments and most of this should be understandable.Code:bool isMouseinRegion(int x1, int y1, int x2, int y2) { POINT cPos; GetCursorPos(&cPos); if(cPos.x > x1 && cPos.x < x2 && cPos.y > y1 && cPos.y < y2){ return true; } else { return false; } }
Anyways there you have it, now you can make your menu's a little better.Code:if(GetAsyncKeyState(VK_LBUTTON)<0){ GetCursorPos(&pos); //ScreenToClient(GetForegroundWindow(),&pos); //You can choose to include this or not. if (!dragging){//if not currently dragging a window then see if our click is if (isMouseinRegion(menux,menuy,menux+width,menuy+height)){ //^^ if inside the bounds of the window //then setup the winodw so that it will drag dragOffset.x = pos.x-menux; dragOffset.y = pos.y-menuy; dragging = true; } }else{//if we are dragging a window then menux = pos.x - dragOffset.x; menuy = pos.y - dragOffset.y; } }else{ dragging = false; }
This is not noob-proof and if you follow my directions it shouldn't be hard to implement.
Last edited by IcySeal; 09-15-2010 at 06:43 PM.
fvestrgenrl (09-17-2010),GodHack2 (09-15-2010),hilolo (09-24-2010),markoj (09-15-2010),NOOB (04-22-2011),Nubzgetkillz (11-27-2010),S0aD (03-07-2011),Solify (09-17-2010),tahha (09-24-2010),Turbulence (03-22-2011),whit (09-15-2010),why06 (09-15-2010)
Nice Release Seal.!!!!!!!!!!!!!
Here's another adapted for code demon's d3d base.
Same as before, but took out width and height.
Code:POINT pos, dragOffset; bool dragging=false;
Crash's function blah blah blah.
Code:bool isMouseinRegion(int x1, int y1, int x2, int y2) { POINT cPos; GetCursorPos(&cPos); if(cPos.x > x1 && cPos.x < x2 && cPos.y > y1 && cPos.y < y2){ return true; } else { return false; } }
Code:if(GetAsyncKeyState(VK_LBUTTON)<0){ GetCursorPos(&pos); //ScreenToClient(GetForegroundWindow(),&pos); //You can choose to include this or not. if (!dragging){//if not currently dragging a window then see if our click is if (isMouseinRegion(dMenu.x,dMenu.y,dMenu.x+dMenu.w,dMenu.y+dMenu.h)){ //^^ if inside the bounds of the window //then setup the winodw so that it will drag dragOffset.x = pos.x-dMenu.x; dragOffset.y = pos.y-dMenu.y; dragging = true; } }else{//if we are dragging a window then dMenu.x = pos.x - dragOffset.x; dMenu.y = pos.y - dragOffset.y; } }else{ dragging = false; }
Nice job icy!I had something like this already though
/ nice work Seal, I used your mouse in region function in the PTC tester xD
Seal the way i use is ALOT FASTER
should i post it?
Mine. It might be bad since I just whipped it up.Code:bool IsMouseOver( int x, int y, int w, int h ) { bool lolitsover; POINT cur; GetCursorPos(&cur); if( cur.x >= x && cur.x <= x + w && cur.y >= y && cur.y <= y + h){ lolitsover = true; } else { lolitsover = false; } return lolitsover; }
Code:int MoveMenu; if(MoveMenu1 > 0){ if( MoveMenu ) { POINT myCursor; GetCursorPos(&myCursor); // get the cursor position. if(GetAsyncKeyState(VK_LBUTTON)) { menu.x = myCursor.x; // set the x of your menu to the cursor x position. menu.y = myCursor.y; // set the y of your menu to the cursor y position. } } }
i think thats right had to change stuff
Credits to Zanza