Sign in to follow this  
Followers 0
Frit

Non-array?

12 posts in this topic

#1 ·  Posted (edited)

Well, i made a script (under help of Smoke in another topic).

It made 2 arrays from a variable ( x and y of the mousepos)

$pos[0] and $pos[1].

I'm going to make the mouse do a drag using these coordinates:

While 1
    If GUICtrlRead($rdy) = 1 Then
        MouseClickDrag ( "left", $pos[0], $pos[1], $pos2[0], $pos2[1])
    EndIf
WEnd

$rdy is a check box.

$pos2 is another mousepos i made.

I think it's correct, but it shows an error "$pos isn't an array-variable".

If there's anything wrong, correct it.

Thanks

Edited by Frit

Share this post


Link to post
Share on other sites



Nothing on mind?

Share this post


Link to post
Share on other sites

I would suggest posting everything Frit... That doesn't say one thing that is the issue... even if you say you are using the example I made... you now have 2 $pos values. I'm not sure if anyone can give anything other than an educated guess.

1. Maybe you haven't called the function yet before you are trying to read MouseClickDrag().


[center]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.[/center]

Share this post


Link to post
Share on other sites

Nothing on mind?

It is hard to tell without seeing the rest of the script.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Almost the full code (i cutted a part that doesn't affect the rest):

Global $pos1, $pos2
HotKeySet( "{ESC}", "Sair" )
HotKeySet( "{F1}", "GetPos1" )
HotKeySet( "{F2}", "GetPos2" )

GUICreate("UDB by Frit", 250, 130)
GuiSetstate()

Global $pos1label = GUICtrlCreateLabel('(x,y)', 190, 10, 80, 30)
GUICtrlSetColor ( $pos1label, 11141120)
GUICtrlCreateLabel('Pos1', 10, 10)
Func GetPos1()
    Local $pos1 = MouseGetPos()
    GUICtrlSetData( $pos1label, $pos1[0] & ',' & $pos1[1])
EndFunc

Global $pos2label = GUICtrlCreateLabel('(x,y)', 190, 30, 80, 30)
GUICtrlSetColor ( $pos2label, 11141120)
GUICtrlCreateLabel('Pos2', 10, 30)
Func GetPos2()
    Local $pos2 = MouseGetPos()
    GUICtrlSetData( $pos2label, $pos2[0] & ',' & $pos2[1])
EndFunc

Global $combo, $rdy, $time
$combo = GUICtrlCreateCombo ("item1", 10, 60, 100, 20)
GUICtrlSetData(-1, "item2|item3|item4|item5", "item1")
$rdy = GUICtrlCreateCheckbox ("Ativar", 10, 90)

;
While 1
    If GUICtrlRead($rdy) = 1 Then
        MouseClickDrag ( "left", $pos1[0], $pos1[1], $pos2[0], $pos2[1])
    EndIf
WEnd

;<another part that doesn't affect the rest> (to make the code smaller)

While 1
GuiSetstate()
Wend

While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case Else
;;;
    EndSelect
WEnd

Func Sair();func sair
    Exit
EndFunc
Edited by Frit

Share this post


Link to post
Share on other sites

Well the cloak and dagger doesn't really affect this... 2 things, you've got $pos as a Global and a Local... remove the local, no need for it (within the function that is... and your not calling the function properly, this will avoid it throwing an error until you hit your hotkeys()

While 1
    If GUICtrlRead($rdy) = 1 And IsArray($pos) And IsArray($pos2) Then
        MouseClickDrag ( "left", $pos1[0], $pos1[1], $pos2[0], $pos2[1])
       ;A suggestion is to clear the array when your done with the drag
       ;Or else it will click and drag over and over
        $pos = ''
        $pos2 = ''
    EndIf
WEnd

[center]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.[/center]

Share this post


Link to post
Share on other sites

=/

Still don't working...

Thanks anyway...

Share this post


Link to post
Share on other sites

=/

Still don't working...

Thanks anyway...

Not working? So your still getting the error ?

[center]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.[/center]

Share this post


Link to post
Share on other sites

Yeah.

But now, the error is because i took off the "local" as you said.

The script seems to be all ok, I really don't have any idea of what is going on.

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

If you have Global $pos, $pos2 that wouldn't cause an error if your functions looked like:

Func GetPos1()
    $pos1 = MouseGetPos()
    GUICtrlSetData( $pos1label, $pos1[0] & ',' & $pos1[1])
EndFunc

P.S. See why pseudo code doesn't work so good.

Edit:

LMFAO... You have $pos1 not $pos... I just noticed that. Change Global $pos, $pos2 to $pos1, $pos2.

Edit2:

BTW... that LMFAO was at myself not you... just incase you thought that... Silly of me not to notice that is what I meant.

Edited by SmOke_N

[center]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.[/center]

Share this post


Link to post
Share on other sites

It would also help to put all your global vars at the top of the script so you can keep track of them.

Share this post


Link to post
Share on other sites

@smoke

xD Great, all done now. Thanks

@machine

ok, i'll do that next time.

Share this post


Link to post
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
Sign in to follow this  
Followers 0