Sign in to follow this  
Followers 0
iXX

Sending keys troubles..

11 posts in this topic

Hi! ;)

I am tryin to send keys to an program in tray icon, but it don't accept Send or ControlSend command. But in old program "Grider" (3.3.8) I can use something like "send event (or command?)" by some other way - it use some W parameter and L parameter ... and this works! (Sending just keyboard keys is not working in Girder too).

So, is in the AutoIt some similar feature?

THNX,

iXX

Share this post


Link to post
Share on other sites



No one knows? ;)

Share this post


Link to post
Share on other sites

iXX,

I think it more a case of no-one having any idea what you are talking abot! ;)

How can you send keys to a tray icon? ;)

Do you have to right click on it first to open a menu? If so, then I have some code to do that - and to move around the menu.

Please explain in more detail what exactly you are trying to do and we will see how we can help. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

OK, I am trying to control program in system tray. Right click to it's icon shows menu:

Posted Image

I want to control item "Disable Wallpaper Slideshow" and "Enable Wallpaper Slideshow". I tryed this code:

WinActivate("[TITLE:Wallpaper Slideshow LT]")

WinWaitActive("[TITLE:Wallpaper Slideshow LT]")

ControlSend("[TITLE:Wallpaper Slideshow LT]", "", "", "!D")

This sometimes works, but - who knows why - just sometimes (~80% probability?).

Second item (Enable Wallpaper Slideshow) don't work at all with this:

WinActivate("[TITLE:Wallpaper Slideshow LT]")

WinWaitActive("[TITLE:Wallpaper Slideshow LT]")

ControlSend("[TITLE:Wallpaper Slideshow LT]", "", "", "!E")

As I sed, Girder command (not sending keystrokes) works perfectly always:

Posted Image

Posted Image

So, maybe this is little clearer explenation?

And, sorry for my bad english...

Share this post


Link to post
Share on other sites

iXX,

I have never seen or used any form of message to activate a systray icon context menu. But others might have - so do not despair.

However, this code will right-click on the tray icon - all you have to do is enter the tooltip text for the particular icon you want.

#Include <GuiToolBar.au3>

Global $hSysTray_Handle, $iSystray_ButtonNumber

Global $sToolTipTitle = "" ; <<<<<<<<<<<<<<<< Enter some tooltip text for the icon you want here

$iSystray_ButtonNumber = Get_Systray_Index($sToolTipTitle)

If $iSystray_ButtonNumber = 0 Then
    MsgBox(16, "Error", "Icon not found in system tray")
    Exit
Else
    Sleep(500)
    _GUICtrlToolbar_ClickButton($hSysTray_Handle, $iSystray_ButtonNumber, "right")
EndIf

Exit

;............

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
        If StringInStr(_GUICtrlToolbar_GetButtonText($hSysTray_Handle, $iSystray_ButtonNumber), $sToolTipTitle) > 0 Then ExitLoop
    Next

    If $iSystray_ButtonNumber = $iSystray_ButCount Then
        Return 0 ; Not found
    Else
        Return $iSystray_ButtonNumber ; Found
    EndIf

EndFunc

I have used Send("{UP}") and ("{ENTER}") very successfully to manoeuvre my way around a menu opened in this way and to select an item within it - but I would add a Sleep(250) or so before Send("{ENTER}") just to be on the safe side. ;)

As your menu appears to have Accelerator keys, you could also try Send "!e" or "!d". ;)

I hope this helps. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Yes, this script works!, shows proper menu. Now seems to be easy to complete what I need... Thank you!

But: By using Girder as mentioned, I am able to switch this two funkcions of program without any menu appeared!

And this is what I asking for: Can AutoIt do this in the same (or similar) way? I mean: hiddenly?

And that is the question. Maybe is here someone with experiences with this piece of old software, to fully understand...

Share this post


Link to post
Share on other sites

iXX,

Stick around for a while, I have asked someone who understands these things better than I do (not difficult!) to take a look. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

But: By using Girder as mentioned, I am able to switch this two funkcions of program without any menu appeared!

And this is what I asking for: Can AutoIt do this in the same (or similar) way? I mean: hiddenly?

And that is the question. Maybe is here someone with experiences with this piece of old software, to fully understand...

The ultimate answer is always yes. AutoIt has access to all the winapi, and ultimately the computer memory itself, so anything is possible. Implementing it is another story.

What you refer to in your first post with W and L is a standard windows message. One of the most common is WM_COMMAND. This is used to trigger events for all controls, as well as menus and accelerators. Luclily for you, a similar question has just been asked here, so I have everything ready to test (unfortunately the method I tried didn't work in that test ;) )

You've done the hard bit... getting the command ID for the menu item. All you need to do is send the message using _SendMessage:

#include<SendMessage.au3>
#include<WindowsConstants.au3>

$hWnd = WinGetHandle("[TITLE:Wallpaper Slideshow LT]")
$CmdID = 32777

_SendMessage($hWnd, $WM_COMMAND, $CmdID)

Does that do it? I tried to test it (difficult without the actual sample) and this worked perfectly:

#include<SendMessage.au3>
#include<WindowsConstants.au3>

#include<GUIMenu.au3>

; Create a window to emulate yours
$hGUI = GUICreate("Wallpaper Slideshow LT")

; Create a menu for is
$hMenu = _GUICtrlMenu_CreatePopup()
_GUICtrlMenu_AddMenuItem($hMenu, 'test', 32777) ; This is the item you are trying to get (same cmd id)

; We register the message so that we can respond to the message
GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")

; Click the menu item!!
$hWnd = WinGetHandle("[TITLE:Wallpaper Slideshow LT]")
$CmdID = 32777
_SendMessage($hWnd, $WM_COMMAND, $CmdID)


Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam)
    Switch $iwParam ; iwParam holds the Cmd ID of the clicked item.
        Case 32777
            ; The item was clicked
            ConsoleWrite('hit' & @CRLF)
    EndSwitch
EndFunc   ;==>WM_COMMAND

Share this post


Link to post
Share on other sites

YES!

This is it! And works! Seems to AutoIt is able to do everything! Well done! I am happy! :);)

Share this post


Link to post
Share on other sites

YES!

This is it! And works! Seems to AutoIt is able to do everything! Well done! I am happy! :);)

Wow... It worked first time did it? that makes a nice change from what I've been having recently where nothing's been working like I think it should.

Glad to see it sorted (and also glad to see you making the change to AutoIt ;) )

Share this post


Link to post
Share on other sites

Mat,

Thank you so much! ;)

iXX,

Worth the wait, I hope you will agree! :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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