bshoenhair Posted December 6, 2004 Share Posted December 6, 2004 Is there anyway to hide the tray Icon of anther Program using the DLL functionality of AutoIt ? If so please give an example. Link to comment Share on other sites More sharing options...
this-is-me Posted December 7, 2004 Share Posted December 7, 2004 No. You can look up madshi's components that can be used in other programming languages. I also was looking for something similar, and it seems that without hooking the application, it is not possible. Who else would I be? Link to comment Share on other sites More sharing options...
bshoenhair Posted December 8, 2004 Author Share Posted December 8, 2004 you need to "subclass" and/or thread attach to the tray to manipulate it, I believe. I'm not motivated to attempt it, but it is possible... of course, as all things are...Lar.<{POST_SNAPBACK}>This is far beyond my capabilities, anyone willing to tackle this ? Link to comment Share on other sites More sharing options...
this-is-me Posted December 8, 2004 Share Posted December 8, 2004 Even if it was possible with dllcall in autoit, it would require a c++ coder to do it. Someone would have to create a dll especailly for you. For something that advanced, I doubt that many people want to do it because it isn't worth their time. Who else would I be? Link to comment Share on other sites More sharing options...
bshoenhair Posted December 8, 2004 Author Share Posted December 8, 2004 Even if it was possible with dllcall in autoit, it would require a c++ coder to do it. Someone would have to create a dll especailly for you. For something that advanced, I doubt that many people want to do it because it isn't worth their time.<{POST_SNAPBACK}>Maybe it is an advanced project, but sure would be a nifty one. By the way, if you dont't ask you will never receive. Link to comment Share on other sites More sharing options...
this-is-me Posted December 8, 2004 Share Posted December 8, 2004 (edited) I would like to see it too, but I just don't think enough support could be raised to get it done. Edited December 8, 2004 by this-is-me Who else would I be? Link to comment Share on other sites More sharing options...
user52 Posted December 21, 2006 Share Posted December 21, 2006 I found enough info on it to know that the code to manage icons of system trays changes with almost every Windows release. It is pretty easy with 2k, XP (i think) just by getting the HWND and using GetWindowLong to divulge information, but I would want to support all OS that I could... Anyway, not that interested right now... Lar. http://skyscraper.fortunecity.com/gigo/311...og/shellico.txt just in case someone was looking for the above shellico.txt script and got access denied (referrer err), here's the script: expandcollapse popup//---------------------------------------------------------------------------- // File: shellico.txt //---------------------------------------------------------------------------- // You are allowed to distribute this document unmodified for free, // without paying me any fee. // The information in this document is provided AS IS, // without any warranties or guarantees. // // All undocumented Windows features used/described in this document // are discovered by me, Nick N. Repin. // // Copyright (c) Nikolay N. Repin (Nick N. Repin), 1998 //---------------------------------------------------------------------------- // Enumeration of all System Tray icons info. // [This file consist of several modules] //---------------------------------------------------------------------------- //********************************************************************* // Part 1. Enumerates all Systray icons info and display icons. // Injectes itself into the Explorer's address space. // // Consist of 2 modules: sh.cpp & shdll.cpp. //********************************************************************* / //---------------------------------------------------------------------------- // File: sh.cpp. // Compile & link with shdll.dll. // Run it in window, not in the full-screen mode. // // Creates the console, attached to the Explorer. // The icons info will be printed on this console. // Icons will be painted on the console window caption // at 200-pixels offset from the left. // Console will be automatically destroyed after 10 sec. //---------------------------------------------------------------------------- #define STRICT #include <windows.h> #include <iostream.h> #include <conio.h> void _import SetTrayHook(); void main(void) { SetTrayHook(); Sleep(15000); SetTrayHook(); } //---------------------------------------------------------------------------- // File: shdll.cpp. // Compile in dll mode. //---------------------------------------------------------------------------- #define STRICT #include <windows.h> #include <commctrl.h> #include <stdlib.h> bool IsNT() { OSVERSIONINFO v; v.dwOSVersionInfoSize=sizeof(OSVERSIONINFO); ::GetVersionEx(&v); return v.dwPlatformId==VER_PLATFORM_WIN32_NT; } bool isNT=IsNT(); void _export SetTrayHook(); void enumerateIcons(); void out(char* p=0); LRESULT CALLBACK MsgProc(int,WPARAM,LPARAM); HINSTANCE hInstance; HHOOK hHook=0; HWND SysTray=0; HWND NotifyWnd=0; DWORD dwExplorerThreadId=0,dwExplorerProcessId=0; char msg[256]; HANDLE hCon=0; HWND wCon=0; BOOL WINAPI DllEntryPoint(HINSTANCE hInstDll,DWORD fdwReason,LPVOID) { switch(fdwReason) { case DLL_PROCESS_ATTACH: hInstance=hInstDll; break; case DLL_THREAD_ATTACH: break; case DLL_PROCESS_DETACH: break; case DLL_THREAD_DETACH: break; } return TRUE; } void SetTrayHook() { if(hHook==NULL) { SysTray=FindWindow("Shell_TrayWnd",NULL); NotifyWnd=FindWindowEx(SysTray,0,"TrayNotifyWnd",0); dwExplorerThreadId=GetWindowThreadProcessId(SysTray, &dwExplorerProcessId); hHook=SetWindowsHookEx(WH_CALLWNDPROC,HOOKPROC(MsgProc), hInstance,dwExplorerThreadId); //PostThreadMessage(dwExplorerThreadId,WM_NULL,0,0); } else { UnhookWindowsHookEx(hHook); hHook=NULL; } return; } bool isFirst=true; LRESULT CALLBACK MsgProc(int nCode,WPARAM wParam,LPARAM lParam) { if(isFirst) { isFirst=false; isNT=IsNT(); SysTray=FindWindow("Shell_TrayWnd",NULL); NotifyWnd=FindWindowEx(SysTray,0,"TrayNotifyWnd",0); // To display messages AllocConsole(); hCon=CreateFile("CONOUT$",GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,OPEN_EXISTING,0,0); SetConsoleMode(hCon,ENABLE_PROCESSED_OUTPUT|ENABLE_WRAP_AT_EOL_OUTPUT); CONSOLE_SCREEN_BUFFER_INFO bi; GetConsoleScreenBufferInfo(hCon,&bi); bi.dwSize.Y=200; SetConsoleScreenBufferSize(hCon,bi.dwSize); SetConsoleTitle("Nick's console"); wCon=FindWindow(0,"Nick's console"); out("We are in the Explorer!\r\n"); wsprintf(msg,"Console wnd=%X\r\n\r\n",wCon); out(); enumerateIcons(); Sleep(10000); // Wait 10 sec CloseHandle(hCon); FreeConsole(); } return CallNextHookEx(hHook,nCode,wParam,lParam); } struct TWIconDataT { DWORD imageIndex; // image index, -1 if no image in iconList union { NOTIFYICONDATAW dw; NOTIFYICONDATAA da; }; }; typedef TWIconDataT* pTWIconDataT; struct TWIconsInfoT { int Cnt; pTWIconDataT* iconData; }; struct TWDataT { DWORD unknown[7]; TWIconsInfoT* iconsInfo; HIMAGELIST iconList; }; typedef pTWIconDataT WINAPI (*COMCTL32_332_T) (TWIconsInfoT* info,int index); COMCTL32_332_T COMCTL32_332; void enumerateIcons() { // Load useful function HINSTANCE hLib=LoadLibrary("COMCTL32.DLL"); COMCTL32_332=(COMCTL32_332_T) GetProcAddress(hLib,LPCSTR(332)); TWDataT* twd=(TWDataT*)GetWindowLong(NotifyWnd,0); wsprintf(msg,"Proc=%X, NotifyWnd=%X, data=%X\r\n",COMCTL32_332, NotifyWnd,twd); out(); int cnt=twd->iconsInfo->Cnt; // icons count if(cnt==0) { out("No tray icons!\r\n"); return; } wsprintf(msg,"Icons count=%d",cnt); out(); int x=200; // Offset for icon painting for(int i=cnt-1;i>=0;i--) { wsprintf(msg,"\r\n\r\n# %d *****************\r\n",i); out(); pTWIconDataT p=COMCTL32_332(twd->iconsInfo,i); wsprintf(msg,"ImageIndex=%d\r\n",p->imageIndex); out(); wsprintf(msg,"hWnd=%X\r\n",p->dw.hWnd); out(); wsprintf(msg,"uID=%d\r\n",p->dw.uID); out(); wsprintf(msg,"uFlags=%d\r\n",p->dw.uFlags); out(); wsprintf(msg,"uCallbackMessage=%d\r\n",p->dw.uCallbackMessage); out(); wsprintf(msg,"hIcon=%X\r\n",p->dw.hIcon); out(); memset(msg,0,sizeof(msg)); strcpy(msg,"szTip="); if(isNT) wcstombs(msg+strlen(msg),p->dw.szTip,sizeof(p->dw.szTip)/2); else strcpy(msg+strlen(msg),p->da.szTip); out(); HICON icon=ImageList_GetIcon(twd->iconList,p->imageIndex,ILD_NORMAL); wsprintf(msg,"Real icon=%X\r\n",icon); // Draw icon HDC dc=GetWindowDC(wCon); ImageList_Draw(twd->iconList,p->imageIndex,dc,x,4,ILD_NORMAL); ReleaseDC(wCon,dc); x+=30; } } void out(char* p) { DWORD dwWritten; if(p) strcpy(msg,p); WriteConsole(hCon,msg,strlen(msg),&dwWritten,0); } //********************************************************************* // Part 2. Console program to enumerate Systray icons info. // Windows95/98. //********************************************************************* #include <windows.h> #include <commctrl.h> #include <iostream.h> #include <stdlib.h> struct TWIconDataT { DWORD internalId; // image index, -1 if no image in iconList NOTIFYICONDATA d; }; typedef TWIconDataT* pTWIconDataT; struct TWIconsInfoT { int Cnt; pTWIconDataT* iconData; }; struct TWDataT { DWORD unknown[7]; TWIconsInfoT* iconsInfo; HIMAGELIST iconList; }; void main(void) { InitCommonControls(); HWND stw=FindWindow("Shell_TrayWnd",0); if(!stw) { cout<<"System tray not found!"<<endl; return; } HWND tw=FindWindowEx(stw,0,"TrayNotifyWnd",0); if(!tw) { cout<<"TrayNotifyWnd not found!"<<endl; return; } TWDataT* twd=(TWDataT*)GetWindowLong(tw,0); if(!twd) { cout<<"Cannot get TrayNotifyWnd data! "<<GetLastError()<<endl; return; } // We cannot just read memory of another process DWORD idExplorer; GetWindowThreadProcessId(tw,&idExplorer); HANDLE hExplorer=OpenProcess(PROCESS_VM_READ,FALSE,idExplorer); if(!hExplorer) { cout<<"Cannot open Explorer process! "<<GetLastError()<<endl; return; } //Read tray window data TWDataT data; BOOL r=ReadProcessMemory(hExplorer,twd,&data,sizeof(data),0); if(!r) { cout<<"Cannot read tray window data! "<<GetLastError()<<endl; return; } cout<<"Image list="<<data.iconList<<endl; // Read icons info TWIconsInfoT iconsInfo; r=ReadProcessMemory(hExplorer,data.iconsInfo,&iconsInfo, sizeof(iconsInfo),0); if(!r) { cout<<"Cannot read icons info! "<<GetLastError()<<endl; return; } if(iconsInfo.Cnt==0) { cout<<"No tray icons!"<<endl; return; } else cout<<"Icons count="<<(iconsInfo.Cnt)<<endl; // Ok, now read pointers to icons data pTWIconDataT* ppIconData=new pTWIconDataT[iconsInfo.Cnt]; r=ReadProcessMemory(hExplorer,iconsInfo.iconData,ppIconData, sizeof(pTWIconDataT)*iconsInfo.Cnt,0); if(!r) { cout<<"Cannot read pointers to icons data! "<<GetLastError()<<endl; return; } // Now read icons data itself pTWIconDataT pIconData=new TWIconDataT[iconsInfo.Cnt]; for(int i=0;i<iconsInfo.Cnt;i++) { r=ReadProcessMemory(hExplorer,ppIconData[i],pIconData+i, sizeof(TWIconDataT),0); if(!r) { cout<<"Cannot read icon data #"<<i<<"! "<<GetLastError()<<endl; return; } } delete[] ppIconData; CloseHandle(hExplorer); // Now, add points to Nick's account for wasted 4 hour!! for(int i=iconsInfo.Cnt-1;i>=0;i--) { cout<<endl<<"# "<<i<<" *****************"<<endl; cout<<"internalId="<<(pIconData[i].internalId)<<endl; cout<<"hWnd="<<(pIconData[i].d.hWnd)<<endl; cout<<"uID="<<(pIconData[i].d.uID)<<endl; cout<<"uFlags="<<(pIconData[i].d.uFlags)<<endl; cout<<"uCallbackMessage="<<(pIconData[i].d.uCallbackMessage)<<endl; cout<<"hIcon="<<(pIconData[i].d.hIcon)<<endl; cout<<"szTip="<<(pIconData[i].d.szTip)<<endl; // Will not work //HICON icon=ImageList_GetIcon(data.iconList,pIconData[i].internalId, // ILD_NORMAL); //cout<<"Real icon="<<icon<<endl; } delete[] pIconData; } //********************************************************************* // Part 3. Console program to enumerate Systray icons info. // Windows NT 4.0. //********************************************************************* #include <windows.h> #include <commctrl.h> #include <iostream.h> #include <stdlib.h> struct TWIconDataT { DWORD internalId; // image index, -1 if no image in iconList NOTIFYICONDATAW d; }; typedef TWIconDataT* pTWIconDataT; struct TWIconsInfoT { int Cnt; pTWIconDataT* iconData; }; struct TWDataT { DWORD unknown[7]; TWIconsInfoT* iconsInfo; HIMAGELIST iconList; }; void main(void) { InitCommonControls(); HWND stw=FindWindow("Shell_TrayWnd",0); if(!stw) { cout<<"System tray not found!"<<endl; return; } HWND tw=FindWindowEx(stw,0,"TrayNotifyWnd",0); if(!tw) { cout<<"TrayNotifyWnd not found!"<<endl; return; } TWDataT* twd=(TWDataT*)GetWindowLong(tw,0); if(!twd) { cout<<"Cannot get TrayNotifyWnd data! "<<GetLastError()<<endl; return; } // We cannot just read memory of another process DWORD idExplorer; GetWindowThreadProcessId(tw,&idExplorer); HANDLE hExplorer=OpenProcess(PROCESS_VM_READ,FALSE,idExplorer); if(!hExplorer) { cout<<"Cannot open Explorer process! "<<GetLastError()<<endl; return; } //Read tray window data TWDataT data; BOOL r=ReadProcessMemory(hExplorer,twd,&data,sizeof(data),0); if(!r) { cout<<"Cannot read tray window data! "<<GetLastError()<<endl; return; } cout<<"Image list="<<data.iconList<<endl; // Read icons info TWIconsInfoT iconsInfo; r=ReadProcessMemory(hExplorer,data.iconsInfo,&iconsInfo, sizeof(iconsInfo),0); if(!r) { cout<<"Cannot read icons info! "<<GetLastError()<<endl; return; } if(iconsInfo.Cnt==0) { cout<<"No tray icons!"<<endl; return; } else cout<<"Icons count="<<(iconsInfo.Cnt)<<endl; // Ok, now read pointers to icons data pTWIconDataT* ppIconData=new pTWIconDataT[iconsInfo.Cnt]; r=ReadProcessMemory(hExplorer,iconsInfo.iconData,ppIconData, sizeof(pTWIconDataT)*iconsInfo.Cnt,0); if(!r) { cout<<"Cannot read pointers to icons data! "<<GetLastError()<<endl; return; } // Now read icons data itself pTWIconDataT pIconData=new TWIconDataT[iconsInfo.Cnt]; for(int i=0;i<iconsInfo.Cnt;i++) { r=ReadProcessMemory(hExplorer,ppIconData[i],pIconData+i, sizeof(TWIconDataT),0); if(!r) { cout<<"Cannot read icon data #"<<i<<"! "<<GetLastError()<<endl; return; } } delete[] ppIconData; CloseHandle(hExplorer); // Now, add points to Nick's account for wasted 4 hour!! for(int i=iconsInfo.Cnt-1;i>=0;i--) { cout<<endl<<"# "<<i<<" *****************"<<endl; cout<<"internalId="<<(pIconData[i].internalId)<<endl; cout<<"hWnd="<<(pIconData[i].d.hWnd)<<endl; cout<<"uID="<<(pIconData[i].d.uID)<<endl; cout<<"uFlags="<<(pIconData[i].d.uFlags)<<endl; cout<<"uCallbackMessage="<<(pIconData[i].d.uCallbackMessage)<<endl; cout<<"hIcon="<<(pIconData[i].d.hIcon)<<endl; char buf[64]; wcstombs(buf,pIconData[i].d.szTip,sizeof(buf)); cout<<"szTip="<<buf<<endl; // Will not work //HICON icon=ImageList_GetIcon(data.iconList,pIconData[i].internalId, // ILD_NORMAL); //cout<<"Real icon="<<icon<<endl; } delete[] pIconData; } //- EOF: shellico.txt --------------------------------------------------------- //---------------------------------------------------------------------------- // File: shico2k.cpp //---------------------------------------------------------------------------- // You are allowed to distribute this document unmodified for free, // without paying me any fee. // The information in this document is provided AS IS, // without any warranties or guarantees. // // All undocumented Windows features used/described in this document // are discovered by me, Nick N. Repin. // // Copyright (c) Nikolay N. Repin (Nick N. Repin), 1999 //---------------------------------------------------------------------------- // // Enumerating systray icons for Win2000. // //---------------------------------------------------------------------------- #include <windows.h> #include <commctrl.h> //****************************************************************** // Note: all the code below must be executed in the context of the // explorer.exe. //****************************************************************** typedef struct { DWORD u1; HWND hwnd; // Window which handles requests about systray icons, // may be, it's the handle of "TrayNotifyWnd". DWORD u2; HIMAGELIST hIList; // Image list which contains icons itself. } TrayDataT, *pTrayDataT; // Same as NOTIFYICONDATA typedef struct { HWND hwnd; UINT uID; DWORD uCallbackMessage; DWORD uFlags; } IconInfoT, *pIconInfoT; // Structure to pass requests about systray icons. typedef struct { DWORD sz; DWORD dwFlags; DWORD p2; int iImage; DWORD p3; pIconInfoT pIconInfo; LPWSTR pTip; DWORD szTip; } ControlDataT, *pControlDataT; //--------------------------------------------------------------------------- // Returns number of icons on systray. int getIconCount(pTrayDataT pData) { return SendMessageW(pData->hwnd,0x418,0,0); } //--------------------------------------------------------------------------- // Returns pointer to IconInfoT struct. iIndex is icon index, from zero // to getIconCount()-1. bFlag must be true. pIconInfoT getIconInfo(pTrayDataT pData,int iIndex,bool bFlag) { ControlDataT s; s.sz=sizeof(s); s.dwFlags=bFlag ? 0x80000010 : 0x10; s.pIconInfo=0; SendMessageW(pData->hwnd,0x43F,iIndex,LPARAM(&s)); return s.pIconInfo; } //--------------------------------------------------------------------------- // Returns index of icon image in the image list. int getImageIndex(pTrayDataT pData,int iIndex) { ControlDataT s; s.sz=sizeof(s); s.dwFlags=0x80000001; SendMessageW(pData->hwnd,0x43F,iIndex,LPARAM(&s)); return s.iImage; } //--------------------------------------------------------------------------- // Sets tip for icon. void setTip(pTrayDataT pData,int iIndex,LPWSTR pTip) { ControlDataT s; s.sz=sizeof(s); s.dwFlags=0x80000002; s.pTip=pTip; s.szTip=MAXDWORD; SendMessageW(pData->hwnd,0x440,iIndex,LPARAM(&s)); } //--------------------------------------------------------------------------- // Gets tip for icon. void getTip(pTrayDataT pData,int iIndex,LPWSTR pTip,DWORD szTip) { ControlDataT s; s.sz=sizeof(s); s.dwFlags=0x80000002; s.pTip=pTip; s.szTip=szTip; SendMessageW(pData->hwnd,0x43F,iIndex,LPARAM(&s)); } //--------------------------------------------------------------------------- void enumerate() { // As usually. HWND hTrayNotifyWnd= FindWindowEx(FindWindow("Shell_TrayWnd",0),0,"TrayNotifyWnd",0); pTrayDataT pData=(pTrayDataT) GetWindowLong(hTrayNotifyWnd,0); int cnt=getIconCount(pData); for(int i=cnt-1;i>=0;i--) { pIconInfoT pInfo=getIconInfo(pData,i,true); int imageIndex=getImageIndex(pData,i); // ImageList_GetIcon(pData->hIList,imageIndex,....) // getTip(...) } } //--------------------------------------------------------------------------- //- EOF: shico2k.cpp -------------------------------------------------------- Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now