Sign in to follow this  
Followers 0
joedimagio

autoit tray application

5 posts in this topic

Here is what I am trying to come up with

An autoit exe running perpetually in the system tray which watches for an external GUI (non-Autoit). Once this GUI is opened, it adds a new menu item to the GUI menu. When the user clicks on the menu item, certain field values in the GUI are saved to a file.

I am trying to simulate this using Notepad. So I would like to have a autiit exe perpetually running on the system tray waiting for a notepad.exe to open. Once available, it will create a menu item which when clicked on, will save the contents of the notepad to a file.

I have figured out the adding menu part. I am not sure of the perpetual tray exe which watches for notepad and also on how to grab contents and save to a file.

Any help will be appreciated. Thanks.

Joe

Share this post


Link to post
Share on other sites



Here is what I am trying to come up with

An autoit exe running perpetually in the system tray which watches for an external GUI (non-Autoit). Once this GUI is opened, it adds a new menu item to the GUI menu. When the user clicks on the menu item, certain field values in the GUI are saved to a file.

I am trying to simulate this using Notepad. So I would like to have a autiit exe perpetually running on the system tray waiting for a notepad.exe to open. Once available, it will create a menu item which when clicked on, will save the contents of the notepad to a file.

I have figured out the adding menu part. I am not sure of the perpetual tray exe which watches for notepad and also on how to grab contents and save to a file.

Any help will be appreciated. Thanks.

Joe

look in the help file at Tray Functions, you can also search for "minimize to tray" on the forums for some ideas on how it all works. ProcessExists() is a good way to check if a process is running, or WinExists() if you just want a window title checked.


[u]You can download my projects at:[/u] Pulsar Software

Share this post


Link to post
Share on other sites

look in the help file at Tray Functions, you can also search for "minimize to tray" on the forums for some ideas on how it all works. ProcessExists() is a good way to check if a process is running, or WinExists() if you just want a window title checked.

Thanks for the pointers. Here is what I did

#include <GuiMenu.au3>
#include <WinAPI.au3>
#include <anygui.au3>

Local $hMainWnd, $hMainMenu, $msg
Local $idNewItem
    
    do
        sleep(50)
    until WinExists("Untitled - Notepad")

    MsgBox(0, "", "Window exists")

    $hMainWnd = _GuiTarget("Untitled - Notepad", 1)
    $hMainMenu = _GUICtrlMenu_GetMenu($hMainWnd)

; Create New menu
    $hNewMenu = _GUICtrlMenu_CreateMenu ()
    _GUICtrlMenu_InsertMenuItem ($hNewMenu, 0, "&New Item", $idNewItem)

    _GUICtrlMenu_InsertMenuItem ($hMainMenu, 5, "&New Menu", 0, $hNewMenu)


    GUISetState(@SW_SHOW)

    MsgBox(0, "", _GUICtrlMenu_GetItemSubMenu ($hMainMenu, 5))
    MsgBox(0, "", _GUICtrlMenu_GetItemSubMenu ($hNewMenu, 0))


    While WinExists($hMainWnd)
       $msg = GUIGetMsg()
       Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case Not WinExists($hMainWnd)
            Exit
        Case $msg = $hNewMenu
             MsgBox(0,"","menu clicked")
        Case Else
       EndSelect
       Sleep(50)
    WEnd

I am trying to find out when the new menu item is clicked, but the case statement for the new menu item does not fire. What am I doing wrong? Thanks for any help.

Share this post


Link to post
Share on other sites

I think it requires to hook the WH_GETMESSAGE but you need to install it using a dll, or more correctly, the hook procedure must be in a dll library, otherwise it'll crush your windows. Note also that you may need to give the menu item ID value that you is unique so you won't handle other control ID messages.

Share this post


Link to post
Share on other sites

Here is another approach. I use free antivirus, AntiVir from http://www.free-av.com/. I like it because it is low overhead and seems to be pretty quick. However, every day it updates and a big pop up window comes up advertising the product. Its not a big deal, but whenever that comes up I have to click the button. I wrote this little script to watch for the process that brings up that window and simply close it. I am using the adlib function.

TraySetToolTip("No Antivir Notify by Reaper")
AdlibEnable("noantivirnotify")

While 1
    Sleep(200)
WEnd
Exit

Func noantivirnotify()
    If ProcessExists("avnotify.exe") Then
        ProcessClose("avnotify.exe")
        TrayTip("No Antivir Notify engaged","Process quieted.",4)
    EndIf
EndFunc

For your purposes, you could watch for the process of the application ("notepad.exe" in your example) and when it shows up, take the desired action. Of course instead of killing it, you would probably focus on it and add the menu buttons, etc.

Anyway, hope that gives you an idea.

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  
Followers 0