AutoHotkey Community

It is currently May 26th, 2012, 2:09 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 18 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Tray Icons on own GUI
PostPosted: January 13th, 2009, 10:00 pm 
Hello, I'm a user from the german forum and I want to post an example for taking the tray "place" in your gui 8)

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 :D

Sorry for my bad English, it is school English yet :D


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 14th, 2009, 1:06 am 
Offline
User avatar

Joined: November 2nd, 2008, 4:23 pm
Posts: 2906
Location: 127.0.0.1
Doesn't seem to do anything. Vista Home Premium.

_________________
aboutscriptappsscripts
Any code ⇈ above ⇈ requires AutoHotkey_L to run


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 14th, 2009, 1:08 am 
Offline

Joined: May 2nd, 2006, 11:16 pm
Posts: 800
Location: Greeley, CO
Doesn't seem to do anything. XP sp3.

_________________
Image
SoggyDog
Dwarf Fortress:
"The most intriguing game I've ever played."


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 14th, 2009, 5:35 am 
Offline

Joined: May 28th, 2008, 2:11 am
Posts: 739
Location: Minnesota, USA
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 January 14th, 2009, 5:38 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 14th, 2009, 5:36 am 
Offline
User avatar

Joined: November 2nd, 2008, 4:23 pm
Posts: 2906
Location: 127.0.0.1
Oh yea the types are missing. Want to fill them in for us? Id do it but I don't kno DllCalls.

_________________
aboutscriptappsscripts
Any code ⇈ above ⇈ requires AutoHotkey_L to run


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 14th, 2009, 5:41 am 
Offline
User avatar

Joined: November 2nd, 2008, 4:23 pm
Posts: 2906
Location: 127.0.0.1
Hmm...Im getting -2 for the first few then A-4 for the rest of the msgboxes.

_________________
aboutscriptappsscripts
Any code ⇈ above ⇈ requires AutoHotkey_L to run


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 14th, 2009, 5:50 am 
Offline

Joined: May 28th, 2008, 2:11 am
Posts: 739
Location: Minnesota, USA
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 January 14th, 2009, 6:22 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 14th, 2009, 5:55 am 
Offline
User avatar

Joined: November 2nd, 2008, 4:23 pm
Posts: 2906
Location: 127.0.0.1
Still not doing anything. Im just suposed to press the buttons, right?

_________________
aboutscriptappsscripts
Any code ⇈ above ⇈ requires AutoHotkey_L to run


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 14th, 2009, 6:08 am 
Offline

Joined: May 28th, 2008, 2:11 am
Posts: 739
Location: Minnesota, USA
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 January 14th, 2009, 6:19 am, edited 2 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 14th, 2009, 6:14 am 
Offline
User avatar

Joined: November 2nd, 2008, 4:23 pm
Posts: 2906
Location: 127.0.0.1
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?

_________________
aboutscriptappsscripts
Any code ⇈ above ⇈ requires AutoHotkey_L to run


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 14th, 2009, 6:19 am 
Offline

Joined: May 28th, 2008, 2:11 am
Posts: 739
Location: Minnesota, USA
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 14th, 2009, 6:52 am 
Offline

Joined: May 14th, 2008, 9:48 pm
Posts: 110
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 February 10th, 2011, 9:39 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 14th, 2009, 7:06 am 
Offline

Joined: May 2nd, 2006, 11:16 pm
Posts: 800
Location: Greeley, CO
@Slanter

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?

_________________
Image
SoggyDog
Dwarf Fortress:
"The most intriguing game I've ever played."


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 14th, 2009, 6:43 pm 
Offline

Joined: January 13th, 2009, 10:02 pm
Posts: 31
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. :oops:

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?

Flashkidasked 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...


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 14th, 2009, 8:38 pm 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
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!


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 18 posts ]  Go to page 1, 2  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 16 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