Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
- ; #Warn ; Enable warnings to assist with detecting common errors.
- SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
- SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
- #SingleInstance Force
- OnMessage(0xF, "WM_PAINT")
- IfExist, HSGraph.ini
- {
- IniRead, maxCurrent, HSGraph.ini, HSGraph, maxCurrent
- IniRead, timeInterval, HSGraph.ini, HSGraph, timeInterval
- IniRead, numIntervals, HSGraph.ini, HSGraph, numIntervals
- IniRead, width, HSGraph.ini, HSGraph, width
- IniRead, height, HSGraph.ini, HSGraph, height
- IniRead, inactive, HSGraph.ini, HSGraph, inactive
- IniRead, playSoundBelowZone, HSGraph.ini, HSGraph, playSoundBelowZone
- }
- else
- {
- maxCurrent := round(((GetZone() - 80) / 25) ** 1.3 * 1.7)
- if !maxCurrent
- maxCurrent := 100
- timeInterval := 8.7
- numIntervals := 3
- width := 1300
- height := 210
- inactive := 20
- playSoundBelowZone := 0
- IniWrite, %maxCurrent%, HSGraph.ini, HSGraph, maxCurrent
- IniWrite, %timeInterval%, HSGraph.ini, HSGraph, timeInterval
- IniWrite, %numIntervals%, HSGraph.ini, HSGraph, numIntervals
- IniWrite, %width%, HSGraph.ini, HSGraph, width
- IniWrite, %height%, HSGraph.ini, HSGraph, height
- IniWrite, %playSoundBelowZone%, HSGraph.ini, HSGraph, playSoundBelowZone
- }
- inactive *= 1000
- Gui, Margin, 6, 4
- Y := mod(height, 12) / 2
- Loop, % height // 12
- Gui, Add, Text, xm+%width% ym+%Y% w18 h11 0x200, % round((height - Y - 6) * maxCurrent / height), Y += 12
- Gui, Add, Text, xm-2 ym w%width% h%height% hwndhGraph gXGraph_GetVal
- pGraph := XGraph(hGraph, 0, 3, "", 0xAAAA00, 1, True)
- Gui, Add, StatusBar
- SB_SetParts(90, 92, 108, 86, 85, 90)
- SB_SetText("Press F1 for help", 7)
- Gui, Show,, Plotting Base Primal Hero Souls
- WinGet, winID, ID, Plotting Base Primal Hero Souls
- helpText =
- (
- So I thought I'd make a little graphing program to help people identify at a glance their real world optimal zone, help see the value of Iris, and see how their skills are performing.
- It'll only work for the browser version of the game because of the way the zone is displayed in the title of the browser.
- How to use:
- Once it's downloaded double click on it. You'll see an empty graph window appear, as your Clicker Heroes game advances through zones the graph will fill in at fixed intervals with the base primal hero souls that have been collected since the last fixed interval. Once it's been filled in a bit you can click on a point on the graph to show the time since the last ascension and the zone at that point. When your 'Recent' average beings to drop below your 'Ascension' average it's a good time to ascend.
- On the first run a .ini file will be created with the default variables. They are as follows:
- * maxCurrent: This is the highest number of base primal hero souls you'll be expecting on a run. It should be a little higher then the highest 'Current' value shown. If it's too high you may have a hard time seeing your graph and if it's too low the graph will be off the screen and a higher suggested value will appear.
- * timeInterval: This is the number of seconds between each zone check
- * numIntervals: This is the number of intervals the 'Recent' average will consider
- * width and height: These control the size of the graph window
- * inactive: This is the number of seconds the program will continue to plot while there are no zone changes
- * playSoundBelowZone: If you'd like a sound to be played when things slow down, set this to a zone you know should be able to insta kill to (this defaults to zero ie off)
- In the bottom left you'll see four averages:
- * Current: is the base primal HS gained over the most recent time interval
- * Recent: is the average of the the base primal HS gained over the number of time intervals specified by numIntervals (defaults to three)
- * Ascension: is the average of the base primal HS gained since the last time the zone dropped by more then two (this will incorrectly see fighting immortals as ascending)
- * Total: is the average since starting the program
- Once you've clicked on the graph you'll see two more numbers:
- * Zone: is the zone at the point you've clicked on the graph
- * Time: is the time at the point you've clicked on the graph since the last ascension (or immortal fight)
- )
- prevZone := GetZone()
- sum := 0, sumSinceLastAscension := 0, i := 0, j := 0, suggestedCurrent := 0, st := A_TickCount, pt := 0, lastSound := 0
- timeIntervalMS := timeInterval * 1000
- SetTimer, Plot, %timeIntervalMS%
- Plot:
- zone := GetZone()
- if (zone = prevZone) ; dealing with inactivity/pausing - after a default of 20s, stops plotting, shaves paused time off of time since last ascension time
- {
- if !pt
- pt := A_TickCount
- if (A_TickCount - pt > inactive)
- return
- }
- else if (pt and A_TickCount - pt > inactive)
- st += A_TickCount - pt - inactive, pt := 0
- if (zone + 1 < prevZone) ; interprets this as ascending
- sumSinceLastAscension := 0, j := 0, st := A_TickCount
- sumPrev := 0
- loop % numIntervals - 1 ; for the 'Recent:' display
- {
- tmp := numIntervals - A_Index + 1
- tmp2 := numIntervals - A_Index
- prev%tmp% := prev%tmp2%
- sumPrev += prev%tmp%
- }
- prev1 := round(GetPrimal(prevZone, zone), 1)
- loop % numIntervals ; if all 'Recent:' intervals are over the 'Current:' creates a new suggest maxCurrent value
- {
- if (prev%A_Index% < maxCurrent)
- break
- if (A_Index = numIntervals)
- suggestedCurrent := (round(prev1 * 1.15) > suggestedCurrent) ? round(prev1 * 1.15) : suggestedCurrent
- }
- sumPrev += prev1
- averagePrev := round(sumPrev / numIntervals, 1)
- sum += prev1, sumSinceLastAscension += prev1
- i++, j++
- average := round(sum / i, 1), averageSinceLastAscension := round(sumSinceLastAscension / j, 1)
- if (zone < playSoundBelowZone and zone > 100 and timeInterval / (zone - prevZone) > 2.6 and A_TickCount - lastSound > 15000 and A_TickCount - st > 30000) ; plays sound if slowing down
- {
- lastSound := A_TickCount
- SoundPlay *48
- SoundPlay *64
- }
- storage := zone + round((A_TickCount - st) / 1000) / 100000 ; XGraph only allows one number to be stored so we sneak two in by using the decminal for time and non decimal section for the zone
- XGraph_Plot(pGraph, height - round(prev1 * height / maxCurrent), storage)
- SB_SetText("Current: " prev1, 1), SB_SetText("Recent: " averagePrev, 2), SB_SetText("Ascension: " averageSinceLastAscension, 3), SB_SetText("Total: " average, 4)
- if suggestedCurrent
- SB_SetText("Press F2 to reload with the suggested new maxCurrent value: " suggestedCurrent, 7)
- prevZone := zone
- Return
- GetZone()
- {
- loop 30
- {
- WinGetTitle, Title, Lvl
- zone := SubStr(Title, 5, InStr(Title, "-") - 6)
- if zone is integer
- return zone
- sleep 1
- }
- return 0
- }
- GetPrimal(a, b)
- {
- reward := 0
- if (a < 95)
- return 0
- loop % b - a
- {
- if (a + A_Index - 1 > 99)
- reward += round(((a + A_Index - 81) / 25) ** 1.3 / 5, 1)
- }
- return reward
- }
- WM_PAINT()
- {
- global
- sleep 1
- WinGet, activeID, ID, A
- if (activeID = winID)
- XGraph_Plot(pGraph)
- }
- ~F1::
- WinGet, activeID, ID, A
- if (activeID = winID)
- MsgBox, %helpText%
- Return
- ~F2::
- WinGet, activeID, ID, A
- if (activeID = winID and suggestedCurrent)
- {
- IniWrite, %suggestedCurrent%, HSGraph.ini, HSGraph, maxCurrent
- reload
- }
- Return
- GuiClose:
- pGraph := XGraph_Detach(pGraph)
- OnExit
- ExitApp
- ;storage := zone + round((A_TickCount - st) / 1000) / 100000
- XGraph_GetVal:
- tempGetVal := XGraph_GetVal(pGraph)
- zoneValue := floor(tempGetVal)
- timeValue := round((tempGetVal - zoneValue) * 100000)
- ; If (Col := ErrorLevel)
- SB_SetText("`Time: " timeValue "s", 5 ), SB_SetText("Zone: " zoneValue, 6)
- return
- /*
- __ __ __ __ __ __ __ _ __
- / /_ / /_/ /_____ _ / // /____ _/ /_ / /________________(_)___ / /_ ____ _______
- / __ \/ __/ __/ __ \(_) // // __ '/ __ \/ //_/ ___/ ___/ __/ / __ \/ __// __ \/ __/ _ \
- / / / / /_/ /_/ /_/ / / // // /_/ / / / / ,< (__ ) /__/ / / / /_/ / /__/ /_/ / / / // /
- /_/ /_/\__/\__/ .___(_) // / \__,_/_/ /_/_/|_/____/\___/_/ /_/ .___/\__(_)____/_/ \__ /
- /_/ /_//_/ /_/ (___/
- Script : XGraph v1.1.1.0 : Real time data plotting.
- http://ahkscript.org/boards/viewtopic.php?t=3492
- Created: 24-Apr-2014, Last Modified: 09-May-2014
- Description : Easy to use, Light weight, fast, efficient GDI based function library for
- graphically plotting real time data.
- Author : SKAN - Suresh Kumar A N ( [email protected] )
- Demos : CPU Load Monitor > http://ahkscript.org/boards/viewtopic.php?t=3413
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- */
- XGraph( hCtrl, hBM := 0, ColumnW := 3, LTRB := "0,2,0,2", PenColor := 0x808080, PenSize := 1, SV := 0 ) {
- Static WM_SETREDRAW := 0xB, STM_SETIMAGE := 0x172, PS_SOLID := 0, cbSize := 136, SRCCOPY := 0x00CC0020
- , GPTR := 0x40, OBJ_BMP := 0x7, LR_CREATEDIBSECTION := 0x2000, LR_COPYDELETEORG := 0x8
- ; Validate control
- WinGetClass, Class, ahk_id %hCtrl%
- Control, Style, +0x5000010E,, ahk_id %hCtrl%
- ControlGet, Style, Style,,, ahk_id %hCtrl%
- ControlGet, ExStyle, ExStyle,,, ahk_id %hCtrl%
- ControlGetPos,,, CtrlW, CtrlH,, ahk_id %hCtrl%
- If not ( Class == "Static" and Style = 0x5000010E and ExStyle = 0 and CtrlW > 0 and CtrlH > 0 )
- Return 0, ErrorLevel := -1
- ; Validate Bitmap
- If ( DllCall( "GetObjectType", "Ptr",hBM ) <> OBJ_BMP )
- hTargetBM := DllCall( "CreateBitmap", "Int",2, "Int",2, "UInt",1, "UInt",16, "Ptr",0, "Ptr" )
- , hTargetBM := DllCall( "CopyImage", "Ptr",hTargetBM, "UInt",0, "Int",CtrlW, "Int",CtrlH
- , "UInt",LR_CREATEDIBSECTION|LR_COPYDELETEORG, "Ptr" )
- else hTargetBM := hBM
- VarSetCapacity( BITMAP,32,0 )
- DllCall( "GetObject", "Ptr",hTargetBM, "Int",( A_PtrSize = 8 ? 32 : 24 ), "Ptr",&BITMAP )
- If NumGet( BITMAP, 18, "UInt" ) < 16 ; Checking if BPP < 16
- Return 0, ErrorLevel := -2
- Else BitmapW := NumGet( BITMAP, 4, "UInt" ), BitmapH := NumGet( BITMAP, 8, "UInt" )
- If ( BitmapW <> CtrlW or BitmapH <> CtrlH )
- Return 0, ErrorLevel := -3
- ; Validate Margins and Column width
- StringSplit, M, LTRB, `, , %A_Space% ; Left,Top,Right,Bottom
- MarginL := ( M1+0 < 0 ? 0 : M1 ), MarginT := ( M2+0 < 0 ? 0 : M2 )
- MarginR := ( M3+0 < 0 ? 0 : M3 ), MarginB := ( M4+0 < 0 ? 0 : M4 )
- ColumnW := ( ColumnW+0 < 0 ? 3 : ColumnW & 0xff ) ; 1 - 255
- ; Derive Columns, BitBlt dimensions, Movement coords for Lineto() and MoveToEx()
- Columns := ( BitmapW - MarginL - MarginR ) // ColumnW
- BitBltW := Columns * ColumnW, BitBltH := BitmapH - MarginT - MarginB
- MX1 := BitBltW - ColumnW, MY1 := BitBltH - 1
- MX2 := MX1 + ColumnW - ( PenSize < 1 ) ; MY2 := < user defined >
- ; Initialize Memory Bitmap
- hSourceDC := DllCall( "CreateCompatibleDC", "Ptr",0, "Ptr" )
- hSourceBM := DllCall( "CopyImage", "Ptr",hTargetBM, "UInt",0, "Int",ColumnW * 2 + BitBltW
- , "Int",BitBltH, "UInt",LR_CREATEDIBSECTION, "Ptr" )
- DllCall( "SaveDC", "Ptr",hSourceDC )
- DllCall( "SelectObject", "Ptr",hSourceDC, "Ptr",hSourceBM )
- hTempDC := DllCall( "CreateCompatibleDC", "Ptr",0, "Ptr" )
- DllCall( "SaveDC", "Ptr",hTempDC )
- DllCall( "SelectObject", "Ptr",hTempDC, "Ptr",hTargetBM )
- If ( hTargetBM <> hBM )
- hBrush := DllCall( "CreateSolidBrush", UInt,hBM & 0xFFFFFF, "Ptr" )
- , VarSetCapacity( RECT, 16, 0 )
- , NumPut( BitmapW, RECT, 8, "UInt" ), NumPut( BitmapH, RECT,12, "UInt" )
- , DllCall( "FillRect", "Ptr",hTempDC, "Ptr",&RECT, "Ptr",hBrush )
- , DllCall( "DeleteObject", "Ptr",hBrush )
- DllCall( "BitBlt", "Ptr",hSourceDC, "Int",ColumnW * 2, "Int",0, "Int",BitBltW, "Int",BitBltH
- , "Ptr",hTempDC, "Int",MarginL, "Int",MarginT, "UInt",SRCCOPY )
- DllCall( "BitBlt", "Ptr",hSourceDC, "Int",0, "Int",0, "Int",BitBltW, "Int",BitBltH
- , "Ptr",hTempDC, "Int",MarginL, "Int",MarginT, "UInt",SRCCOPY )
- ; Validate Pen color / Size
- PenColor := ( PenColor + 0 <> "" ? PenColor & 0xffffff : 0x808080 ) ; Range: 000000 - ffffff
- PenSize := ( PenSize + 0 <> "" ? PenSize & 0xf : 1 ) ; Range: 0 - 15
- hSourcePen := DllCall( "CreatePen", "Int",PS_SOLID, "Int",PenSize, "UInt",PenColor, "Ptr" )
- DllCall( "SelectObject", "Ptr",hSourceDC, "Ptr",hSourcePen )
- DllCall( "MoveToEx", "Ptr",hSourceDC, "Int",MX1, "Int",MY1, "Ptr",0 )
- hTargetDC := DllCall( "GetDC", "Ptr",hCtrl, "Ptr" )
- DllCall( "BitBlt", "Ptr",hTargetDC, "Int",0, "Int",0, "Int",BitmapW, "Int",BitmapH
- , "Ptr",hTempDC, "Int",0, "Int",0, "UInt",SRCCOPY )
- DllCall( "RestoreDC", "Ptr",hTempDC, "Int",-1 )
- DllCall( "DeleteDC", "Ptr",hTempDC )
- DllCall( "SendMessage", "Ptr",hCtrl, "UInt",WM_SETREDRAW, "Ptr",False, "Ptr",0 )
- hOldBM := DllCall( "SendMessage", "Ptr",hCtrl, "UInt",STM_SETIMAGE, "Ptr",0, "Ptr",hTargetBM )
- DllCall( "SendMessage", "Ptr",hCtrl, "UInt",WM_SETREDRAW, "Ptr",True, "Ptr",0 )
- DllCall( "DeleteObject", "Ptr",hOldBM )
- ; Create / Update Graph structure
- DataSz := ( SV = 1 ? Columns * 8 : 0 )
- pGraph := DllCall( "GlobalAlloc", "UInt",GPTR, "Ptr",cbSize + DataSz, "UPtr" )
- NumPut( DataSz, pGraph + cbSize - 8 )
- VarL := "cbSize / hCtrl / hTargetDC / hSourceDC / hSourceBM / hSourcePen / ColumnW / Columns / "
- . "MarginL / MarginT / MarginR / MarginB / MX1 / MX2 / BitBltW / BitBltH"
- Loop, Parse, VarL, /, %A_Space%
- NumPut( %A_LoopField%, pGraph + 0, ( A_Index - 1 ) * 8 )
- Return pGraph
- }
- ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- XGraph_Info( pGraph, FormatFloat := "" ) {
- Static STM_GETIMAGE := 0x173
- IfEqual, pGraph, 0, Return "", ErrorLevel := -1
- T := "`t", TT := "`t:`t", LF := "`n", SP := " "
- pData := pGraph + NumGet( pGraph + 0 ), DataSz := Numget( pData-8 )
- If ( FormatFloat <> "" and DataSz )
- GoTo, XGraph_Info_Data
- VarL := "cbSize / hCtrl / hTargetDC / hSourceDC / hSourceBM / hSourcePen / ColumnW / Columns / "
- . "MarginL / MarginT / MarginR / MarginB / MX1 / MX2 / BitBltW / BitBltH"
- Loop, Parse, VarL, /, %A_Space%
- Offset := ( A_Index - 1 ) * 8, %A_LoopField% := NumGet( pGraph + 0, OffSet )
- , RAW .= SubStr( Offset SP,1,3 ) T SubStr( A_LoopField SP,1,16 ) T %A_LoopField% LF
- hTargetBM := DllCall( "SendMessage", "Ptr",hCtrl, "UInt",STM_GETIMAGE, "Ptr",0, "Ptr",0 )
- VarSetCapacity( BITMAP,32,0 )
- DllCall( "GetObject", "Ptr",hTargetBM, "Int",( A_PtrSize = 8 ? 32 : 24 ), "Ptr",&BITMAP )
- TBMW := NumGet( BITMAP, 4, "UInt" ), TBMH := NumGet( BITMAP, 8, "UInt" )
- TBMB := NumGet( BITMAP, 12, "UInt" ) * TBMH, TBMZ := Round( TBMB/1024,2 )
- TBPP := NumGet( BITMAP, 18, "UShort" )
- Adj := ( Adj := TBMW - MarginL - BitBltW - MarginR ) ? " (-" Adj ")" : ""
- DllCall( "GetObject", "Ptr",hSourceBM, "Int",( A_PtrSize = 8 ? 32 : 24 ), "Ptr",&BITMAP )
- SBMW := NumGet( BITMAP, 4, "UInt" ), SBMH := NumGet( BITMAP, 8, "UInt" )
- SBMB := NumGet( BITMAP, 12, "UInt" ) * SBMH, SBMZ := Round( SBMB/1024,2 )
- SBPP := NumGet( BITMAP, 18, "UShort" )
- Return "GRAPH Properties" LF LF
- . "Screen BG Bitmap " TT TBMW ( Adj ) "x" TBMH " " TBPP "bpp ( " TBMZ " KB )" LF
- . "Margins ( L,T,R,B )" TT MarginL "," MarginT "," MarginR "," MarginB LF
- . "Client Area " TT MarginL "," MarginT "," MarginL+BitBltW-1 "," MarginT+BitBltH-1 LF LF
- . "Memory Bitmap " TT SBMW "x" SBMH " " SBPP "bpp ( " SBMZ " KB )" LF
- . "Graph Width " TT BitBltW " px ( " Columns " cols x " ColumnW " px )" LF
- . "Graph Height (MY2) " TT BitBltH " px ( y0 to y" BitBltH - 1 " )" LF
- . "Graph Array " TT ( DataSz=0 ? "NA" : Columns " cols x 8 bytes = " DataSz " bytes" ) LF LF
- . "Pen start position " TT MX1 "," BitBltH - 1 LF
- . "LineTo position " TT MX2 "," "MY2" LF
- . "MoveTo position " TT MX1 "," "MY2" LF LF
- . "STRUCTURE ( Offset / Variable / Raw value )" LF LF RAW
- XGraph_Info_Data:
- AFF := A_FormatFloat
- SetFormat, FloatFast, %FormatFloat%
- Loop % DataSz // 8
- Values .= SubStr( A_Index " ", 1, 4 ) T NumGet( pData - 8, A_Index * 8, "Double" ) LF
- SetFormat, FloatFast, %AFF%
- StringTrimRight, Values, Values, 1
- Return Values
- }
- ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- XGraph_Plot( pGraph, MY2 := "", SetVal := "", Draw := 1 ) {
- Static SRCCOPY := 0x00CC0020
- IfEqual, pGraph, 0, Return "", ErrorLevel := -1
- pData := pGraph + NumGet( pGraph + 0 ), DataSz := Numget( pData - 8 )
- , hSourceDC := NumGet( pGraph + 24 ), BitBltW := NumGet( pGraph + 112 )
- , hTargetDC := NumGet( pGraph + 16 ), BitBltH := NumGet( pGraph + 120 )
- , ColumnW := NumGet( pGraph + 48 )
- , MarginL := NumGet( pGraph + 64 ), MX1 := NumGet( pGraph + 096 )
- , MarginT := NumGet( pGraph + 72 ), MX2 := NumGet( pGraph + 104 )
- If not ( MY2 = "" )
- DllCall( "BitBlt", "Ptr",hSourceDC, "Int",0, "Int",0, "Int",BitBltW + ColumnW, "Int",BitBltH
- , "Ptr",hSourceDC, "Int",ColumnW, "Int",0, "UInt",SRCCOPY )
- , DllCall( "LineTo", "Ptr",hSourceDC, "Int",MX2, "Int",MY2 )
- , DllCall( "MoveToEx", "Ptr",hSourceDC, "Int",MX1, "Int",MY2, "Ptr",0 )
- If ( Draw = 1 )
- DllCall( "BitBlt", "Ptr",hTargetDC, "Int",MarginL, "Int",MarginT, "Int",BitBltW, "Int",BitBltH
- , "Ptr",hSourceDC, "Int",0, "Int",0, "UInt",SRCCOPY )
- If not ( MY2 = "" or SetVal = "" or DataSz = 0 )
- DllCall( "RtlMoveMemory", "Ptr",pData, "Ptr",pData + 8, "Ptr",DataSz - 8 )
- , NumPut( SetVal, pData + DataSz - 8, 0, "Double" )
- Return 1
- }
- ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- XGraph_SetVal( pGraph, Double := 0, Column := "" ) {
- IfEqual, pGraph, 0, Return "", ErrorLevel := -1
- pData := pGraph + NumGet( pGraph + 0 ), DataSz := Numget( pData - 8 )
- IfEqual, DataSz, 0, Return 0
- If ( Column = "" )
- DllCall( "RtlMoveMemory", "Ptr",pData, "Ptr",pData + 8, "Ptr",DataSz - 8 )
- , pNumPut := pData + DataSz
- else Columns := NumGet( pGraph + 56 )
- , pNumPut := pData + ( Column < 0 or Column > Columns ? Columns * 8 : Column * 8 )
- Return NumPut( Double, pNumPut - 8, 0, "Double" ) - 8
- }
- ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- XGraph_GetVal( pGraph, Column := "" ) {
- Static RECT
- If not VarSetCapacity( RECT )
- VarSetCapacity( RECT, 16, 0 )
- IfEqual, pGraph, 0, Return "", ErrorLevel := -1
- pData := pGraph + NumGet( pGraph + 0 ), DataSz := Numget( pData - 8 )
- Columns := NumGet( pGraph + 56 )
- If not ( Column = "" or DataSz = 0 or Column < 1 or Column > Columns )
- Return NumGet( pData - 8, Column * 8, "Double" ), ErrorLevel := Column
- hCtrl := NumGet( pGraph + 8 ), ColumnW := NumGet( pGraph + 48 )
- , BitBltW := NumGet( pGraph + 112 ), MarginL := NumGet( pGraph + 64 )
- , BitBltH := NumGet( pGraph + 120 ), MarginT := NumGet( pGraph + 72 )
- , Numput( MarginL, RECT, 0, "Int" ), Numput( MarginT, RECT, 4, "Int" )
- , DllCall( "ClientToScreen", "Ptr",hCtrl, "Ptr",&RECT )
- , DllCall( "GetCursorPos", "Ptr",&RECT + 8 )
- , MX := NumGet( RECT, 8, "Int" ) - NumGet( RECT, 0, "Int" )
- , MY := NumGet( RECT,12, "Int" ) - NumGet( RECT, 4, "Int" )
- , Column := ( MX >= 0 and MY >= 0 and MX < BitBltW and MY < BitBltH ) ? MX // ColumnW + 1 : 0
- Return ( DataSz and Column ) ? NumGet( pData - 8, Column * 8, "Double" ) : "", ErrorLevel := Column
- }
- ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- XGraph_GetMean( pGraph, TailCols := "" ) {
- IfEqual, pGraph, 0, Return "", ErrorLevel := -1
- pData := pGraph + NumGet( pGraph + 0 ), DataSz := Numget( pData - 8 )
- IfEqual, DataSz, 0, Return 0, ErrorLevel := 0
- Columns := NumGet( pGraph + 56 )
- pDataEnd := pGraph + NumGet( pGraph + 0 ) + ( Columns * 8 )
- TailCols := ( TailCols = "" or TailCols < 1 or Tailcols > Columns ) ? Columns : TailCols
- Loop %TailCols%
- Value += NumGet( pDataEnd - ( A_Index * 8 ), 0, "Double" )
- Return Value / TailCols, ErrorLevel := TailCols
- }
- ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- XGraph_Detach( pGraph ) {
- IfEqual, pGraph, 0, Return 0
- VarL := "cbSize / hCtrl / hTargetDC / hSourceDC / hSourceBM / hSourcePen"
- Loop, Parse, VarL, /, %A_Space%
- %A_LoopField% := NumGet( pGraph + 0, ( A_Index - 1 ) * 8 )
- DllCall( "ReleaseDC", "Ptr",hCtrl, "Ptr",hTargetDC )
- DllCall( "RestoreDC", "Ptr",hSourceDC, "Int",-1 )
- DllCall( "DeleteDC", "Ptr",hSourceDC )
- DllCall( "DeleteObject", "Ptr",hSourceBM )
- DllCall( "DeleteObject", "Ptr",hSourcePen )
- Return DllCall( "GlobalFree", "Ptr",pGraph, "Ptr" )
- }
- ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- XGraph_MakeGrid( CellW, CellH, Cols, Rows, GLClr, BGClr, ByRef BMPW := "", ByRef BMPH := "" ) {
- Static LR_Flag1 := 0x2008 ; LR_CREATEDIBSECTION := 0x2000 | LR_COPYDELETEORG := 8
- , LR_Flag2 := 0x200C ; LR_CREATEDIBSECTION := 0x2000 | LR_COPYDELETEORG := 8 | LR_COPYRETURNORG := 4
- , DC_PEN := 19
- BMPW := CellW * Cols + 1, BMPH := CellH * Rows + 1
- hTempDC := DllCall( "CreateCompatibleDC", "Ptr",0, "Ptr" )
- DllCall( "SaveDC", "Ptr",hTempDC )
- If ( DllCall( "GetObjectType", "Ptr",BGClr ) = 0x7 )
- hTBM := DllCall( "CopyImage", "Ptr",BGClr, "Int",0, "Int",BMPW, "Int",BMPH, "UInt",LR_Flag2, "UPtr" )
- , DllCall( "SelectObject", "Ptr",hTempDC, "Ptr",hTBM )
- Else
- hTBM := DllCall( "CreateBitmap", "Int",2, "Int",2, "UInt",1, "UInt",24, "Ptr",0, "Ptr" )
- , hTBM := DllCall( "CopyImage", "Ptr",hTBM, "Int",0, "Int",BMPW, "Int",BMPH, "UInt",LR_Flag1, "UPtr" )
- , DllCall( "SelectObject", "Ptr",hTempDC, "Ptr",hTBM )
- , hBrush := DllCall( "CreateSolidBrush", "UInt",BGClr & 0xFFFFFF, "Ptr" )
- , VarSetCapacity( RECT, 16 )
- , NumPut( BMPW, RECT, 8, "UInt" ), NumPut( BMPH, RECT, 12, "UInt" )
- , DllCall( "FillRect", "Ptr",hTempDC, "Ptr",&RECT, "Ptr",hBrush )
- , DllCall( "DeleteObject", "Ptr",hBrush )
- hPenDC := DllCall( "GetStockObject", "Int",DC_PEN, "Ptr" )
- DllCall( "SelectObject", "Ptr",hTempDC, "Ptr",hPenDC )
- DllCall( "SetDCPenColor", "Ptr",hTempDC, "UInt",GLClr & 0xFFFFFF )
- Loop, % Rows + 1 + ( X := Y := 0 )
- DllCall( "MoveToEx", "Ptr",hTempDC, "Int",X, "Int",Y, "Ptr",0 )
- , DllCall( "LineTo", "Ptr",hTempDC, "Int",BMPW, "Int",Y ), Y := Y + CellH
- Loop, % Cols + 1 + ( X := Y := 0 )
- DllCall( "MoveToEx", "Ptr",hTempDC, "Int",X, "Int",Y, "Ptr",0 )
- , DllCall( "LineTo", "Ptr",hTempDC, "Int",X, "Int",BMPH ), X := X + CellW
- DllCall( "RestoreDC", "Ptr",hTempDC, "Int",-1 )
- DllCall( "DeleteDC", "Ptr",hTempDC )
- Return hTBM
- }
- ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement