AutoHotkey Community

It is currently May 27th, 2012, 5:39 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: February 2nd, 2010, 5:35 am 
Hi guys,

I'm currently writing a bit of code to modify a third-party application (an instant messenger) that's stored in the system tray. When you click it, a buddy list window opens. Unfortunately, this window appears in the taskbar, but shouldn't, so I read through this thread to remove it from there. There are actually two ways to remove the window from the taskbar:
- Make it a toolwindow or
- Make it the child of an invisible process

First I tried the first approach, but failed because each time I click the tray icon of that application again, the window appears in usual window style and, of course, also in the taskbar. So I set up a timer to look for the window continuously and set the toolwindow style, but that had two bad effects:
- it took some time to update the style, so the window always popped up in the taskbar for a short moment
- I couldn't manage to get it right so it doesn't show the window when it's hidden... that made the window start flashing without content...

For interested people, that's the relevant code for this:
Code:
#Persistent
SetTimer, DeleteTaskBarEntry, 100
return

DeleteTaskBarEntry:
   WinWait, Buddy-Liste
   
   if ErrorLevel
   {
   
   }
   else
   {
      WinGet, ExStyle, ExStyle, Buddy-Liste

      if (ExStyle & +0x80)
      {

      }
      else
      {
         DetectHiddenWindows On
         WinHide
         WinSet, ExStyle, +0x80 ; 0x80 is WS_EX_TOOLWINDOW
         WinShow
      }
   }
return


So after some time I tried the second approach that looked much more satisfying after a short time. The window gets deleted from the taskbar just as I wanted to, and additionally, it doesn't show up in the taskbar for a short time. But unfortunately, I'm lost again because there is some strange behavior in that approach that was discussed in the thread I linked as well. That's the relevant code (just for testing purpose, it's in a timer loop like the other approach in the real version):

Code:
F12::
   WinGet, hw_notepad, ID, Unbenannt - Editor

   if hw_notepad=
   {
         
   }
   else
   {
      hw_parent := DllCall("GetParent", "uint", hw_notepad)
      WinGet, hw_progman, ID, Program Manager ahk_class Progman
      DllCall("SetParent", "uint", hw_notepad, "uint", hw_progman)
   }
return


No matter what programm you use to test this, the window is always in the background and - sadly - stays there. My actual question now is: How do I bring that window from the background to the foreground? I tried a lot of things now (maybe I just used them wrong?), but none worked: WinActivate, SetWindowPos, SetForegroundWindow, WinHide + WinShow... :(

Is someone able and willing to help me? I'm not really sticking to that solution, so if my problem (removing the buddy list from the taskbar) can be solved in another way without these disturbing issues, please feel free to tell me.

Thanks =)


Report this post
Top
  
Reply with quote  
 Post subject: :(
PostPosted: February 5th, 2010, 11:22 am 
Guys, does really noone have an idea? I know it's annoying to selfbumb unanswered threads to the top again, but... well I don't know how to finish this sentence... yeah, it's lame, but, please!, help me :)


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 15th, 2010, 2:14 pm 
i have the same problem, so far i have not figured it out...


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 15th, 2010, 4:03 pm 
If you pin your window to the desktop (by setting the parent program manager )you can't have it on top! You can not have it both ways!!


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 16th, 2010, 4:36 pm 
Offline

Joined: February 7th, 2008, 9:48 pm
Posts: 509
You can use Sean's program to remove the taskbutton and then use WinActivate if you need.But i only tried it in winXP

Maybe the title is misleading but the downloaded zipfile also contains taskbutton.ahk and trayicon.ahk so it works on both trayicons and taskbuttons.

http://www.autohotkey.com/forum/topic17314.html




I used this once to play with notepad program,it will hide then show the button (if notepad is running!)



Code:
DetectHiddenWindows, On

; see source of this program here http://www.autohotkey.com/forum/topic17314.html 

program=notepad.exe  ;procesname program to remove taskbar button (can be pid also)


data:= TaskButtons(program)
pos:=regexmatch(data,"\| idn:( \d+ )\|",idn)
idxTB:=   GetTaskSwBar()
SendMessage, 0x404, idn1, true, ToolbarWindow32%idxTB%, ahk_class Shell_TrayWnd
sleep 5000
SendMessage, 0x404, idn1, false, ToolbarWindow32%idxTB%, ahk_class Shell_TrayWnd

Return







TaskButtons(sExeName = "")
{
   WinGet,   pidTaskbar, PID, ahk_class Shell_TrayWnd
   hProc:=   DllCall("OpenProcess", "Uint", 0x38, "int", 0, "Uint", pidTaskbar)
   pProc:=   DllCall("VirtualAllocEx", "Uint", hProc, "Uint", 0, "Uint", 32, "Uint", 0x1000, "Uint", 0x4)
   idxTB:=   GetTaskSwBar()
      SendMessage, 0x418, 0, 0, ToolbarWindow32%idxTB%, ahk_class Shell_TrayWnd   ; TB_BUTTONCOUNT
   Loop,   %ErrorLevel%
   {
      SendMessage, 0x417, A_Index-1, pProc, ToolbarWindow32%idxTB%, ahk_class Shell_TrayWnd   ; TB_GETBUTTON
      VarSetCapacity(btn,32,0)
      DllCall("ReadProcessMemory", "Uint", hProc, "Uint", pProc, "Uint", &btn, "Uint", 32, "Uint", 0)
         iBitmap   := NumGet(btn, 0)
         idn   := NumGet(btn, 4)
         Statyle := NumGet(btn, 8)
      If   dwData   := NumGet(btn,12)
         iString   := NumGet(btn,16)
      Else   dwData   := NumGet(btn,16,"int64"), iString:=NumGet(btn,24,"int64")
      DllCall("ReadProcessMemory", "Uint", hProc, "Uint", dwData, "int64P", hWnd:=0, "Uint", NumGet(btn,12) ? 4:8, "Uint", 0)
      If Not   hWnd
         Continue
      WinGet, pid, PID,              ahk_id %hWnd%
      WinGet, sProcess, ProcessName, ahk_id %hWnd%
      WinGetClass, sClass,           ahk_id %hWnd%
      If !sExeName || (sExeName = sProcess) || (sExeName = pid)
         VarSetCapacity(sTooltip,128), VarSetCapacity(wTooltip,128*2)
      ,   DllCall("ReadProcessMemory", "Uint", hProc, "Uint", iString, "Uint", &wTooltip, "Uint", 128*2, "Uint", 0)
      ,   DllCall("WideCharToMultiByte", "Uint", 0, "Uint", 0, "str", wTooltip, "int", -1, "str", sTooltip, "int", 128, "Uint", 0, "Uint", 0)
      ,   sTaskButtons .= "idx: " . A_Index-1 . " | idn: " . idn . " | pid: " . pid . " | hWnd: " . hWnd . " | Class: " . sClass . " | Process: " . sProcess . "`n" . "   | Tooltip: " . sTooltip . "`n"
   }
   DllCall("VirtualFreeEx", "Uint", hProc, "Uint", pProc, "Uint", 0, "Uint", 0x8000)
   DllCall("CloseHandle", "Uint", hProc)
   Return   sTaskButtons
}


GetTaskSwBar()
{
   ControlGet, hParent, hWnd,, MSTaskSwWClass1 , ahk_class Shell_TrayWnd
   ControlGet, hChild , hWnd,, ToolbarWindow321, ahk_id %hParent%
   Loop
   {
      ControlGet, hWnd, hWnd,, ToolbarWindow32%A_Index%, ahk_class Shell_TrayWnd
      If  Not   hWnd
         Break
      Else If   hWnd = %hChild%
      {
         idxTB := A_Index
         Break
      }
   }
   Return   idxTB
}


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: HotkeyStick, mrhobbeys and 58 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group