anixon Posted July 8, 2010 Share Posted July 8, 2010 After opening Skype if you click on [X] the Skype Window only closes [this does not QUIT the application] and the Skype Icon remains on the Windows Notification Bar. If you right click the Skype Icon then you are offered a menu which allows you to re-open the Skype window. If you use this code: $Title = "Skype" WinActivate($Title, "") WinClose($Title, "") Skype is Quit which is not the condition I wish to achieve. My question is with the Skype Window Active how do a simulate the user clicking on [X] so that the Skype remains running with the Icon appearing on the Windows Notification Bar rather than choosing to simply minimize the window. Assistance is always appreciated.. Ant Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 8, 2010 Moderators Share Posted July 8, 2010 anixon, Try this: $Title = "Skype" WinActivate($Title, "") ; Reduce to tray icon only WinSetState($Title, "", @SW_HIDE) Sleep(2000) ; Reopen main window WinSetState($Title, "", @SW_SHOW) Works on my Skype. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
anixon Posted July 8, 2010 Author Share Posted July 8, 2010 (edited) anixon, Try this: $Title = "Skype" WinActivate($Title, "") ; Reduce to tray icon only WinSetState($Title, "", @SW_HIDE) Sleep(2000) ; Reopen main window WinSetState($Title, "", @SW_SHOW) Works on my Skype. M23 Thanks M23 Thats terrific but I want to leave the user with the ability to re-open the Skype Window by right clicking the Skype Icon on the Notification Bar. When you use @SW_HIDE the 'Skype open' Menu Function is disabled. Perhaps the best way would be to use the AutoIT Send function to perform the Skype Menu process 'Skype/Close'. This appears to work well with Vista at least or is their a better or more robust way of achieving the same result? $Title = "Skype" WinActivate($Title, "") Send("{ALT}{DOWN 8}{ENTER}") Ant.. And this is the complete code: expandcollapse popup;//Include [Autoit Library Routine/s] #include <GuiToolbar.au3> #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #include <Constants.au3> ;//Set Global Variables Global $SkypeTitle = "Skype", $SkypeTitleClose = "Skype™", $sSkypeDir = "\Skype\Phone\", $sSkypeExe = "Skype.exe", $hSysTray_Handle ;//Open Skype If Not ProcessExists($sSkypeExe) Then ShellExecute(@ProgramFilesDir & $sSkypeDir & $sSkypeExe, "", "", "", @SW_SHOWDEFAULT) WinWaitActive($SkypeTitle, "", 20) Else ;//Check if Skype has Icon on Notification Area of the Taskbar $iSystray_ButtonNumber = _Get_Systray_Index($SkypeTitle) If $iSystray_ButtonNumber <> 0 Then Sleep(500) _GUICtrlToolbar_ClickButton($hSysTray_Handle, $iSystray_ButtonNumber, "right") Sleep(500) Send("{DOWN}{DOWN}{ENTER}") Else Msgbox(0,$SkypeTitle, "Please Open SKYPE", 20) EndIf EndIf ;//Close Skype Window and Leave Running Sleep(5000) WinActivate($SkypeTitleClose, "") Send("{ALT}{DOWN 8}{ENTER}") ;//Find Skype Tool Tip Func _Get_Systray_Index($sToolTipTitle) While 1 ; Find Systray Handle $hSysTray_Handle = ControlGetHandle('[Class:Shell_TrayWnd]', '', '[Class:ToolbarWindow32;Instance:1]') If @error Then ExitLoop ; Get systray item count Local $iSystray_ButCount = _GUICtrlToolbar_ButtonCount($hSysTray_Handle) If $iSystray_ButCount = 0 Then ExitLoop ; Look for wanted tooltip For $iSystray_ButtonNumber = 0 To $iSystray_ButCount - 1 If StringInStr(_GUICtrlToolbar_GetButtonText($hSysTray_Handle, $iSystray_ButtonNumber), $sToolTipTitle) = 1 Then ExitLoop Next If $iSystray_ButtonNumber = $iSystray_ButCount Then Return 0 ; Not found Else Return $iSystray_ButtonNumber ; Found EndIf ExitLoop WEnd EndFunc ;==>_Get_Systray_Index For this close Skype and keep running code to work correctly and thereby avoiding it selecting a Skypelink window the code has been modified as follows: ;//Close Skype Window and Leave Running Sleep(5000) WinSetState($SkypeTitleClose, "", @SW_SHOWDEFAULT) WinActivate($SkypeTitleClose) WinWaitActive($SkypeTitleClose, "", 20) Sleep(500) Send("{ALT}{DOWN 8}{ENTER}") please note that to select the Skype Window the $SkypeTitleClose variable containing the Skype TM symbol $SkypeTitleClose = "Skype™" is used. Ant.. Edited July 9, 2010 by anixon 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