pchakraborty Posted December 24, 2010 Posted December 24, 2010 (edited) Hi I am new to AutoIt. I am trying to get the coordinates of a button in a page. I am not able to do so. I tried by hard coding the mouse cordinates displayed in the AutoIt Window Info tool and it works. By the same coordinates don't work in some other machine. Please suggest some way to find the coordinates of the button dynamically, irrespective of machine I am executing my script, so that I could go to that coordinate and mouse click on that button. Please help. I am currently trying this code as below WinActivate("Online Community - Windows Internet Explorer"); ControlClick("Online Community - Windows Internet Explorer", "", "Browse...", "left", 1); WinWait("Choose File to Upload"); WinActivate("Choose File to Upload"); ControlSetText("Choose File to Upload", "", "[CLASS:Edit; INSTANCE:1]", "D:\Image1.jpg"); ControlClick("Choose File to Upload", "", "[CLASS:Button; INSTANCE:2]"); Thanks Parikshit Edited December 24, 2010 by pchakraborty
Moderators Melba23 Posted December 24, 2010 Moderators Posted December 24, 2010 pchakraborty,Welcome to the AutoIt forum. ControlGetPos should get you the position of the button, but as you already have sufficient ID information to try and use ControlClick I am somewhat at a loss to see why you need it. Furthermore, if the ID information is not good enough to let you use ControlClick, then I would be very surprised if it was sufficient to get the position either! 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
pchakraborty Posted December 25, 2010 Author Posted December 25, 2010 (edited) HiThanks for the reply. But let me explain you clearly what I am facing.I have one webpage and there is a Browse button in that page to select and upload file. Initially i tried with ControlClick as belowControlClick("Online Community Windows Internet Explorer", "", "&fileData", "left", 1)But the script is not able to proceed further. Rather, it is getting stuck in that statement and not working for me. Then I tried with MouseClick, but for that I had to provide both X&Y coordinates. I got those coordinates through Info tool and it was working fine for the moment. Next moment the coordinates got changed and my script failed.For getting the coordinates of the Browse button dynamically, I tried ControlGetPos also, but its giving me the coordinates of the page i am in, rather than the coordinates of the button. The info tool always gives me the ControlID for the Browse button as 0.I am currently trying the code as below:dim $pos;WinActivate("Online Community Windows Internet Explorer");$pos = ControlGetPos("Online Community Windows Internet Explorer", "", "&fileData");MouseClick("left", $pos[0], $pos[1], 2)WinWait("Choose File to Upload");WinActivate("Choose File to Upload");Sleep(1000);ControlSetText("Choose File to Upload", "", "[CLASS:Edit; INSTANCE:1]", "D:\Pic1.jpg");Sleep(1000);ControlClick("Choose File to Upload", "", "[CLASS:Button; INSTANCE:2]");Sleep(1000);fileData is the name of the button.But unfortunately, that is also not working. Really no idea how to proceed and what else to try. Please helpThankspchakraborty Edited December 25, 2010 by pchakraborty
Moderators Melba23 Posted December 26, 2010 Moderators Posted December 26, 2010 pchakraborty,Apologies, I did not notice you were trying to interact with a web page - although the clue was there: "Online Community Windows Internet Explorer".Look at the IE management UDF in the Help file - there are lots of functions there to help you interact with web pages (if you use IE of course). They act directly on the page, so you will not have the coordinate problem on differenet machines when you use them. 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
pchakraborty Posted December 26, 2010 Author Posted December 26, 2010 Hi Thanks for your reply. But I need my script to work in different browsers like firefox,chrome, safari etc and not only in IE. Could you please suggest how should I proceed and solve this problem? Thanks pchakraborty
Santhoshi_ch Posted February 8, 2024 Posted February 8, 2024 Hi @pchakraborty Did you get any solution for this? Because I am having the same issue now.
Musashi Posted February 8, 2024 Posted February 8, 2024 26 minutes ago, Santhoshi_ch said: Hi @pchakraborty Did you get any solution for this? Because I am having the same issue now. Since the user @pchakraborty has not been active in the forum for 13 years, you will probably not receive an answer from him. Therefore, it would be better to start a new thread. Regarding your question: The following links should help you : https://www.autoitscript.com/wiki/WebDriver#FAQ "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."
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