qwertylol Posted May 14, 2007 Posted May 14, 2007 I am trying to figure this out: how do I make the mouse cursor, knowing the center of it, move in a perfectly circular way? like, if I want to "manually" draw a circle in mspaint, how do I write a script to draw it ?
Zedna Posted May 14, 2007 Posted May 14, 2007 Use MouseMove() and Sin(), Cos() Resources UDF ResourcesEx UDF AutoIt Forum Search
Zedna Posted May 14, 2007 Posted May 14, 2007 can you be more specific? Look at this (not mine) script for idea: expandcollapse popup#NoTrayIcon #include <GUIConstants.au3> #include <Constants.au3> If $CmdLine[0] > 0 Then $CommandLine = StringLeft($CmdLine[1], 2) Else $CommandLine = "/c" EndIf Global $DetailsLevel = RegRead("HKEY_CURRENT_USER\Software\MathMagicSCR", "DetailsLevel") If $DetailsLevel = "" Then $DetailsLevel = 3 EndIf Global $Delay = RegRead("HKEY_CURRENT_USER\Software\MathMagicSCR", "Delay") If $Delay = "" Then $Delay = 30 EndIf Global $WaitTime = RegRead("HKEY_CURRENT_USER\Software\MathMagicSCR", "WaitTime") If $WaitTime = "" Then $WaitTime = 2 EndIf Global $Cursor = RegRead("HKEY_CURRENT_USER\Software\MathMagicSCR", "Cursor") If $Cursor = "" Then $Cursor = 1 EndIf Global $MultiColor = RegRead("HKEY_CURRENT_USER\Software\MathMagicSCR", "MultiColor") If $MultiColor = "" Then $MultiColor = 1 EndIf Global $Gradient = RegRead("HKEY_CURRENT_USER\Software\MathMagicSCR", "Gradient") If $Gradient = "" Then $Gradient = 1 EndIf Global Const $Pi = 3.1415926535897932384626433832795 Global $IncreaseSize = (360/($DetailsLevel*90)) * (@DesktopWidth/1000) Global $MaxTimes = ($DetailsLevel * 90) Global $Pos = MouseGetPos() Global $Color0 If $CommandLine = "/c" Then $GUI = GuiCreate("MathMagic Screensaver Options", 250, 175, -1, -1, $WS_CAPTION) GuiCtrlCreateLabel("Details level:", 10, 13, 100, 20) $DetailsSlider = GuiCtrlCreateSlider(120, 5, 120, 30) GuiCtrlCreateLabel("Drawing speed:", 10, 45, 100, 25) $SpeedSlider = GuiCtrlCreateSlider(120, 40, 120, 30) GuiCtrlCreateLabel("Time between draws:", 10, 75, 100, 25) $WaitSlider = GuiCtrlCreateSlider(120, 70, 120, 30) $CursorCheck = GUICtrlCreateCheckbox("Show pencil", 15, 115, 75, 15) $ColorCheck = GUICtrlCreateCheckbox("Multi-colors", 95, 115, 70, 15) $GradientCheck = GUICtrlCreateCheckbox("Gradient", 170, 115, 65, 15) $OK = GuiCtrlCreateButton("OK", 10, 135, 90, 30) $Cancel = GuiCtrlCreateButton("Cancel", 160, 135, 80, 30) $About = GuiCtrlCreateButton("About", 100, 135, 60, 30) GUICtrlSetData($DetailsSlider, $DetailsLevel) GUICtrlSetData($SpeedSlider, (500 - $Delay) / 10) GUICtrlSetData($WaitSlider, $WaitTime) GUICtrlSetLimit($DetailsSlider, 10, 1) GUICtrlSetLimit($SpeedSlider, 50, 1) GUICtrlSetLimit($WaitSlider, 10, 0) GUICtrlSetState($CursorCheck, $Cursor) GUICtrlSetState($ColorCheck, $MultiColor) GUICtrlSetState($GradientCheck, $Gradient) GuiSetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $Cancel Exit Case $About MsgBox(64, "About", "MathMagic Screensaver" & @CRLF & @CRLF & "2006 - CoePSX") Case $OK $DetailsLevel = GUICtrlRead($DetailsSlider) $Delay = 500 - GUICtrlRead($SpeedSlider)*10 $WaitTime = GUICtrlRead($WaitSlider) RegWrite("HKEY_CURRENT_USER\Software\MathMagicSCR", "DetailsLevel", "REG_SZ", $DetailsLevel) RegWrite("HKEY_CURRENT_USER\Software\MathMagicSCR", "Delay", "REG_SZ", $Delay) RegWrite("HKEY_CURRENT_USER\Software\MathMagicSCR", "WaitTime", "REG_SZ", $WaitTime) RegWrite("HKEY_CURRENT_USER\Software\MathMagicSCR", "Cursor", "REG_SZ", GUICtrlRead($CursorCheck)) RegWrite("HKEY_CURRENT_USER\Software\MathMagicSCR", "MultiColor", "REG_SZ", GUICtrlRead($ColorCheck)) RegWrite("HKEY_CURRENT_USER\Software\MathMagicSCR", "Gradient", "REG_SZ", GUICtrlRead($GradientCheck)) Exit EndSwitch WEnd ElseIf $CommandLine = "/s" Then $Window = GUICreate("", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP, BitOr($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW)) $Label = GUICtrlCreateLabel("", 20, 20, 60, 30) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetFont($Label, 18, 400) $Graphic = GUICtrlCreateGraphic(0, 0, @DesktopWidth, @DesktopHeight) $Pointer = GUICtrlCreateLabel("", @DesktopWidth, @DesktopHeight, 6, 6) GUICtrlSetBkColor($Pointer, 0xFFFFFF) GUISetBkColor(0) GUISetCursor(16, 1) GUISetState() Opt("ColorMode", 1) Opt("GUIOnEventMode", 1) GUISetOnEvent($GUI_EVENT_MOUSEMOVE, "Quit") $GDI32 = DllOpen("gdi32.dll") $USER32 = DllOpen("user32.dll") $GUIHDC = DllCall ($USER32,"int","GetDC","hwnd", $Window) While GUIGetMsg() <> $GUI_EVENT_CLOSE $PicSize = 1 Do $iNumber = Random(10, 350, 1) Until $iNumber <> 180 If $iNumber < 180 Then $iColors = Round(360/$iNumber) Else $iColors = Round(Abs(360/(360-$iNumber))) EndIf For $i = 0 To $iColors Assign("Color" & $i, ColorGradient(RandomColor(), RandomColor(), $MaxTimes+1)) Next GUICtrlSetColor($Label, $Color0[0]) GUICtrlSetData($Label, $iNumber & "°") DllCall ($GDI32, "int", "MoveToEx", "hwnd", $GUIHDC[0], "int", @DesktopWidth/2, "int", @DesktopHeight/2, "ptr", 0) For $R = 1 To $MaxTimes $PicSize += $IncreaseSize $X = Sin($iNumber * ($R*($Pi/180))) * $PicSize + @DesktopWidth/2 $Y= Cos($iNumber * ($R*($Pi/180))) * $PicSize + @DesktopHeight/2 If $MultiColor = 1 Then If $Gradient = 1 Then $NowColor = Eval("Color" & Mod($R, $iColors)) $NowColor = $NowColor[$R] Else $NowColor = Eval("Color" & Mod($R, $iColors)) $NowColor = $NowColor[0] EndIf Else If $Gradient = 1 Then $NowColor = $Color0[$R] Else $NowColor = $Color0[0] EndIf EndIf GUICtrlSetColor($Label, $Color0[$R]) If $Cursor = 1 Then GUICtrlSetPos($Pointer, $X-3, $Y-3) $Pen = DllCall($GDI32, "hwnd", "CreatePen", "int", "0", "int", "0", "hwnd", $NowColor) DllCall($GDI32, "hwnd", "SelectObject", "hwnd", $GUIHDC[0], "hwnd", $Pen[0]) DllCall ($GDI32, "int", "LineTo", "hwnd", $GUIHDC[0], "int", $X, "int", $Y) Sleep($Delay) Next DllCall ($USER32,"int","ReleaseDC","int",$GUIHDC[0],"hwnd",$Window) Sleep($WaitTime*1000) GUICtrlDelete($Graphic) $Graphic = GUICtrlCreateGraphic(0, 0, @DesktopWidth, @DesktopHeight) WEnd EndIf Func Quit() Exit EndFunc Func ColorGradient($hInitialColor, $hFinalColor, $iReturnSize) $hInitialColor = Hex($hInitialColor, 6) $hFinalColor = Hex($hFinalColor, 6) Local $iRed1 = Dec (StringLeft($hInitialColor, 2)) Local $iGreen1 = Dec (StringMid($hInitialColor, 3, 2)) Local $iBlue1 = Dec (StringMid($hInitialColor, 5, 2)) Local $iRed2 = Dec (StringLeft($hFinalColor, 2)) Local $iGreen2 = Dec (StringMid($hFinalColor, 3, 2)) Local $iBlue2 = Dec (StringMid($hFinalColor, 5, 2)) Local $iPlusRed = ($iRed2-$iRed1)/($iReturnSize-1) Local $iPlusBlue = ($iBlue2-$iBlue1)/($iReturnSize-1) Local $iPlusGreen = ($iGreen2-$iGreen1)/($iReturnSize-1) Dim $iColorArray[$iReturnSize] For $i = 0 To $iReturnSize-1 $iNowRed = Floor($iRed1 + ($iPlusRed*$i)) $iNowBlue = Floor($iBlue1 + ($iPlusBlue*$i)) $iNowGreen = Floor($iGreen1 + ($iPlusGreen*$i)) $iColorArray[$i] = Dec (Hex($iNowRed, 2) & Hex($iNowGreen, 2) & Hex($iNowBlue, 2)) Next Return ($iColorArray) EndFunc Func RandomColor($hMinColor = 0x000000, $hMaxColor = 0xFFFFFF) $hMinColor = Hex($hMinColor, 6) $hMaxColor = Hex($hMaxColor, 6) Local $iRed1 = Dec (StringLeft($hMinColor, 2)) Local $iGreen1 = Dec (StringMid($hMinColor, 3, 2)) Local $iBlue1 = Dec (StringMid($hMinColor, 5, 2)) Local $iRed2 = Dec (StringLeft($hMaxColor, 2)) Local $iGreen2 = Dec (StringMid($hMaxColor, 3, 2)) Local $iBlue2 = Dec (StringMid($hMaxColor, 5, 2)) Local $iRndRed = Random($iRed1, $iRed2, 1) Local $iRndGreen = Random($iGreen1, $iGreen2, 1) Local $iRndBlue = Random($iBlue1, $iBlue2, 1) Return Dec (Hex($iRndRed, 2) & Hex($iRndGreen, 2) & Hex($iRndBlue, 2)) EndFunc Resources UDF ResourcesEx UDF AutoIt Forum Search
Lord_Doominik Posted May 14, 2007 Posted May 14, 2007 then you should thay the radius of the circle you want to draw.
qwertylol Posted May 14, 2007 Author Posted May 14, 2007 ok the help file is very difficult to understand so I have the center of the circle (x,y) I have the radius, how do I mose sin and cos to calculate the x and y?
yxrkt Posted May 14, 2007 Posted May 14, 2007 ok the help file is very difficult to understandwhat ..? are you drunk ?
qwertylol Posted May 14, 2007 Author Posted May 14, 2007 got it. $x = $center_x + $radius * sin($pi / $degree) )
qwertylol Posted May 14, 2007 Author Posted May 14, 2007 ok the next problem is to deal with the string behind the decimal how do I write this? 12.4 = 12 12.5 = 13 thing?
Zedna Posted May 14, 2007 Posted May 14, 2007 ok the next problem is to deal with the string behind the decimalhow do I write this? 12.4 = 12 12.5 = 13 thing?Instead of such stupid questions make some pause in your "scripting" and look at language base info into Helpfile first. Also use forum Search. Resources UDF ResourcesEx UDF AutoIt Forum Search
SadBunny Posted May 14, 2007 Posted May 14, 2007 I can't find it How can you not find a command named Round when you are looking for a way to Round numbers?!?Cheers. Roses are FF0000, violets are 0000FF... All my base are belong to you.
qwertylol Posted May 14, 2007 Author Posted May 14, 2007 well... I was not educated in english when I first learned the term "round." that's why.
Achilles Posted May 15, 2007 Posted May 15, 2007 ok the next problem is to deal with the string behind the decimal how do I write this? 12.4 = 12 12.5 = 13 thing?Something like this: $number = Round(12.5)If you haven't found it already... My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]
MrCreatoR Posted May 15, 2007 Posted May 15, 2007 It's also not mine, i made just a litle editing:_MouseMoveCircle(400, 400, 50, 600) Func _MouseMoveCircle($xPos, $yPos, $Radius, $TimeExp); x coord, y coord, radius, time to loop (milliseconds) Local $TimeInit = TimerInit() Local $xPosMov, $yPosMov Do $TimeDiff = TimerDiff($TimeInit) $xPosMov = $xPos + ($Radius * Sin($TimeDiff/100)) $yPosMov = $yPos + ($Radius * Cos($TimeDiff/100)) MouseMove($xPosMov, $yPosMov, 1) Until $TimeDiff > $TimeExp EndFunc Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team
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