BrettF Posted August 22, 2008 Share Posted August 22, 2008 (edited) Personally, I would be way easier to use the _IE* functions.... EDIT: Missed some words... Edited August 22, 2008 by BrettF Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
DaBoSS Posted August 22, 2008 Author Share Posted August 22, 2008 whats it mean if i missed a seperator? here is code so far: Local $coords While 1 $coords = PixelSearch (0, 60, @DesktopWidth - 1024, @DesktopHeight - 639, Hexcolorhere, Shadevariationherecoulduse0XFFFFFF) ; that would search the whole screen for the pixel. If @Error Then Else MouseClick('left', $Coords[792], $Coords[581], 1, 0) EndIf what should i change? Link to comment Share on other sites More sharing options...
Writeous Posted August 22, 2008 Share Posted August 22, 2008 (edited) whats it mean if i missed a seperator? here is code so far: Local $coords While 1 $coords = PixelSearch (0, 60, @DesktopWidth - 1024, @DesktopHeight - 639, Hexcolorhere, Shadevariationherecoulduse0XFFFFFF) ; that would search the whole screen for the pixel. If @Error Then Else MouseClick('left', $Coords[792], $Coords[581], 1, 0) EndIf what should i change? CODELocal $coords While 1 $coords = PixelSearch (0, 0, @DesktopWidth - 1024, @DesktopHeight - 639, 0XFFFFFF, 0, 0) ; it will search whole screen for anything BLACK, then click it... If @Error Then Else MouseClick('left', $Coords[0], $Coords[1], 1, 0) ; do not change this EndIf Wend Or, if you have AIM. Just IM me: Bluetigerprd ... And yes, you could use _IE commands, which would be more efficient, but i'm a noob with those. You would need a more experienced Autoit user to help with that. Edited August 22, 2008 by Writeous [center][/center] Link to comment Share on other sites More sharing options...
BrettF Posted August 22, 2008 Share Posted August 22, 2008 Could you post the source of a page please? Just so I know what to look for with links etc. Cheers, Brett Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
maxlarue Posted August 22, 2008 Share Posted August 22, 2008 expandcollapse popup#include <IE.au3> HotKeySet("{ESC}", "terminate") $site = "www.google.com" ;you want to find an image, so its likely going to have certain info ;firebug is a firefox addon which lets you navigate the DOM (document object model) ;once you find a unique identifier for the button you want to press, do like this.. ;here are some example calls to the DOM ;this is what google's main search box looks like ;<input value="" title="Google Search" size="55" name="q" maxlength="2048"/> ;we'll write a generalized function to search for elements with unique attributes ;for instance, there are two attributes that look unique, name="q" and title="Google Search".. ;both of these are not likley to be found in a different input Func find_by_attr($ie, $tag, $attribute, $text) $temp_ie = _IEDocGetObj($ie) ;get all the DOM elements with tag input (for instance) ... those are the ones that look like <input value="".... $elements = $ie.document.getElementsByTagName($tag) ;parse the elements for the one your looking for, there might be more than one, look at IE.AU3 for some similar functions which allow you to specify an index For $element in $elements ;MsgBox(0, "", $element.getAttribute($tag)) $my_attribute = $element.getAttribute($attribute) If $my_attribute = $text Then ;this is an exact match, use StringInStr($my_attribute, $text) for substring matching return $element EndIf Next EndFunc ;an example call will look like this ; find_by_attr($ie, "img", "alt", "Submit") ;will find the first image element with alt="Submit" ; or for the example I gave with google, you could do it like this: ;find_by_attr($ie, "input", "name", "q") ;if your object has an ID, its really easy to access, as IDs MUST be unique. Names are not neccesarily unique though. An object can have an ID and a Name. ;$ie.document.getElementById("gbar");gets the gbar at the top of google.com ;now that you have the element, you need to click on it, this can be done by finding its position ; if the position is off the page, you'll need to write a function which detects it, and then scrolls down appropriately ; IE uses something like $ie.scrollTop and $ie.scrollLeft i believe, i'd need to double check, but i'm not going to if you don't need it ;so lets write a function to find the object on the screen, and another one to click it: func locate_center($object) $top = _IEPropertyGet($object, "screeny") $left = _IEPropertyGet($object, "screenx") $width = _IEPropertyGet($object, "width") $height =_IEPropertyGet($object, "height") ;xy coords of the CENTER of the object Dim $coords[2] = [ $left + $width / 2, $top + $height / 2] return $coords EndFunc ;now you can write a mouse function to move the mouse over the object and click it, ;this simulates exactly what a user would do func move($object, $click = 1) ;extra protection: if not IsObj($object) Then MsgBox(0, "", "failed to find object") terminate() EndIf $center = locate_center($object) MouseMove($center[0], $center[1]) if( $click = 1) Then MouseClick("left") EndIf EndFunc main() Func main() $ie = _IECreate($site) move(find_by_attr($ie, "input", "name", "q"), 1) Send("AutoIt Rocks") Send("{ENTER}") EndFunc func terminate() exit EndFunc hope this helps you'll need IE to do this, maybe version 7 i don't know, but you get the idea you can look at the IE.au3 files for more control if you don't want to get firebug, just click 'view source' on your browser, and find out what unique identifiers your button has. you don't need to search for it if it has an ID, or if its the only one if its kind, just do something like $ie.document.getElementById("Submit_Button") or if you know, for instnace that its the 4th input box in the 2nd form on the page what you can do is this: $ie.document.getEelementsByTagName("form").item(3).getElementsByTagName("input").item(2) notice, the arrays are 0-indexed this is probably more control than you need, but it may come in use for other ppl You'll have to write a loop with a 15 minute timer or whatever and call the find function each time while true sleep(900000);15min $testobj = find_by_attr($ie, "input", "name", "q") if isObj($testobj) then move($testobj);click on it, or do whatever else.... ;you can test if it moved to a different page by using $ie.locationURL or something ;for instnace if StringInStr($ie.locationURL, "www.google.com") then <do stuff> endif endif wend Link to comment Share on other sites More sharing options...
DaBoSS Posted August 22, 2008 Author Share Posted August 22, 2008 (edited) this is my current code Local $coords While 1 $coords = PixelSearch (0, 0, @DesktopWidth - 1024, @DesktopHeight - 768, Hexcolorhere, Shadevariationherecoulduse0X8FBEFF, 793, 663) ; that would search the whole screen for the pixel. If @Error Then Else MouseClick('left', $Coords[0], $Coords[1], 1, 0) EndIf still says im missing a seperator on line 4 Edited August 22, 2008 by DaBoSS 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