autoit0822

Close Evernote Control

13 posts in this topic

How can I create a script that will automatically close a control in Evernote after a few seconds? Using Au3Info, I know that the class of the control is ENMainFrameNotification; what other information should I provide?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

What are you hoping to close?

You could use a HotKey

;~ Example 1
HotKeySet("{PAUSE}", "Pause")

While 1
    Sleep(100)
WEnd

Func Pause()
;~ When Pause key is pressed and Evernote Window is open
    If WinActive('[CLASS:ENMainFrame]') Then
        ;~ Checks to see if the Left Pane is expanded or hidden and hide it if true
        If ControlCommand('[CLASS:ENMainFrame]', '', 'ENNavPaneCtrl1', 'IsVisible', '') Then Send('{F10}')
    EndIf
EndFunc

Or you can start EverNote using the following

;~ Example 2
;~ Evernote File Path
Global $sREG_EVERNOTE = RegRead('HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\AppPaths\Evernote.exe', '')
    If FileExists($sREG_EVERNOTE) = 0 Then Exit
Run($sREG_EVERNOTE)
;~ Wait 5 seconds for Evernote Window to open 
WinWaitActive('[CLASS:ENMainFrame]', 5)
    ;~ Checks to see if the Left Pane is expanded or hidden and hide it if true
    If ControlCommand('[CLASS:ENMainFrame]', '', 'ENNavPaneCtrl1', 'IsVisible', '') Then Send('{F10}')

 

Edited by Subz

Share this post


Link to post
Share on other sites

I want to close the ENMainFrameNotification notification that appears in the program with a button to dismiss it.

Share this post


Link to post
Share on other sites

Are you able to send through Au3Info information on Class, ClassNameNN?  I have Evernote on my system (I haven't used it for ages, but can't find the ENMainFrameNotification notification window you're describing are you able to give us instructions on how to get the notification to appear (preferred), however if not a screenshot.

Share this post


Link to post
Share on other sites

Class is ENMainFrame; ClassnameNN is ENMainFrameNotification1. I have attached a screenshot; the notification appears if your subscription is about to expire, or if you do not have one.

2017-01-12 06_19_54-Evernote.png

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Try:

Global $sREG_EVERNOTE = RegRead('HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\Evernote.exe', '')
    If $sREG_EVERNOTE = '' Then $sREG_EVERNOTE = RegRead('HKLM64\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\Evernote.exe', '')
    If $sREG_EVERNOTE = '' Then $sREG_EVERNOTE = RegRead('HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\Evernote.exe', '')
    If FileExists($sREG_EVERNOTE) = 0 Then Exit
Global $hRUN_EVERNOTE = Run($sREG_EVERNOTE)
    AdlibRegister('EN_Notification')
While 1
    Sleep(100)
WEnd

Func EN_Notification()
    ;~ Checks to see if Notification Bar is visible
    If WinActive('[CLASS:ENMainFrame]') And ControlCommand('[CLASS:ENMainFrame]', '', 'ENMainFrameNotification1', 'IsVisible', '') Then
        Sleep(5000) ;~ Wait for 5 seconds
        ;~ Get the position of Notification Bar
        $hEN_Notification = ControlGetPos('[CLASS:ENMainFrame]', '', 'ENMainFrameNotification1')
        ;~ Left mouse click
        ;~ x = Notification Bar Width - Notification Height/2
        ;~ y = Notification Bar Height/2
        ControlClick('[CLASS:ENMainFrame]', '', 'ENMainFrameNotification1', 'left', 1, $hEN_Notification[2] - ($hEN_Notification[3]/2), ($hEN_Notification[3]/2))
    EndIf
    If ProcessExists($hRUN_EVERNOTE) = 0 Then Exit
EndFunc

 

Edited by Subz
Added Sleep for 5 Seconds

Share this post


Link to post
Share on other sites

Thank you; but what if I don't have that registry key? (The path is %LOCALAPPDATA%\Apps\Evernote\Evernote\Evernote.exe)

Share this post


Link to post
Share on other sites

Can you check 'HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\Evernote.exe', it sounds like you have a per user installation rather than a per machine.  If you can confirm I can update the code.

Share this post


Link to post
Share on other sites

There it is :)

Share this post


Link to post
Share on other sites

#10 ·  Posted

Updated the script to detect HKLM, HKLM64 and HKCU.

Share this post


Link to post
Share on other sites

#11 ·  Posted

This works well, thanks; just a couple of points:

  1. If I want to keep the notification visible for a few seconds (in the event that it is something useful), do I just change Sleep?
  2. How can I keep the program in memory, and run it each time that I open Evernote (which is always in memory, but minimised to the taskbar)?

Share this post


Link to post
Share on other sites

#12 ·  Posted

A1. I have updated the function above so that it shows for 5 seconds before closing the notification.
A2. You should use the compiled script for starting EverNote, it will remain in memory until you Quit EverNote, so if the notification appears again it will wait 5 seconds before closing the notification.

Share this post


Link to post
Share on other sites

#13 ·  Posted

Thank you, again; this is great!

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