Jump to content

Control question


Bert
 Share

Recommended Posts

I have a window that has a control on it. I know the ID of it. I need to be able to tell when the mouse clicks on it. How do I do that?

I tried to use the Window info tool to see if anything is different when the contropl is clicked, and I can't see anything to tell the difference with. Can I do this with a mouse click detection of some type? Lost here, need some direction.

:o

Link to comment
Share on other sites

Ok, I can see what you are getting at, but I see I will have another problem. The program has tabs, and there are 2 different buttons in the same location. They have different IDs, but that is the only difference. How can I tell then the control was clicked? :o

Link to comment
Share on other sites

  • Moderators

Have you looked at the ControlCommand() options?

Edit:

Example:

$MyWindow = 'Window Title'
$TextIfAny = 'Readable text from control'
If ControlCommand($MyWindow, $TextIfAny, 'ClassNameNN', 'IsChecked', '') Then;Do Something

Edit2:

This may work also:

Opt('MouseCoordMode', 2)
Dim $CPos = ControlGetPos('window title', 'text of control if any', 'classnamenn')
While 1
    Local $Mpos = MouseGetPos()
    If $Mpos[0] >= $CPos[0] And $Mpos[0] <= $CPos[2] + $CPos[0] And $Mpos[1] >= $CPos[1] And $Mpos[1] <= $CPos[3] + $CPos[1] _ 
        And _IsPressed('01') And ControlCommand('window title', 'text if any', 'classnamenn', 'IsVisible', '') Then
    ;do something
    EndIf
WEnd

Func _IsPressed($s_hexKey, $v_dll = 'user32.dll')
    Local $a_R = DllCall($v_dll, "int", "GetAsyncKeyState", "int", '0x' & $s_hexKey)
    If Not @error And BitAND($a_R[0], 0x8000) = 0x8000 Then Return 1
    Return 0
EndFunc

Edit again, been a while since I played with something like this, so I haven't tested the above.

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

This might work. I was thinking while driving home about the problem, and I came up with a solution, but not sure on how to do it. When the button I want to keep a eye on is clicked, it makes a file in the same folder. I thought of having a range of where _ispressed is to be able to look, and if that happens, it would look for the file. If the file is found, then I know the button got pressed.

@Smoke: I like your solution much better, so I'm going to try it first. I still need to do something with the file afterwords, and I'm going to need to use Randell's excel script to look at it. The files are CSV files, but I suspect Randel's script can do it just fine simply by renaming the file first. I will post the code when I'm done.

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