JayFran 0 Posted September 13, 2010 Basically, depending on which account i login in to, there are different id's (I know, its stupid) anyhow I came up with something like this, I just can't get it to work, I think I might be close tho. Please give me an assist. For $i = 1 To 3 $c_status0 = "mx5677[R:0]" & StringFormat("",$i) $c_status1 = "mx5671[R:0]" & StringFormat("",$i) $c_status2 = "mx5671[R:0]_image" & StringFormat("",$i) Next Sleep(250) Sleep(1000) $try2 = _IEGetObjById($oIE, $i) _IEAction($try2, "click") $hwnd = _IEPropertyGet($oIE, "hwnd") ControlSend($hwnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{Enter}") Share this post Link to post Share on other sites
JohnOne 1,603 Posted September 13, 2010 For $i = 1 To 3 $c_status0 = "mx5677[R:0]" & StringFormat("",$i) $c_status1 = "mx5671[R:0]" & StringFormat("",$i);<<<<<<This for next loop makes no sense $c_status2 = "mx5671[R:0]_image" & StringFormat("",$i) Next Sleep(250) Sleep(1000) $try2 = _IEGetObjById($oIE, $i) ;<<<<<<<<< $i here has no meaning its only valid in the loop _IEAction($try2, "click") $hwnd = _IEPropertyGet($oIE, "hwnd") ControlSend($hwnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{Enter}") You need to explain what you are trying to do. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Share this post Link to post Share on other sites
JayFran 0 Posted September 13, 2010 You need to explain what you are trying to do.Maybe the title is a little misleading. I'm asking how do take 3 variables and have 1 variable that fits one of the three and then sends a click command to that element based on the id returned? Share this post Link to post Share on other sites
JohnOne 1,603 Posted September 13, 2010 Try this For $i = 1 To 3 $try2 = _IEGetObjById($oIE, $i) If IsObj($try2) Then _IEAction($try2, "click") EndIf Next $hwnd = _IEPropertyGet($oIE, "hwnd") ControlSend($hwnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{Enter}") AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Share this post Link to post Share on other sites
JayFran 0 Posted September 13, 2010 Try this For $i = 1 To 3 $try2 = _IEGetObjById($oIE, $i) If IsObj($try2) Then _IEAction($try2, "click") EndIf Next $hwnd = _IEPropertyGet($oIE, "hwnd") ControlSend($hwnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{Enter}") The $c_status are each of the different id's that is shown depending on which username i login into with. I only added the the StringFormat think that each $c_status variable will be marked as $i. Then from there IE would click on which ever one returned for $i. So I added your portion back into the loop and I get a status no match for 1,2 & 3 For $i = 1 To 3 $c_status0 = "mx5677[R:0]" & StringFormat("",$i) $c_status1 = "mx5671[R:0]" & StringFormat("",$i) $c_status2 = "mx5671[R:0]_image" & StringFormat("",$i) $try2 = _IEGetObjById($oIE, $i) If IsObj($try2) Then _IEAction($try2, "click") EndIf Next $hwnd = _IEPropertyGet($oIE, "hwnd") ControlSend($hwnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{Enter}") Share this post Link to post Share on other sites
JayFran 0 Posted September 13, 2010 So I discover that $i is returning with a value of 1 2 and 3. not the assigned ids. i know i cant write it like this: WinActivate("Activities and Tasks - Windows Internet Explorer") WinWaitActive("Activities and Tasks - Windows Internet Explorer") For $i = 1 To 4 $i = "mx5677[R:0]" ;& StringFormat("",$i) $i = "mx5671[R:0]" ;& StringFormat("",$i) $i = "mx5671[R:0]_image" ;& StringFormat("",$i) $i = "mx5677[R:0]_image" ;& StringFormat("",$i) ;MsgBox(0, "", $i) $try2 = _IEGetObjById($oIE, $i) If IsObj($try2) Then _IEAction($try2, "focus") $hwnd = _IEPropertyGet($oIE, "hwnd") ControlSend($hwnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{Enter}") If @error Then ConsoleWrite("There was an error " & $i & @CRLF) ;EndIf Next But essentially it would return like that picking which id fit for the logged in user. hopes this helps a little with the logic Share this post Link to post Share on other sites
JohnOne 1,603 Posted September 14, 2010 (edited) OK, I think I get you now.Its an array you need to store your strings in and loop through.Local $aID[4] = ["mx5677[R:0]", "mx5671[R:0]", "mx5671[R:0]_image", "mx5677[R:0]_image"] For $i = 0 To UBound($aID) -1 $try2 = _IEGetObjById($oIE, $aID[$i]) If IsObj($try2) Then _IEAction($try2, "focus") $hwnd = _IEPropertyGet($oIE, "hwnd"); rethink this, that function does not return a window or control handle ControlSend($hwnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{Enter}") If @error Then ConsoleWrite("There was an error " & $i & @CRLF) ;EndIf Next Edited September 14, 2010 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Share this post Link to post Share on other sites
JayFran 0 Posted September 14, 2010 OK, I think I get you now. Its an array you need to store your strings in and loop through. Local $aID[4] = ["mx5677[R:0]", "mx5671[R:0]", "mx5671[R:0]_image", "mx5677[R:0]_image"] For $i = 0 To UBound($aID) -1 $try2 = _IEGetObjById($oIE, $aID[$i]) If IsObj($try2) Then _IEAction($try2, "focus") $hwnd = _IEPropertyGet($oIE, "hwnd"); rethink this, that function does not return a window or control handle ControlSend($hwnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{Enter}") If @error Then ConsoleWrite("There was an error " & $i & @CRLF) ;EndIf Next NICE!!!! Thats work perfect. Thanks! On last thing, it works perfect in source mode but when I compile it, on my second user account it acts as if it wants to open it and then nothing happens. I had this problem before, its like the script is stalling or something. Do you have any suggestions for a fix? Share this post Link to post Share on other sites
JayFran 0 Posted September 14, 2010 Please omit the last comment. I got it to work. Thanks again! Share this post Link to post Share on other sites