Sign in to follow this  
Followers 0
TheReveller

Modelise a graphic curve on screen

9 posts in this topic

#1 ·  Posted (edited)

Hello,

I downloaded AutoHotkey to do some easy scripts, but I couldn't find how to draw over the screen and still be able to interract with the screen, so I downloaded AutoIt 3.

Here is my newbie ugly script for AutoHotkey :

#Persistent 
#SingleInstance force 
SetTitleMatchMode, 2 
InputBox, nx, Calculateur de coordonnées graphiques, Entrez la valeur maximale en X,, 310, 140 
if ErrorLevel 
{ 
ExitApp 
} 
InputBox, ny, Calculateur de coordonnées graphiques, Entrez la valeur maximale en Y,, 310, 140 
if ErrorLevel 
{ 
ExitApp 
} 
InputBox, ox, Calculateur de coordonnées graphiques, Entrez la valeur de l'origine en X,, 310, 140,,,,, 0 
if ErrorLevel 
{ 
ExitApp 
} 
InputBox, oy, Calculateur de coordonnées graphiques, Entrez la valeur de l'origine en Y,, 310, 140,,,,, 0 
if ErrorLevel 
{ 
ExitApp 
} 
CoordMode, Mouse, Screen 
While not GetKeyState("LButton") 
{ 
ToolTip % "Cliquez sur l'origine (" . ox . ", " . oy . ")" 
} 
KeyWait, LButton, D 
MouseGetPos, x1, y1 
KeyWait, LButton 
While not GetKeyState("LButton") 
{ 
ToolTip % "Cliquez sur le maximum en XY (" . nx . ", " . ny . ")" 
} 
KeyWait, LButton, D 
MouseGetPos, x2, y2 
KeyWait, LButton 
n := 0 
While not GetKeyState("Space") 
{ 
While not GetKeyState("LButton") and not GetKeyState("Space") 
{ 
MouseGetPos, x, y 
ToolTip % ((x - x1) / (x2 - x1)) * (nx - ox) + ox . ", " . ((y - y1) / (y2 - y1)) * (ny - oy) + oy . "`nCliquez pour copier cette valeur`nValeurs enregistrées : " . n 
} 
if not GetKeyState("Space") 
{ 
KeyWait, LButton, D 
MouseGetPos, x3, y3 
KeyWait, LButton 
tx%n% := ((x3 - x1) / (x2 - x1)) * (nx - ox) + ox 
ty%n% := ((y3 - y1) / (y2 - y1)) * (ny - oy) + oy 
n += 1 
} 
} 
a := 0 
Clipboard := "X`tY" 
Loop %n% 
{ 
Clipboard .= "`r`n" . tx%a% . "`t" . ty%a% 
a++ 
} 
Run, Excel.exe 
Sleep, 100 
IfWinNotActive, Microsoft Excel
{
WinActivate, Microsoft Excel
WinWaitActive, Microsoft Excel
Sleep, 100
} 
Send, {Ctrl Down}v{Ctrl Up}
ExitApp 
Esc::ExitApp

What it does :

You define the maximum X, the maximum Y, the origin X and Y.

You click on the origin, then on the maximums.

Then, you click on the screen to define the coordinates.

Finally, you press space and it opens Excel and pastes the values.

What I wish I could do :

It would draw a transparent (50%, red) rectangle (or 4 lines) that defines the limits of the graph from the origins to the maximums.

It would draw 2 lines following the cursor, a line for X between origin and maximum and a line for Y between origin and maximum, still transparent (50%, green)

On click, it would draw a small filled rectangle 5x5 (50%, blue) and there would be blue lines from point 1 to point 2.

Mouseover a dot and press delete to delete it, if you have point 1, 2 and 3 and you delete point 2, the lines goes from point 1 to point 3 and the point 3 becomes the point 2.

And maybe a way to click-hold then drag a dot and on release it would save the new position.

I'm sorry it looks as if I want you to build the code for me, but you are very advanced with AutoIt and I'm not a programmer and this would be pretty helpful at my work. If you can propose me something and some clues so I can start with this...

Many thanks for you help,

TheReveller

Edited by TheReveller

Share this post


Link to post
Share on other sites



...but I couldn't find how to draw over the screen and still be able to interract with the screen...

...If you can propose me something and some clues so I can start with this...

Something to get y started

#include <GuiConstantsEx.au3>
#include <GDIPlus.au3>
#Include <Misc.au3>
#include <WindowsConstants.au3>
Opt("MouseCoordMode",2) 

$answer1 = InputBox("1", "Start position on the screen x")
$answer2 = InputBox("2", "Start position on the screen y")
$answer3 = InputBox("3", "Size of the box x")
$answer4 = InputBox("4", "Size of the box y")

Global $hGUI, $hWnd, $hGraphic,$hGraphic,$1,$2

$hGUI = GUICreate("GDI+",$answer3,$answer4,$answer1,$answer2,$WS_POPUP)
WinSetTrans($hGUI, "", (255/100)*50)
GUISetState()
_GDIPlus_Startup ()
$x = GUICtrlCreateGraphic(0, 0, 400, 300)
GUICtrlSetBkColor(-1, 0x00ff00)
$hWnd = WinGetHandle("GDI+")

Do
    $1 = MouseGetPos()
    ToolTip($1[0]&","&$1[1]&" "&"0"&","&"0",0,0)
Until _IsPressed("01")
Do
    $2 = MouseGetPos()
    ToolTip($1[0]&","&$1[1]&" "&$2[0]&","&$2[1],0,0)
Until Not _IsPressed("01")

$hGraphic = _GDIPlus_GraphicsCreateFromHWND ($hWnd)
$hPen = _GDIPlus_PenCreate (0xFFFF0000,2)
$hPen1 = _GDIPlus_PenCreate (0xFF000000,6)
_GDIPlus_GraphicsDrawLine ($hGraphic, $1[0], $1[1], $2[0], $2[1], $hPen)
_GDIPlus_GraphicsDrawLine ($hGraphic, $1[0]-3, $1[1], $1[0]+3, $1[1], $hPen1)
_GDIPlus_GraphicsDrawLine ($hGraphic, $2[0]-3, $2[1], $2[0]+3, $2[1], $hPen1)

While 1
    If _IsPressed("01") Then
        $pos = MouseGetPos()
        $hGraphic = _GDIPlus_GraphicsCreateFromHWND ($hWnd)
        $hPen = _GDIPlus_PenCreate (0xFFFF0000,2)
        _GDIPlus_GraphicsDrawLine ($hGraphic, $1[0], $1[1], $2[0], $2[1], $hPen)
        Sleep(10)
        Do
            Sleep(10)
        Until Not _IsPressed("01")
        _GDIPlus_GraphicsClear($hGraphic,0xFF00ff00)
    EndIf
WEnd

Other functions that can help y

HotKeySet()

Func()

WinSetState()

GDI or other exsamples can b located in help file, or try Forum Search.

One more thing y need is your imagination and hard work.

Good luck and welcome to forum.


TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Ok, then for the start.

Here is what I've tried for the moment :

#include <GuiConstantsEx.au3>
#include <GDIPlus.au3>
#Include <Misc.au3>
#include <WindowsConstants.au3> 

$mx = InputBox("Calculateur de coordonnées graphiques", "Entrez la valeur maximale en X", 100, Default, 310, 140)
$my = InputBox("Calculateur de coordonnées graphiques", "Entrez la valeur maximale en Y", 100, Default, 310, 140)
$ox = InputBox("Calculateur de coordonnées graphiques", "Entrez la valeur de l'origine en X", 0, Default, 310, 140)
$oy = InputBox("Calculateur de coordonnées graphiques", "Entrez la valeur de l'origine en Y", 0, Default, 310, 140)

Global $hGUI, $hWnd, $hGraphic,$hGraphic,$o,$m,$n,$xy[256][2],$t,$c,$i,$v[256][2]

Do
    $o = MouseGetPos()
    ToolTip("Cliquez sur l'origine ("&$ox&", "&$oy&")", Default, Default, Default, Default, 4)
Until _IsPressed("01")

Do
Until Not _IsPressed("01")

Do
    $m = MouseGetPos()
    ToolTip("Cliquez sur le maximum en XY ("&$mx&", "&$my&")", Default, Default, Default, Default, 4)
Until _IsPressed("01")

Do
Until Not _IsPressed("01")

$hGUI = GUICreate("Graphique",Abs($m[0]-$o[0]),Abs($m[1]-$o[1]),$o[0],$m[1],$WS_POPUP)
WinSetTrans($hGUI, "", (255/100)*25)
GUISetState()
_GDIPlus_Startup ()
$x = GUICtrlCreateGraphic(0,0,Abs($m[0]-$o[0]),Abs($m[1]-$o[1]))
GUICtrlSetBkColor(-1, 0x00ff00)
$hWnd = WinGetHandle("Graphique")

$hGraphic = _GDIPlus_GraphicsCreateFromHWND ($hWnd)
$hPen = _GDIPlus_PenCreate (0xFFFF0000,2)
$hPen1 = _GDIPlus_PenCreate (0xFF000000,6)

$n = 0
Do
    Do
        $t = MouseGetPos()
        $xy[$n][0] = $t[0]
        $xy[$n][1] = $t[1]
        ToolTip("("&(($xy[$n][0]-$o[0])/($m[0]-$o[0]))*($mx-$ox)+$ox&", "&(($xy[$n][1]-$o[1])/($m[1]-$o[1]))*($my-$oy)+$oy&")"&@CRLF&"Cliquez pour copier cette valeur"&@CRLF&"Valeurs enregistrées : "&$n, Default, Default, Default, Default, 4)
        $v[$n][0] = (($xy[$n][0]-$o[0])/($m[0]-$o[0]))*($mx-$ox)+$ox
        $v[$n][1] = (($xy[$n][1]-$o[1])/($m[1]-$o[1]))*($my-$oy)+$oy
    Until _IsPressed("01") or _IsPressed("20")
    
    Do
    Until Not _IsPressed("01") or _IsPressed("20")
    
    If Not _IsPressed("20") Then
        
    If $n = 0 Then
        _GDIPlus_GraphicsDrawLine ($hGraphic, $xy[$n][0]-$o[0]-3, $xy[$n][1]-$m[1], $xy[$n][0]-$o[0]+3, $xy[$n][1]-$m[1], $hPen1)
    Else
        _GDIPlus_GraphicsDrawLine ($hGraphic, $xy[$n-1][0]-$o[0], $xy[$n-1][1]-$m[1], $xy[$n][0]-$o[0], $xy[$n][1]-$m[1], $hPen)
        _GDIPlus_GraphicsDrawLine ($hGraphic, $xy[$n][0]-$o[0]-3, $xy[$n][1]-$m[1], $xy[$n][0]-$o[0]+3, $xy[$n][1]-$m[1], $hPen1)
    EndIf
    
    $n += 1
    
    EndIf
    
Until _IsPressed("20")

$i = 0

ClipPut("X"&@TAB&"Y")

Do
    $c = ClipGet()
    ClipPut($c&@CRLF&$v[$i][0]&@TAB&$v[$i][1])
    $i += 1
Until $i == $n

Run("Excel.exe", Default, @SW_MAXIMIZE)
WinWaitActive("Microsoft Excel")
Sleep("100")
Send("{CTRLDOWN}v{CTRLUP}")

Can you help me to improve my script, there is certainly some useless tricks I've done that can be modified by some function I don't know.

Also, it doesn't seem to run Excel and I don't know why.

And how can I run two things at the same time. I mean, there is a Do...Until running waiting for a click, but if it's a click-drag on a dot, I want another Do...Until to run that would modify the coordinates of that dots and the lines would also follow. If the mouse is over a dot and you press Delete or whatever, it deletes the dot, modifies the array of values and refreshes the lines of the graph.

Another thing, I want to keep that green zone, but if I click out of the zone, I want the lines to appear still even if it's out of that green zone and how can I set different transparency if I want the green zone to be 10% and the lines to be 25% for example ?

Do know why sometimes the lines seems to be broken ?

Finally, can I create an Array with undefine dimension ?

Thanks for the help, I'm learning !

Edited by TheReveller

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

PS : I meaned "Ok, thanks for the start".

I added comments in english in my bad newbie scripting so it will be easier for you to help me, thanks.

Here are my last updates :

#include <GuiConstantsEx.au3>
#include <GDIPlus.au3>
#Include <Misc.au3>
#include <WindowsConstants.au3> 

HotKeySet("{ESC}","quitter"); Quit

Func quitter()
    Exit
EndFunc

$mx = InputBox("Calculateur de coordonnées graphiques", "Entrez la valeur maximale en X", 100, Default, 310, 140); Value of X max
If @error > 0 Then
    Exit
EndIf
$my = InputBox("Calculateur de coordonnées graphiques", "Entrez la valeur maximale en Y", 100, Default, 310, 140); Value of Y max
If @error > 0 Then
    Exit
EndIf
$ox = InputBox("Calculateur de coordonnées graphiques", "Entrez la valeur de l'origine en X", 0, Default, 310, 140); Value of X min
If @error > 0 Then
    Exit
EndIf
$oy = InputBox("Calculateur de coordonnées graphiques", "Entrez la valeur de l'origine en Y", 0, Default, 310, 140); Value of Y min
If @error > 0 Then
    Exit
EndIf

Global $hGUI, $hWnd, $hGraphic,$hGraphic,$o,$o2,$m,$m2,$n,$xy[256][2],$t,$c,$i,$v[256][2],$r; Max dimension of 256, don't know how to do more

Do
    $o = MouseGetPos()
    $o2 = MouseGetPos()
    ToolTip("Cliquez sur l'origine ("&$ox&", "&$oy&")", Default, Default, Default, Default, 4); Get the position of the min X and min Y
Until _IsPressed("01")

Do; Only way I found to wait until click is released
Until Not _IsPressed("01")

Do
    $m = MouseGetPos()
    $m2 = MouseGetPos()
    ToolTip("Cliquez sur le maximum en XY ("&$mx&", "&$my&")", Default, Default, Default, Default, 4); Get the position of the max X and max Y
Until _IsPressed("01")

Do; Only way I found to wait until click is released
Until Not _IsPressed("01")

If $o[0] > $m[0] Then; Swap the min and the max X if the max X is to the left of the min X for GUI purpose
    $o2[0] = $m[0]
    $m2[0] = $o[0]
EndIf
If $o[1] < $m[1] Then; Swap the min and the max Y if the max Y is under the min Y for GUI purpose
    $o2[1] = $m[1]
    $m2[1] = $o[1]
EndIf

$hGUI = GUICreate("Graphique",Abs($m[0]-$o[0]),Abs($m[1]-$o[1]),$o2[0],$m2[1],$WS_POPUP); Use min2 X and max2 Y  to define left and top
WinSetTrans($hGUI, "", (255/100)*25)
GUISetState(); Didn't really touch to this stuff
_GDIPlus_Startup ()
$x = GUICtrlCreateGraphic(0,0,Abs($m[0]-$o[0]),Abs($m[1]-$o[1]))
GUICtrlSetBkColor(-1, 0x00ff00)
$hWnd = WinGetHandle("Graphique")

$hGraphic = _GDIPlus_GraphicsCreateFromHWND ($hWnd)
$hPen = _GDIPlus_PenCreate (0xFFFF0000,2)
$hPen1 = _GDIPlus_PenCreate (0xFF000000,6)

$n = 0; Counts the number of saved values
Do
    Do
        $t = MouseGetPos(); Temporary variable, I couldn't do directly $xy[$n] = MouseGetPos()
        $xy[$n][0] = $t[0]
        $xy[$n][1] = $t[1]
        
        If _IsPressed("2E") Then; If DELETE key is detected
            For $d = 0 To $n-1 
                If $t[0] >= $xy[$d][0]-3 and $t[0] <= $xy[$d][0]+3 and $t[1] >= $xy[$d][1]-3 and $t[1] <= $xy[$d][1]+3 Then; Look if mouse is over a dot
                    ToolTip("", Default, Default, Default, Default, 4); I hate when tooltip stucks where he shouldn't, so I delete it
                    If MsgBox(292, "Suppression", "Supprimer ce point ?") == 6 Then; Ask if you really want to delete that dot
                        _GDIPlus_GraphicsClear($hGraphic); The only way I found is to restart the drawing
                        GUICtrlDelete($x)
                        $x = GUICtrlCreateGraphic(0,0,Abs($m[0]-$o[0]),Abs($m[1]-$o[1]))
                        GUICtrlSetBkColor(-1, 0x00ff00)
                        $hWnd = WinGetHandle("Graphique")
                        $hGraphic = _GDIPlus_GraphicsCreateFromHWND ($hWnd)
                        $hPen = _GDIPlus_PenCreate (0xFFFF0000,2)
                        $hPen1 = _GDIPlus_PenCreate (0xFF000000,6)
                        $r = 0
                    
                        While $d < $n; Shift the values of the dots
                            $xy[$d][0] = $xy[$d+1][0]
                            $xy[$d][1] = $xy[$d+1][1]
                            $d += 1
                        WEnd
                        $n -= 1; Decrease the number of dots
                    
                        For $r = 0 To $n-1; Redraw the lines
                            If $r = 0 Then
                                _GDIPlus_GraphicsDrawLine ($hGraphic, $xy[$r][0]-$o2[0]-3, $xy[$r][1]-$m2[1], $xy[$r][0]-$o2[0]+3, $xy[$r][1]-$m2[1], $hPen1)
                            Else
                                _GDIPlus_GraphicsDrawLine ($hGraphic, $xy[$r-1][0]-$o2[0], $xy[$r-1][1]-$m2[1], $xy[$r][0]-$o2[0], $xy[$r][1]-$m2[1], $hPen)
                                _GDIPlus_GraphicsDrawLine ($hGraphic, $xy[$r][0]-$o2[0]-3, $xy[$r][1]-$m2[1], $xy[$r][0]-$o2[0]+3, $xy[$r][1]-$m2[1], $hPen1)
                            EndIf
                            $v[$r][0] = (($xy[$r][0]-$o[0])/($m[0]-$o[0]))*($mx-$ox)+$ox; Resave the values
                            $v[$r][1] = (($xy[$r][1]-$o[1])/($m[1]-$o[1]))*($my-$oy)+$oy
                        Next
                        ExitLoop
                    EndIf
                EndIf
            Next
        EndIf
        
        ToolTip("("&(($xy[$n][0]-$o[0])/($m[0]-$o[0]))*($mx-$ox)+$ox&", "&(($xy[$n][1]-$o[1])/($m[1]-$o[1]))*($my-$oy)+$oy&")"&@CRLF&"Cliquez pour copier cette valeur"&@CRLF&"Valeurs enregistrées : "&$n, Default, Default, Default, Default, 4)
        $v[$n][0] = (($xy[$n][0]-$o[0])/($m[0]-$o[0]))*($mx-$ox)+$ox; Saves the value
        $v[$n][1] = (($xy[$n][1]-$o[1])/($m[1]-$o[1]))*($my-$oy)+$oy
        
    Until _IsPressed("01") or _IsPressed("20"); SPACE should end the graphic
    
    Do; Waits for the mouse button to be released, the only way I found
    Until Not _IsPressed("01") or _IsPressed("20")
    
    If Not _IsPressed("20") Then
        
    If $n = 0 Then; Draw the line and/or the dot
        _GDIPlus_GraphicsDrawLine ($hGraphic, $xy[$n][0]-$o2[0]-3, $xy[$n][1]-$m2[1], $xy[$n][0]-$o2[0]+3, $xy[$n][1]-$m2[1], $hPen1)
    Else
        _GDIPlus_GraphicsDrawLine ($hGraphic, $xy[$n-1][0]-$o2[0], $xy[$n-1][1]-$m2[1], $xy[$n][0]-$o2[0], $xy[$n][1]-$m2[1], $hPen)
        _GDIPlus_GraphicsDrawLine ($hGraphic, $xy[$n][0]-$o2[0]-3, $xy[$n][1]-$m2[1], $xy[$n][0]-$o2[0]+3, $xy[$n][1]-$m2[1], $hPen1)
    EndIf
    
    $n += 1; Increase the number of saved values
    
    EndIf
    
Until _IsPressed("20"); End the graphic with SPACE

$i = 0

ClipPut("X"&@TAB&"Y"); Title in clipboard

Do; Put the values in the clipboard
    $c = ClipGet()
    ClipPut($c&@CRLF&$v[$i][0]&@TAB&$v[$i][1])
    $i += 1
Until $i == $n

Run("C:\Program Files\Microsoft Office\Office12\EXCEL.exe", "", @SW_MAXIMIZE); Only way I found to run Excel.exe
WinWaitActive("Microsoft Excel"); Wait active
Sleep("100")
Send("{CTRLDOWN}v{CTRLUP}"); Paste the values

I still wish to improve my script, to be able to click-drag, to be able to draw outside the green zone and maybe other features would help if you propose. Anyway, I can tell you many things I would like to add, but for the moment I don't want to waste too much time trying to get the script perfect.

Thanks for you help !

Edited by TheReveller

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

With "interract with the screen" i thought that youd like to minimize gui or make it trans (or to make some collors trans between Gui and that collor) to see whats behinde him and in that way to interact with screen, or maby to register double click on gui ond send that click behinde gui.

"draw outside the green zone" you mented directly on the desktop, or any other opened app, and out of the gui, did you?

Dont know if you can make 1 collor transparent on one transparent gui and still to b able to interract on desktop. And i dont think that its posible to draw anything outside of a gui area.

I know that with _WinAPI_SetLayeredWindowAttributes (use forum search) you can make one color (only one) to disapeare (from 0-255 trans) so that you can directly interact with the screen (on place where that collor is on 0 trans), other collors will not have trans ability. Trying WinSetTrans or _GDIPlus_PenCreate (0x80FF0000,2) to set trans on that collor i think that it will not have any effect in this case.

"to be able to click-drag" if instead spot on that place you create small gui and use GUIGetCursorInfo() to detect when mouse is on that gui (spot) them use WinMove() with MouseGetPos to change spot position, after that put hotkey to delete last active gui.

Edit:

Try this post from Example Scripts to see if it can help you PNG as GUI

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 

Share this post


Link to post
Share on other sites

I wish it could be as the Clock example in AutoIt Advanced GUI Example, we can click through it and it's also always at the foremost. I also wish the cursor to always be a cross. I did what I could for the moment and I know it's not perfect. I wish every line and dot would have an ID I could use to then resize and reposition each line and dot created. I don't have much time to look up at functions and other scripts, so I'm doing with what I find first and seems easy to me.

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Here is what I've done rapidly for the moment. When I'll have more time, I'll put that in functions and improve the code to delete the useless things. There is still many advices I could use if you have. I want to add an history list to be able to do "undo" and "redo", I want to add the possibility to make more than one curve, the possibility to choose easier a dot when two or more dots are over each other, I want to add fast keys that wouldn't ask prompt and message boxes, I want to improve the way to find the best place the dot should be inserted and much more.

PS : Comments may not be updated and the code IS BADLY coded.

At this moment :

LeftClick = Add the next dot

RightClick = Insert a dot

XButton1 = End the curve and pastes in Excel (Path may not be the same as yours, I'll have to fix that to find the path)

Ctrl = Mouse-over a dot to have informations

Ctrl-LeftClick = Mouse-over a dot to move the dot

Ctrl-RightClick = Mouse-over a dot to delete the dot

Arrows = Mouse move ±1 pixel

#include <GuiConstantsEx.au3>
#include <GDIPlus.au3>
#Include <Misc.au3>
#include <WindowsConstants.au3> 


Global $hGUI, $hWnd, $hGraphic,$hGraphic,$x,$o,$o2,$m,$m2,$n,$xy[256][2],$t,$c,$i,$v[256][2],$r,$p,$dot,$moving, $mm; Max dimension of 256, don't know how to do more

HotKeySet("{ESC}","quitter"); Quit
HotKeySet("{F5}","rafraichir"); Refresh

; Temporary, must be able to do hold Ctrl and Shift while doing Arrows, as the mouse move
HotKeySet("{Left}","curseur")
HotKeySet("{Up}","curseur")
HotKeySet("{Right}","curseur")
HotKeySet("{Down}","curseur")

; To do : Enter = LClick, Shift-Enter = RClick, ...

Func curseur()
    If _IsPressed("25") Then
        $mm = MouseGetPos()
        MouseMove($mm[0]-1, $mm[1], 0)
    EndIf
    If _IsPressed("26") Then
        $mm = MouseGetPos()
        MouseMove($mm[0], $mm[1]-1, 0)
    EndIf
    If _IsPressed("27") Then
        $mm = MouseGetPos()
        MouseMove($mm[0]+1, $mm[1], 0)
    EndIf
    If _IsPressed("28") Then
        $mm = MouseGetPos()
        MouseMove($mm[0], $mm[1]+1, 0)
    EndIf
    $mm = MouseGetPos()
    If $x Then
        ToolTip("("&(($mm[0]-$o[0])/($m[0]-$o[0]))*($mx-$ox)+$ox&", "&(($mm[1]-$o[1])/($m[1]-$o[1]))*($my-$oy)+$oy&")"&@CRLF&"Cliquez pour copier cette valeur"&@CRLF&"Valeurs enregistrées : "&$n, Default, Default, Default, Default, 4)
    EndIf
;Sleep("100")
EndFunc

Func rafraichir()
    If $x Then
        _GDIPlus_GraphicsClear($hGraphic); The only way I found is to restart the drawing
        GUICtrlDelete($x)
        $x = GUICtrlCreateGraphic($o2[0],$m2[1],Abs($m[0]-$o[0]),Abs($m[1]-$o[1]))
        GUICtrlSetBkColor(-1, 0x00ff00)
        $hGraphic = _GDIPlus_GraphicsCreateFromHWND ($hWnd)
        $r = 0
        For $r = 0 To $n-1; Redraw the lines
            If $r = 0 Then
                _GDIPlus_GraphicsDrawLine ($hGraphic, $xy[$r][0]-$o2[0]-4, $xy[$r][1]-$m2[1], $xy[$r][0]-$o2[0]+4, $xy[$r][1]-$m2[1], $hPen1)
            Else
                _GDIPlus_GraphicsDrawLine ($hGraphic, $xy[$r-1][0]-$o2[0], $xy[$r-1][1]-$m2[1], $xy[$r][0]-$o2[0], $xy[$r][1]-$m2[1], $hPen)
                _GDIPlus_GraphicsDrawLine ($hGraphic, $xy[$r][0]-$o2[0]-4, $xy[$r][1]-$m2[1], $xy[$r][0]-$o2[0]+4, $xy[$r][1]-$m2[1], $hPen1)
            EndIf
            $v[$r][0] = (($xy[$r][0]-$o[0])/($m[0]-$o[0]))*($mx-$ox)+$ox; Resave the values
            $v[$r][1] = (($xy[$r][1]-$o[1])/($m[1]-$o[1]))*($my-$oy)+$oy
        Next
     EndIf
EndFunc

Func quitter()
    Exit
EndFunc

$mx = InputBox("Graphique", "Entrez la valeur maximale en X", 100, Default, 310, 140); Value of X max
If @error > 0 Then
    Exit
EndIf
$my = InputBox("Graphique", "Entrez la valeur maximale en Y", 100, Default, 310, 140); Value of Y max
If @error > 0 Then
    Exit
EndIf
$ox = InputBox("Graphique", "Entrez la valeur de l'origine en X", 0, Default, 310, 140); Value of X min
If @error > 0 Then
    Exit
EndIf
$oy = InputBox("Graphique", "Entrez la valeur de l'origine en Y", 0, Default, 310, 140); Value of Y min
If @error > 0 Then
    Exit
EndIf

$hGUI = GUICreate("Graphique",@DesktopWidth,@DesktopHeight,0,0,$WS_POPUP); Use min2 X and max2 Y  to define left and top
$hWnd = WinGetHandle("Graphique")
GUISetCursor(3, 1, $hWnd)
WinSetTrans($hGUI, "", (255/100)*40)
GUISetState(); Didn't really touch to this stuff

Do
    $o = MouseGetPos()
    $o2 = MouseGetPos()
    ToolTip("Cliquez sur l'origine ("&$ox&", "&$oy&")", Default, Default, Default, Default, 4); Get the position of the min X and min Y
Until _IsPressed("01")

Do; Only way I found to wait until click is released
Until Not _IsPressed("01")

Do
    $m = MouseGetPos()
    $m2 = MouseGetPos()
    ToolTip("Cliquez sur le maximum en XY ("&$mx&", "&$my&")", Default, Default, Default, Default, 4); Get the position of the max X and max Y
Until _IsPressed("01")

Do; Only way I found to wait until click is released
Until Not _IsPressed("01")

If $o[0] > $m[0] Then; Swap the min and the max X if the max X is to the left of the min X for GUI purpose
    $o2[0] = $m[0]
    $m2[0] = $o[0]
EndIf
If $o[1] < $m[1] Then; Swap the min and the max Y if the max Y is under the min Y for GUI purpose
    $o2[1] = $m[1]
    $m2[1] = $o[1]
EndIf

_GDIPlus_Startup ()
$x = GUICtrlCreateGraphic($o2[0],$m2[1],Abs($m[0]-$o[0]),Abs($m[1]-$o[1]))
GUICtrlSetBkColor(-1, 0x00ff00)

$hGraphic = _GDIPlus_GraphicsCreateFromHWND ($hWnd)
$hPen = _GDIPlus_PenCreate (0xFFFF0000,3)
$hPen1 = _GDIPlus_PenCreate (0xFF000000,8)

$n = 0; Counts the number of saved values
Do
    Do
        $t = MouseGetPos(); Temporary variable, I couldn't do directly $xy[$n] = MouseGetPos()
        $xy[$n][0] = $t[0]
        $xy[$n][1] = $t[1]
        $moving = -1
        
        While _IsPressed("11")
            $t = MouseGetPos(); Temporary variable, I couldn't do directly $xy[$n] = MouseGetPos()
            $dot = -1
            For $d = 0 To $n-1 
                If $t[0] >= $xy[$d][0]-4 and $t[0] <= $xy[$d][0]+4 and $t[1] >= $xy[$d][1]-4 and $t[1] <= $xy[$d][1]+4 Then; Look if mouse is over a dot
                    $dot = $d
                   ;ToolTip("Point "&$d+1&@CRLF&"("&$v[$d][0]&", "&$v[$d][1]&")", Default, Default, Default, Default, 4); Information about the current dot
                    ExitLoop
                Else
                    $dot = -1
                ;ToolTip("Positionnez le curseur sur un point", Default, Default, Default, Default, 4)
                EndIf
            Next
            If $dot >= 0 Then
                ToolTip("Point "&$dot+1&@CRLF&"("&$v[$dot][0]&", "&$v[$dot][1]&")", Default, Default, Default, Default, 4); Information about the current dot
            Else
                ToolTip("Positionnez le curseur sur un point", Default, Default, Default, Default, 4)
            EndIf
            
            While _IsPressed("01")
                If $moving = -1 Then
                    ToolTip("Positionnez le curseur sur un point", Default, Default, Default, Default, 4)
                    $t = MouseGetPos(); Temporary variable, I couldn't do directly $xy[$n] = MouseGetPos()
                    For $d = 0 To $n-1 
                        If $t[0] >= $xy[$d][0]-4 and $t[0] <= $xy[$d][0]+4 and $t[1] >= $xy[$d][1]-4 and $t[1] <= $xy[$d][1]+4 Then; Look if mouse is over a dot
                            ToolTip("Point "&$d+1&@CRLF&"("&$v[$d][0]&", "&$v[$d][1]&")", Default, Default, Default, Default, 4); Information about the current dot
                            $t = MouseGetPos(); Temporary variable, I couldn't do directly $xy[$n] = MouseGetPos()
                            $moving = $d
                            If $t[0] <> $xy[$d][0] or $t[1] <> $xy[$d][1] Then
                                $xy[$d][0] = $t[0]
                                $xy[$d][1] = $t[1]
                                rafraichir()
                                Sleep("50")
                            EndIf
                            ExitLoop
                        EndIf
                    Next
                Else
                    ToolTip("Point "&$moving+1&@CRLF&"("&$v[$moving][0]&", "&$v[$moving][1]&")", Default, Default, Default, Default, 4); Information about the current dot
                    $t = MouseGetPos(); Temporary variable, I couldn't do directly $xy[$n] = MouseGetPos()
                    If $t[0] <> $xy[$moving][0] or $t[1] <> $xy[$moving][1] Then
                        $xy[$moving][0] = $t[0]
                        $xy[$moving][1] = $t[1]
                        rafraichir()
                        Sleep("50")
                    EndIf
                EndIf
            WEnd
            $moving = -1
            
            If _IsPressed("02") Then; If RIGHTCLICK key is detected
            For $d = 0 To $n-1 
                If $t[0] >= $xy[$d][0]-4 and $t[0] <= $xy[$d][0]+4 and $t[1] >= $xy[$d][1]-4 and $t[1] <= $xy[$d][1]+4 Then; Look if mouse is over a dot
                    ToolTip("", Default, Default, Default, Default, 4); I hate when tooltip stucks where he shouldn't, so I delete it
                    If MsgBox(36, "Supprimer", "Supprimer ce point ?"&@CRLF&@CRLF&"Point "&$d+1&@CRLF&"("&$v[$d][0]&", "&$v[$d][1]&")") == 6 Then; Ask if you really want to delete that dot
                        _GDIPlus_GraphicsClear($hGraphic); The only way I found is to restart the drawing
                        GUICtrlDelete($x)
                        $x = GUICtrlCreateGraphic($o2[0],$m2[1],Abs($m[0]-$o[0]),Abs($m[1]-$o[1]))
                        GUICtrlSetBkColor(-1, 0x00ff00)
                        $hGraphic = _GDIPlus_GraphicsCreateFromHWND ($hWnd)
                        $r = 0
                    
                        While $d < $n; Shift the values of the dots
                            $xy[$d][0] = $xy[$d+1][0]
                            $xy[$d][1] = $xy[$d+1][1]
                            $d += 1
                        WEnd
                        $n -= 1; Decrease the number of dots
                    
                        For $r = 0 To $n-1; Redraw the lines
                            If $r = 0 Then
                                _GDIPlus_GraphicsDrawLine ($hGraphic, $xy[$r][0]-$o2[0]-4, $xy[$r][1]-$m2[1], $xy[$r][0]-$o2[0]+4, $xy[$r][1]-$m2[1], $hPen1)
                            Else
                                _GDIPlus_GraphicsDrawLine ($hGraphic, $xy[$r-1][0]-$o2[0], $xy[$r-1][1]-$m2[1], $xy[$r][0]-$o2[0], $xy[$r][1]-$m2[1], $hPen)
                                _GDIPlus_GraphicsDrawLine ($hGraphic, $xy[$r][0]-$o2[0]-4, $xy[$r][1]-$m2[1], $xy[$r][0]-$o2[0]+4, $xy[$r][1]-$m2[1], $hPen1)
                            EndIf
                            $v[$r][0] = (($xy[$r][0]-$o[0])/($m[0]-$o[0]))*($mx-$ox)+$ox; Resave the values
                            $v[$r][1] = (($xy[$r][1]-$o[1])/($m[1]-$o[1]))*($my-$oy)+$oy
                        Next
                        ExitLoop
                    EndIf
                EndIf
            Next
            EndIf
        WEnd
        
        If _IsPressed("02") Then; If RIGHTCLICK key is detected
            $dot = -1
            For $d = 0 To $n-2
                If ($xy[$d][0] < $t[0] and $xy[$d+1][0] >= $t[0]) or ($xy[$d+1][0] < $t[0] and $xy[$d][0] >= $t[0]) Then
                    $dot = $d+2
                    ExitLoop
                EndIf
            Next
            If $dot == -1 Then
                If ($xy[0][0] >= $t[0] and $xy[1][0] >= $xy[0][0]) or ($xy[0][0] < $t[0] and $xy[1][0] < $xy[0][0]) Then 
                    $dot = 1
                Else
                    $dot = $n+1
                EndIf
            EndIf
            ToolTip("", Default, Default, Default, Default, 4); I hate when tooltip stucks where he shouldn't, so I delete it
            $p = InputBox("Insérer", "Quelle position voulez-vous donner à ce point ?"&@CRLF&@CRLF&"("&(($xy[$n][0]-$o[0])/($m[0]-$o[0]))*($mx-$ox)+$ox&", "&(($xy[$n][1]-$o[1])/($m[1]-$o[1]))*($my-$oy)+$oy&")", $dot, Default, 310, 160)
            If Not @error Then
                _GDIPlus_GraphicsClear($hGraphic); The only way I found is to restart the drawing
                GUICtrlDelete($x)
                $x = GUICtrlCreateGraphic($o2[0],$m2[1],Abs($m[0]-$o[0]),Abs($m[1]-$o[1]))
                GUICtrlSetBkColor(-1, 0x00ff00)
                $hGraphic = _GDIPlus_GraphicsCreateFromHWND ($hWnd)
                $d = $n
    
                While $d >= $p-1; Shift the values of the dots
                    $xy[$d+1][0] = $xy[$d][0]
                    $xy[$d+1][1] = $xy[$d][1]
                    $d -= 1
                WEnd
                
                $xy[$p-1][0] = $t[0]
                $xy[$p-1][1] = $t[1]
                    
                For $r = 0 To $n; Redraw the lines
                    If $r = 0 Then
                        _GDIPlus_GraphicsDrawLine ($hGraphic, $xy[$r][0]-$o2[0]-4, $xy[$r][1]-$m2[1], $xy[$r][0]-$o2[0]+4, $xy[$r][1]-$m2[1], $hPen1)
                    Else
                        _GDIPlus_GraphicsDrawLine ($hGraphic, $xy[$r-1][0]-$o2[0], $xy[$r-1][1]-$m2[1], $xy[$r][0]-$o2[0], $xy[$r][1]-$m2[1], $hPen)
                        _GDIPlus_GraphicsDrawLine ($hGraphic, $xy[$r][0]-$o2[0]-4, $xy[$r][1]-$m2[1], $xy[$r][0]-$o2[0]+4, $xy[$r][1]-$m2[1], $hPen1)
                    EndIf
                    $v[$r][0] = (($xy[$r][0]-$o[0])/($m[0]-$o[0]))*($mx-$ox)+$ox; Resave the values
                    $v[$r][1] = (($xy[$r][1]-$o[1])/($m[1]-$o[1]))*($my-$oy)+$oy
                Next
                ExitLoop
            EndIf
        EndIf
        
        ToolTip("("&(($xy[$n][0]-$o[0])/($m[0]-$o[0]))*($mx-$ox)+$ox&", "&(($xy[$n][1]-$o[1])/($m[1]-$o[1]))*($my-$oy)+$oy&")"&@CRLF&"Cliquez pour copier cette valeur"&@CRLF&"Valeurs enregistrées : "&$n, Default, Default, Default, Default, 4)
        $v[$n][0] = (($xy[$n][0]-$o[0])/($m[0]-$o[0]))*($mx-$ox)+$ox; Saves the value
        $v[$n][1] = (($xy[$n][1]-$o[1])/($m[1]-$o[1]))*($my-$oy)+$oy
        
    Until (_IsPressed("01") and Not _IsPressed("11")) or _IsPressed("05"); XBUTTON1 should end the graphic
    
    Do; Waits for the mouse button to be released, the only way I found
    Until Not _IsPressed("01") or _IsPressed("05")
    
    If Not _IsPressed("05") Then
        
    If $n = 0 Then; Draw the line and/or the dot
        _GDIPlus_GraphicsDrawLine ($hGraphic, $xy[$n][0]-$o2[0]-4, $xy[$n][1]-$m2[1], $xy[$n][0]-$o2[0]+4, $xy[$n][1]-$m2[1], $hPen1)
    Else
        _GDIPlus_GraphicsDrawLine ($hGraphic, $xy[$n-1][0]-$o2[0], $xy[$n-1][1]-$m2[1], $xy[$n][0]-$o2[0], $xy[$n][1]-$m2[1], $hPen)
        _GDIPlus_GraphicsDrawLine ($hGraphic, $xy[$n][0]-$o2[0]-4, $xy[$n][1]-$m2[1], $xy[$n][0]-$o2[0]+4, $xy[$n][1]-$m2[1], $hPen1)
    EndIf
    
    $n += 1; Increase the number of saved values
    
    EndIf
    
Until _IsPressed("05"); End the graphic with XBUTTON1

$i = 0

ClipPut("X"&@TAB&"Y"); Title in clipboard

Do; Put the values in the clipboard
    $c = ClipGet()
    ClipPut($c&@CRLF&$v[$i][0]&@TAB&$v[$i][1])
    $i += 1
Until $i == $n

Run("C:\Program Files\Microsoft Office\Office11\EXCEL.exe", "", @SW_MAXIMIZE); Only way I found to run Excel.exe
WinWaitActive("Microsoft Excel"); Wait active
Sleep("100")
Send("{CTRLDOWN}v{CTRLUP}"); Paste the values
Edited by TheReveller

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

I was wondering how can I find the path of Excel ?

If I write Run("Excel.exe"), it won't work and I don't know why. You can do Run("Notepad.exe") and it will do it, but if you write Run("Excel.exe") it doesn't seem to find it, but on AutoHotkey it would work.

Thanks.

Edit :

I think I found something :

$path = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\excel.exe","Path")
Run($path&"EXCEL.exe", "", @SW_MAXIMIZE);

But why this won't work ?

$path = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\excel.exe","Path")
Run("EXCEL.exe", $path, @SW_MAXIMIZE);

Thanks.

Edited by TheReveller

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Hello,

I improved my code a little bit and I would like you to comment changes I could do. There is certainly many useless things in the code I can delete or some things I should code differently.

Can you tell me how bug-safe this is ?

Also, I am wondering why do I have extra empty lines when pasting in Excel and if I copy the clipboard in Notepad I also have extra TAB and CRLF.

Another is that my history functions aren't working well and I still have to improve my dot insert script.

By the way, I just had some weird crash where it said that $hHook wasn't declared and I had to restart my computer because the dialog box wouldn't stop.

PS : I'm not a programmer, I'm totally newbie at scripting.

Fast instructions about the script :

- Start the script

- Do "Ok" for the default values at the five inputboxes that will appear (last one has "Graph1" as default value)

- Click somewhere on the bottom-left corner of the screen for (0, 0)

- Click somewhere on the upper-right corner of the screen for (100, 100)

- Click to draw

Controls :

- Escape : Quits program

- F5 : Refreshes the draw

- LeftClick or Enter : Adds a dot to the current graph

- XButton1 or End : Ends the draw, opens Excel and pastes the values one graph per sheet and puts in clipboard all the values so you can paste in Notepad

- Space : Adds a new graph

- Alt-Space : Inserts a new graph

- Alt-Delete : Deletes the current graph

- Ctrl-Space : Changes the name of the current graph

- Scroll or +/- : Changes the selected graph

- RightClick or Alt-Enter : Inserts a dot to the current graph at some choosen position

- Arrows : Moves the mouse slowly

- Ctrl : Move the mouse over a dot of the current graph to have info

- Ctrl-Scroll or Ctrl-+/- : If over a dot, changes the selected dot if stacked

- Ctrl-LeftClick or Ctrl-Alt-Arrows : Moves the selected dot

- Ctrl-RightClick or Ctrl-Delete : Deletes the current dot of the current graph

- Ctrl-Z : Undo (May not work correctly, but should be crash-safe)

- Ctrl-R : Redo (Won't work correctly, but should be crash-safe)

Thanks.

#include <GuiConstantsEx.au3>
#include <GDIPlus.au3>
#include <Misc.au3>
#include <WindowsConstants.au3> 
#include <Excel.au3>
#include <WinAPI.au3>

; ====================================
; Detects Mouse Wheel - Start
; ====================================

Global $wheel = 0

Global Const $WM_MOUSEWHEEL = 0x020A

Global Const $tagMSLLHOOKSTRUCT = $tagPOINT&';dword mouseData;dword flags;dword time;ulong_ptr dwExtraInfo'

$hFunc = DllCallbackRegister("Mouse_LL", "long", "int;wparam;lparam")
$pFunc = DllCallbackGetPtr($hFunc)
$hHook = _WinAPI_SetWindowsHookEx($WH_MOUSE_LL, $pFunc, _WinAPI_GetModuleHandle(0))

Func OnAutoItExit()
    _WinAPI_UnhookWindowsHookEx($hHook)
    DllCallbackFree($hFunc)
EndFunc

Func Mouse_LL($iCode, $iwParam, $ilParam)
    Local $tMSLLHOOKSTRUCT = DllStructCreate($tagMSLLHOOKSTRUCT, $ilParam)
    
    If $iCode < 0 Then
        Return _WinAPI_CallNextHookEx($hHook, $iCode, $iwParam, $ilParam)
    EndIf
    
    If $iwParam = $WM_MOUSEWHEEL Then
        Local $iValue = DllStructGetData($tMSLLHOOKSTRUCT, 'mouseData')/2^16
        If BitAND($iValue, 0x8000) Then $iValue = BitOR($iValue, 0xFFFF0000)
        
        If $iValue == 120 Then
            $wheel = 1
        ElseIf $iValue == -120 Then
            $wheel = -1
        Else
            $wheel = 0
        EndIf
    EndIf
        
    Return _WinAPI_CallNextHookEx($hHook, $iCode, $iwParam, $ilParam)
EndFunc

; ====================================
; Detects Mouse Wheel - End
; ====================================

; For _IsPressed
Global Const $_LButton = "01"
Global Const $_RButton = "02"
Global Const $_XButton1 = "05"
Global Const $_Enter = "0D"
Global Const $_Ctrl = "11"
Global Const $_Alt = "12"
Global Const $_Space = "20"
Global Const $_End = "23"
Global Const $_Left = "25"
Global Const $_Up = "26"
Global Const $_Right = "27"
Global Const $_Down = "28"
Global Const $_Delete = "2E"
Global Const $_R = "52"
Global Const $_Z = "5A"
Global Const $_Add = "6B"
Global Const $_Substract = "6D"

Global $hGUI, $hGUIGraphic = 0, $hWnd, $hGraphic, $hDot, $hPen; Graph

Global $colors[8]; Graph colors
$colors[0] = 0xFFFF0000; Red
$colors[1] = 0xFF0000FF; Blue
$colors[2] = 0xFFFFFF00; Yellow
$colors[3] = 0xFFFF00FF; Pink
$colors[4] = 0xFF00FFFF; Light Blue
$colors[5] = 0xFFFF8000; Orange
$colors[6] = 0xFF800080; Purple
$colors[7] = 0xFFC0C0C0; Light Gray

Global $history[256][8][256][2], $histn[256][8], $histg[256], $histnb = 0, $histnow = 0; History
Global $graph[8][256][2], $graphname[8], $graphnb = 0, $graphnow = 0, $temp[2], $n[8], $ntotal = 0; Dots
Global $saved[8][256][2]; Saved dots

Global $dotnow = 0, $dotlist[256], $dotnb = 0, $pos, $dot, $d; Dot management

Global $i, $j, $k; Loops

Global $input, $clipboard, $cancel; Inputs

Global $mx, $my, $ox, $oy, $m[2], $o[2], $m2[2], $o2[2]; Min/max

Global $mm[2], $moving, $moved = 0; Mouse management

Global $path = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\excel.exe","Path"); Excel path

HotKeySet("{ESC}","quitnow"); Quit
HotKeySet("{F5}","regraph"); Refresh

Func quitnow(); Quits
    Exit
EndFunc

Func _Mod($value1, $value2); Looping Mod
    Return Abs(Mod(Mod($value1,$value2)+$value2,$value2))
EndFunc

Func movecursor(); Moves cursor with arrows
    If _IsPressed($_Left) Then
        $mm = MouseGetPos()
        MouseMove($mm[0]-1, $mm[1], 0)
    EndIf
    If _IsPressed($_Up) Then
        $mm = MouseGetPos()
        MouseMove($mm[0], $mm[1]-1, 0)
    EndIf
    If _IsPressed($_Right) Then
        $mm = MouseGetPos()
        MouseMove($mm[0]+1, $mm[1], 0)
    EndIf
    If _IsPressed($_Down) Then
        $mm = MouseGetPos()
        MouseMove($mm[0], $mm[1]+1, 0)
    EndIf
    $mm = MouseGetPos()
    Sleep("150")
EndFunc

Func regraph(); Refreshes
    If $hGUIGraphic Then
        _GDIPlus_GraphicsClear($hGraphic); The only way I found is to restart the drawing
        GUICtrlDelete($hGUIGraphic)
        $hGUIGraphic = GUICtrlCreateGraphic($o2[0],$m2[1],Abs($m[0]-$o[0]),Abs($m[1]-$o[1]))
        GUICtrlSetBkColor(-1, 0x00ff00)
        $hGraphic = _GDIPlus_GraphicsCreateFromHWND ($hWnd)
        $i = 0
        $j = 0
        For $j = 0 To $graphnb; For each graph
            For $i = 0 To $n[$j]-1; Redraw the lines
                $hPen = _GDIPlus_PenCreate ($colors[$j],3)
                If $i = 0 Then
                    _GDIPlus_GraphicsDrawLine ($hGraphic, $graph[$j][$i][0]-$o2[0]-4, $graph[$j][$i][1]-$m2[1], $graph[$j][$i][0]-$o2[0]+4, $graph[$j][$i][1]-$m2[1], $hDot)
                Else
                    _GDIPlus_GraphicsDrawLine ($hGraphic, $graph[$j][$i-1][0]-$o2[0], $graph[$j][$i-1][1]-$m2[1], $graph[$j][$i][0]-$o2[0], $graph[$j][$i][1]-$m2[1], $hPen)
                    _GDIPlus_GraphicsDrawLine ($hGraphic, $graph[$j][$i][0]-$o2[0]-4, $graph[$j][$i][1]-$m2[1], $graph[$j][$i][0]-$o2[0]+4, $graph[$j][$i][1]-$m2[1], $hDot)
                EndIf
                $saved[$j][$i][0] = (($graph[$j][$i][0]-$o[0])/($m[0]-$o[0]))*($mx-$ox)+$ox; Resave the values
                $saved[$j][$i][1] = (($graph[$j][$i][1]-$o[1])/($m[1]-$o[1]))*($my-$oy)+$oy
            Next
        Next
     EndIf
EndFunc

Func deletedot($whichdot, $whichgraph); Deletes a dot
    ToolTip("", Default, Default, Default, Default, 4); I hate when tooltip stucks where he shouldn't, so I delete it
    If MsgBox(36, "Supprimer", "Supprimer ce point ?"&@CRLF&@CRLF&"Courbe : "&$graphname[$whichgraph]&@CRLF&"Point "&$whichdot+1&@CRLF&"("&$saved[$whichgraph][$whichdot][0]&", "&$saved[$whichgraph][$whichdot][1]&")") == 6 Then; Ask if you really want to delete that dot
        Do; Avoids some bugs
            Sleep("100")
        Until Not _IsPressed($_Enter)
        $d = $whichdot
        While $d < $n[$whichgraph]; Shifts the values of the dots
            $graph[$whichgraph][$d][0] = $graph[$whichgraph][$d+1][0]
            $graph[$whichgraph][$d][1] = $graph[$whichgraph][$d+1][1]
            $d += 1
        WEnd
        $n[$whichgraph] -= 1; Decreases the number of dots
        $ntotal -= 1
        savehist()
        regraph()
    EndIf
EndFunc

Func deletegraph(); Deletes a dot
    ToolTip("", Default, Default, Default, Default, 4); I hate when tooltip stucks where he shouldn't, so I delete it
    If MsgBox(36, "Supprimer", "Supprimer cette courbe ?"&@CRLF&@CRLF&$graphname[$graphnow]) == 6 Then; Ask if you really want to delete that graph
        Do; Avoids some bugs
            Sleep("100")
        Until Not _IsPressed($_Enter)
        $i = $graphnow
        $ntotal = 0
        While $i < $graphnb; Shifts graphs
            For $j = 0 To $n[$i]
                $graph[$i][$j][0] = $graph[$i+1][$j][0]
                $graph[$i][$j][1] = $graph[$i+1][$j][1]
            Next
            $graphname[$i] = $graphname[$i+1]
            $n[$i] = $n[$i+1]
            $ntotal += 1
            $i += 1
        WEnd
        $graphnb -= 1
        $graphnow = $graphnb
        savehist()
        regraph()
    EndIf
EndFunc

Func overadot($whichgraph); Returns the dot the mouse is over in a graph
    $temp = MouseGetPos(); Temporary variable
    $dotnb = 0; Counts the number of dots
    For $d = 0 To $n[$whichgraph]-1 
        If $temp[0] >= $graph[$whichgraph][$d][0]-4 and $temp[0] <= $graph[$whichgraph][$d][0]+4 and $temp[1] >= $graph[$whichgraph][$d][1]-4 and $temp[1] <= $graph[$whichgraph][$d][1]+4 Then; Look if mouse is over a dot
            $dotlist[$dotnb] = $d; Lists the dots
            $dotnb += 1; Increases the number of dots found
        EndIf
    Next
    If $dotnb < $dotnow Then; Avoids some bugs
        $dotnow = $dotnb
    EndIf
    If $dotnb == 0 Then; If no dot found
        $dotlist[$dotnow] = -1
    EndIf
    Return $dotlist[$dotnow]
EndFunc

Func insertdot($whichgraph); Inserts a dot
    $temp = MouseGetPos(); Temporary variable
    $dot = -1
    For $d = 0 To $n[$whichgraph]-2
        If ($graph[$whichgraph][$d][0] < $temp[0] and $graph[$whichgraph][$d+1][0] >= $temp[0]) or ($graph[$whichgraph][$d+1][0] < $temp[0] and $graph[$whichgraph][$d][0] >= $temp[0]) Then; Some AI insert for default value, has to be improved
            $dot = $d+2
            ExitLoop
        EndIf
    Next
    If $dot == -1 Then; Still AI to be improved
        If ($graph[$whichgraph][0][0] >= $temp[0] and $graph[$whichgraph][1][0] >= $graph[$whichgraph][0][0]) or ($graph[$whichgraph][0][0] < $temp[0] and $graph[$whichgraph][1][0] < $graph[$whichgraph][0][0]) Then 
            $dot = 1
        Else
            $dot = $n[$whichgraph]+1
        EndIf
    EndIf
    ToolTip("", Default, Default, Default, Default, 4); I hate when tooltip stucks where he shouldn't, so I delete it
    Do
        $input = InputBox("Insérer", "Quelle position voulez-vous donner à ce point ?"&@CRLF&@CRLF&$graphname[$graphnow]&@CRLF&"("&(($graph[$whichgraph][$n[$whichgraph]][0]-$o[0])/($m[0]-$o[0]))*($mx-$ox)+$ox&", "&(($graph[$whichgraph][$n[$whichgraph]][1]-$o[1])/($m[1]-$o[1]))*($my-$oy)+$oy&")", $dot, Default, 310, 160); Still ask where you want that dot
        $cancel = @error
        If (Not StringIsDigit($input) Or $input < 1 Or $input > $n[$whichgraph]+1) And $cancel <> 1 Then
            MsgBox(16, "Graphique", "Veuillez entrer une position valide")
        EndIf
    Until (StringIsDigit($input) And $input >= 1 And $input <= $n[$whichgraph]+1) Or $cancel == 1
    If $cancel == 0 Then
        _GDIPlus_GraphicsClear($hGraphic); The only way I found is to restart the drawing
        GUICtrlDelete($hGUIGraphic)
        $hGUIGraphic = GUICtrlCreateGraphic($o2[0],$m2[1],Abs($m[0]-$o[0]),Abs($m[1]-$o[1]))
        GUICtrlSetBkColor(-1, 0x00ff00)
        $hGraphic = _GDIPlus_GraphicsCreateFromHWND ($hWnd)
        $d = $n[$whichgraph]
    
        While $d >= $input-1; Shift the values of the dots
            $graph[$whichgraph][$d+1][0] = $graph[$whichgraph][$d][0]
            $graph[$whichgraph][$d+1][1] = $graph[$whichgraph][$d][1]
            $d -= 1
        WEnd
                
        $graph[$whichgraph][$input-1][0] = $temp[0]
        $graph[$whichgraph][$input-1][1] = $temp[1]
        $n[$graphnow] += 1
        $ntotal += 1
        savehist()
        regraph()
    EndIf
Do; Avoids some bugs
    Sleep("100")
Until Not _IsPressed($_LButton) And Not _IsPressed($_Enter)
EndFunc

Func insertgraph()
    ToolTip("", Default, Default, Default, Default, 4); I hate when tooltip stucks where he shouldn't, so I delete it
    Do
        $pos = InputBox("Insérer", "Quelle position voulez-vous donner à cette courbe ?", $graphnow+1, Default, 310, 160); New graph position
        $cancel = @error
        If (Not StringIsDigit($pos) Or $pos < 1 Or $pos > $graphnb+2) And $cancel <> 1 Then
            MsgBox(16, "Graphique", "Veuillez entrer une position valide")
        EndIf
    Until (StringIsDigit($pos) And $pos >= 1 And $pos <= $graphnb+2) Or $cancel == 1
    If $cancel == 0 Then
        $input = InputBox("Graphique", "Entrez le nom de la courbe "&$pos, "Graph"&$pos, Default, 310, 140); Ask for new graph name
        $cancel = @error
    EndIf
    If $cancel == 0 Then
        For $i = $graphnb To $pos-1 Step -1; Shifts graphs
            For $j = 0 To $n[$i]-1
                $graph[$i+1][$j][0] = $graph[$i][$j][0]
                $graph[$i+1][$j][1] = $graph[$i][$j][1]
            Next
            $n[$i+1] = $n[$i]
            $graphname[$i+1] = $graphname[$i]
        Next
        $graphnb += 1
        $graphnow = $pos-1
        $graphname[$graphnow] = $input
        $n[$graphnow] = 0
        savehist()
        regraph()
    EndIf
    Do; Avoids some bugs
        Sleep("100")
    Until Not _IsPressed($_LButton) And Not _IsPressed($_Enter)
EndFunc

Func savehist(); Has to be fixed
    If $histnb < 256 Then
        For $i = 0 To $graphnb
            For $j = 0 To $n[$i]
                $history[$histnb][$i][$j][0] = $graph[$i][$j][0]
                $history[$histnb][$i][$j][1] = $graph[$i][$j][1]
            Next
            $histn[$histnb][$i] = $n[$i]
        Next
        $histg[$histnb] = $graphnb
        $histnow += 1
        $histnb = $histnow
    Else
        For $k = 0 To $histnb-2
            For $i = 0 To $graphnb
                For $j = 0 To $n[$i]
                    $history[$k][$i][$j][0] = $history[$k+1][$i][$j][0]
                    $history[$k][$i][$j][1] = $history[$k+1][$i][$j][1]
                Next
                $histn[$k][$i] = $histn[$k+1][$i]
            Next
            $histg[$k] = $histg[$k+1] 
        Next
        savehist()
    EndIf
EndFunc

Func undo(); Undo the previous action, has to be fixed
    If $histnow > 0 Then
        $histnow -= 1
        $ntotal = 0
        For $i = 0 To $histg[$histnow]
            For $j = 0 To $histn[$histnow][$i]
                 $graph[$i][$j][0] = $history[$histnow][$i][$j][0]
                 $graph[$i][$j][1] = $history[$histnow][$i][$j][1]
            Next
            $n[$i] = $histn[$histnow][$i]
            $ntotal += $n[$i]
        Next
        $graphnb = $histg[$histnow]
        $graphnow = $histg[$histnow]
        regraph()
    EndIf
EndFunc

Func redo(); Redo the next action, has to be fixed
    If $histnow < $histnb-1 Then
        $histnow += 1
        $ntotal = 0
        For $i = 0 To $histg[$histnow]
            For $j = 0 To $histn[$histnow][$i]
                 $graph[$i][$j][0] = $history[$histnow][$i][$j][0]
                 $graph[$i][$j][1] = $history[$histnow][$i][$j][1]
            Next
            $n[$i] = $histn[$histnow][$i]
            $ntotal += $n[$i]
        Next
        $graphnb = $histg[$histnow]
        $graphnow = $histg[$histnow]
        regraph()
    EndIf
EndFunc

Do
    $mx = InputBox("Graphique", "Entrez la valeur maximale en X", 100, Default, 310, 140); Value of X max
    If @error > 0 Then
        Exit
    EndIf
    If Not StringIsFloat($mx) And Not StringIsDigit($mx) Then
        MsgBox(16, "Graphique", "Veuillez entrer un nombre valide")
    EndIf
Until StringIsFloat($mx) Or StringIsDigit($mx)
Do
    $my = InputBox("Graphique", "Entrez la valeur maximale en Y", 100, Default, 310, 140); Value of Y max
    If @error > 0 Then
        Exit
    EndIf
    If Not StringIsFloat($my) And Not StringIsDigit($my) Then
        MsgBox(16, "Graphique", "Veuillez entrer un nombre valide")
    EndIf
Until StringIsFloat($my) Or StringIsDigit($my)
Do
    $ox = InputBox("Graphique", "Entrez la valeur de l'origine en X", 0, Default, 310, 140); Value of X min
    If @error > 0 Then
        Exit
    EndIf
    If Not StringIsFloat($ox) And Not StringIsDigit($ox) Then
        MsgBox(16, "Graphique", "Veuillez entrer un nombre valide")
    EndIf
Until StringIsFloat($ox) Or StringIsDigit($ox)  
Do
    $oy = InputBox("Graphique", "Entrez la valeur de l'origine en Y", 0, Default, 310, 140); Value of Y min
    If @error > 0 Then
        Exit
    EndIf
    If Not StringIsFloat($oy) And Not StringIsDigit($oy) Then
        MsgBox(16, "Graphique", "Veuillez entrer un nombre valide")
    EndIf
Until StringIsFloat($oy) Or StringIsDigit($oy)

$graphname[0] = InputBox("Graphique", "Entrez le nom de la courbe 1", "Graph1", Default, 310, 140); Graph name

Do; Avoids some bugs
    Sleep("100")
Until Not _IsPressed($_LButton) And Not _IsPressed($_Enter)

$hGUI = GUICreate("Graphique",@DesktopWidth,@DesktopHeight,0,0,$WS_POPUP); Graph stuff, didn't really touch it
$hWnd = WinGetHandle("Graphique")
GUISetCursor(3, 1, $hWnd)
WinSetTrans($hGUI, "", (255/100)*40)
GUISetState()

Do
    If _IsPressed($_Left) Or _IsPressed($_Up) Or _IsPressed($_Right) Or _IsPressed($_Down) Then; Moves cursor with arrows
        movecursor()
    EndIf
    $o = MouseGetPos()
    $o2 = MouseGetPos()
    ToolTip("Cliquez sur l'origine ("&$ox&", "&$oy&")", Default, Default, Default, Default, 4); Get the position of the min X and min Y
Until _IsPressed($_LButton) Or _IsPressed($_Enter)

Do; Avoids some bugs
    Sleep("100")
Until Not _IsPressed($_LButton) And Not _IsPressed($_Enter)

Do
    If _IsPressed($_Left) Or _IsPressed($_Up) Or _IsPressed($_Right) Or _IsPressed($_Down) Then; Moves cursor with arrows
        movecursor()
    EndIf
    $m = MouseGetPos()
    $m2 = MouseGetPos()
    ToolTip("Cliquez sur le maximum en XY ("&$mx&", "&$my&")", Default, Default, Default, Default, 4); Get the position of the max X and max Y
Until (_IsPressed($_LButton) Or _IsPressed($_Enter)) And $m[0] <> $o[0] And $m[1] <> $o[1]

Do; Avoids some bugs
    Sleep("100")
Until Not _IsPressed($_LButton) And Not _IsPressed($_Enter)

If $o[0] > $m[0] Then; Swap the min and the max X if the max X is to the left of the min X for GUI purpose
    $o2[0] = $m[0]
    $m2[0] = $o[0]
EndIf
If $o[1] < $m[1] Then; Swap the min and the max Y if the max Y is under the min Y for GUI purpose
    $o2[1] = $m[1]
    $m2[1] = $o[1]
EndIf

_GDIPlus_Startup (); Graph stuff
$hGUIGraphic = GUICtrlCreateGraphic($o2[0],$m2[1],Abs($m[0]-$o[0]),Abs($m[1]-$o[1]))
GUICtrlSetBkColor(-1, 0x00ff00)

$hGraphic = _GDIPlus_GraphicsCreateFromHWND ($hWnd)
$hPen = _GDIPlus_PenCreate ($colors[$graphnow],3)
$hDot = _GDIPlus_PenCreate (0xFF000000,8)

$n[$graphnow] = 0; Counts the number of saved values
savehist(); First save for history

While Not _IsPressed($_XButton1) And Not _IsPressed($_End); Loop ends with XButton1 or End
    
    While Not (_IsPressed($_LButton) And Not _IsPressed($_Ctrl)) And Not (_IsPressed($_Enter) And Not _IsPressed($_Alt)) And Not _IsPressed($_XButton1) And Not _IsPressed($_End); Loop ends with LButton (must not be holding Ctrl) or Enter (must not be holding Alt) or XButton1 or End
        
        $temp = MouseGetPos(); Temporary variable
        $graph[$graphnow][$n[$graphnow]][0] = $temp[0]
        $graph[$graphnow][$n[$graphnow]][1] = $temp[1]
        $moving = -1; Not moving a dot
        
        If _IsPressed($_Left) Or _IsPressed($_Up) Or _IsPressed($_Right) Or _IsPressed($_Down) Then; Moves cursor with arrows
            movecursor()
        EndIf
        
        If $Wheel == 1 Or _IsPressed($_Add) Then; Mouse wheel or +/- changes selected graph
            $graphnow = _Mod($graphnow+1, $graphnb+1)
            $Wheel = 0
            If _IsPressed($_Add) Then
                Sleep("200")
            EndIf
        ElseIf $Wheel == -1 Or _IsPressed($_Substract) Then
            $graphnow = _Mod($graphnow-1, $graphnb+1)
            $Wheel = 0
            If _IsPressed($_Substract) Then
                Sleep("200")
            EndIf
        EndIf
        
        While _IsPressed($_Ctrl); While holding Ctrl
            $temp = MouseGetPos(); Temporary variable
            $dot = overadot($graphnow); Finds if mouse over a dot
            
            If _IsPressed($_Z) Then; Ctrl-Z : undo
                undo()
                Do; Avoids some bugs
                    Sleep("100")
                Until Not _IsPressed($_Z)
            EndIf
            If _IsPressed($_R) Then; Ctrl-R : redo
                redo()
                Do; Avoids some bugs
                    Sleep("100")
                Until Not _IsPressed($_R)
            EndIf
            
            If _IsPressed($_Left) Or _IsPressed($_Up) Or _IsPressed($_Right) Or _IsPressed($_Down) Then; Moves cursor with arrows
                movecursor()
            EndIf
            
            If _IsPressed($_Space) Then; Changes current graph name
                $input = InputBox("Graphique", "Quel nom voulez-vous donner à cette courbe ?"&@CRLF&@CRLF&$graphname[$graphnow], $graphname[$graphnow], Default, 310, 160)
                If Not @error Then
                    $graphname[$graphnow] = $input
                EndIf
                Do; Avoids some bugs
                    Sleep("100")
                Until Not _IsPressed($_LButton) And Not _IsPressed($_Enter)
            EndIf
    
            If $dot >= 0 Then; If mouve is over a dot
                If $Wheel == 1 Or _IsPressed($_Add) Then; Mouse wheel or +/- changes selected dot
                    $dotnow = _Mod($dotnow+1, $dotnb)
                    $Wheel = 0
                    If _IsPressed($_Add) Then; Avoids some bugs
                        Sleep("200")
                    EndIf
                ElseIf $Wheel == -1 Or _IsPressed($_Substract) Then
                    $dotnow = _Mod($dotnow-1, $dotnb)
                    $Wheel = 0
                    If _IsPressed($_Substract) Then; Avoids some bugs
                        Sleep("200")
                    EndIf
                EndIf
                ToolTip("Courbe : "&$graphname[$graphnow]&@CRLF&"Point "&$dot+1&" ["&$dotnb&"] "&@CRLF&"("&$saved[$graphnow][$dot][0]&", "&$saved[$graphnow][$dot][1]&")", Default, Default, Default, Default, 4); Information about the current dot
            Else
                ToolTip("Positionnez le curseur sur un point", Default, Default, Default, Default, 4); Mouse not over a dot
            EndIf
            
            While _IsPressed($_LButton) Or  (_IsPressed($_Alt) And (_IsPressed($_Left) Or _IsPressed($_Up) Or _IsPressed($_Right) Or _IsPressed($_Down))); While Ctrl-LButton or Ctrl-Alt-Arrows
                If _IsPressed($_Left) Or _IsPressed($_Up) Or _IsPressed($_Right) Or _IsPressed($_Down) Then; Moves cursor with arrows
                    movecursor()
                EndIf
                If $moving = -1 Then; If wasn't previously moving
                    ToolTip("Positionnez le curseur sur un point", Default, Default, Default, Default, 4)
                    $temp = MouseGetPos(); Temporary variable
                    If overadot($graphnow) > -1 Then; Look if mouse is over a dot
                        $dot = overadot($graphnow)
                        $moving = $dot; Selects the dot to hold and move
                        ToolTip("Courbe : "&$graphname[$graphnow]&@CRLF&"Point "&$dot+1&@CRLF&"("&$saved[$graphnow][$dot][0]&", "&$saved[$graphnow][$dot][1]&")", Default, Default, Default, Default, 4); Information about the current dot
                        $temp = MouseGetPos(); Temporary variable
                        If $temp[0] <> $graph[$graphnow][$dot][0] or $temp[1] <> $graph[$graphnow][$dot][1] Then; Moves the dot when mouse move
                            $graph[$graphnow][$dot][0] = $temp[0]
                            $graph[$graphnow][$dot][1] = $temp[1]
                            regraph()
                            $moved = 1; Dot has been moved
                            Sleep("50")
                        EndIf
                    EndIf
                Else; If a dot is already selected, keep holding and moving
                    ToolTip("Courbe : "&$graphname[$graphnow]&@CRLF&"Point "&$moving+1&@CRLF&"("&$saved[$graphnow][$moving][0]&", "&$saved[$graphnow][$moving][1]&")", Default, Default, Default, Default, 4); Information about the current dot
                    $temp = MouseGetPos(); Temporary variable
                    If $temp[0] <> $graph[$graphnow][$moving][0] or $temp[1] <> $graph[$graphnow][$moving][1] Then; Moves the dot when mouse move
                        $graph[$graphnow][$moving][0] = $temp[0]
                        $graph[$graphnow][$moving][1] = $temp[1]
                        regraph()
                        $move = 1; Dot has been moved
                        Sleep("50")
                    EndIf
                EndIf
            WEnd
            $moving = -1; Dot released
            If $moved Then; Dot has been moved, saves now the new coordinates in history
                savehist()
                $moved = 0
            EndIf
            
            If _IsPressed($_RButton) Or _IsPressed($_Delete) Then; If Ctrl-RButton or Ctrl-Delete
                If overadot($graphnow) > -1 Then; If mouse is over a dot
                    deletedot(overadot($graphnow),$graphnow); Deletes the dot
                EndIf
            EndIf
        WEnd
        
        If _IsPressed($_Alt) And _IsPressed($_Delete) And $graphnb > 0 Then
            deletegraph()
        EndIf
        
        If _IsPressed($_Alt) And _IsPressed($_Space) And $graphnb < 8 Then
            insertgraph()
        EndIf
        
        If _IsPressed($_Space) And Not _IsPressed($_Ctrl) And Not _IsPressed($_Alt) Then; If Space while not holding Ctrl
            ToolTip("", Default, Default, Default, Default, 4); I hate when tooltip stucks where he shouldn't, so I delete it
            If $graphnb < 7 Then
                $graphname[$graphnb+1] = InputBox("Graphique", "Entrez le nom de la courbe "&$graphnb+2, "Graph"&$graphnb+2, Default, 310, 140); Ask for new graph name
                If Not @error Then; Adds the new graph
                    $graphnb += 1
                    $graphnow = $graphnb
                    $n[$graphnow] = 0
                    $hPen = _GDIPlus_PenCreate ($colors[$graphnow],3); New color for the graph
                EndIf
            Else
                MsgBox(16, "Graphique", "Quantité maximale de courbes atteinte"); Eight graphs is max
            EndIf
            Do; Avoids some bugs
                Sleep("100")
            Until Not _IsPressed($_Enter) And Not _IsPressed($_Space)
        EndIf
        
        If _IsPressed($_RButton) Or (_IsPressed($_Alt) And _IsPressed($_Enter)) Then; If RButton or Alt-Enter
            insertdot($graphnow); Inserts a dot
        EndIf
        
        ToolTip("Courbe : "&$graphname[$graphnow]&@CRLF&"("&(($graph[$graphnow][$n[$graphnow]][0]-$o[0])/($m[0]-$o[0]))*($mx-$ox)+$ox&", "&(($graph[$graphnow][$n[$graphnow]][1]-$o[1])/($m[1]-$o[1]))*($my-$oy)+$oy&")"&@CRLF&"Valeurs enregistrées : "&$n[$graphnow]&" ["&$ntotal&"]", Default, Default, Default, Default, 4); General info
    
    WEnd

    If Not _IsPressed($_XButton1) And Not _IsPressed($_End) Then; If XButton1 or End weren't pressed
        Do; Avoids some bugs
                Sleep("100")
        Until (Not _IsPressed($_LButton) And Not _IsPressed($_Enter))

        If $n[$graphnow] == 0 Then; Draws the line and/or the dot
            _GDIPlus_GraphicsDrawLine ($hGraphic, $graph[$graphnow][$n[$graphnow]][0]-$o2[0]-4, $graph[$graphnow][$n[$graphnow]][1]-$m2[1], $graph[$graphnow][$n[$graphnow]][0]-$o2[0]+4, $graph[$graphnow][$n[$graphnow]][1]-$m2[1], $hDot)
        Else
            _GDIPlus_GraphicsDrawLine ($hGraphic, $graph[$graphnow][$n[$graphnow]-1][0]-$o2[0], $graph[$graphnow][$n[$graphnow]-1][1]-$m2[1], $graph[$graphnow][$n[$graphnow]][0]-$o2[0], $graph[$graphnow][$n[$graphnow]][1]-$m2[1], $hPen)
            _GDIPlus_GraphicsDrawLine ($hGraphic, $graph[$graphnow][$n[$graphnow]][0]-$o2[0]-4, $graph[$graphnow][$n[$graphnow]][1]-$m2[1], $graph[$graphnow][$n[$graphnow]][0]-$o2[0]+4, $graph[$graphnow][$n[$graphnow]][1]-$m2[1], $hDot)
        EndIf
        
        $saved[$graphnow][$n[$graphnow]][0] = (($graph[$graphnow][$n[$graphnow]][0]-$o[0])/($m[0]-$o[0]))*($mx-$ox)+$ox; Saves the value
        $saved[$graphnow][$n[$graphnow]][1] = (($graph[$graphnow][$n[$graphnow]][1]-$o[1])/($m[1]-$o[1]))*($my-$oy)+$oy
    
        $n[$graphnow] += 1; Increases the number of saved values
        $ntotal += 1
        regraph()
        savehist(); Saves history
    EndIf
    
WEnd; End the graphic with XBUTTON1

$oExcel = _ExcelBookNew(); Opens Excel
_ExcelSheetDelete($oExcel, 2); Deletes extra sheets
_ExcelSheetDelete($oExcel, 2)
_ExcelSheetNameSet($oExcel, $graphname[0]); Sets the name of the sheet
_ExcelSheetMove($oExcel, $graphname[0], 2, True); Place it first

For $i = 0 To $graphnb; Copies all the values of the each graph in one sheet per graph
    ClipPut("X"&@TAB&"Y")
    Sleep("100")
    For $j = 0 To $n[$i]
        $clipboard = ClipGet()
        ClipPut($clipboard&@CRLF&$saved[$i][$j][0]&@TAB&$saved[$i][$j][1])
    Next
    Sleep("100")
    Send("{CTRLDOWN}v{CTRLUP}")
    Sleep("100")
    ClipPut("X"&@TAB&"Y")
    If $i < $graphnb Then
        Sleep("100")
        _ExcelSheetAddNew($oExcel, $graphname[$i+1])
        Sleep("100")
        _ExcelSheetMove($oExcel, $graphname[$i+1], $i+2, False)
    EndIf
Next

ClipPut("")

For $i = 0 To $graphnb; Still, copies all the values in clipboard if you want to paste in Notepad
    $clipboard = ClipGet()
    ClipPut($clipboard&$graphname[$i]&@CRLF&"X"&@TAB&"Y")
    For $j = 0 To $n[$i]
        $clipboard = ClipGet()
        ClipPut($clipboard&@CRLF&$saved[$i][$j][0]&@TAB&$saved[$i][$j][1])
    Next
    If $i < $graphnb Then
        $clipboard = ClipGet()
        ClipPut($clipboard&@CRLF&@CRLF)
    EndIf
Next
Edited by TheReveller

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0