| View previous topic :: View next topic |
| Author |
Message |
V@no
Joined: 13 Sep 2007 Posts: 37
|
Posted: Thu Apr 03, 2008 1:53 am Post subject: ControlSend,,!f,Title - doesn't send ALT |
|
|
hello!
I've been trying figure this out and tryed to search for a solution, so far no results.
here is a simple script:
| Code: | WinWait, ahk_class Notepad
ControlSend,,!f, ahk_class Notepad |
It supposed to send ALT+F and open File menu in notepad, however notepad prints "f" letter and no menu opens.
What do I do wrong?
Thank you. |
|
| Back to top |
|
 |
k3ph
Joined: 20 Jul 2006 Posts: 174
|
Posted: Thu Apr 03, 2008 9:51 am Post subject: |
|
|
according to the manual:
| Code: | However, in some cases these modifier events may interfere with the active window, especially if the user is actively typing during a ControlSend or if the Alt key is being sent (since Alt activates the active window's menu bar). This can be avoided by explicitly sending modifier up and down events as in this example:
ControlSend, Edit1, {Alt down}f{Alt up}, Untitled - Notepad |
weird, it doesn't works here too.
| Code: | DetectHiddenWindows, On
; activates status bar
ControlSend, Edit1, {Alt down}v{Alt up}s, ahk_class Notepad
|
|
|
| Back to top |
|
 |
Oberon
Joined: 18 Feb 2008 Posts: 453
|
Posted: Thu Apr 03, 2008 10:13 am Post subject: |
|
|
| You can try WinMenuSelectItem. |
|
| Back to top |
|
 |
Lexikos
Joined: 17 Oct 2006 Posts: 2737 Location: Australia, Qld
|
Posted: Thu Apr 03, 2008 10:41 am Post subject: |
|
|
If the user presses a key while holding Alt, the system sends WM_SYSKEYDOWN and WM_SYSKEYUP. Since ControlSend simulates keystrokes by sending WM_KEYDOWN and WM_KEYUP, it won't trigger the menu. Even if it sent WM_SYSKEYDOWN, the window would have to be active for the menu to show.
| Code: | WinActivate, ahk_class Notepad
PostMessage, 0x104, % Asc("F"), 2**29,, ahk_class Notepad
|
|
|
| Back to top |
|
 |
V@no
Joined: 13 Sep 2007 Posts: 37
|
Posted: Thu Apr 03, 2008 1:21 pm Post subject: |
|
|
Thanks for the replys.
Notepad example was just an example, since it has same effect - doesn't work...
In my case, I'm trying make it press a button in Windows Live Messenger that can be done by combination of ALT+C and if possible without need of activating the window...
Lexikos' example worked great with notepad, but for some reason it doesn't work with WLM window (specifically at Emoticons window ALT+C to create new emoticon)...it does presses ALT, and something else (I can hear a windows sound just like if you press ALT and a not assigned key, like ALT+J...)
P.S.
The window I'm trying to press ALT+C looks like this:
 |
|
| Back to top |
|
 |
Lexikos
Joined: 17 Oct 2006 Posts: 2737 Location: Australia, Qld
|
Posted: Fri Apr 04, 2008 1:28 am Post subject: |
|
|
| Assuming Alt+C is associated with one of those controls, have you tried ControlSend {Enter} or ControlClick directly to the control? |
|
| Back to top |
|
 |
V@no
Joined: 13 Sep 2007 Posts: 37
|
Posted: Fri Apr 04, 2008 1:41 am Post subject: |
|
|
Yes, I've tried send {Enter} it closes the window and inserts selected emoticon into message field. Also tried {Esc} - it closes the window...
I'm trying avoid anything mouse related, because of different skins that could possibly change position of buttons.
I also tried use {Tab}, but for some reason it takes several attempts to move focus between the buttons...weird. |
|
| Back to top |
|
 |
Lexikos
Joined: 17 Oct 2006 Posts: 2737 Location: Australia, Qld
|
Posted: Fri Apr 04, 2008 1:51 am Post subject: |
|
|
ControlSend is very different to Send. Send {Enter} sends an Enter keystroke to the window, activating the default button. ControlSend,Button1,{Enter} sends an Enter keystroke to a specific button.
ControlClick does not need to rely on mouse coordinates if you specify a control. |
|
| Back to top |
|
 |
V@no
Joined: 13 Sep 2007 Posts: 37
|
Posted: Fri Apr 04, 2008 2:02 am Post subject: |
|
|
| Well, the problem is I don't know the name of the control for that window...Neither AHK's "Window spy", nor "Winspector spy" shows anything other then ahk_class for the whole window... |
|
| Back to top |
|
 |
Lexikos
Joined: 17 Oct 2006 Posts: 2737 Location: Australia, Qld
|
Posted: Fri Apr 04, 2008 4:06 am Post subject: |
|
|
Ah, that's a pain. This seems to work for me:
| Code: | ; WM_COMMAND=0x111
PostMessage, 0x111, 2326,,, Emoticons
| ID (2326) was discovered using Spy++ (note: Winspector is an alternative.) |
|
| Back to top |
|
 |
|