Jump to content

ControlClick will not click button


wzc0014
 Share

Go to solution Solved by wzc0014,

Recommended Posts

I have tried that as well. Does not work. I only use a variable because when analyzing data the name changes from day to day and it's easier to change it once rather than 5 times. I have a loop because my other window is a stack of images. I plot the values of the images to the window I am trying to copy from, paste them in excel then close the plot window, move to the next image, and then replot copy paste etc. That loops for however many number of images I have in the stack. Everything else works I just can't get the copy button to click.

Link to comment
Share on other sites

It's all very confusing as to what you are trying to achieve.

Run this code in scite4autoit, see if you understand why your loop makes no sense...

$var = "PC_0to280"

ConsoleWrite(Int($var) & @LF)

For $i = 1 To $var
    ConsoleWrite($i & @LF)
Next

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

I apologize. I had only posted the portion of code I was having trouble with, the button not clicking. 

This is it in its entirety. 

   $svar = "PC_0to280"
   ;name of imajeJ stack
   $svar1 = " (75%)"
   ;window size
   $svar2 = "Microsoft Excel - 020915_PC data 0 to 280 by 20"
   ;Name of excel workbook
   $svar3 = "154"
   ;mouse x axis
   $svar4 = "423"
   ;mouse y axis
   $svar5 = "70"
   ;number of images in stack


   WinActivate($svar & $svar1)
   Sleep(0500)
   WinWaitActive($svar & $svar1)
   Sleep(1000)
   WinActivate("ImageJ")
   Sleep(0500)
   WinWaitActive("ImageJ")
   Sleep(2500)
   Send("{ALTDOWN}")
   Sleep(0050)
   SEND("{ALTUP}")
   Sleep(0050)
   Send("{RIGHT}")
   Sleep(0050)
   Send("{DOWN}")
   Send("{DOWN}")
   Send("{DOWN}")
   Send("{DOWN}")
   Send("{DOWN}")
   Send("{DOWN}")
   Send("{DOWN}")
   Send("{DOWN}")
   Send("{DOWN}")
   Send("{DOWN}")
   Send("{DOWN}")
   Send("{DOWN}")
   Sleep(0050)
   Send("{RIGHT}")
   Sleep(0050)
   Send("{DOWN}")
   Send("{DOWN}")
   Send("{DOWN}")
   Send("{DOWN}")
   Send("{DOWN}")
   Send("{DOWN}")
   Send("{DOWN}")
   Send("{DOWN}")
   Send("{DOWN}")
   Send("{DOWN}")
   Send("{DOWN}")
   Send("{DOWN}")
   Send("{DOWN}")
   Send("{DOWN}")
   Send("{DOWN}")
   Send("{DOWN}")
   Sleep(0050)
   Send("{ENTER}")
   Sleep(1000)
   Send("1280")
   Sleep(0500)
   Send("{TAB}")
   Send("43")
   Sleep(0500)
   Send("{TAB}")
   Send("0")
   Sleep(0500)
   Send("{TAB}")
   Send("469")
   Sleep(0500)
   Send("{ENTER}")
   Sleep(1000)


   For $i = 1 To $svar5
   Sleep (0500)
   Send("^k")
   WinActivate("Plot of " & $svar)
   WinWaitActive("Plot of " & $svar)
   Sleep(0500)
   ControlClick("Plot of PC_0to280", "", 3, "left")
   Sleep(0500)
   WinActivate($svar2)
   WinWaitActive($svar2)
   Send("^v")
   Sleep(0500)
   Send("{RIGHT}")
   Send("{RIGHT}")
   WinClose("Plot of " & $svar)
   WinActivate($svar & $svar1)
   WinWaitActive($svar & $svar1)
   Send("+{RIGHT}")
Next
Edited by wzc0014
Link to comment
Share on other sites

If ....

ControlClick("Plot of PC_0to280", "", "[CLASS:Button; INSTANCE:3]", "left")

...does not work to simply close your window of that name, then I would assume your window has non standard controls (which just happen to look like standard controls) and you will have to find another way.

IUIAutomation is where people go from here, you will find that in example scripts.

Also if you are going to do something like...

Send("{DOWN}")
Send("{DOWN}")
Send("{DOWN}")
Send("{DOWN}")
Send("{DOWN}")
Send("{DOWN}")
Send("{DOWN}")
Send("{DOWN}")
Send("{DOWN}")
Send("{DOWN}")
Send("{DOWN}")
Send("{DOWN}")

You might as well do...

Send("{DOWN 12}")

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

Then I'm 99% certain it is not a standard control.

If you are not up for IUIAutomation, I suggest to send what ever series of TAB and Arrow keys get you to the button, and then Enter of SpaceBar, whatever works.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

  • Solution

Thank you. I had tried to activate it and then press enter earlier, but I never thought to try "Space"! It works with space now. 

This is the code I ended up using. The controlclick won't click the button but it "activates" it and then I can press space to "click" it. 

ControlClick("Plot of " & $svar,"",3)
Send("{Space}")

Thanks for your help.

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...