Sign in to follow this  
Followers 0
MasonMill

Array help

8 posts in this topic

Hi Guys,

I have a message box that a red tab pops up if i get a message from someone and the script is supposed to click on that red tab( tab could pop up anywhere) and type a message saying im not here. Im getting an error so somethings not right in me script. Any ideas why?

the error reads

Mouseclick("Left", $newtab[0], $newtab[1],1,0)

Mouseclick("Left", $newtab^ERROR

Error: Subscript used with non-Array variable.

here is my script.

While 1

sleep(2000)

NewMessage()

WEnd

Func NewMessage()

$newtab = PixelSearch(12, 608, 511, 630, 0x842523) ; Looks for color

If $newtab = 1 Then ;If it exists then

send("{ESCAPE}");toggles correct mode to use cursor

sleep(1000)

MouseClick("Left", $newtab[0], $newtab[1], 1, 0) ;Clicks the first instance of that color

sleep(500)

send("{ENTER}");opens text field

send("I am not here right now, please leave a message")

sleep(2000)

send("{ENTER}");sends message

exit

EndIf

EndFunc

Share this post


Link to post
Share on other sites



While 1
sleep(2000)
NewMessage()
WEnd

Func NewMessage()
$newtab = PixelSearch(12, 608, 511, 630, 0x842523) ; Looks for color
If Not @error Then ;If it exists then
send("{ESCAPE}");toggles correct mode to use cursor
sleep(1000)
MouseClick("Left", $newtab[0], $newtab[1], 1, 0) ;Clicks the first instance of that color
sleep(500)
send("{ENTER}");opens text field
send("I am not here right now, please leave a message")
sleep(2000)
send("{ENTER}");sends message
exit
EndIf
EndFunc

try this

Share this post


Link to post
Share on other sites

MasonMill,

Your line to check if PixelSearch has found the colour is wrong.

If it is successful then you have an array - if it fails you have a return value of 1.

Perhaps if you tried something like this:

Func NewMessage()
    $newtab = PixelSearch(12, 608, 511, 630, 0x842523) ; Looks for color
    If @error = 1 Then ;If it does not exist then
        ; do whatever you do if it fails
    Else ; It does exist
        Send("{ESCAPE}");toggles correct mode to use cursor
        ; etc

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Thanks for the help guys, SEuBo i tried what you suggested but it doesnt respond that. I tried that erlier too. Melba if i dont want anything to happen if the is no tab and just want a response if the red appears how do i code that line?

Here is how i had it earlier but it didnt work either.

While 1

sleep(2000)

NewMessage()

WEnd

Func NewMessage()

$newtab = PixelSearch(12, 608, 511, 630, 0x842523) ; Looks for color

If IsArray($newtab) = 1 Then ;If it exists then

send("{ESCAPE}");toggles correct mode to use cursor

sleep(1000)

MouseClick("Left", $newtab[0], $newtab[1], 1, 0) ;Clicks the first instance of that color

sleep(500)

send("{ENTER}");opens text field

send("I am not here right now, please leave a message")

sleep(2000)

send("{ENTER}");sends message

exit

EndIf

EndFunc

Share this post


Link to post
Share on other sites

MasonMill,

Are you saying that the If IsArray($newtab) = 1 Then version did not work? Because it looks fine to me - you will just return from the function if PixelSearch finds nothing.

You could also write it as If @error <> 1 Then - or If Not @error Then - it comes to the same thing. ;)

M23

P.S. When you post code, please use Code tags. Put [autoit ] before and [/autoit ] after your posted code (but omit the trailing space - it is only there so the tags display here).


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Yeah, the IsArray version doesnt work. I tohught it looked perfect! Any suggestions why it doesnt work? I know the pixelsearch and color are right becasue it starts the script with the version of the original post, I dont know why this one doesnt work. Duely noted on the [autoit] and [autoit/]

Share this post


Link to post
Share on other sites

DUH, i got it! I needed to set the threshold a little higher on the pixel search. the message box is a bit transparent.... =/

Thanks for the sounding board guys!

Share this post


Link to post
Share on other sites

MasonMill,

Glad I could help! ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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