ofLight Posted October 24, 2006 Share Posted October 24, 2006 I am trying to creat a Windows autoupdater that will open windows Update and begin installation, However i am Having a bit of a ruff start due to Windows not acting the same every time. After "Microsoft Windows Update" is started I get one of 3 windows depending on the system that was used for the install. What I need is the best Function for Looping in Autoit, using the While Command has been suggested but Aperantly I am not understanding how the Basic Syntax should look any Suggestions whould be apreciated_WindowsUpdate('Windows update')Func _WindowsUpdate($wup) Run('"c:\program files\Internet explorer\IEXPLORE.EXE" http://update.microsoft.com', "", @SW_MAXIMIZE) ;see if 'Microsoft Windows Update' exsists ;if yes then try to make it the active window, if Unseccesfull ; scan for any of 3 windows and excecute command to close for ; particular window. ;Then try to make 'Microsoft Windows Update' active window again There is always a butthead in the crowd, no matter how hard one tries to keep them out.......Volly Link to comment Share on other sites More sharing options...
creeping Posted October 24, 2006 Share Posted October 24, 2006 I suggest you search google for general programming techniques like program control Link to comment Share on other sites More sharing options...
ofLight Posted October 25, 2006 Author Share Posted October 25, 2006 ok thisis what i have so far. Can anyone tell me why the function _Find01() is not executing??? im Stumped. expandcollapse popupOpt("WinTitleMatchMode", 3) ;1=start, 2=subStr, 3=exact, 4=advanced Global $pixel01 = Int(IniRead(".\PixelSearch01.ini","record01","PixelColor","-1")) Global $chksum01 = Int(IniRead(".\PixelSearch01.ini","record01","PixelCheckSum","-1")) Global $pixel02 = Int(IniRead(".\PixelSearch01.ini","record02","PixelColor","-1")) Global $chksum02 = Int(IniRead(".\PixelSearch01.ini","record02","PixelCheckSum","-1")) Global Const $SM_VIRTUALWIDTH = 78 Global Const $SM_VIRTUALHEIGHT = 79 ;Global $pos[0] = 0, $pos[1] = 0 $VIRTUALDESKTOPWIDTH = DLLCall("user32.dll","int","GetSystemMetrics","int",$SM_VIRTUALWIDTH) $VIRTUALDESKTOPWIDTH = $VIRTUALDESKTOPWIDTH[0] $VIRTUALDESKTOPHEIGHT = DLLCall("user32.dll","int","GetSystemMetrics","int",$SM_VIRTUALHEIGHT) $VIRTUALDESKTOPHEIGHT = $VIRTUALDESKTOPHEIGHT[0] $var01 = EnvGet('PATH') $var02 = Winactive('Microsoft Windows Update') $var03 = WinActive('Security Warning') ;--------------------------------------------------------------------- Run('"c:\program files\Internet explorer\IEXPLORE.EXE" http://update.microsoft.com', "", @SW_MAXIMIZE) WinWait('Microsoft Windows Update') Sleep(5000) _WindowsUpdate() Func _WindowsUpdate() WinActivate('Microsoft Windows Update') If $var02 = 1 then _Find01() ElseIf $var02 = 0 then _Bend() Else EndIF EndFunc Func _Bend() Sleep(1000) If WinActive('Security Warning') Then Send('!y') ElseIf WinActive('Internet Explorer - Security Warning') Then Send('!i') ElseIf WinActive('Internet Explorer') Then Send('{ENTER}') Else _WindowsUpdate() EndIf EndFunc Func _find01();install now Button If $pixel01 = -1 Or $chksum01 = -1 Then MsgBox(4096,"Error","Could not read INI") Exit EndIf $x = 0 $y = 0 $ypixel = $VIRTUALDESKTOPHEIGHT - 1 While 1 $xy = PixelSearch($x,$y,$VIRTUALDESKTOPWIDTH - 1,$ypixel,$pixel01) If @error And $ypixel = ($VIRTUALDESKTOPHEIGHT - 1)Then _Bend ;Error Could not find area. ; Exit ElseIf @error Then $y = $ypixel + 1 $ypixel = ($VIRTUALDESKTOPHEIGHT - 1) $x = 0 ElseIf $chksum01 = PixelCheckSum($xy[0]-8,$xy[1]-8,$xy[0]+8,$xy[1]+8) Then MouseMove($xy[0],$xy[1]) ;ToolTip("There it is.") Sleep(3000) $pos = MouseGetPos() ;MsgBox(4096, "Mouse x,y:", $pos[0] & "," & $pos[1]) ;MouseMove( $pos[0]+30, $pos[1]+30, 0) ;Sleep(500) MouseDown("left") Sleep(100) MouseUp("left") _Find02 ;Exit Else $y = $xy[1] $ypixel = $y $x = $xy[0] + 1 EndIf WEnd EndFunc Func find02();Custom Button If $pixel01 = -1 Or $chksum01 = -1 Then MsgBox(4096,"Error","Could not read INI") Exit EndIf $x = 0 $y = 0 $ypixel = $VIRTUALDESKTOPHEIGHT - 1 While 1 $xy = PixelSearch($x,$y,$VIRTUALDESKTOPWIDTH - 1,$ypixel,$pixel02) If @error And $ypixel = ($VIRTUALDESKTOPHEIGHT - 1)Then ; if cant find Custom button, then may haveto scroll down and try again Exit ElseIf @error Then $y = $ypixel + 1 $ypixel = ($VIRTUALDESKTOPHEIGHT - 1) $x = 0 ElseIf $chksum02 = PixelCheckSum($xy[0]-8,$xy[1]-8,$xy[0]+8,$xy[1]+8) Then MouseMove($xy[0],$xy[1]) ;ToolTip("There it is.") Sleep(3000) $pos = MouseGetPos() ;MsgBox(4096, "Mouse x,y:", $pos[0] & "," & $pos[1]) MouseMove( $pos[0]+30, $pos[1]+30, 0) Sleep(500) MouseDown("left") Sleep(100) MouseUp("left") ;Exit Else $y = $xy[1] $ypixel = $y $x = $xy[0] + 1 EndIf WEnd EndFunc There is always a butthead in the crowd, no matter how hard one tries to keep them out.......Volly Link to comment Share on other sites More sharing options...
lod3n Posted November 2, 2006 Share Posted November 2, 2006 I posted something that does this:http://www.autoitscript.com/forum/index.php?showtopic=35158 [font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font] Link to comment Share on other sites More sharing options...
Confuzzled Posted November 7, 2006 Share Posted November 7, 2006 Have you tried AutoPatcher? 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