Jump to content

Recommended Posts

Posted

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 :))

Posted

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

Posted

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!
Posted

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

f_mrcleansmalm_77ce002.jpgAutoIt has helped make me wealthy

Posted (edited)

Damn, you had me entertained for a while:

;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 by Nahuel
Posted

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...

Posted

Damn, you had me entertained for a while:

;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 ;)

Posted (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 by Tasmania
Posted

That one worked, after I changed the class name, but it didn't get the brush... it just used the pencil ;)

Nice :P

But... You got the control class name of the brush and it clicked on the pencil? :)

Posted

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" ;)
Posted

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.

Posted

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 :)

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...