flynch Posted October 12, 2007 Share Posted October 12, 2007 Erm. Say I write a AUTOIT app that opens paint, clicks the pencil tool, changes colour to blue and then draws some stuff using MouseClick. I'm guessing it wont work on another PC as they'll have a different resolution. How do I go about fixing this? While still using MouseClick. (Want to use because of the movement of the mouse ) Link to comment Share on other sites More sharing options...
Blue_Drache Posted October 12, 2007 Share Posted October 12, 2007 Set the resolution of the MS Paint window to 800x600 and use Opt("MouseCoordMode",0) Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache Link to comment Share on other sites More sharing options...
Tasmania Posted October 12, 2007 Share Posted October 12, 2007 Or, if you are just clicking... just use ControlClick() Link to comment Share on other sites More sharing options...
Blue_Drache Posted October 12, 2007 Share Posted October 12, 2007 It'd be much more efficient to use a MouseDown() event and then drag the cursor to and fro than it would be to click each individual point. *crosses eyes* Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache Link to comment Share on other sites More sharing options...
Tasmania Posted October 12, 2007 Share Posted October 12, 2007 It'd be much more efficient to use a MouseDown() event and then drag the cursor to and fro than it would be to click each individual point. *crosses eyes*This is true, however he was saying that originally he was using mouseclick He could be using the line tool! Link to comment Share on other sites More sharing options...
LarryDalooza Posted October 12, 2007 Share Posted October 12, 2007 Opt("MouseCoordMode",2) Opt("WinWaitDelay",50) Run("mspaint") WinWait("untitled - Paint") $hwnd = WinGetHandle("untitled - Paint") ClickRed($hwnd) Sleep(3000) WinMove($hwnd,"",200,200,500,400) ClickRed($hwnd) Sleep(3000) WinMove($hwnd,"",100,400,300,600) ClickRed($hwnd) Sleep(3000) WinSetState($hwnd,"",@SW_MAXIMIZE) ClickRed($hwnd) MsgBox(4096,"","Get It?" & @LF & @LF & "http://tech.groups.yahoo.com/group/AutoIt3/") Func ClickRed($hWin) If Not WinActive($hWin) Then WinActivate($hWin) WinWaitActive($hWin) Local $pos = WinGetClientSize($hWin) MouseClick("left",71,$pos[1] - 40) EndFunc AutoIt has helped make me wealthy Link to comment Share on other sites More sharing options...
Nahuel Posted October 12, 2007 Share Posted October 12, 2007 (edited) Damn, you had me entertained for a while: expandcollapse popup;Mouse coordenates relative to active window Opt("MouseCoordMode",2) ;Run Paint Run("mspaint") ;Wait for paint to be active (Using [CLASS:MSPaintApp] will make it work on any computer) WinWaitActive("[CLASS:MSPaintApp]") ;Maximize paint WinSetState("[CLASS:MSPaintApp]","",@SW_MAXIMIZE) ;Get position of brush button $ControlPos=ControlGetPos("[CLASS:MSPaintApp]","","[CLASSNN:ToolChild8]") ;Click on brush MouseClick("left",$ControlPos[0]+$ControlPos[2]/2,$ControlPos[1]+$ControlPos[3]/2) ;Move the mouse a bit onto the white zone (This might fuck in computers where the tools have been ;moved from original position. MouseMove($ControlPos[0]+($ControlPos[2]/2)+50,$ControlPos[1]+$ControlPos[3]/2) ;Draw "H" $CurPos=MouseGetPos() MouseClickDrag("left",$CurPos[0],$CurPos[1],$CurPos[0],$CurPos[1]+200,1) $CurPos=MouseGetPos() MouseClickDrag("left",$CurPos[0],$CurPos[1],$CurPos[0],$CurPos[1]-100,1) $CurPos=MouseGetPos() MouseClickDrag("left",$CurPos[0],$CurPos[1],$CurPos[0]+50,$CurPos[1],1) $CurPos=MouseGetPos() MouseClickDrag("left",$CurPos[0],$CurPos[1],$CurPos[0],$CurPos[1]-100,1) $CurPos=MouseGetPos() MouseClickDrag("left",$CurPos[0],$CurPos[1],$CurPos[0],$CurPos[1]+200,1) ;Draw "e" $CurPos=MouseGetPos() MouseMove($CurPos[0]+25,$CurPos[1]-35,5) $CurPos=MouseGetPos() MouseClickDrag("left",$CurPos[0],$CurPos[1],$CurPos[0]+35,$CurPos[1],1) $CurPos=MouseGetPos() MouseClickDrag("left",$CurPos[0],$CurPos[1],$CurPos[0],$CurPos[1]-20,1) $CurPos=MouseGetPos() MouseClickDrag("left",$CurPos[0],$CurPos[1],$CurPos[0]-35,$CurPos[1],1) $CurPos=MouseGetPos() MouseClickDrag("left",$CurPos[0],$CurPos[1],$CurPos[0],$CurPos[1]+60,1) $CurPos=MouseGetPos() MouseClickDrag("left",$CurPos[0],$CurPos[1],$CurPos[0]+35,$CurPos[1],1) ;Draw the l's $CurPos=MouseGetPos() MouseMove($CurPos[0]+25,$CurPos[1]-200,5) $CurPos=MouseGetPos() MouseClickDrag("left",$CurPos[0],$CurPos[1],$CurPos[0],$CurPos[1]+200,1) $CurPos=MouseGetPos() MouseMove($CurPos[0]+25,$CurPos[1]-200,5) $CurPos=MouseGetPos() MouseClickDrag("left",$CurPos[0],$CurPos[1],$CurPos[0],$CurPos[1]+200,1) ;Draw the "o" $CurPos=MouseGetPos() MouseMove($CurPos[0]+25,$CurPos[1]-35,5) $CurPos=MouseGetPos() MouseClickDrag("left",$CurPos[0],$CurPos[1],$CurPos[0]+35,$CurPos[1],1) $CurPos=MouseGetPos() MouseClickDrag("left",$CurPos[0],$CurPos[1],$CurPos[0],$CurPos[1]+35,1) $CurPos=MouseGetPos() MouseClickDrag("left",$CurPos[0],$CurPos[1],$CurPos[0]-35,$CurPos[1],1) $CurPos=MouseGetPos() MouseClickDrag("left",$CurPos[0],$CurPos[1],$CurPos[0],$CurPos[1]-35,1) -edit- Just tested it in WinXP and it doesn't work. Apparently it can't find the control class name. So use AutoIt Window Info tool to get the classname and replace it in the script. I suppose it should work then... Larry's example is very good. Edited October 12, 2007 by Nahuel Link to comment Share on other sites More sharing options...
Tasmania Posted October 12, 2007 Share Posted October 12, 2007 You know what sucks? Both applications that were just written don't run on my computer! Link to comment Share on other sites More sharing options...
Nahuel Posted October 12, 2007 Share Posted October 12, 2007 You know what sucks? Both applications that were just written don't run on my computer!If you have XP, read above. Larry's does work here... Link to comment Share on other sites More sharing options...
Tasmania Posted October 12, 2007 Share Posted October 12, 2007 Damn, you had me entertained for a while: expandcollapse popup;Mouse coordenates relative to active window Opt("MouseCoordMode",2) ;Run Paint Run("mspaint") ;Wait for paint to be active (Using [CLASS:MSPaintApp] will make it work on any computer) WinWaitActive("[CLASS:MSPaintApp]") ;Maximize paint WinSetState("[CLASS:MSPaintApp]","",@SW_MAXIMIZE) ;Get position of brush button $ControlPos=ControlGetPos("[CLASS:MSPaintApp]","","[CLASSNN:ToolChild8]") ;Click on brush MouseClick("left",$ControlPos[0]+$ControlPos[2]/2,$ControlPos[1]+$ControlPos[3]/2) ;Move the mouse a bit onto the white zone (This might fuck in computers where the tools have been ;moved from original position. MouseMove($ControlPos[0]+($ControlPos[2]/2)+50,$ControlPos[1]+$ControlPos[3]/2) ;Draw "H" $CurPos=MouseGetPos() MouseClickDrag("left",$CurPos[0],$CurPos[1],$CurPos[0],$CurPos[1]+200,1) $CurPos=MouseGetPos() MouseClickDrag("left",$CurPos[0],$CurPos[1],$CurPos[0],$CurPos[1]-100,1) $CurPos=MouseGetPos() MouseClickDrag("left",$CurPos[0],$CurPos[1],$CurPos[0]+50,$CurPos[1],1) $CurPos=MouseGetPos() MouseClickDrag("left",$CurPos[0],$CurPos[1],$CurPos[0],$CurPos[1]-100,1) $CurPos=MouseGetPos() MouseClickDrag("left",$CurPos[0],$CurPos[1],$CurPos[0],$CurPos[1]+200,1) ;Draw "e" $CurPos=MouseGetPos() MouseMove($CurPos[0]+25,$CurPos[1]-35,5) $CurPos=MouseGetPos() MouseClickDrag("left",$CurPos[0],$CurPos[1],$CurPos[0]+35,$CurPos[1],1) $CurPos=MouseGetPos() MouseClickDrag("left",$CurPos[0],$CurPos[1],$CurPos[0],$CurPos[1]-20,1) $CurPos=MouseGetPos() MouseClickDrag("left",$CurPos[0],$CurPos[1],$CurPos[0]-35,$CurPos[1],1) $CurPos=MouseGetPos() MouseClickDrag("left",$CurPos[0],$CurPos[1],$CurPos[0],$CurPos[1]+60,1) $CurPos=MouseGetPos() MouseClickDrag("left",$CurPos[0],$CurPos[1],$CurPos[0]+35,$CurPos[1],1) ;Draw the l's $CurPos=MouseGetPos() MouseMove($CurPos[0]+25,$CurPos[1]-200,5) $CurPos=MouseGetPos() MouseClickDrag("left",$CurPos[0],$CurPos[1],$CurPos[0],$CurPos[1]+200,1) $CurPos=MouseGetPos() MouseMove($CurPos[0]+25,$CurPos[1]-200,5) $CurPos=MouseGetPos() MouseClickDrag("left",$CurPos[0],$CurPos[1],$CurPos[0],$CurPos[1]+200,1) ;Draw the "o" $CurPos=MouseGetPos() MouseMove($CurPos[0]+25,$CurPos[1]-35,5) $CurPos=MouseGetPos() MouseClickDrag("left",$CurPos[0],$CurPos[1],$CurPos[0]+35,$CurPos[1],1) $CurPos=MouseGetPos() MouseClickDrag("left",$CurPos[0],$CurPos[1],$CurPos[0],$CurPos[1]+35,1) $CurPos=MouseGetPos() MouseClickDrag("left",$CurPos[0],$CurPos[1],$CurPos[0]-35,$CurPos[1],1) $CurPos=MouseGetPos() MouseClickDrag("left",$CurPos[0],$CurPos[1],$CurPos[0],$CurPos[1]-35,1) -edit- Just tested it in WinXP and it doesn't work. Apparently it can't find the control class name. So use AutoIt Window Info tool to get the classname and replace it in the script. I suppose it should work then... Larry's example is very good.That one worked, after I changed the class name, but it didn't get the brush... it just used the pencil Nice Link to comment Share on other sites More sharing options...
Tasmania Posted October 12, 2007 Share Posted October 12, 2007 (edited) If you have XP, read above. Larry's does work here...Larry's repositions, but after the first move it doesn't reposition correctly.The last one fishes the red button off screen and it won't click it, instead it maximizes whatever is on my taskbar Edited October 12, 2007 by Tasmania Link to comment Share on other sites More sharing options...
Nahuel Posted October 12, 2007 Share Posted October 12, 2007 That one worked, after I changed the class name, but it didn't get the brush... it just used the pencil Nice But... You got the control class name of the brush and it clicked on the pencil? Link to comment Share on other sites More sharing options...
Tasmania Posted October 12, 2007 Share Posted October 12, 2007 But... You got the control class name of the brush and it clicked on the pencil? Rather it moves it to the control toolbox area and clicks on "nothing" Link to comment Share on other sites More sharing options...
aslani Posted October 12, 2007 Share Posted October 12, 2007 -edit-Just tested it in WinXP and it doesn't work. Apparently it can't find the control class name. So use AutoIt Window Info tool to get the classname and replace it in the script.I suppose it should work then...Larry's example is very good.Sorry, doesn't work for me either, but it's very inspiring. [font="Georgia"]Chances are, I'm wrong.[/font]HotKey trouble?Stringregexp GuideAutoIT Current Version Link to comment Share on other sites More sharing options...
flynch Posted October 13, 2007 Author Share Posted October 13, 2007 Hahaha. Theses are the problems i'm talking about. Probably because of different resolutions. Gotta remember, on your screen the pos might be red, but on someone elses it might be the taskbar. Link to comment Share on other sites More sharing options...
Nahuel Posted October 13, 2007 Share Posted October 13, 2007 Well, PixelSearch() should help with that. Notice that my script will get the position of the brush botton and then will click it. Also, it gets the window by class, not by name, so it can work with any language. You have many ideas to combine now, you can do something better 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