MasonMill Posted December 22, 2009 Share Posted December 22, 2009 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 Link to comment Share on other sites More sharing options...
SEuBo Posted December 22, 2009 Share Posted December 22, 2009 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 AutoIt Examples/UDF's:Generate Function at Runtime using IRunningObjectTable / AutoItObjectVery Simple Inter-Process Communication (using AutoItObject Pure AutoIt) Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 22, 2009 Moderators Share Posted December 22, 2009 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 ; etcM23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
MasonMill Posted December 22, 2009 Author Share Posted December 22, 2009 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 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 22, 2009 Moderators Share Posted December 22, 2009 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. M23P.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 Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
MasonMill Posted December 22, 2009 Author Share Posted December 22, 2009 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/] Link to comment Share on other sites More sharing options...
MasonMill Posted December 22, 2009 Author Share Posted December 22, 2009 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! Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 22, 2009 Moderators Share Posted December 22, 2009 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 Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now