 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
umek
Joined: 02 Oct 2004 Posts: 74
|
Posted: Wed Oct 20, 2004 9:14 am Post subject: Bug or feature? |
|
|
I have a menu which refers to several subroutines. When I use ControlClick in one of these subroutines,
the ControlFocus gets executed. I managed it by Send, {ENTER} but I assume there's another way to solve it.
greetz |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10465
|
Posted: Wed Oct 20, 2004 12:18 pm Post subject: |
|
|
What kind of menu is it? You might try using WinMenuSelectItem on a standard menu bar. If the script owns the menu, you should directly call the menu's subroutine rather than have the script try to "automate itself".
If the above doesn't help, please post an example to clarify. |
|
| Back to top |
|
 |
umek
Joined: 02 Oct 2004 Posts: 74
|
Posted: Wed Oct 20, 2004 12:45 pm Post subject: |
|
|
Sorry, I was talking about a AHK created menu ....
The bold line is my problem ...
;#NoTrayIcon
#Persistent
Menu, SubMenuStatus, Add, ACT, ChangeStatus
Menu, SubMenuStatus, Add, PEN, ChangeStatus
Menu, SubMenuStatus, Add, DEL, ChangeStatus
Menu, SubMenuService, Add, PPR1, MakeService
Menu, SubMenuService, Add, PPR2, MakeService
Menu, SubMenuService, Add, PPR3, MakeService
Menu, SubMenuApp, Add, Restart, Restart
Menu, SubMenuApp, Add, Exit, Quit
Menu, App, Add, Status, :SubMenuStatus
Menu, App, Add
Menu, App, Add, Service, :SubMenuService
Menu, App, Add
Menu, App, Add, Program, :SubMenuApp
Return
;**********************************************
LControl & LButton::
Menu, App, Show
Return
;**********************************************
ChangeStatus:
AppTitle = Auto WFM v1.0
BasicTitle = Clarify
IDTitle = 120
StatusScrTitle = Activity Status Note
IfWinExist, %BasicTitle%
{
WinActivate ; use the window found above
Send, ^g
Sleep, 500
}
Else
{
MsgBox, 48, %AppTitle%, %BasicTitle% does not exist.
Return
}
WinWaitActive, %StatusScrTitle%, , 2
if ErrorLevel <> 0
{
MsgBox, WinWait timed out.
Return
}
Else
{
ControlGetText, ReadCurrentStatus, Edit8, %StatusScrTitle%
Sleep, 1000
}
If ReadCurrentStatus = %A_ThisMenuItem%
{
MsgBox, 48, %AppTitle%, The status is already %A_ThisMenuItem%.
ControlClick, Button1, %StatusScrTitle%
Return
}
Else
{
Control, ChooseString, %A_ThisMenuItem%, ComboBox1, %StatusScrTitle%
Sleep, 250
ControlGetText, ChangedStatus, ComboBox1, %StatusScrTitle%
Sleep, 250
}
If ChangedStatus <> %A_ThisMenuItem%
{
MsgBox, 48, %AppTitle%, Could not change to %A_ThisMenuItem%.
Return
}
Else
{
ControlClick, Button2, %StatusScrTitle%
Sleep, 50
ControlClick, Button2, %StatusScrTitle%
Sleep, 500
Return
}
Return
;**********************************************
MakeService:
SetTitleMatchMode, 2
SetTitleMatchMode, fast
AppTitle = Auto WFM v1.0
BasicTitle = Clarify
IDTitle = 120
DispScrTitle = SDC
ServiceScrTitle = 2004
IfWinExist, %IDTitle%
{
WinActivate ; use the window found above
Send, ^t
Sleep, 2500
}
Else
{
MsgBox, 48, %AppTitle%, You should open a Case ID to create a service.`t
Return
}
IfWinActive, %DispScrTitle%
{
ControlClick, Button5, %DispScrTitle%
Sleep, 1000
}
Else
WinWaitActive, %ServiceScrTitle%, , 2
if ErrorLevel <> 0
{
MsgBox, WinWait timed out.
Return
}
Else
{
Sleep, 3500
Control, ChooseString, PUMA, ComboBox4, %ServiceScrTitle%
Sleep, 500
ControlSetText, Edit3, , %ServiceScrTitle%
ControlSetText, Edit4, , %ServiceScrTitle%
ControlSetText, Edit5, , %ServiceScrTitle%
ControlSetText, Edit6, , %ServiceScrTitle%
Control, ChooseString, %A_ThisMenuItem%, ComboBox25, %ServiceScrTitle%
Sleep, 500
ControlGetText, Product, TSpecialEdit23, WFM Case Generator
ControlSetText, Edit3, %Product%, %ServiceScrTitle%
ControlGetText, ErrorCode, TSpecialEdit20, WFM Case Generator
ControlSetText, Edit33, %ErrorCode%, %ServiceScrTitle%
Sleep, 100
ControlClick, TNeoBookPushBtn17, WFM Case Generator
Sleep, 100
ControlFocus, Button16, %WinTitleVar1%
Send, +{TAB}
Send, ^v
Sleep, 500
}
Return
;**********************************************
Restart:
Reload
Return
;**********************************************
Quit:
ExitApp
Return
;**********************************************
I get only the focus on Button5, it doesn't click it.
greetz |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10465
|
Posted: Wed Oct 20, 2004 1:08 pm Post subject: |
|
|
| Quote: | | I get only the focus on Button5, it doesn't click it. | I've observed ControlClick to have problems with certain apps. If the button has a shortcut key (underlined letter), you could try using the Send command to send it. Otherwise, you could press the shortcut key of a nearby control then send {Tab 3} or +{Tab 3} to navigate to it and then "Send {Space}" (replace 3 with the actual number of tabs needed). You could also try:
ControlFocus, Button5, %DispScrTitle% ; This line might not be required.
ControlSend, Button5, {Space}, %DispScrTitle% |
|
| Back to top |
|
 |
umek
Joined: 02 Oct 2004 Posts: 74
|
Posted: Wed Oct 20, 2004 1:47 pm Post subject: |
|
|
Thx it works!
But it's a little bit confusing because MakeService: as stand alone script
(with no subroutines) runs as requested. All buttons with ControlClick
becomes clicked. But I will keep in view ... |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|