Hide console app but still show tray Icon
Hey, i'm making a tray icon only app, the tray icon works fine,but not when I set the output to Windows Application to hide the console.
33 Replies
Right now, I minimise the console but it is not great
I see it on start, for half a sec, and I see it in the taskbar
you could maybe try using the get function to get the ex_style of the console window. then add the WSEX TOOLWINDOW bit to it and then set it using https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setwindowlongw that should hide the window from the taskbar
SetWindowLongW function (winuser.h) - Win32 apps
Changes an attribute of the specified window. The function also sets the 32-bit (long) value at the specified offset into the extra window memory. (Unicode)
or else i suggest making a window application without a console and making your own message only window. that way you would only see the tray icon https://learn.microsoft.com/en-us/windows/win32/winmsg/window-features#message-only-windows
Window Features - Win32 apps
This overview discusses features of windows such as window types, states, size, and position.
note its not that easy to make your own window
😮
i'll try to understand that
not the best written out explenation
I got an error, SetWindowLongPtr need one more argument
dwNewLong
whoops
i fixed it
thats just what i could remember
the doc is not very expresive about what this does
this gets the extra window styles the console window has and then sets them again + the toolwindow style
the result is the exact same as before
can you see the console window still in the taskbar?
Yes
but at least the tray icon is there
well i guess thats not possible then
console windows are special
maybe if I use the original cmd, not windows terminal
yeah then maybe
or you have to make your own window but thats not easy
that's it
hmm
well that might do it
but now i need to do something to stop the app from running x)
whats the app supposed to do?
change a tray icon if i'm in cap mode or not
So if sift is pressed, or CapsLock clicked
oh ur writing an entire app for that
some keyboards like the one of my laptop has a light in the caps lock key so i can see if its caps locked
do you have a way to know if the key is locked yet?
i used to have a python app that does is using while true and vkstate but is was making me lag
so rn i don't really know
yeah dont keep calling that in a loop
well, you could build upon this project of mine https://github.com/QubitTooLate/Keylogging/blob/main/samples/Console/Program.cs
GitHub
Keylogging/samples/Console/Program.cs at main · QubitTooLate/Keylog...
Useful wrapper for Hot Keys and Raw Input in C#. Contribute to QubitTooLate/Keylogging development by creating an account on GitHub.
you can keep track if the caps lock key has been pressed or not
i also have a message only window in here so acrually this could be perfect for you
just add the tray icon to the code
with kind like an event ?
when a key is pressed
yeah this uses RAW INPUT which gives events when keys get pressed
nice, i have to see how I will handle shift
so it doesnt have to loop a function and only runs on an event, very efficient
cause it is supposed to be kept pressed
here is the list of keys
https://learn.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes
Virtual-Key Codes (Winuser.h) - Win32 apps
The following table shows the symbolic constant names, hexadecimal values, and mouse or keyboard equivalents for the virtual-key codes used by the system. The codes are listed in numeric order.
this was terrible, but working x)
thank you
to use it my project, i have to put the source code of this in the same folder ?
yeah i havent made it the easiest thing to use. yeah put the source code in one of your folders and then reference the library project of the solution in your project so you can compile and use it