Jump to content

Recommended Posts

Posted

I was given this example script to determine when a button is clicked. I can't get this code to work right.

;upper left     X: 187  Y: 557
;Lower right:         X: 298    Y: 588
#Include <Misc.au3>
$dll = DllOpen("user32.dll")
Global $CPos
While 1
    Local $Mpos = MouseGetPos()
    If $Mpos[0] >= $CPos[0] And $Mpos[0] <= $CPos[187] + $CPos[557] And $Mpos[1] >= $CPos[1] And $Mpos[1] <= $CPos[298] + $CPos[588] _ 
        And _IsPressed('01', $dll)   And ControlCommand('ARGIS made EASY - Ver: 1.115', '', 'ThunderRT6CommandButton3', 'IsVisible', '') Then
    MsgBox(0, "", "it worked");do something
    EndIf
WEnd

The error I get is: Subscript used with non-Array variable.

Thoughts?

Posted

ummm.... where are you declaring $CPos as an array? all i see is

Global $CPos...

AutoIt Console written in C#. Write au3 code right at the console :D_FileWriteToLineWrite to a specific line in a file.My UDF Libraries: MySQL UDF Library version 1.6 MySQL Database UDF's for AutoItI have stopped updating the MySQL thread above, all future updates will be on my SVN. The svn location is:kan2.sytes.net/publicsvn/mysqlnote: This will still be available, but due to my new job, and school hours, am no longer developing this udf.My business: www.hirethebrain.com Hire The Brain HireTheBrain.com Computer Consulting, Design, Assembly and RepairOh no! I've commited Scriptocide!
  • Moderators
Posted (edited)

When I gave you the example... $CPos = ControlGetPos() (you forgot that), and need to take out the other [557] etc... the '['0, or 1, or 2, or 3']' is all that is allowed there.

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.

Posted (edited)

I was trying to find the post where you explained it, and I couldn't find it. Thats why I am confused. :o

edit: ok, found it, and I changed the code to this.

CODE
#Include <Misc.au3>

$CPos = ControlGetPos('ARGIS made EASY - Ver: 1.115', '',29)

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 _IsPressed2('01') And ControlCommand('ARGIS made EASY - Ver: 1.115', 'Submit to Argis', 'ThunderRT6CommandButton3', 'IsVisible', '') Then

MsgBox(0, "", "it worked") ;do something

EndIf

WEnd

Func _IsPressed2($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

It still isn't seeing when I click the button. I needed to change the name of the function for it is a duplicate name with a existing function. Here is the information from the window viewer:

>>>>>>>>>>>> Window Details <<<<<<<<<<<<<

Title: ARGIS made EASY - Ver: 1.115

Class: ThunderRT6FormDC

Size: X: 0 Y: 0 W: 498 H: 643

>>>>>>>>>>> Mouse Details <<<<<<<<<<<

Screen: X: 289 Y: 568

Cursor ID: 2

>>>>>>>>>>> Pixel Color Under Mouse <<<<<<<<<<<

RGB: Hex: 0xFFC0C0 Dec: 16761024

>>>>>>>>>>> Control Under Mouse <<<<<<<<<<<

Size: X: 184 Y: 528 W: 113 H: 33

Control ID: 29

ClassNameNN: ThunderRT6CommandButton3

Text: Submit to Argis

Style: 0x5401000B

ExStyle: 0x00000004

>>>>>>>>>>> Status Bar Text <<<<<<<<<<<

>>>>>>>>>>> Visible Window Text <<<<<<<<<<<

Select a value

Select a value

Select a value

Select a value

Select a value

Select a value

Select a value

Select a value

Active

Active

Select a value

Select a value

Infrastructure

user

02/18/2006

Add to update

user

user

02/18/2006

Add to Update

Submit to Argis

user

user

02/18/2006

Add to Update

Add to Update

02/18/2006

About this application

Edited by vollyman
  • Moderators
Posted

I was trying to find the post where you explained it, and I couldn't find it. Thats why I am confused. :o

edit: ok, found it, and I changed the code to this.

CODE
#Include <Misc.au3>

$CPos = ControlGetPos('ARGIS made EASY - Ver: 1.115', '',29)

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 _IsPressed2('01') And ControlCommand('ARGIS made EASY - Ver: 1.115', 'Submit to Argis', 'ThunderRT6CommandButton3', 'IsVisible', '') Then

MsgBox(0, "", "it worked") ;do something

EndIf

WEnd

Func _IsPressed2($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

It still isn't seeing when I click the button. I needed to change the name of the function for it is a duplicate name with a existing function. Here is the information from the window viewer:
1. You could have removed my _IsPressed() function if you were going to use the Misc.au3 file I added that function so people didn't have to use the #include <>.

2. I don't understand what the issue is, what's doing or not doing for that matter, care to elaborate?

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.

Posted (edited)

its really hard to tell so.. to test it

If $Mpos[0] >= $CPos[0] then

msgbox()

if $Mpos[0] <= $CPos[2] + $CPos[0] then

msgbox()

put each test in a line and have a messagebox let you know just how far into the testing you have gotten

8)

Edited by Valuater

NEWHeader1.png

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
×
×
  • Create New...