Hide external window

Just starting out? Need help? Post your questions and find answers here.
UserOfPure
Enthusiast
Enthusiast
Posts: 469
Joined: Sun Mar 16, 2008 9:18 am

Re: Hide external window

Post by UserOfPure »

He said "like Notepad" which means "for example, Notepad" in English. So yes, he was referring to Notepad directly. As for the code, Fluid Byte's example using the Calculator's exact window caption will work. Fluid Byte used the class name instead (class is the first param, title is the second param) so something like FindWindow_(0,"Calculator") will do it.
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4995
Joined: Sun Apr 12, 2009 6:27 am

Re: Hide external window

Post by RASHAD »

OK run FindWindow_(0,"Notepad")
And tell me if it work or not
FindWindow_() it is not a reliable func
See Running one instance thread
Egypt my love
mx101
User
User
Posts: 73
Joined: Thu Sep 18, 2008 3:21 pm

Re: Hide external window

Post by mx101 »

RASHAD wrote:OK I am using Windows 7 x64
Please put some code using FindWindow_() to hide Calculator prog

mx101 did not say Notepad he said like NotePad so the choices are open
Please check
yes this is just example.

i need to hide a window that i call from another program is a console program.

thanks to all
User avatar
Fluid Byte
Addict
Addict
Posts: 2336
Joined: Fri Jul 21, 2006 4:41 am
Location: Berlin, Germany

Re: Hide external window

Post by Fluid Byte »

RASHAD wrote:OK I am using Windows 7 x64
Please put some code using FindWindow_() to hide Calculator prog

Code: Select all

RunProgram("calc")
Delay(500)
hwndNotepad = FindWindow_("CalcFrame",0)
Delay(500)
ShowWindow_(hwndNotepad,#SW_HIDE)
:roll:
RASHAD wrote:FindWindow_() it is not a reliable func
Nonsense :wink:
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4995
Joined: Sun Apr 12, 2009 6:27 am

Re: Hide external window

Post by RASHAD »

MSDN

http://msdn.microsoft.com/en-us/librar ... .85).aspx

Remarks

If the lpWindowName parameter is not NULL, FindWindow calls the GetWindowText function to retrieve the window name for comparison. For a description of a potential problem that can arise, see the Remarks for GetWindowText.


For a description of a potential problem that can arise, see the Remarks for GetWindowText.


GetWindowText

http://msdn.microsoft.com/en-us/librar ... .85).aspx


Remarks

If the target window is owned by the current process, GetWindowText causes a WM_GETTEXT message to be sent to the specified window or control. If the target window is owned by another process and has a caption, GetWindowText retrieves the window caption text. If the window does not have a caption, the return value is a null string. This behavior is by design. It allows applications to call GetWindowText without becoming unresponsive if the process that owns the target window is not responding. However, if the target window is not responding and it belongs to the calling application, GetWindowText will cause the calling application to become unresponsive.

To retrieve the text of a control in another process, send a WM_GETTEXT message directly instead of calling GetWindowText.



Depending on the Caption Text is the Nonsense and nothing else
Egypt my love
User avatar
Fluid Byte
Addict
Addict
Posts: 2336
Joined: Fri Jul 21, 2006 4:41 am
Location: Berlin, Germany

Re: Hide external window

Post by Fluid Byte »

You first posted a totally overkill solution for a pretty simple problem. I proved how to solve it easier. You also said it doesn't work with calc.exe on Windows 7, again I proved the opposite. Last but not least you say FindWindow_() is unreliable and post some irrelevant info from MSDN. Again you are missing the point since you continue to ignore the fact we are talking about the CLASSNAME, not the WINDOWTITLE.
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4995
Joined: Sun Apr 12, 2009 6:27 am

Re: Hide external window

Post by RASHAD »

I only have the prog. name for examole calc.exe
The Caption text will not be OK all times
And I do't want to hack the prog to get the ClassName 'Calcframe' for example
Your solutins are specific for special case And you do't like MSDN saying
So I will not argue with you anymore.

Chao
Egypt my love
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: Hide external window

Post by ts-soft »

RASHAD wrote:And I do't want to hack the prog to get the ClassName 'Calcframe' for example

Code: Select all

Define ClassName.s{#MAX_PATH}
RunProgram("calc")
Delay(1000)
GetClassName_(GetForegroundWindow_(), @ClassName, #MAX_PATH)
Debug ClassName
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4995
Joined: Sun Apr 12, 2009 6:27 am

Re: Hide external window

Post by RASHAD »

@Thomas
You are using PureBasic to run the external prog (Not always will happen)
you assumed that the prog is focused (GetForegroundWindow_()) (Not always will happen)
If you will try to make a perfect code using that tech. you will come to a complicated one

No special case please

Have a good day
Egypt my love
User avatar
Rook Zimbabwe
Addict
Addict
Posts: 4322
Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:

Re: Hide external window

Post by Rook Zimbabwe »

Fluid Byte wrote:Be happy it's just Notepad and not some system critical application :P
Yeah or the AV or Malware scanners... THAT would be a different way of hooking it though... 8)

Good thing we aren't helping with that!
Binarily speaking... it takes 10 to Tango!!!

Image
http://www.bluemesapc.com/
SeregaZ
Enthusiast
Enthusiast
Posts: 628
Joined: Fri Feb 20, 2009 9:24 am
Location: Almaty (Kazakhstan. not Borat, but Triple G)
Contact:

Re: Hide external window

Post by SeregaZ »

why RunProgram with #PB_Program_Hide dont work?

Code: Select all

RunProgram("calc.exe", "", "", #PB_Program_Hide)
run then find window and then hide window - make some splash of this programm. it is not acceptably. who know how made it without this splashes? i mean start programm already hide. and then after some time show to user.
SeregaZ
Enthusiast
Enthusiast
Posts: 628
Joined: Fri Feb 20, 2009 9:24 am
Location: Almaty (Kazakhstan. not Borat, but Triple G)
Contact:

Re: Hide external window

Post by SeregaZ »

i learn to hide window by ShowWindow_(HNDL, #SW_HIDE)
but - if this window is internet explorer window, and if after hiding in this window some thing happen - open.window or form.submit by javascripts - this window some time make show again, or this hide window take main focus, so if i write in this moment some text in word or playing full screen game - this hide window take focus, and it means i write text not to word but in this hide explorer or if it was full screen game - he is minimized.
so main question is - how to make this explorer - after hide - absolutly unfocusable? and if i unhide explorer - again to focusable.
something like if i run this explorer under another user in windows xp.
Post Reply