Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > General Coding > Coding Tutorials
You last visited: Today at 11:28

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[C++]Minimizing,Maximizing extern applications

Discussion on [C++]Minimizing,Maximizing extern applications within the Coding Tutorials forum part of the General Coding category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: May 2007
Posts: 102
Received Thanks: 49
[C++]Minimizing,Maximizing extern applications

==========Get handle from an application==========
We must get the handle from an application before minimizing it.
To get a handle and minimize a program , you use HWND,FindWindow and ShowWindow ( API ).
HWND :(h) handle (Wnd) Window.

Code:
HWND mywindow;
FindWindow(NULL,"SRO_Client");
We declare mywindow as a HWND.
We use the FindWindow function to search windows.
The first parameter NULL defines that it should find any window whose title matches to the second parameter ( ' SRO_Client ' ).
The second parameter is the title of the window we search ( ' SRO_Client ' ).

To search child windows, beginning with a specified child window, use the FindWindowEx function.


==========Check if notepad is opened==========
Code:
#include <windows.h> //imports HWND,FindWindow,ShowWindow
#include <iostream> //imports cout and cin
using namespace std;

int main()
{
   HWND hWnd_my_application;  //We declare hWnd_my_application as a HWND
   hWnd_my_application = FindWindow(NULL,"notepad");  //Searches the window 'notepad'
   
   if(hWnd_my_application) // if we find the notepad our application does : 
   {
      cout << "I have found your window :-)nn" << endl;
      system("pause"); 
   }
    else // else our console application does : 
   {
      cout << "Sorry,I haven't found your window.Maybe it isn't opened...nn" << endl;
      system("pause"); 
   }
}
We declare hWnd_my_application as a HWND.
Our first parameter in FindWindow is NULL.So it will find any window whose title name is 'notepad'.
After that we use a if-else-statement to display if we have found our notepad.
The \n is an escape-sequence.I will make a new thread about escape sequences.
\n stands for newline


==========Minimizing and Maximizing==========
We use the ShowWindow function to change a windows's show state.
Code:
HWND window_one;
window_one = FindWindow(NULL,SRO_Client);
ShowWindow(window_one, SW_MINIMIZE);
The first parameter is the window we want to handle.
The second parameter specifies how the window is to be shown :

Quote:
SW_FORCEMINIMIZE
Windows 2000/XP: Minimizes a window, even if the thread that owns the window is not responding. This flag should only be used when minimizing windows from a different thread.
SW_HIDE
Hides the window and activates another window.
SW_MAXIMIZE
Maximizes the specified window.
SW_MINIMIZE
Minimizes the specified window and activates the next top-level window in the Z order.
SW_RESTORE
Activates and displays the window. If the window is minimized or maximized, the system restores it to its original size and position. An application should specify this flag when restoring a minimized window.
SW_SHOW
Activates the window and displays it in its current size and position.
SW_SHOWDEFAULT
Sets the show state based on the SW_ value specified in the STARTUPINFO structure passed to the CreateProcess function by the program that started the application.
SW_SHOWMAXIMIZED
Activates the window and displays it as a maximized window.
SW_SHOWMINIMIZED
Activates the window and displays it as a minimized window.
SW_SHOWMINNOACTIVE
Displays the window as a minimized window. This value is similar to SW_SHOWMINIMIZED, except the window is not activated.
SW_SHOWNA
Displays the window in its current size and position. This value is similar to SW_SHOW, except the window is not activated.
SW_SHOWNOACTIVATE
Displays a window in its most recent size and position. This value is similar to SW_SHOWNORMAL, except the window is not actived.
SW_SHOWNORMAL
Activates and displays a window. If the window is minimized or maximized, the system restores it to its original size and position. An application should specify this flag when displaying the window for the first time.
Example :
Code:
#include <windows.h> //imports HWND,FindWindow,ShowWindow
#include <iostream> //imports cout and cin
using namespace std;

int main()
{
   HWND hWnd_my_application;  
   hWnd_my_application = FindWindow(NULL,"SRO_Client");  
   
   if(hWnd_my_application)
   {
      cout << "I have found your window :-) and minimized it hehenn" << endl;
      ShowWindow(hWnd_my_application,SW_MINIMIZE);
      system("pause"); 
   }
    else
   {
      cout << "Sorry,I haven't found your window.Maybe it isn't opened...nn" << endl;
      system("pause"); 
   }
}
Parameters for window's state are from Microsoft MSDN,
link :
Opalis is offline  
Thanks
6 Users
Old 05/11/2008, 15:41   #2
 
sluk's Avatar
 
elite*gold: 0
Join Date: Jan 2006
Posts: 168
Received Thanks: 5
so like this you could protect your programs from being opened twice!, thanks helped me!
sluk is offline  
Thanks
1 User
Old 11/06/2008, 18:15   #3
 
elite*gold: 0
Join Date: Nov 2008
Posts: 9
Received Thanks: 3
ty it helped me, this is nice
Hygeru is offline  
Old 11/28/2008, 16:29   #4
 
eledok's Avatar
 
elite*gold: 0
Join Date: Nov 2008
Posts: 5
Received Thanks: 0
nice tips thx.
eledok is offline  
Reply


Similar Threads Similar Threads
[Release]Stop freeze when minimizing the game
09/03/2012 - Shaiya Hacks, Bots, Cheats & Exploits - 66 Replies
Hi guys, You know, when you minimize the game window your char doesn't work/hit/walk anymore... but there is a way to stop! lilprohacker found an andress called "301B08" He implemented it in a CheatEngine file you can download it here cheatengine you can get here
Gm id extern ändern
07/16/2010 - Metin2 Private Server - 6 Replies
Hallo E*PvP, gibt es eine möglichkeit die gm-id extren, d.h auf einer webseite, ändern zu lassen? dankeschön lg org. ps:lösung=thanks
my game keeps minimizing to a little box in the corner of my screen....
06/26/2009 - 9Dragons - 4 Replies
my game keeps minimizing to a little box in the corner of my screen.... WTF!!? anyone else ever had this happen? or know how to fix it? i've installed new gfx drivers and everything and its not helping.
ECX auslesen |inj dll? or extern?
12/25/2008 - General Coding - 8 Replies
hi also ich versuche jetzt schon ein wenig länger eine möglichkeit zu finden ECX an einer bestimmten stelle im code von Guild Wars auszulesen bis jetzt hab ich eine DLL, die injected wird die enthält ne func zum code patchen , um meine eigendliche funktion aufzurufen soweit so gut, das klappt alles da GW TLS (Thread Local Storage) nutzt hab ich meine func als "naked" definiert
Extern useful programs.
10/21/2006 - CO2 Exploits, Hacks & Tools - 1 Replies
Hello there. I just want to share this with others. There is a program called No Alt-Tab . You could find it by searchinf in google "no alt tab". It is a tiny program "always on top" that draw a transparent (you have to chose the level of opacity in option) in the full screen game window.A icon of every aplication on task bar is drawed in a tiny rectangle.Switchin' is a pleasure. It is very useful for those who use 2 or more clients and why not other programs. Hope you enjoy this, have...



All times are GMT +2. The time now is 11:28.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.