Jump to content

ControlClick and ControlCommand


Recommended Posts

Hi guys Im hoping someone can help me Im trying to open by keyboard command a button on a application that brings up a list or menu without using the mouse to click on, now Im trying to do this using the "Controlcommand" code but it doesnt seem to work I also tried to do this using "Controlclick" command to but didnt work either, I dont know if its the application itself which is restricting.

ControlClick ( "Application", "FormView", 59664, "", "" )

and

ControlCommand ( "Application", "FormView", 59664, "", ""

Thanks

Link to comment
Share on other sites

  • Moderators

Try using ClassNameNN as the ControlID if that doesn't work, then be more specific (eg.. at least a program name).

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Try using ClassNameNN as the ControlID if that doesn't work, then be more specific (eg.. at least a program name).

The program imtrying to use is REMEDY its a ticketing app, the error Im getting is that it does not know what the classnameNN or ControlID is when I put it in the code.

Bassically getting "error unknown function name"

I really want to avoid using mouse coords to point and click as resolution and window size may vary from time to time.

Edited by snowboarder187
Link to comment
Share on other sites

  • Moderators

The program imtrying to use is REMEDY its a ticketing app, the error Im getting is that it does not know what the classnameNN or ControlID is when I put it in the code.

Bassically getting "error unknown function name"

I really want to avoid using mouse coords to point and click as resolution and window size may vary from time to time.

You don't get that error message if you have the wrong ClassNameNN or ControlID... post your code so someone can figure out what you've done wrong. Use SciTe Editor and some of the Syntax Checking options in the tools if you want to try and figure it out on your own.

Edit:

Probably missing an #include

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

You don't get that error message if you have the wrong ClassNameNN or ControlID... post your code so someone can figure out what you've done wrong. Use SciTe Editor and some of the Syntax Checking options in the tools if you want to try and figure it out on your own.

Edit:

Probably missing an #include

Im failry new to AutoIT, Ive only just used it to pretty much run advanced Macro's but the code is as follows:

Winwaitactive ("Remedy Support - [Remedy Support (New)]")

ControlClick ( "Remedy Support - [Remedy Support (New)]", "FormView", AfxFrameOrView421, "", "" )

that is using the ClassnameNN as identified on Active Window Info the Control ID is 59664, The syntax is a copy and paste from the online documentation, unless im missing extra coding somewhere I dont know why its not working as intended, sorry for the ignorance if shown but i guess thats why Im here asking for help, Thanks.

Link to comment
Share on other sites

  • Moderators

You need to put quotation marks around any strings AfxFrameOrView421 should be "AfxFrameOrView421" and does the title actually have "[]" brackets in it?

Edit:

Also the text "FormView" needs to be the text of the control id or ClassNameNN, if it great, if not then change it, if you don't understand replace "FormView" with "" (blank string).

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

You need to put quotation marks around any strings AfxFrameOrView421 should be "AfxFrameOrView421" and does the title actually have "[]" brackets in it?

Edit:

Also the text "FormView" needs to be the text of the control id or ClassNameNN, if it great, if not then change it, if you don't understand replace "FormView" with "" (blank string).

I fixed the brackets and the syntax new code is :

Winwaitactive ("Remedy Support - Remedy Support (New)]")

ControlClick ( "Remedy Support - Remedy Support (New)]", "FormView", "59664", "", "" )

I also tried it using the classnameNN but nothing happens, the script just pause's now... dont know what Im doing wrong, its so hard just to get a menu to pop up from a button which is normally clicked on.. lol

If you can figure this out for you are a true master...

Link to comment
Share on other sites

I fixed the brackets and the syntax new code is :

Winwaitactive ("Remedy Support - Remedy Support (New)]")

ControlClick ( "Remedy Support - Remedy Support (New)]", "FormView", "59664", "", "" )

I also tried it using the classnameNN but nothing happens, the script just pause's now... dont know what Im doing wrong, its so hard just to get a menu to pop up from a button which is normally clicked on.. lol

If you can figure this out for you are a true master...

Also should I be using controlclick or controlcommand for this type of action?

Honestly dont know the diff here..

Link to comment
Share on other sites

  • Moderators

I fixed the brackets and the syntax new code is :

Winwaitactive ("Remedy Support - Remedy Support (New)]")

ControlClick ( "Remedy Support - Remedy Support (New)]", "FormView", "59664", "", "" )

I also tried it using the classnameNN but nothing happens, the script just pause's now... dont know what Im doing wrong, its so hard just to get a menu to pop up from a button which is normally clicked on.. lol

If you can figure this out for you are a true master...

I'm a master in my own mind regardless :D

Your using WinWaitActive() function... what does just the name of that make you think of? That it will wait for the window to be active before it clicks on it? If you answered yes, your right.

Make sure you have the title correct... Try this:

Opt('WinTitleMatchMode', 2)
$Title = WinGetTitle("Remedy Support")
WinWaitActive($Title)
ControlClick($Title, "", "AfxFrameOrView421");Note, the clicks and times are optional, but you don't leave them blank because that will return 0 clicks and 0 times clicked
Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

I'm a master in my own mind regardless :D

Your using WinWaitActive() function... what does just the name of that make you think of? That it will wait for the window to be active before it clicks on it? If you answered yes, your right.

Make sure you have the title correct... Try this:

Opt('WinTitleMatchMode', 2)
$Title = WinGetTitle("Remedy Support")
WinWaitActive($Title)
ControlClick($Title, "", "AfxFrameOrView421");Note, the clicks and times are optional, but you don't leave them blank because that will return 0 clicks and 0 times clicked
Yep winwaitactive is there just for testing, I usually run the script and then maximise the window so it catches the application when I maximise the window, I just tried ur code does the same thing just sit's there in pause. Also it might not be working because it is not "clicking" but to my understanding it should activate the button with at least 1 click by default, I can get this button working if I use the mouse coords to just macro a click on it but I really really dont wont to do that as I explained earlier window size will vary from time to time...
Link to comment
Share on other sites

  • Moderators

Sounds like you don't have the right button or window title name to me. Use a messagebox after WinWaitActive() to see if it's getting past that... and try this:

Opt('WinTitleMatchMode', 2)
$Title = WinGetTitle("Remedy Support")
If Not WinExists($Title) Then MsgBox(64, 'Info:', 'Wrong Title')
WinWait($Title)
ControlClick($Title, "", "AfxFrameOrView421")
If ControlCommand($Title, '', 'AfxFrameOrView421', 'IsVisible', '') Then
    MsgBox(64, 'Info:', 'The control Exists, should have been clicked')
Else
    MsgBox(64, 'Error', 'You have something wrong there')
EndIf

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Sounds like you don't have the right button or window title name to me. Use a messagebox after WinWaitActive() to see if it's getting past that... and try this:

Opt('WinTitleMatchMode', 2)
$Title = WinGetTitle("Remedy Support")
If Not WinExists($Title) Then MsgBox(64, 'Info:', 'Wrong Title')
WinWait($Title)
ControlClick($Title, "", "AfxFrameOrView421")
If ControlCommand($Title, '', 'AfxFrameOrView421', 'IsVisible', '') Then
    MsgBox(64, 'Info:', 'The control Exists, should have been clicked')
Else
    MsgBox(64, 'Error', 'You have something wrong there')
EndIf
Ran that code "the control exist shouldhave been clicked" so yeh dunno why its not pushing the button required...
Link to comment
Share on other sites

'AfxFrameOrView421' does not seem to be a real button and the brief description also makes me curious of what it is and how you would operate it manually by mouse? Once the operation can be realized, then the correct Control*() functions can be used.

Edited by MHz
Link to comment
Share on other sites

  • Moderators

Here my last attempt, if it doesn't work, read the Control functions in the help file:

Opt('WinTitleMatchMode', 2)
$Title = WinGetTitle("Remedy Support")
If Not WinExists($Title) Then MsgBox(64, 'Info:', 'Wrong Title')
WinWait($Title)
ControlFocus($Title, "", "AfxFrameOrView421")
ControlClick($Title, "", "AfxFrameOrView421")
If ControlCommand($Title, '', 'AfxFrameOrView421', 'IsVisible', '') Then
    MsgBox(64, 'Info:', 'The control Exists, should have been clicked')
Else
    MsgBox(64, 'Error', 'You have something wrong there')
EndIf

Look for the AutoIt 1-2-3 tutorial in the help file, that may give yo some quick insight with an interactive tutorial that takes like 30 minutes or so.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • Moderators

'AfxFrameOrView421' does not seem to be a real button and the brief description also makes me curious of what it is and how you would operate it manually by mouse? Once the operation can be realized, then the correct Control*() functions can be used.

Doesn't look like one to me either... but hey, I don't have the program and trying to give the benefit of the doubt... Maybe ControlListView() or Control* like you said, I dunno.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Doesn't look like one to me either... but hey, I don't have the program and trying to give the benefit of the doubt... Maybe ControlListView() or Control* like you said, I dunno.

Since doubt positively exists and so far guessing has failed, then More information is needed.

@snowboarder187

The operation of this button.

Do you have to rightclick it to get the menu? or leftclick? of hover over the button?

Can AutoIt Info Tool see the button and the menu?

Edit1:

Also, does AutoIt Info Tool display that the button is hidden?

Edit2:

Also, using Find Classes By Text by LxP may help with identifying the button, incase another does occupy the same position.

Edited by MHz
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...