1. SysTrayIconRemove
- Posted by useless Jul 06, 2011
- 2803 views
Is there something like SysTrayIconRemove in any Eu code? I am using
junk = system_exec("taskkill /F /T /IM program.exe",2)
on winxp to kill, obviously, program.exe, because there is no command to close or find another exit node on program. Then, i use
system("start /MIN \"\" \"C:\\Program Files\\programBundle\\program\\program.exe\"",0)
to restart it, during which it randomly(?) picks another exit node.
However, i get a lot of ghost icons in the systray area, which aren't removed unless the mouse cursor is moved over them slowly. How do i remove these icons from within the Eu program so i don't get 10k of them building up?
useless
2. Re: SysTrayIconRemove
- Posted by mattlewis (admin) Jul 06, 2011
- 2816 views
Is there something like SysTrayIconRemove in any Eu code? I am using
junk = system_exec("taskkill /F /T /IM program.exe",2)
on winxp to kill, obviously, program.exe, because there is no command to close or find another exit node on program. Then, i use
system("start /MIN \"\" \"C:\\Program Files\\programBundle\\program\\program.exe\"",0)
to restart it, during which it randomly(?) picks another exit node.
However, i get a lot of ghost icons in the systray area, which aren't removed unless the mouse cursor is moved over them slowly. How do i remove these icons from within the Eu program so i don't get 10k of them building up?
My guess is that the program isn't cleaning up after itself when it gets killed. You've probably tried this, but different flags passed to taskkill might allow the program to shut down more gracefully.
You might have better luck sending a WM_CLOSE message to the program, if possible. You might check out these from the archive for some ideas on how to accomplish that from within a euphoria program:
Process Viewer | A wrapper for 'CreateToolhelp32Snapshot', it lists all running processes along with any associated files/dlls with path, IDs number of threads. Example program included (example needs Win32Lib) | Pete Stoner | Jun 16/06 |
Monitor all windows | A utility that displays information on all the windows in your system. It lets you switch to them and optionally close them. The source plus a translated .exe are included. | Greg Haberek | Apr 7/03 |
Matt
3. Re: SysTrayIconRemove
- Posted by useless Jul 06, 2011
- 2822 views
Is there something like SysTrayIconRemove in any Eu code? I am using
junk = system_exec("taskkill /F /T /IM program.exe",2)
on winxp to kill, obviously, program.exe, because there is no command to close or find another exit node on program. Then, i use
system("start /MIN \"\" \"C:\\Program Files\\programBundle\\program\\program.exe\"",0)
to restart it, during which it randomly(?) picks another exit node.
However, i get a lot of ghost icons in the systray area, which aren't removed unless the mouse cursor is moved over them slowly. How do i remove these icons from within the Eu program so i don't get 10k of them building up?
My guess is that the program isn't cleaning up after itself when it gets killed. You've probably tried this, but different flags passed to taskkill might allow the program to shut down more gracefully.
I have tried all the flags, but the /? for taskkill specifies the kill is forcefull, regardless of flags set.
You might have better luck sending a WM_CLOSE message to the program, if possible. You might check out these from the archive for some ideas on how to accomplish that from within a euphoria program:
Process Viewer | A wrapper for 'CreateToolhelp32Snapshot', it lists all running processes along with any associated files/dlls with path, IDs number of threads. Example program included (example needs Win32Lib) | Pete Stoner | Jun 16/06 |
Monitor all windows | A utility that displays information on all the windows in your system. It lets you switch to them and optionally close them. The source plus a translated .exe are included. | Greg Haberek | Apr 7/03 |
Matt
I tried windows.zip years ago, and again just now. No joy to be had. It thinks it's killed the app, so i then use taskkill, and taskkill actually does it.
Processviewer has the normal problem when using win32lib, there's no compatable win32lib for it, because it wasn't shipped with the one it was written to use. I have piles of these programs from the archives.
useless
4. Re: SysTrayIconRemove
- Posted by andi49 Jul 07, 2011
- 2757 views
Maybe, this one helps you out. You haven't told what library you use (win32lib etc.). So this doesn't need any.
-- This closes (a freshly startet, no text loaded) notepad (at least on my machine) include dll.e include machine.e without warning constant WM_CLOSE = #0010, WM_QUIT = #0012, WM_DESTROY = #0002 constant caption_of_program_to_close = "untitled - notepad" -- change this to the caption of your prog -- constant caption_of_program_to_close = "c:\\windows\\system32\\cmd.exe" atom hwnd,void,szName constant user32 = open_dll("user32.dll") constant FindWindow = define_c_func(user32,"FindWindowA",{C_INT,C_INT},C_INT) constant SendMessage = define_c_func(user32,"SendMessageA",{C_INT,C_INT,C_INT,C_INT},C_INT) szName=allocate_string(caption_of_program_to_close) -- Findwindow (in this case) is searching for a Window with the Caption -- the string szName points to. Case doesn't matter hwnd=c_func(FindWindow,{0,szName}) -- If it is succesfull it returns the handle to the window free(szName) -- Send the WM_CLOSE (or any other message) void=c_func(SendMessage,{hwnd,WM_CLOSE,0,0})
5. Re: SysTrayIconRemove
- Posted by petelomax Jul 07, 2011
- 2740 views
Apparently, there is an alternative trick, outlined here
HTH, Pete
6. Re: SysTrayIconRemove
- Posted by useless Jul 07, 2011
- 2679 views
Maybe, this one helps you out. You haven't told what library you use (win32lib etc.). So this doesn't need any.
Nice code, but it closes only the open control panel window. It doesn't affect the exe or the icon in the systray.
Autoit has code that apparently does do this. Somehow, i figured Eu would too.
useless
7. Re: SysTrayIconRemove
- Posted by mattlewis (admin) Jul 18, 2011
- 2665 views
Maybe, this one helps you out. You haven't told what library you use (win32lib etc.). So this doesn't need any.
Nice code, but it closes only the open control panel window. It doesn't affect the exe or the icon in the systray.
Autoit has code that apparently does do this. Somehow, i figured Eu would too.
This looks promising. And the blog post that the answer is based upon.
In short the following C code would need to be ported to euphoria:
#define FW(x,y) FindWindowEx(x, NULL, y, L"") void RefreshTaskbarNotificationArea() { HWND hNotificationArea; RECT r; GetClientRect( hNotificationArea = FindWindowEx( FW(FW(FW(NULL, L"Shell_TrayWnd"), L"TrayNotifyWnd"), L"SysPager"), NULL, L"ToolbarWindow32", L"Notification Area"), &r); for (LONG x = 0; x < r.right; x += 5) for (LONG y = 0; y < r.bottom; y += 5) SendMessage( hNotificationArea, WM_MOUSEMOVE, 0, (y << 16) + x); }
Matt
(I found this while trying to research your more recent post.)
8. Re: SysTrayIconRemove
- Posted by ne1uno Jul 20, 2011
- 2619 views
This looks promising. And the blog post that the answer is based upon.
In short the following C code would need to be ported to euphoria:
#define FW(x,y) FindWindowEx(x, NULL, y, L"") void RefreshTaskbarNotificationArea() { HWND hNotificationArea; RECT r; GetClientRect( hNotificationArea = FindWindowEx( FW(FW(FW(NULL, L"Shell_TrayWnd"), L"TrayNotifyWnd"), L"SysPager"), NULL, L"ToolbarWindow32", L"Notification Area"), &r); for (LONG x = 0; x < r.right; x += 5) for (LONG y = 0; y < r.bottom; y += 5) SendMessage( hNotificationArea, WM_MOUSEMOVE, 0, (y << 16) + x); }
Matt
(I found this while trying to research your more recent post.)
I started from original blog post, the formatting on the page had some mixed unicode quotes. that and lack of exact line numbers yesterday made debugging interesting for a while.
structs branch does need a way to redefine DWORD, UINT etc.
using eu4 structs branch, here's what I have. not sure it works yet. nothing obvious happens and I don't have a misbehaving program handy to test.
haven't found how to find which icon is under the mouse cursor yet. that should make it possible to obtain a HWND and get the struct the tooltip is passed in. you may also have to inject into the process to get it. solution may after all need something less programatic like Autoit due to windows bugs.
see the link to the VB code that should list the tooltips of all icons. I haven't integrated that code.
9. Re: SysTrayIconRemove
- Posted by useless Jul 23, 2011
- 2534 views
Appologies for not being able to reply sooner, but the computers have been so busy i could not get much of anything to work, including email and browsers, or any application's menus.
I'll try some of the code as soon as i can. The app in question is the Vidalia bundle for using Tor, but many apps change the text popup for systray icons, including Proxomitron, MS's Security Essentials, and MS's networking stuff.
useless
10. Re: SysTrayIconRemove
- Posted by andi49 Jul 25, 2011
- 2401 views
Hallo, here is a piece of code that helps me get rid of some Icons from a Wlan USB Stick. It's a kind of BruteForce, because it forces the DesktopWindow and all it Childs to Redraw. So you maybe got some flicker on the screen.
Hope it helps
Andreas
include dll.e object Void constant Null=0 constant user32 = open_dll("user32.dll") constant myRedrawWindow = define_c_func(user32,"RedrawWindow",{C_ULONG,C_INT,C_INT,C_INT},C_INT) function or_all(sequence s) -- or together all elements of a sequence atom result result = 0 for i = 1 to length(s) do result = or_bits(result, s[i]) end for return result end function -- RedrawWindow() flags global constant RDW_INVALIDATE =#0001, RDW_INTERNALPAINT =#0002, RDW_ERASE =#0004, RDW_VALIDATE =#0008, RDW_NOINTERNALPAINT =#0010, RDW_NOERASE =#0020, RDW_NOCHILDREN =#0040, RDW_ALLCHILDREN =#0080, RDW_UPDATENOW =#0100, RDW_ERASENOW =#0200, RDW_FRAME =#0400, RDW_NOFRAME =#0800 procedure RedrawWindow(atom handle) --Parameters --hWnd [in] --A handle to the window to be redrawn. If this parameter is NULL, the desktop window is updated. --BOOL RedrawWindow( -- __in HWND hWnd, -- __in const RECT *lprcUpdate, -- __in HRGN hrgnUpdate, -- __in UINT flags -- ); Void=c_func(myRedrawWindow,{handle,Null,Null,or_all({RDW_UPDATENOW,RDW_ALLCHILDREN,RDW_INVALIDATE,RDW_ERASE})}) end procedure RedrawWindow(Null)