Jump to content

Non-array?


Frit
 Share

Recommended Posts

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
Link to comment
Share on other sites

  • Moderators

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

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

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
Link to comment
Share on other sites

  • Moderators

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

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

  • Moderators

=/

Still don't working...

Thanks anyway...

Not working? So your still getting the error ?

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

  • Moderators

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

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

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