Jump to content
Sign in to follow this  
aphesia

tray problem

Recommended Posts

aphesia

hello, i´m currently working on little script with should make the vista sidebar to smth like the max dashboard:

when pressing alt+s , sidebar.exe starts with all my widgets

when pressing alt+c the process will be closed.

the only problem: the sidebar icon keeps in the tray until i move the mouse on it. how can i solve this?

script:

#include <reducemem.au3>

#include <Constants.au3>

Func sidebar()

run(@ProgramFilesDir & "\Windows Sidebar\sidebar.exe")

EndFunc

Func sidebar2()

ProcessClose("sidebar.exe")

EndFunc

while 1

_ReduceMemory()

HotKeySet("!s", "sidebar")

HotKeySet("!c", "sidebar2")

;some other stuff here too

WEnd

Share this post


Link to post
Share on other sites
Richard Robertson

That is because you are terminating the process instead of letting it shutdown correctly. Is there a menu or something you can click to make it close correctly?

Share this post


Link to post
Share on other sites
aphesia

right click tray icon -> left click exit (not alt-shortcut possible)

thats all i know about closeing the sidebar correctly.

i thought about processclose + tray refresh but i think smth like that doesnt exist ^_^

Share this post


Link to post
Share on other sites
Authenticity

You can use Winspector or Spy++ to see which message it sends (which may be constant) and send it to the window or the control. You can also use _GUICtrlToolBar_* to preform a mouse click to show the dialog window and preform another click to click on the exit menu.

Edited by Authenticity

Share this post


Link to post
Share on other sites
Richard Robertson

Actually, yes, inspecting the window message would be the nicest solution.

Share this post


Link to post
Share on other sites
aphesia

i never used one of these programms and also i never coded something like that. so i atm have absolutly no clue what you guys are talking about ;)

a programm which spys what happens when i press exit in windows sidebar. And then i can use this somehow in autoit to exit it without clicking on exit.

will dl this programms and try my luck ^_^

thanks

Share this post


Link to post
Share on other sites
Authenticity

Requires a little understanding of API and control messages. If you don't have those you can read on MSDN or use the second method of using _GUICtrlToolBar_* functions to click the program tray icon to open the dialog and then just use WinSpy to get something to help you uniquely identify the new dialog characteristics and wait for it to be active... then just Send("{UP}{ENTER}") or something. ;]

Share this post


Link to post
Share on other sites
aphesia

hmm dont really want smth like send/mouseclick as this would rly stop the feeling oh a dashboard ^_^

but i havent check these things yet.. will do it tonight as i´m going into the sun now. if anyone got an example or smth , would rly need it ;)

thx

Share this post


Link to post
Share on other sites
Authenticity

#include <GuiButton.au3>
#include <GuiToolBar.au3>

Dim $hToolBar = ControlGetHandle('[CLASS:Shell_TrayWnd]', '', 'ToolbarWindow321')
Dim $hButton = ControlGetHandle('[CLASS:Shell_TrayWnd]', '', 'Button2')

For $i = 0 to _GUICtrlToolbar_ButtonCount($hToolBar)-1
    If StringInStr(_GUICtrlToolbar_GetButtonText($hToolBar, _
            _GUICtrlToolbar_IndexToCommand($hToolBar, $i)), 'vol') Then ExitLoop
Next

_GUICtrlButton_Click($hButton)
_GUICtrlToolbar_ClickIndex($hToolBar, $i, 'right')

WinWait('[W:164; H:40]')
ConsoleWrite('Test' & @LF)

Dim $hMenu = WinGetHandle('[W:164; H:40]')
ControlSend($hMenu, '', '', '+a')

If the size of the menu is not the same which may happen you'll need to wait for [CLASS:#32678] or something.

Share this post


Link to post
Share on other sites
aphesia

well this wont work then if the sidebar tray icon isn´t on the same position all the time.. or am i wrong?

Share this post


Link to post
Share on other sites
Authenticity

Not necessary. It's likely that the right click dialog height and width are constants. The tray icon doesn't need to be anywhere specific because $i will be the index of the tray icon to click on. You can change the loop a little bit to be more correct:

For $i = 0 To _GUICtrlToolbar_ButtonCount($hToolBar)-1
   ; If something Then
   ;    ; Click the toolbar button index and exit the loop.
   ;     ExitLoop
   ; EndIf
   ;....
Next

Share this post


Link to post
Share on other sites
aphesia

hmm dont rly get the script and also dotn get it work ;)

will give it a try later again

thanks ^_^

Share this post


Link to post
Share on other sites
Authenticity

Well, if you're using Vista it may be different for you, I use XP. The [W:xx; H:xx] may as well be different for you because it's just to illustrate.

Share this post


Link to post
Share on other sites
aphesia

for me it opens the "safely remove hardware" thingy.. hmm

Dim $hToolBar = ControlGetHandle('[CLASS:Shell_TrayWnd]', '', 'ToolbarWindow321')

Dim $hButton = ControlGetHandle('[CLASS:Shell_TrayWnd]', '', 'Button2')

MsgBox(0,"", $hToolBar)

MsgBox(0,"", $hButton )

htoolbar seems to be right but hbutton = empty Edited by aphesia

Share this post


Link to post
Share on other sites
Authenticity

Post AutoIt Window Info summary about the '<<' button if you don't mind. ;]

Share this post


Link to post
Share on other sites
Authenticity

Or it's '>>' on you machine if it's right to left... It's the button that expands the toolbar so you can see the rest of the tray icons.

Share this post


Link to post
Share on other sites
aphesia

dont have this icon/button ^_^ i always see all the tray icons

Share this post


Link to post
Share on other sites
Authenticity
^_^ Interesting... and the code is not working? So if it you don't need to expand the toolbar then just remove the code that relating to the button and test again. First do an output loop to see if you can successfully see the toolbar buttons text and if you can it may be necessary to change "vol" in the loop to what you need. What is your OS?

Share this post


Link to post
Share on other sites
aphesia

vista 64 home premium

dont rly knwo what this "vol" even means.

also:

Dim $hButton = ControlGetHandle('[CLASS:Shell_TrayWnd]', '', 'Button2')

MsgBox(0,"", $hButton )

the msgbox is empty

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.