Post Reply 
Hide Window on Startup
Author Message
S7*
Sweet Dreams

Posts: 16,689.4373
Threads: 1,056
Joined: 3rd Apr 2007
Reputation: 14.29926
E-Pigs: 383.2289
Offline
Post: #1
Hide Window on Startup
Hallo,

Anyone know how I could go about making a program invisible/hidden when run on startup?


Need to make sure the main window isn't seen so it runs in the background.
13/08/2010 03:09 AM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA
Smart Alternative

Posts: 17,022.2988
Threads: 1,174
Joined: 19th Jan 2007
Reputation: -1.71391
E-Pigs: 446.1274
Offline
Post: #2
RE: Hide Window on Startup
Hmm interesting.  The Windows CreateProcess API function seems to allow it through the lpStartupInfo parameter, but IDK if there's something which will do it for you...
I think this only affects a startup window, and may not work if the application creates multiple windows, or perhaps doesn't define the window as a startup one...

What application are you trying to hide?
13/08/2010 04:54 AM
Visit this user's website Find all posts by this user Quote this message in a reply
S7*
Sweet Dreams

Posts: 16,689.4373
Threads: 1,056
Joined: 3rd Apr 2007
Reputation: 14.29926
E-Pigs: 383.2289
Offline
Post: #3
RE: Hide Window on Startup
Fomine NetSend GUI for LAN message sending, because the msg (previously net send) command doesn't work on the LAN - NetSend GUI uses standard TCP/IP and it worked straight away.

In order to receive messages NetSend GUI has to be running, so putting it in Startup is logical. However, I don't want anyone but me sending messages - so I removed the Send button, as well as the Tray icon with Resource Hacker but the program always appears center of the screen, automatically going on top of all other windows when it starts up so it's hard to ignore.

I looked around for a better more suited for the purpose program yesterday and surprised not to find any. (Almost always I end up looking at msg/net send related pages)
(This post was last modified: 13/08/2010 05:05 AM by S7*.)
13/08/2010 05:03 AM
Find all posts by this user Quote this message in a reply
SchmilK
Noob

Posts: 4,698.2833
Threads: 359
Joined: 16th Apr 2007
Reputation: 0.38918
E-Pigs: 82.0546
Offline
Post: #4
RE: Hide Window on Startup
(13/08/2010 05:03 AM)S7* Wrote:  Fomine NetSend GUI for LAN message sending, because the msg (previously net send) command doesn't work on the LAN - NetSend GUI uses standard TCP/IP and it worked straight away.

In order to receive messages NetSend GUI has to be running, so putting it in Startup is logical. However, I don't want anyone but me sending messages - so I removed the Send button, as well as the Tray icon with Resource Hacker but the program always appears center of the screen, automatically going on top of all other windows when it starts up so it's hard to ignore.

I looked around for a better more suited for the purpose program yesterday and surprised not to find any. (Almost always I end up looking at msg/net send related pages)

maybe try launching as a service via registry and see if its still centered?

HKLM\Software\Microsoft\Windows\CurrentVersion\RunServices

limneosgreen Wrote:Take my advice, don't try to install custom themes ... it's possible to brick ur psp.. why just don't change wallpaper
13/08/2010 06:07 AM
Find all posts by this user Quote this message in a reply
S7*
Sweet Dreams

Posts: 16,689.4373
Threads: 1,056
Joined: 3rd Apr 2007
Reputation: 14.29926
E-Pigs: 383.2289
Offline
Post: #5
RE: Hide Window on Startup
I don't have that registry key O.o

Nevertheless I added the Service but no dice: "Error 1053: The service did not respond to the start or control request in a timely fashion" - it's not even starting the program ~_~

Thanks for the suggestion though.
13/08/2010 06:47 AM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA
Smart Alternative

Posts: 17,022.2988
Threads: 1,174
Joined: 19th Jan 2007
Reputation: -1.71391
E-Pigs: 446.1274
Offline
Post: #6
RE: Hide Window on Startup
Sure it doesn't work over LAN?
Perhaps you've disabled whatever protocol it relies on.

Lol @ hijacking other computers on your network.


Anyway, I tried - can't get it to work :(
For some reason, it ignores me if I tell it to hide.  It works fine if I say to minimize etc.  Documentation says nothing about not being able to hide...

C Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <windows.h>
#include <string.h>

#include <wchar.h>

int main(void) {
	
	STARTUPINFOW si;
	PROCESS_INFORMATION pi;
	int result=1;
	WCHAR* cmdIn = (WCHAR*)GetCommandLineW();
	int numArgs, tmpLen;
	LPWSTR* cmdArgs = CommandLineToArgvW((LPCWSTR)cmdIn, &numArgs);
	WCHAR cmd[MAX_PATH];
	
	si.cb = sizeof(pi);
	si.lpReserved = NULL;
	si.lpDesktop = NULL;
	si.lpTitle = NULL;
	si.dwFlags = STARTF_USESHOWWINDOW;
	si.wShowWindow = SW_HIDE;
	si.cbReserved2 = 0;
	si.lpReserved2 = NULL;
	
	// utilise existing command line
	tmpLen = wcslen(*cmdArgs);
	if(cmdIn[0] == L'"') tmpLen += 2; // take quotes into consideration
	cmdIn += tmpLen;
	// chomp spaces
	while(cmdIn[0] == L' ')
		cmdIn++;
	
	wcscpy(cmd, cmdIn);
	
	ShellExecuteW(NULL, L"open", (LPWSTR)cmd, NULL, NULL, SW_HIDE);
	//result = CreateProcessW(NULL, (LPWSTR)cmd, NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL, NULL, &si, &pi);
	//CloseHandle(pi.hThread);
	//CloseHandle(pi.hProcess);
	
	
	LocalFree(cmdArgs);
	return !result;
}



EDIT:
I'm not sure if user mode applications can be run as services, but actually SchmilK has a good idea.  Try using psexec and running it on the SYSTEM account.

(This post was last modified: 13/08/2010 06:55 AM by ZiNgA BuRgA.)
13/08/2010 06:53 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Slushba132
BustyLoli-Chan

Posts: 3,125.3993
Threads: 508
Joined: 20th Feb 2008
Reputation: -8.27558
E-Pigs: 73.1299
Offline
Post: #7
RE: Hide Window on Startup
:o

I can write such an app.
I used this to hide a command window for the ventrilo server I run

If you know about programming
look into the c++ function
ShowWindow();
as in
ShowWindow((HWND)ventProc»MainWindowHandle.ToPointer(), SW_HIDE);

if you need me to write an application let me know the exe name or the main window name of the application you want to hide.

but doing this means you will have to call a program to hide that program and then possibly call another program when you want to unhide it

(This post was last modified: 13/08/2010 07:23 AM by Slushba132.)
13/08/2010 07:18 AM
Visit this user's website Find all posts by this user Quote this message in a reply
S7*
Sweet Dreams

Posts: 16,689.4373
Threads: 1,056
Joined: 3rd Apr 2007
Reputation: 14.29926
E-Pigs: 383.2289
Offline
Post: #8
RE: Hide Window on Startup
Tried it, the messages don't appear on the user though :[

I think I'll have to figure out how to get msg/net send working otherwise look somewhere else.

Thanks for the help guys.

Edit - Slush - NetSendGUI.exe
(This post was last modified: 13/08/2010 07:36 AM by S7*.)
13/08/2010 07:35 AM
Find all posts by this user Quote this message in a reply
Slushba132
BustyLoli-Chan

Posts: 3,125.3993
Threads: 508
Joined: 20th Feb 2008
Reputation: -8.27558
E-Pigs: 73.1299
Offline
Post: #9
RE: Hide Window on Startup
So I'm looking at my program I wrote and what it appears to do is start itself, and then start the process I want. Then since the program that started the process has a handle to that process it hides it's window =3
so it's essentially what you want but I guess you also want me to exit/hide the process that starts the process

EDIT:
My compiler is being stupid right now and won't let me start a new project, but c# and c++ 2010 are out now so I guess I'll upgrade them and then get right on this. Sorry for the inconvenience.

(This post was last modified: 13/08/2010 05:19 PM by Slushba132.)
13/08/2010 05:12 PM
Visit this user's website Find all posts by this user Quote this message in a reply
ZiNgA BuRgA
Smart Alternative

Posts: 17,022.2988
Threads: 1,174
Joined: 19th Jan 2007
Reputation: -1.71391
E-Pigs: 446.1274
Offline
Post: #10
RE: Hide Window on Startup
Hiding the window after the app starts means you're going to have to do some polling, which isn't exactly nice (perfectly plausible to have the actual window flash on screen).
You don't need to handle the process itself, just run it, and poll with something like FindWindow.
Good luck otherwise.
(This post was last modified: 13/08/2010 05:27 PM by ZiNgA BuRgA.)
13/08/2010 05:27 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 3 Guest(s)

 Quick Theme: