Jump to content

Eleasar

Members
  • Posts

    3
  • Joined

  • Last visited

Eleasar's Achievements

Seeker

Seeker (1/7)

0

Reputation

  1. After some more testing and looking through the forum i found the task bar method to find an icon and click that, navigate once up and hit enter which effectively closes Evernote. But when windows is locked it seems that this is not working (would make sense): #Include <GuiToolBar.au3> AutoItSetOption("WinTitleMatchMode", 2) #NoTrayIcon Global $hSysTray_Handle, $iSystray_ButtonNumber Global $sToolTipTitle = "Evernote" ; <<<<<<<<<<<<<<<< Enter some tooltip text for the icon you want here While True Sleep(100) If ProcessExists("logonui.exe") then $iSystray_ButtonNumber = Get_Systray_Index($sToolTipTitle) If $iSystray_ButtonNumber = -1 Then MsgBox(16, "Error", "Icon not found in system tray") Exit Else ;Sleep(500) WinActivate('[Class:Shell_TrayWnd]') _GUICtrlToolbar_ClickButton($hSysTray_Handle, $iSystray_ButtonNumber, "right", True, 1, 0) Send("{UP}") Send("{ENTER}") MsgBox(0, "Success", "program closed") EndIf Exit EndIf WEnd Func Get_Systray_Index($sToolTipTitle) ; Find systray handle $hSysTray_Handle = ControlGetHandle("[Class:Shell_TrayWnd]", "", "[Class:ToolbarWindow32;Instance:1]") If @error Then MsgBox(16, "Error", "System tray not found") Exit EndIf ; Get systray item count Local $iSystray_ButCount = _GUICtrlToolbar_ButtonCount($hSysTray_Handle) If $iSystray_ButCount = 0 Then MsgBox(16, "Error", "No items found in system tray") Exit EndIf ; Look for wanted tooltip ;For $iSystray_ButtonNumber = 0 To $iSystray_ButCount - 1 =========== "OLD" instruction For $iSystray_ButtonNumber = 1 To $iSystray_ButCount ; =========== MODIFIED instruction If StringInStr(_GUICtrlToolbar_GetButtonText($hSysTray_Handle, $iSystray_ButtonNumber), $sToolTipTitle) = 1 Then ExitLoop Next ;If $iSystray_ButtonNumber = $iSystray_ButCount Then ;=========== "OLD" instruction If $iSystray_ButtonNumber = $iSystray_ButCount + 1 Then ; =========== MODIFIED instruction Return 0 ; Not found Else Return $iSystray_ButtonNumber ; Found EndIf EndFunc Had to set Evernote to always show its icon for it to work. Any idea on how to still get this working even though the Computer is then locked?
  2. Ok thanks! After your link i found the correct words to search for and found the following very small construct that did the job: While True Sleep(1000) If ProcessExists("logonui.exe") then MsgBox(0, "Details", "locked") EndIf WEnd Not sure if i should ask in a new thread but i got the following problem testing with Evernote (should finally work with trillian, evernote and maybe a few more programms). It closes notepad just fine but not evernote. Evernote is handling the close action differently (right click in taskbar > close or on the red X) - it will just hide itself - but not even this is working from autoit. Only with (manual) key command CTRL+Q it will really close. Sending this command to Evernote is not working even in non-locked state. And when Evernote is minimized the WinList will not find it either... This is my program so far: ;#requireadmin Opt("WinTitleMatchMode", 2) While True Sleep(1000) If ProcessExists("logonui.exe") then ;CloseProgram("Notepad") Sleep(1000) CloseProgram("Evernote") ;MsgBox(0, "Details", "locked") EndIf WEnd Func CloseProgram($name) $var = WinList($name) For $i = 1 to $var[0][0] ; Only display visble windows that have a title If $var[$i][0] <> "" AND IsVisible($var[$i][1]) Then WinActivate($var[$i][1]) Sleep(500) Send("!{F4}") Send("^Q") WinClose($var[$i][1]) ;Send("^q") ;WinClose($var[$i][1]) ;WinKill($var[$i][1]) ;MsgBox(0, "Details", "Title=" & $var[$i][0] & @LF & "Handle=" & $var[$i][1]) ;ProcessClose("evernote.exe") EndIf Next EndFunc Func IsVisible($handle) If BitAnd( WinGetState($handle), 2 ) Then Return 1 Else Return 0 EndIf EndFunc
  3. Hi, i did search for a way to close a specific program (just sending ALT+F4 or specific key combination) to a program when windows (Windows 7) is locked. I was not able to find an example on how to achieve this. If anyone got one that would be great! If it helps i always lock the computer with the windows-key+L. Thanks in advance
×
×
  • Create New...