fenhanxue Posted November 22, 2017 Share Posted November 22, 2017 (edited) i need to draw a line form position 0 ($x_0,$y_0 ) to position 1 ($x_1,$y_1 ) i will click left mouse 2 times position_0 is the mouse pos where i first click left mouse position_1 is the mouse pos where i click left mouse again and between the 2 clicks, i want to draw a line start form position_0 to where my mouse moved to . expandcollapse popup#include <Misc.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #Include <WinAPI.au3> Opt("MouseCoordMode", 2) $hGUI = GUICreate("Draw a line",400,400) $g = GUICtrlCreateGraphic(0, 0, 400, 400) GUICtrlSetBkColor($g, 0xCCFFCC) GUISetState() ;1 first,i moved mouse to position($x_0,$y_0),click mouse left Do Until _IsPressed('01') Local $temp = MouseGetPos() Local $x_0 = $temp[0] Local $y_0 = $temp[1] Sleep(500) ;2 then ,I will move mouse to a random position ($x_r ,$y_r) ;===== how to show a line form $x_0,$y_0 to $x_r ,$y_r ???? ;once i move the mouse ,the line should be redrawed immediately ;3 finally, i click mouse left in position ($x_1,$y_1),there should be only one line form $x_0,$y_0 to $x_1,$y_1 Do Until _IsPressed('01') ConsoleWrite('2') Local $temp = MouseGetPos() Local $x_1 = $temp[0] Local $y_1 = $temp[1] GUICtrlSetGraphic($g,$GUI_GR_MOVE,$x_0,$y_0) GUICtrlSetGraphic($g,$GUI_GR_LINE,$x_1,$y_1) _WinAPI_RedrawWindow($hGUI) Sleep(5000) Edited November 22, 2017 by fenhanxue 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