How to maximize a child window of a non-PB program?

Just starting out? Need help? Post your questions and find answers here.
T4r4ntul4
Enthusiast
Enthusiast
Posts: 118
Joined: Tue Mar 04, 2014 4:15 pm
Location: Netherlands

How to maximize a child window of a non-PB program?

Post by T4r4ntul4 »

Hi all,

The program i try to maximize is not from PB, its a program that already started on windows when i execute my software.

How to maximize a child window of that program?

I can however maximize all windows with:

Code: Select all

SendMessage_(FindWindow_("Shell_TrayWnd",""), #WM_COMMAND, #MIN_ALL_UNDO, 0)
Problem is that the child window doesnt maximize with the above command.

I think i need this:
https://docs.microsoft.com/en-us/window ... dwindowexa

I have read somewhere that you need to search or loop through the child windows, but i dont know how to translate that to PB.

Any help is very appreciated!
User avatar
RSBasic
Moderator
Moderator
Posts: 1218
Joined: Thu Dec 31, 2009 11:05 pm
Location: Gernsbach (Germany)
Contact:

Re: How to maximize a child window of a non-PB program?

Post by RSBasic »

You can maximize a foreign window with ShowWindow_(). Example with Notepad program:

Code: Select all

EnableExplicit

Define Handle

RunProgram("notepad.exe")
Delay(2000)
Handle = FindWindow_("notepad", #Null)
If Handle
  ShowWindow_(Handle, #SW_MAXIMIZE)
EndIf
You can determine the foreign window with FindWindow_(). Either search for the window title or the class name.
To get the class name, use these tools:
http://www.rsbasic.de/temp/WinSpy.exe
or
http://www.rsbasic.de/temp/ShoWin.exe

You can also get the handle with EnumWindows_().
Image
Image
T4r4ntul4
Enthusiast
Enthusiast
Posts: 118
Joined: Tue Mar 04, 2014 4:15 pm
Location: Netherlands

Re: How to maximize a child window of a non-PB program?

Post by T4r4ntul4 »

Thanks that works, now i try to get the child window up, iam trying something like this:

Code: Select all

EnableExplicit

Define Handle

Delay(1000)
Handle = FindWindowEx_("ApplicationFrameWindow", 0, "MAKEINTATOM(0x8000)", "")


If Handle
  ShowWindow_(Handle, #SW_MAXIMIZE) ;  #SW_MINIMIZE ; #SW_MAXIMIZE
EndIf
as stated here: https://docs.microsoft.com/en-us/window ... dwindowexa

but thats not working, why?
User avatar
RSBasic
Moderator
Moderator
Posts: 1218
Joined: Thu Dec 31, 2009 11:05 pm
Location: Gernsbach (Germany)
Contact:

Re: How to maximize a child window of a non-PB program?

Post by RSBasic »

FindWindowEx_() (search for child window) only works with FindWindow_() (search for main window).
Example:

Code: Select all

EnableExplicit

Define Handle

RunProgram("notepad.exe")
Delay(2000)

Handle = FindWindow_("notepad", 0)
Handle = FindWindowEx_(Handle, 0, "Edit", 0)

SendMessage_(Handle, #WM_SETTEXT, 0, "Hallo T4r4ntul4")
Image
Image
Post Reply