HuaAi Posted July 18, 2015 Posted July 18, 2015 (edited) I am trying to use AutoIt to locate a checkbox in a form from a webpage. This page is basically the result of a search operation from a list of users. In normal cases the search should either return one matching result or none. But it could return multiple users. I want to check a check box associate with one user only (I know the username).The checkbox:<th class="check-column" scope="row"> <label class="screen-reader-text" for="user_62">Select testuser1</label> <input name="users[]" class="subscriber" id="user_62" type="checkbox" value="62"> </th>As you can see most of the fields are quite generic, I can't really use "name" or "id" to do this, but the label "Select testuser1" can be used for my script to identify this user (testuser1). I tried to find a function in IE.au3 to get the this checkbox but couldn't seem to find it, is there an obvious way to accomplish this? Apparently I could just use coordicates to move the mouse and check this checkbox, but it's less elegant in many ways.Thank you for your help! I am attaching the html for the form down below as well in case I missed something important for this puzzle: <form method="get"> <table class="wp-list-table widefat fixed striped users"> <tbody id="the-list" data-wp-lists="list:user"> <tr id="user-62"> <th class="check-column" scope="row"><label class="screen-reader-text" for="user_62">Select testuser1</label> <input name="users[]" class="subscriber" id="user_62" type="checkbox" value="62"> </th> <td class="username column-username"> <img width="32" height="32" class="avatar avatar-32 photo" alt="" src="http://2.xxxxx.com/avatar/2239cdc9d7fa98b276c2589dbe90d0eb?s=32&d=mm&r=g" srcset="http://2.xxxxx.com/avatar/2239cdc9d7fa98b276c2589dbe90d0eb?s=64&d=mm&r=g 2x"> <strong> <a href="http://xxxxx.com/wp-admin/user-edit.php?user_id=62&wp_http_referer=%2Fwp-admin%2Fusers.php%3Fs%3Dtestuser1%26action%3D-1%26new_role%26paged%3D1%26action2%3D-1">testuser1 </a> </strong> <br> <div class="row-actions"> <span class="edit"><a href="http://xxxxx.com/wp-admin/user-edit.php?user_id=62&wp_http_referer=%2Fwp-admin%2Fusers.php%3Fs%3Dtestuser1%26action%3D-1%26new_role%26paged%3D1%26action2%3D-1">Edit</a> | </span> <span class="delete"><a class="submitdelete" href="users.php?action=delete&user=62&_wpnonce=c3d7ef021d">Delete</a></span> </div> </td> <td class="name column-name">testuser1 tu</td> <td class="email column-email"><a title="E-mail: xxxxx@xxxxx.xxxxx" href="mailto:xxxxx@xxxxx.xxxxx">xxxxx@xxxxx.xxxxx</a></td> <td class="role column-role">Subscriber</td> <td class="posts column-posts num">0</td> <td class="xxxxx column-xxxxx">xxxxx</td> <td class="xxxxx column-xxxxx">Jul 10, 2015<br>6:31 AM</td> </tr> </tbody> <tfoot> </table> </form> Edited July 18, 2015 by HuaAi
jaberwacky Posted July 19, 2015 Posted July 19, 2015 Is _IEAction what you're looking for? HuaAi 1 Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum?
jguinch Posted July 20, 2015 Posted July 20, 2015 Try this code :#Include <IE.au3> $sUser = "testuser1" $oIE = _IEcreate("http://the-url") ; replace it by your url $content = _IEDocReadHTML($oIE) $id = StringRegExp($content, 'for="([^"]+)">Select ' & $sUser & '', 1)[0] $oCheckbox = _IEGetObjById($oIE, $id) $oCheckbox.checked = True HuaAi 1 Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF
HuaAi Posted July 20, 2015 Author Posted July 20, 2015 Thank you @jguinch, this is exactly what I was looking for!
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