 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Dbof Guest
|
Posted: Tue Jan 13, 2009 9:00 pm Post subject: Tray Icons on own GUI |
|
|
Hello, I'm a user from the german forum and I want to post an example for taking the tray "place" in your gui
| Code: | ;DLLCall()
Loop, 2
Gui, Add, Button, w200 h50 gHa%A_Index%, Button%A_Index%
Gui, Show, w500 h500, Hallo!
WinGet, SelfHandle, ID, Hallo!
return
Ha1:
TNAHandle := GetHandle()
TBHandle := DllCall("FindWindow", "Shell_TrayWnd")
OriginTB := DllCall("GetParent", TBHandle)
OriginParent := DllCall("GetParent", TNAHandle)
DllCall("SetParent", TNAHandle, SelfHandle)
return
Ha2:
DllCall("SetParent", TNAHandle, OriginParent)
return
GetHandle()
{
Result := DllCall("FindWindow", "Shell_TrayWnd", 0)
Result := DllCall("FindWindowEx", Result, 0, "TrayNotifyWnd", 0)
Result := DllCall("FindWindowEx", Result, 0, "Syspager", 0)
Result := DllCall("FindWindowEx", Result, 0, "ToolbarWindow32", "Infobereich", 0) ;English user must change that, I think
return Result
} |
Please try it and post any comments to it. I hope it will be useful to someone
Sorry for my bad English, it is school English yet  |
|
| Back to top |
|
 |
Frankie
Joined: 02 Nov 2008 Posts: 2850
|
Posted: Wed Jan 14, 2009 12:06 am Post subject: |
|
|
Doesn't seem to do anything. Vista Home Premium. _________________ aboutscript ⍟ apps ⍟ scripts
Any code ⇈ above ⇈ requires AutoHotkey_L to run |
|
| Back to top |
|
 |
SoggyDog
Joined: 02 May 2006 Posts: 783 Location: Greeley, CO
|
|
| Back to top |
|
 |
Slanter
Joined: 28 May 2008 Posts: 739 Location: Minnesota, USA
|
Posted: Wed Jan 14, 2009 4:35 am Post subject: |
|
|
Is it just me, or are all the DllCalls missing parameters?
EDIT: Every single DllCall fails and sets ErrorLevel... | Code: | ;DLLCall()
Loop, 2
Gui, Add, Button, w200 h50 gHa%A_Index%, Button%A_Index%
Gui, Show, w500 h500, Hallo!
WinGet, SelfHandle, ID, Hallo!
return
Ha1:
TNAHandle := GetHandle()
TBHandle := DllCall("FindWindow", "Shell_TrayWnd")
MsgBox % ErrorLevel
OriginTB := DllCall("GetParent", TBHandle)
MsgBox % ErrorLevel
OriginParent := DllCall("GetParent", TNAHandle)
MsgBox % ErrorLevel
DllCall("SetParent", TNAHandle, SelfHandle)
MsgBox % ErrorLevel
return
Ha2:
DllCall("SetParent", TNAHandle, OriginParent)
MsgBox % ErrorLevel
return
GetHandle()
{
Result := DllCall("FindWindow", "Shell_TrayWnd", 0)
MsgBox % ErrorLevel
Result := DllCall("FindWindowEx", Result, 0, "TrayNotifyWnd", 0)
MsgBox % ErrorLevel
Result := DllCall("FindWindowEx", Result, 0, "Syspager", 0)
MsgBox % ErrorLevel
Result := DllCall("FindWindowEx", Result, 0, "ToolbarWindow32", "Infobereich", 0) ;English user must change that, I think
MsgBox % ErrorLevel
return Result
} |
_________________ Unless otherwise stated, all code is untested
(\__/) This is Bunny.
(='.'=) Cut, copy, and paste bunny onto your sig.
(")_(") Help Bunny gain World Domination.
Last edited by Slanter on Wed Jan 14, 2009 4:38 am; edited 1 time in total |
|
| Back to top |
|
 |
Frankie
Joined: 02 Nov 2008 Posts: 2850
|
Posted: Wed Jan 14, 2009 4:36 am Post subject: |
|
|
Oh yea the types are missing. Want to fill them in for us? Id do it but I don't kno DllCalls. _________________ aboutscript ⍟ apps ⍟ scripts
Any code ⇈ above ⇈ requires AutoHotkey_L to run |
|
| Back to top |
|
 |
Frankie
Joined: 02 Nov 2008 Posts: 2850
|
Posted: Wed Jan 14, 2009 4:41 am Post subject: |
|
|
Hmm...Im getting -2 for the first few then A-4 for the rest of the msgboxes. _________________ aboutscript ⍟ apps ⍟ scripts
Any code ⇈ above ⇈ requires AutoHotkey_L to run |
|
| Back to top |
|
 |
Slanter
Joined: 28 May 2008 Posts: 739 Location: Minnesota, USA
|
Posted: Wed Jan 14, 2009 4:50 am Post subject: |
|
|
Fixed the DllCalls for the most part, but half of them still set A_LastError to 1400 (Invalid window handle), meaning nothing happens. One of them had an extra parameter too, which I ended up just deleting, but other calls should still work even if this messed with the functionality of that part... | Code: | ;DLLCall()
Loop, 2
Gui, Add, Button, w200 h50 gHa%A_Index%, Button%A_Index%
Gui, Show, w500 h500, Hallo!
WinGet, SelfHandle, ID, Hallo!
return
Ha1:
TNAHandle := GetHandle()
TBHandle := DllCall("FindWindow", str, "Shell_TrayWnd", str, 0)
OriginTB := DllCall("GetParent", Int, TBHandle) ; Error 1400: Invalid window handle
OriginParent := DllCall("GetParent", Int, TNAHandle) ; Error 1400: Invalid window handle
DllCall("SetParent", Int, TNAHandle, Int, SelfHandle) ; Error 1400: Invalid window handle
return
Ha2:
DllCall("SetParent", Int, TNAHandle, Int, OriginParent) ; Error 1400: Invalid window handle
return
GetHandle()
{
Result := DllCall("FindWindow", str, "Shell_TrayWnd", str, 0)
Result := DllCall("FindWindowEx", Int, Result, Int, 0, str, "TrayNotifyWnd", str, 0)
Result := DllCall("FindWindowEx", Int, Result, Int, 0, str, "Syspager", str, 0)
Result := DllCall("FindWindowEx", Int, Result, Int, 0, str, "ToolbarWindow32", str, 0)
return Result
} |
_________________ Unless otherwise stated, all code is untested
(\__/) This is Bunny.
(='.'=) Cut, copy, and paste bunny onto your sig.
(")_(") Help Bunny gain World Domination.
Last edited by Slanter on Wed Jan 14, 2009 5:22 am; edited 1 time in total |
|
| Back to top |
|
 |
Frankie
Joined: 02 Nov 2008 Posts: 2850
|
Posted: Wed Jan 14, 2009 4:55 am Post subject: |
|
|
Still not doing anything. Im just suposed to press the buttons, right? _________________ aboutscript ⍟ apps ⍟ scripts
Any code ⇈ above ⇈ requires AutoHotkey_L to run |
|
| Back to top |
|
 |
Slanter
Joined: 28 May 2008 Posts: 739 Location: Minnesota, USA
|
Posted: Wed Jan 14, 2009 5:08 am Post subject: |
|
|
| Frankie wrote: | | Still not doing anything. Im just suposed to press the buttons, right? | That's the point... nothing happens. Also, some of these DllCalls seem rather pointless. For example (DetectHiddenWindows set to On): | Code: | DllCall("FindWindow", str, "Shell_TrayWnd", str, 0)
; Same thing as
WinExist("ahk_class Shell_TrayWnd") + 0
; This whole thing
Result := DllCall("FindWindowEx", Int, Result, Int, 0, str, "TrayNotifyWnd", str, 0)
Result := DllCall("FindWindowEx", Int, Result, Int, 0, str, "Syspager", str, 0)
Result := DllCall("FindWindowEx", Int, Result, Int, 0, str, "ToolbarWindow32", str, 0)
; Would likely have the same result as
Result := WinExist("ahk_class ToolbarWindow32") + 0
; which doesn't exist anyways...
; This variable is never used:
OriginTB := DllCall("GetParent", UInt, TBHandle) | What this boils down to is | Code: | ;DLLCall()
Loop, 2
Gui, Add, Button, w200 h50 gHa%A_Index%, Button%A_Index%
Gui, Show, w500 h500, Hallo!
WinGet, SelfHandle, ID, Hallo!
return
Ha1:
TNAHandle := WinExist("ahk_class ToolbarWindow32") + 0
TBHandle := WinExist("ahk_class Shell_TrayWnd") + 0
; OriginTB := DllCall("GetParent", Int, TBHandle) ; Error 1400: Invalid window handle
OriginParent := DllCall("GetParent", Int, TNAHandle) ; Error 1400: Invalid window handle
DllCall("SetParent", Int, TNAHandle, Int, SelfHandle) ; Error 1400: Invalid window handle
return
Ha2:
DllCall("SetParent", Int, TNAHandle, Int, OriginParent) ; Error 1400: Invalid window handle
return |
_________________ Unless otherwise stated, all code is untested
(\__/) This is Bunny.
(='.'=) Cut, copy, and paste bunny onto your sig.
(")_(") Help Bunny gain World Domination.
Last edited by Slanter on Wed Jan 14, 2009 5:19 am; edited 2 times in total |
|
| Back to top |
|
 |
Frankie
Joined: 02 Nov 2008 Posts: 2850
|
Posted: Wed Jan 14, 2009 5:14 am Post subject: |
|
|
I don't kno DllCalls at all but now that you pointed that out ive come to the conclution that this does nothing at all. True or false? _________________ aboutscript ⍟ apps ⍟ scripts
Any code ⇈ above ⇈ requires AutoHotkey_L to run |
|
| Back to top |
|
 |
Slanter
Joined: 28 May 2008 Posts: 739 Location: Minnesota, USA
|
Posted: Wed Jan 14, 2009 5:19 am Post subject: |
|
|
The point of this seems to be to set your GUI to be the parent window of the icons, so it may be OS-specific, but it definitely does not do anything on Win2K.
EDIT: Figured it out... Here's what he was trying to accomplish. Button 1 takes the icons and puts them in your GUI, button 2 puts them back where they came from. | Code: | Loop, 2 {
y := A_Index*50
Gui, Add, Button, w200 h50 y%y% x0 gHa%A_Index%, Button%A_Index%
}
Gui, Show, w500 h500, Hallo!
WinGet, SelfHandle, ID, Hallo!
return
Ha1:
ControlGet, TNAHandle, HWND,, ToolbarWindow321, ahk_class Shell_TrayWnd
TBHandle := WinExist("ahk_class Shell_TrayWnd")
OriginParent := DllCall("GetParent", Int, TNAHandle)
DllCall("SetParent", Int, TNAHandle, Int, SelfHandle)
return
Ha2:
DllCall("SetParent", Int, TNAHandle, Int, OriginParent)
return |
And here's an example of how to move them to a specific control in your GUI (still uses Ha1 & Ha2 from previous) | Code: | Loop, 2 {
y := A_Index*50
Gui, Add, Button, w200 h50 x0 gHa%A_Index%, Button%A_Index%
}
Gui, Add, Text, hwndSelfHandle w200 h50
Gui, Show, w500 h500, Hallo!
return |
You'll want to be careful with this, because if the script exits while the icons are in the GUI you need to restart explorer to restore them. I'd suggest always having OnExit point to the label that restores them. _________________ Unless otherwise stated, all code is untested
(\__/) This is Bunny.
(='.'=) Cut, copy, and paste bunny onto your sig.
(")_(") Help Bunny gain World Domination. |
|
| Back to top |
|
 |
jmanx
Joined: 14 May 2008 Posts: 110
|
Posted: Wed Jan 14, 2009 5:52 am Post subject: |
|
|
i'm not a critic or anything but Slanter, you know how to get all the icons from the tray? Not just the visible ones (like when you click on that little arrow to reveal them all)
________
Herbalaire
Last edited by jmanx on Thu Feb 10, 2011 8:39 pm; edited 1 time in total |
|
| Back to top |
|
 |
SoggyDog
Joined: 02 May 2006 Posts: 783 Location: Greeley, CO
|
|
| Back to top |
|
 |
Dbof
Joined: 13 Jan 2009 Posts: 31
|
Posted: Wed Jan 14, 2009 5:43 pm Post subject: |
|
|
Oh man, am I stupid? I posted the wrong code, it was the incomplete one. I am so sorry, I had no time to watch at it a second time.
| Code: |
;DLLCall()
#SingleInstance force
OnExit, ExitAndRestore
Loop, 2 {
y := A_Index*50
Gui, Add, Button, w200 h50 y%y% x0 gHa%A_Index%, Button%A_Index%
}
Gui, Show, w500 h500, Hello!
WinGet, ID, ID, Hello!
return
GuiClose:
ExitApp
Ha1:
TNAHandle := GetHandle()
TBHandle := DllCall("FindWindow", str, "Shell_TrayWnd", Uint, 0)
OriginTB := DllCall("GetParent", Uint, TBHandle)
OriginParent := DllCall("GetParent", Uint, TNAHandle)
DllCall("SetParent", Uint, TNAHandle, Uint, ID)
return
F11::
Ha2:
DllCall("SetParent", UInt, TNAHandle, Uint, OriginParent)
return
GetHandle()
{
Result := DllCall("FindWindow", str, "Shell_TrayWnd", Uint, 0)
Result := DllCall("FindWindowEx", Uint, Result, Uint, 0, str, "TrayNotifyWnd", int, 0)
Result := DllCall("FindWindowEx", Uint, Result, Uint, 0, str, "Syspager", int, 0)
Result := DllCall("FindWindowEx", Uint, Result, Uint, 0, str, "ToolbarWindow32", Uint, 0)
return Result
}
ExitAndRestore:
Gosub Ha2
ExitApp
|
With the first button you take the icons on the GUI, with the second you put it back.
| Quote: | | i'm not a critic or anything but Slanter, you know how to get all the icons from the tray? Not just the visible ones (like when you click on that little arrow to reveal them all) |
Yeah, you're right, you don't get all the icons, when the "hide inactive" function of Windows is active.
| Quote: | | I'm glad somebody figured this out, but now that we all know what's going on (and not to ask you to speak for Dbof) but why would I need this? |
Flashkid asked in the German forum(and afaik in the English, too) for a possibility to take the tray area on your own gui, so I thought this could be useful to someone else here.
Sorry for the misunderstanding and I hope it will be useful to someone... |
|
| Back to top |
|
 |
Laszlo
Joined: 14 Feb 2005 Posts: 4710 Location: Boulder, CO
|
Posted: Wed Jan 14, 2009 7:38 pm Post subject: |
|
|
| At the first run the script copied the full tray to the GUI at pressing Button1, but nothing happened at Button2. I restarted the script, and this time it moved all task buttons to the GUI at Button1, and moved them back to the taskbar at Button2. I reloaded the script when the task buttons were in the GUI, and now all of them disapeared. The script does not do anything anymore. I have to reboot... so be careful! |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|