Jump to content

ControlClick will not click button


Go to solution Solved by wzc0014,

Recommended Posts

Posted

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.

Posted (edited)

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
Posted

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.

Posted

I will assume it is not a standard window then. Thanks for the suggestion. I am new to this if you can't notice so I tried doing things the simplest way

  • Solution
Posted

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.

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
  • Recently Browsing   0 members

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