Jump to content

andybiochem

Active Members
  • Posts

    308
  • Joined

  • Last visited

  • Days Won

    1

andybiochem last won the day on February 21 2019

andybiochem had the most liked content!

Recent Profile Visitors

444 profile views

andybiochem's Achievements

Universalist

Universalist (7/7)

16

Reputation

  1. Hi All, Firstly, I accept no responsibility for how you use the following UDF, use at your own risk! Below is a very basic UDF that will allow communication with Binance's API (binance.com, not the US version). There is no error handling - add this yourself if you are concerned. If you are going to use this UDF in any meaningful way, carefully check the return of every single call, to make sure there is no error in the data you are receiving back from Binance. e.g. if you are pulling ticker prices, and suddenly you get $NULL returned, this could affect how you go on to place orders etc. I have very intentionally not provided an example of how to place orders using the UDF. If you are technically minded enough to use the UDF and understand how to construct the POST data, this should not be an issue. If you are struggling to work out how to place orders with this, please stop - no good can come from not fully understanding Binance's API and trying to automate it. In any event, please start with POSTing to "/api/v3/order/test" before commiting to your live account! The whole UDF calls directly on winhttp.dll, this was the only method I could find that gave a decent reliability, TCP / INET functions I found quite unreliable. Every UDF return gives you the HTTP Code and API Weight pulled out of the http header. Monitor these carefully if you're making heavy/lots of calls to the API; it's very easy to make a mistake and spam Binance's server, which will lead in a ban. Lastly, if you get "Timestamp for this request is outside of the recvwindow" errors back from Binance, it is because your computer clock is not synced with an NTP properly. Sync your clock, and the error should go away, try rebooting too - BUT, the error will probably return after a few days/weeks as the sync drops. Monitor for this error, and keep on top of it if you can! ;----- API Keys ----- Global $sAPI_Key_Access = "enter your access key" Global $sAPI_Key_Secret = "enter your secret key" ;----- Prepare DLL ----- Global $hDll_WinHTTP = DllOpen("winhttp.dll") ;########## EXAMPLE API CALLS ########## ;----- Ping Binance ----- Global $sRet = _BINANCE_API_Call("api/v3/ping") ConsoleWrite($sRet & @CRLF & @CRLF) ;----- Get Binance's Server Time ----- $sRet = _BINANCE_API_Call("api/v3/time") ConsoleWrite($sRet & @CRLF & @CRLF) ;----- Get BTC/USDT Average Price ----- $sRet = _BINANCE_API_Call("api/v3/avgPrice","symbol=BTCUSDT") ConsoleWrite($sRet & @CRLF & @CRLF) ;----- Get ETH/BTC Live Ticker Price ----- For $i = 1 To 5 Sleep(100) $sRet = _BINANCE_API_Call("api/v3/ticker/price", "symbol=ETHBTC") ConsoleWrite($sRet & @CRLF) Next ConsoleWrite(@CRLF) ;----- Get Last 10 ETH/BTC Trades ----- $sRet = _BINANCE_API_Call("api/v3/trades", "symbol=ETHBTC&limit=10") ConsoleWrite($sRet & @CRLF & @CRLF) ;----- Get Your Account Data ----- $sRet = _BINANCE_API_Call("api/v3/account") ConsoleWrite($sRet & @CRLF & @CRLF) Func _BINANCE_API_Call($sEndPoint, $sParameters = "") ;************************************************** ; Performs Binance API Call Via Native WinHTTP dll ;************************************************** ;----- Vars ----- ; Presume GET, assign POST if needed in switch Local $sGETorPOST = "GET" ;----- Check Endpoint Required ----- ; Some endpoints require signing, other endpoints can be ; added as new cases. Switch $sEndPoint Case "api/v3/account" $sParameters &= "&timestamp=" & _TimeStamp() $sParameters &= "&signature=" & _HMAC($sParameters, $sAPI_Key_Secret) Case "api/v3/order" $sGETorPOST = "POST" $sParameters &= "&timestamp=" & _TimeStamp() $sParameters &= "&signature=" & _HMAC($sParameters, $sAPI_Key_Secret) Case "api/v3/myTrades" $sParameters &= "&timestamp=" & _TimeStamp() $sParameters &= "&signature=" & _HMAC($sParameters, $sAPI_Key_Secret) EndSwitch ;----- Start Session ----- Local $hHTTP_Session = DllCall($hDll_WinHTTP, "handle", "WinHttpOpen", "wstr", "Mozilla/4.0", "dword", 0, "wstr", "", "wstr", "", "dword", 0)[0] ;----- Connect To Binance Server ----- Local $hHTTP_Connection = DllCall($hDll_WinHTTP, "handle", "WinHttpConnect", "handle", $hHTTP_Session, "wstr", "api.binance.com", "dword", 443, "dword", 0)[0] ;----- Prepare Request Data ----- If $sParameters <> "" Then $sParameters = "?" & $sParameters Local $hHTTP_Request = DllCall($hDll_WinHTTP, "handle", "WinHttpOpenRequest", "handle", $hHTTP_Connection, "wstr", $sGETorPOST, "wstr", $sEndPoint & $sParameters, "wstr", "HTTP/1.1", "wstr", "", "ptr", 0, "dword", 0x00800000)[0] ;----- Add Request Header ----- ; Adds API key to header even if not specifically needed, inconsequential DllCall($hDll_WinHTTP, "bool", "WinHttpAddRequestHeaders", "handle", $hHTTP_Request, "wstr", "X-MBX-APIKEY: " & $sAPI_Key_Access, "dword", -1, "dword", 0x10000000) ;----- Send Request To Server ----- DllCall($hDll_WinHTTP, "bool", "WinHttpSendRequest", "handle", $hHTTP_Request, "wstr", "", "dword", 0, "ptr", 0, "dword", 0, "dword", 0, "dword_ptr", 0) ;----- Recieve Response ----- DllCall($hDll_WinHTTP, "bool", "WinHttpReceiveResponse", "handle", $hHTTP_Request, "ptr", 0) ;----- Recieve Headers ----- ; Extract HTTP return code and API weight Local $sHeaders = DllCall($hDll_WinHTTP, "bool", "WinHttpQueryHeaders", "handle", $hHTTP_Request, "dword", 22, "wstr", "", "wstr", "", "dword*", 65536, "dword*", 0)[4] Local $sHTTP_ReturnCode = StringMid($sHeaders, StringInStr($sHeaders, "HTTP/1.1 ") + 9, StringInStr($sHeaders, @CR, 0, 1, StringInStr($sHeaders, "HTTP/1.1 ") + 9) - (StringInStr($sHeaders, "HTTP/1.1 ") + 9)) Local $sAPI_Weight = StringMid($sHeaders, StringInStr($sHeaders, "x-mbx-used-weight: ") + 19, StringInStr($sHeaders, @CR, 0, 1, StringInStr($sHeaders, "x-mbx-used-weight: ") + 19) - (StringInStr($sHeaders, "x-mbx-used-weight: ") + 19)) Local $sAPI_IPBan_RetryAfter_Sec = StringInStr($sHeaders, "Retry-After: ") = 0 ? "" : StringMid($sHeaders, StringInStr($sHeaders, "Retry-After: ") + 13, StringInStr($sHeaders, @CR, 0, 1, StringInStr($sHeaders, "Retry-After: ") + 13) - (StringInStr($sHeaders, "Retry-After: ") + 13)) ;----- Get Data ----- Local $sData = "" Local $iBytesToRead, $hBuffer_Data While 1 ;- Get Bytes To Read In This Loop - $iBytesToRead = DllCall($hDll_WinHTTP, "bool", "WinHttpQueryDataAvailable", "handle", $hHTTP_Request, "dword*", 0)[2] ;- Check If No More Data To Read - If $iBytesToRead <= 0 Then ExitLoop ;- Prep Data Buffer - $hBuffer_Data = DllStructCreate("char[" & $iBytesToRead & "]") ;- Read Data To Buffer - DllCall($hDll_WinHTTP, "bool", "WinHttpReadData", "handle", $hHTTP_Request, "struct*", $hBuffer_Data, "dword", $iBytesToRead, "dword*", 0) ;- Get Data From Buffer - $sData &= DllStructGetData($hBuffer_Data, 1) ;- Release - $hBuffer_Data = "" WEnd ;----- Close Handles ----- DllCall($hDll_WinHTTP, "bool", "WinHttpCloseHandle", "handle", $hHTTP_Request) DllCall($hDll_WinHTTP, "bool", "WinHttpCloseHandle", "handle", $hHTTP_Connection) DllCall($hDll_WinHTTP, "bool", "WinHttpCloseHandle", "handle", $hHTTP_Session) ;----- Return Data ----- ; Include HTTP Code and API Weight to check for overuse, and retry period if banned ; HTTP CODES : 429=over request limit, 418=IP banned due to overuse ; API WEIGHT : over 1200 will lead to ban Return '{"HTTPCode":"' & $sHTTP_ReturnCode & '","APIWeight":"' & $sAPI_Weight & ($sAPI_IPBan_RetryAfter_Sec = "" ? "" : '","Retry-After":"' & $sAPI_IPBan_RetryAfter_Sec) & '"}' & $sData EndFunc ;==>_BINANCE_API_Call Func _HMAC($bData, $bKey) ;************************************************** ; Create HMAC SHA256 Signature ;************************************************** Local $oHMAC = ObjCreate("System.Security.Cryptography.HMAC" & "SHA256") $oHMAC.key = Binary($bKey) Local $bHash = $oHMAC.ComputeHash_2(Binary($bData)) Return StringLower(StringMid($bHash, 3)) EndFunc ;==>_HMAC Func _TimeStamp() ;************************************************** ; Create UNIX-style TimeStamp ;************************************************** ; This is 'unix time', aka UTC time in milliseconds Local $aTimeStamp = DllCall("msvcrt.dll", "int:cdecl", "time", "int", 0) Return ($aTimeStamp[0] * 1000) + @MSEC ;convert to miliseconds EndFunc ;==>_TimeStamp An example return would be: {"HTTPCode":"200 OK","APIWeight":"4"}{"symbol":"ETHBTC","price":"0.07152900"} The first {} block is the HTTP code and API weight, the second {} block is the full Binance JSON reply. The JSON can be queried with a JSON UDF (do a search on the forum), or can be split with regexp. Again, please use with caution! Feel free to donate if you find this useful!: NANO nano_1161rm7egfzwgbtckwe8aoicee55897bbgc8apzrp1s3fzyyn7zqobbtkmfh
  2. Hi all, It has been a long time since I posted here, but I thought I might share a few things. First topic is setting up a webserver to use https. This assumes you already have a working autoit http webserver. If not, the code below will server up a simple "hello world" response: ;----- Start TCP & Listen ----- TCPStartup() Global $iMainSocket = TCPListen("127.0.0.1", 80) Global $iNewSocket ;----- HTML Reply ----- Global $sHTML = "Hello, world!" ;########## LOOP ########## While 1 ;----- SLEEP ----- Sleep(100) ;----- Accept New Connection ----- $iNewSocket = TCPAccept($iMainSocket) If @error Then ContinueLoop ;----- Check if Client Wants Something ----- TCPRecv($iNewSocket, 1024) If @error Then ContinueLoop ;----- Send Back HTML ----- TCPSend($iNewSocket, Binary($sHTML & @CRLF & @CRLF)) ;----- Drop Socket ----- TCPCloseSocket($iNewSocket) WEnd ;########## END LOOP ########## Note that it is important that the autoit server is listening on 127.0.0.1 as in the code above - this is the IP address stunnel will be sending received https data to. Install stunnel Stunnel will automatically generate a self-signed certificate. Replace the stunnel configuration file with this: [https] accept = 443 connect = 80 cert = stunnel.pem TIMEOUTclose = 0 Make sure both stunnel and your webserver are running, and you should be able to connect to the webserver using https.
  3. From the function file: ; #FUNCTION# ;=============================================================================== ; Name...........: _GUICtrlTable_Create ; Description ...: Creates a 'table' of label controls, and preps the 'border array' ; Syntax.........: _GUICtrlTable_Create($iLeft, $iTop, $iWidth, $iHeight, $iRows, $iColumns[, $iGapWidth = 1]) ; Parameters ....: $iLeft - Horisontal position of first cell ; $iTop - Vertical position of first cell ; $iWidth - Initial width of each cell ; $iHeight - Initial height of each cell ; $iRows - Number of rows in table ; $iColumns - Number of columns in table ; $iGapWidth - Size (pixels) of gap between each cell (can be zero = no gaps) ; Return values .: Success - Returns array of label IDs for other functions ($ReturnedArray[ROW][COLUMN]) ; Failure - (under construction) ; Notes .........: Rows/Columns are NOT zero-indexed. The first row IS row 1, the first column IS col 1 etc In your code you are creating a table with cells 400x400 pixels in size. The table then does not fill with your data because you are using the zeroeth array elements for storage. This works fine: #include <Table.au3> Dim $enumcolors[11][3] $enumcolors[1][1] = "9" ; the first element of the first columns says how many colors are in the list $enumcolors[2][1] = "009D9D9C" $enumcolors[3][1] = "00B2B4B5" $enumcolors[4][1] = "00596475" $enumcolors[5][1] = "00686B6F" $enumcolors[6][1] = "00BCBEBC" $enumcolors[7][1] = "00BDBFBF" $enumcolors[8][1] = "00B9BEBF" $enumcolors[9][1] = "00B9BCBD" $enumcolors[10][1] = "00C1C1BF" $enumcolors[1][2] = "how of each..." ; the first element of the second column says how many of each color are $enumcolors[2][2] = "1" $enumcolors[3][2] = "1" $enumcolors[4][2] = "7" $enumcolors[5][2] = "2" $enumcolors[6][2] = "2" $enumcolors[7][2] = "2" $enumcolors[8][2] = "8" $enumcolors[9][2] = "6" $enumcolors[10][2] = "6" Guicreate("list",-1,-1,-1,-1,-1,0x2000000) GUISetState() GUISetState(@SW_LOCK) $table = _GUICtrlTable_Create(0,0,70,15,ubound($enumcolors)-1,ubound($enumcolors,2)-1, 2) _GUICtrlTable_Set_Text_FromArray($table,$enumcolors) GUISetState(@SW_UNLOCK) while 1 $msj = Guigetmsg() switch $msj case -3 Exit EndSwitch WEnd The borders are simply colored labels that are 'sent to the back' of the gui, below the input boxes. It might be that they are bieng sent below the tab control too? Not sure.
  4. Ooof! Thanks for putting up your script... but that's made it even more confusing to me!! One thing I have noticed is that after creating your transparent GUI, you're not switching back to the main gui with GUISwitch() Try adding: GUISwitch($Main) ... immediately after GUISetState(@SW_SHOW) on line 393. I often run into problems when using multiple GUIs, as it is difficult to keep up with which GUI is the "current" gui. Let us know how this goes....we can try something else if it doesn't work. Ta! [EDIT] as a quick example, see this script: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Include <WinAPI.au3> #include <StaticConstants.au3> #include "Graph UDF.au3" ;----- Data array ----- Global $aData[1] ;----- GUI ----- $GUI_Main = GUICreate("Graph GUI", 600, 500) ;----- Graph ----- $hGraph = _Graph_Create(40, 120, 540, 340) ;----- Initial set up ----- _Graph_SetRange_X($hGraph, 1, 11, 10) _Graph_SetRange_Y($hGraph, -20, 20, 4, 1, 1) _Graph_SetGrid_Y($hGraph, 10) ;----- Capture box ----- Global $Capture_Left = 40 Global $Capture_Top = 20 Global $Capture_Width = 200 Global $Capture_Height = 40 Global $CaptureBox = GUICtrlCreateLabel("", $Capture_Left, $Capture_Top, $Capture_Width, $Capture_Height, $SS_BLACKFRAME) GUICtrlCreateLabel("Click in box",$Capture_Left,$Capture_Top-15,80,15) ;----- Show GUI ----- GUISetState(@SW_SHOW) ;----- Create Transparent GUI ----- $GUI_Transparent = GUICreate("minigui",$Capture_Left, $Capture_Top, $Capture_Width, $Capture_Height, $WS_POPUPWINDOW, $WS_EX_LAYERED + $GUI_WS_EX_PARENTDRAG, WinGetHandle(AutoItWinGetTitle())) WinSetOnTop($GUI_Transparent, "minigui", 1);~con esta orden le decimos que esté siempre encima de todo la ventana pequeña. prueba a abrir el programa y a minimizarlo... siempre estará ahí la ventanita :D GUISetBkColor(0xABCDEF);~y con esta orden y lo de abajo le decimos que la haga transparente _WinAPI_SetLayeredWindowAttributes($GUI_Transparent, 0xABCDEF, 255) ;----- Show transparent GUI ----- GUISetState(@SW_SHOW) ;----- Switch Back to Main GUI ----- GUISwitch($GUI_Main) ;try commenting me out: graph redraw fails ;----- LOOP ----- While 1 $nMsg = GUIGetMsg() Switch $nMsg Case -3 ;exit clicked Exit Case $CaptureBox ;capture box clicked _Data_AddPoint() _Graph_Redraw() EndSwitch WEnd Func _Data_AddPoint() ;********************************************************* ; Add a data point to the data array ;********************************************************* ;----- Get point ----- $MousePos = GUIGetCursorInfo($GUI_Main) $MousePos = $MousePos[0] - $Capture_Left $MousePos = $MousePos / $Capture_Width $MousePos = $MousePos * 40 - 20 ;----- Add to array ----- ReDim $aData[UBound($aData) + 1] $aData[UBound($aData) - 1] = $MousePos EndFunc ;==>_Data_AddPoint Func _Graph_Redraw() ;********************************************************* ; Redraw the graph area from the data array ;********************************************************* ;----- Lock up GUI (minimise flicker) ----- GUISetState(@SW_LOCK) ;----- Clear the graph ----- _Graph_Clear($hGraph) ;----- Redraw the grid ----- _Graph_SetGrid_Y($hGraph, 10) ;----- Decide on X range ----- $UpperXLimit = UBound($aData) - 1 $LowerXLimit = $UpperXLimit - 10 If $LowerXLimit < 1 Then $LowerXLimit = 1 ;----- Set new x range if needed ----- If $UpperXLimit > 10 Then _Graph_SetRange_X($hGraph, $LowerXLimit, $UpperXLimit, 10) ;----- Draw all Data points in range ----- For $i = $LowerXLimit To $UpperXLimit If $i = $LowerXLimit Then _Graph_Plot_Start($hGraph, $i, $aData[$i]) ;if first point in range, create start point _Graph_Plot_Line($hGraph, $i, $aData[$i]) _Graph_Plot_Point($hGraph, $i, $aData[$i]) Next ;----- Refresh graph ----- _Graph_Refresh($hGraph) ;----- Unlock gui again ----- GUISetState(@SW_UNLOCK) EndFunc ;==>_Graph_Redraw If you remove the GuiSwitch, the graph does not draw properly. Also in the script is an example how to automatically 'move' the graph x axis with increasing data points (click repeatedly in the box) Hope this helps
  5. Really want to help, but I can't get my head around what you want to do with the snippets of code you've posted. Can you post a full script showing the problem, that'll make thing easier to correct. Ta [EDIT] The differences between this UDF and my GDI version is simply that this version uses the AutoIt-native Graphic functions, and is thus limited to what AI provides. The GDI version uses GDI+ to draw the graphs, so things like double-buffering (no flickering), antialias, and alpha-channel colours can be used. In my opinion the GDI version is much nicer, but is a bit more of a hassle to use, and can conflict with other GUI elements (e.g. transparancies, painting)
  6. Sorry you're having problems with my UDF . Can you post a small script that recreates the gap problem? I've tried a dozen or so different tables, but can't get the error you describe. Are you editing the cells manually via control id's, or are you sticking to the udf functions? Cheers
  7. Your problem with flickering can be mostly solved with use of: 1)GUI double buffer using 0x2000000 as an extended style 2) Put GUISetState(@SW_LOCK) and GUISetState(@SW_UNLOCK) around your re-graphing function, just before it's deleted and until just after it's refreshed. Example: #include <GUIConstantsEx.au3> GUICreate("", 586, 314, -1, -1, -1, 0x2000000) Global $aData[101] Global $gGraph = _Graph_Create(50, 18, 513, 254) _Graph_SetRange_X($gGraph, 1, 100, 0) _Graph_SetRange_Y($gGraph, 0, 100, 10) _Redraw() GUISetState() Do Sleep(50) _Randomise() _Redraw() Until GUIGetMsg() = -3 Func _Randomise() For $i = 1 To 99 $aData[$i] = $aData[$i + 1] Next $aData[100] = Random(0, 100) EndFunc ;==>_Randomise Func _Redraw() GUISetState(@SW_LOCK) _Graph_Clear($gGraph) _Graph_SetGrid_X($gGraph, 5, 0x468c2f) _Graph_SetGrid_Y($gGraph, 10, 0x468c2f) _Graph_Set_Color($gGraph, 0xF9F32B) _Graph_Plot_Start($gGraph, 1, $gGraph[1]) For $i = 1 To 100 _Graph_Plot_Line($gGraph, $i, $aData[$i]) _Graph_Plot_Point($gGraph, $i, $aData[$i]) Next _Graph_Refresh($gGraph) GUISetState(@SW_UNLOCK) EndFunc ;==>_Redraw ;#### GRAPH UDF ############################################################################################################### ; #FUNCTION# ============================================================================ ; Name...........: _Graph_Create ; Description ...: Creates graph area, and prepares array of specified data ; Syntax.........: _Graph_Create($iLeft,$iTop,$iWidth,$iHeight) ; Parameters ....: $iLeft - left most position in GUI ; $iTop - top most position in GUI ; $iWidth - width of graph in pixels ; $iHeight - height of graph in pixels ; Return values .: Returns array containing variables for subsequent functions... ; Returned Graph array is: ; [1] graphic control handle ; [2] left ; [3] top ; [4] width ; [5] height ; [6] x low ; [7] x high ; [8] y low ; [9] y high ; [10] x ticks handles ; [11] x labels handles ; [12] y ticks handles ; [13] y labels handles ; [14] Border Colour ; [15] Fill Colour ; ======================================================================================= Func _Graph_Create($iLeft, $iTop, $iWidth, $iHeight, $hColourBorder = 0x000000, $hColorFill = 0xFFFFFF) $hWnd = GUICtrlCreateGraphic($iLeft, $iTop, $iWidth + 1, $iHeight + 1) GUICtrlSetColor(-1, $hColourBorder) GUICtrlSetBkColor(-1, $hColorFill) Local $ahTicksLabelsX[1] Local $ahTicksLabelsY[1] Local $ahTicksX[1] Local $ahTicksY[1] Dim $aGraphArray[16] = ["", $hWnd, $iLeft, $iTop, $iWidth, $iHeight, 0, 1, 0, 1, _ $ahTicksX, $ahTicksLabelsX, $ahTicksY, $ahTicksLabelsY, $hColourBorder, $hColorFill] Return $aGraphArray EndFunc ;==>_Graph_Create ; #FUNCTION# ============================================================================ ; Name...........: _Graph_Delete ; Description ...: Deletes previously created graph and related ticks/labels ; Syntax.........: _Graph_Delete(ByRef $aGraphArray) ; Parameters ....: $aGraphArray - the array returned from _Graph_Create ; ======================================================================================= Func _Graph_Delete(ByRef $aGraphArray) ;----- delete x ticks/labels ----- $ahTicksX = $aGraphArray[10] $ahTicksLabelsX = $aGraphArray[11] For $i = 1 to (UBound($ahTicksX) - 1) GUICtrlDelete($ahTicksX[$i]) Next For $i = 1 to (UBound($ahTicksLabelsX) - 1) GUICtrlDelete($ahTicksLabelsX[$i]) Next ;----- delete y ticks/labels ----- $ahTicksY = $aGraphArray[12] $ahTicksLabelsY = $aGraphArray[13] For $i = 1 to (UBound($ahTicksY) - 1) GUICtrlDelete($ahTicksY[$i]) Next For $i = 1 to (UBound($ahTicksLabelsY) - 1) GUICtrlDelete($ahTicksLabelsY[$i]) Next Dim $ahTicksLabelsY[1] ;----- delete graphic control ----- GUICtrlDelete($aGraphArray[1]) ;----- close array ----- $aGraphArray = 0 EndFunc ;==>_Graph_Delete ; #FUNCTION# ============================================================================ ; Name...........: _Graph_Clear ; Description ...: Clears graph content ; Syntax.........: _Graph_Clear(ByRef $aGraphArray) ; Parameters ....: $aGraphArray - the array returned from _Graph_Create ; ======================================================================================= Func _Graph_Clear(ByRef $aGraphArray) GUICtrlDelete($aGraphArray[1]) $aGraphArray[1] = GUICtrlCreateGraphic($aGraphArray[2], $aGraphArray[3], _ $aGraphArray[4] + 1, $aGraphArray[5] + 1) GUICtrlSetBkColor(-1, 0x000000) GUICtrlSetColor(-1, 0x000000) EndFunc ;==>_Graph_Clear ; #FUNCTION# ============================================================================ ; Name...........: _Graph_SetRange_X ; Description ...: Allows user to set the range of the X axis and set ticks and rounding levels ; Syntax.........: _Graph_SetRange_X(ByRef $aGraphArray,$iLow,$iHigh,$iXTicks = 1,$bLabels = 1,$iRound = 0) ; Parameters ....: $aGraphArray - the array returned from _Graph_Create ; $iLow - the lowest value for the X axis (can be negative) ; $iHigh - the highest value for the X axis ; $iXTicks - [optional] number of ticks to show below axis, if = 0 then no ticks created ; $bLabels - [optional] 1=show labels, any other number=do not show labels ; $iRound - [optional] rounding level of label values ; ======================================================================================= Func _Graph_SetRange_X(ByRef $aGraphArray, $iLow, $iHigh, $iXTicks = 1, $bLabels = 1, $iRound = 0) ;----- load user vars to array ----- $aGraphArray[6] = $iLow $aGraphArray[7] = $iHigh ;----- prepare nested array ----- $ahTicksX = $aGraphArray[10] $ahTicksLabelsX = $aGraphArray[11] ;----- delete any existing ticks ----- For $i = 1 to (UBound($ahTicksX) - 1) GUICtrlDelete($ahTicksX[$i]) Next Dim $ahTicksX[1] ;----- create new ticks ----- For $i = 1 To $iXTicks + 1 ReDim $ahTicksX[$i + 1] $ahTicksX[$i] = GUICtrlCreateLabel("", (($i - 1) * ($aGraphArray[4] / $iXTicks)) + $aGraphArray[2], _ $aGraphArray[3] + $aGraphArray[5], 1, 5) GUICtrlSetBkColor(-1, 0x000000) GUICtrlSetState(-1, $GUI_DISABLE) Next ;----- delete any existing labels ----- For $i = 1 to (UBound($ahTicksLabelsX) - 1) GUICtrlDelete($ahTicksLabelsX[$i]) Next Dim $ahTicksLabelsX[1] ;----- create new labels ----- For $i = 1 To $iXTicks + 1 ReDim $ahTicksLabelsX[$i + 1] $ahTicksLabelsX[$i] = GUICtrlCreateLabel("", _ ($aGraphArray[2] + (($aGraphArray[4] / $iXTicks) * ($i - 1))) - (($aGraphArray[4] / $iXTicks) / 2), _ $aGraphArray[3] + $aGraphArray[5] + 10, $aGraphArray[4] / $iXTicks, 13, 1) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) Next ;----- if labels are required, then fill ----- If $bLabels = 1 Then For $i = 1 To (UBound($ahTicksLabelsX) - 1) GUICtrlSetData($ahTicksLabelsX[$i], _ StringFormat("%." & $iRound & "f", _Graph_Reference_Pixel("p", (($i - 1) * ($aGraphArray[4] / $iXTicks)), _ $aGraphArray[6], $aGraphArray[7], $aGraphArray[4]))) Next EndIf ;----- load created arrays back into array ----- $aGraphArray[10] = $ahTicksX $aGraphArray[11] = $ahTicksLabelsX EndFunc ;==>_Graph_SetRange_X ; #FUNCTION# ============================================================================ ; Name...........: _Graph_SetRange_Y ; Description ...: Allows user to set the range of the Y axis and set ticks and rounding levels ; Syntax.........: _Graph_SetRange_Y(ByRef $aGraphArray,$iLow,$iHigh,$iYTicks = 1,$bLabels = 1,$iRound = 0) ; Parameters ....: $aGraphArray - the array returned from _Graph_Create ; $iLow - the lowest value for the Y axis (can be negative) ; $iHigh - the highest value for the Y axis ; $iYTicks - [optional] number of ticks to show next to axis, if = 0 then no ticks created ; $bLabels - [optional] 1=show labels, any other number=do not show labels ; $iRound - [optional] rounding level of label values ; ======================================================================================= Func _Graph_SetRange_Y(ByRef $aGraphArray, $iLow, $iHigh, $iYTicks = 1, $bLabels = 1, $iRound = 0) ;----- load user vars to array ----- $aGraphArray[8] = $iLow $aGraphArray[9] = $iHigh ;----- prepare nested array ----- $ahTicksY = $aGraphArray[12] $ahTicksLabelsY = $aGraphArray[13] ;----- delete any existing ticks ----- For $i = 1 to (UBound($ahTicksY) - 1) GUICtrlDelete($ahTicksY[$i]) Next Dim $ahTicksY[1] ;----- create new ticks ----- For $i = 1 To $iYTicks + 1 ReDim $ahTicksY[$i + 1] $ahTicksY[$i] = GUICtrlCreateLabel("", $aGraphArray[2] - 5, _ ($aGraphArray[3] + $aGraphArray[5]) - (($aGraphArray[5] / $iYTicks) * ($i - 1)), 5, 1) GUICtrlSetBkColor(-1, 0x000000) GUICtrlSetState(-1, $GUI_DISABLE) Next ;----- delete any existing labels ----- For $i = 1 to (UBound($ahTicksLabelsY) - 1) GUICtrlDelete($ahTicksLabelsY[$i]) Next Dim $ahTicksLabelsY[1] ;----- create new labels ----- For $i = 1 To $iYTicks + 1 ReDim $ahTicksLabelsY[$i + 1] $ahTicksLabelsY[$i] = GUICtrlCreateLabel("", $aGraphArray[2] - 40, _ ($aGraphArray[3] + $aGraphArray[5]) - (($aGraphArray[5] / $iYTicks) * ($i - 1)) - 6, 30, 13, 2) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) Next ;----- if labels are required, then fill ----- If $bLabels = 1 Then For $i = 1 To (UBound($ahTicksLabelsY) - 1) GUICtrlSetData($ahTicksLabelsY[$i], StringFormat("%." & $iRound & "f", _Graph_Reference_Pixel("p", _ (($i - 1) * ($aGraphArray[5] / $iYTicks)), $aGraphArray[8], $aGraphArray[9], $aGraphArray[5]))) Next EndIf ;----- load created arrays back into array ----- $aGraphArray[12] = $ahTicksY $aGraphArray[13] = $ahTicksLabelsY EndFunc ;==>_Graph_SetRange_Y ; #FUNCTION# ============================================================================= ; Name...........: _Graph_Plot_Start ; Description ...: Move starting point of plot ; Syntax.........: _Graph_Plot_Start(ByRef $aGraphArray,$iX,$iY) ; Parameters ....: $aGraphArray - the array returned from _Graph_Create ; $iX - x value to start at ; $iY - y value to start at ; ======================================================================================== Func _Graph_Plot_Start(ByRef $aGraphArray, $iX, $iY) ;----- MOVE pen to start point ----- GUICtrlSetGraphic($aGraphArray[1], $GUI_GR_MOVE, _ _Graph_Reference_Pixel("x", $iX, $aGraphArray[6], $aGraphArray[7], $aGraphArray[4]), _ _Graph_Reference_Pixel("y", $iY, $aGraphArray[8], $aGraphArray[9], $aGraphArray[5])) EndFunc ;==>_Graph_Plot_Start ; #FUNCTION# ============================================================================= ; Name...........: _Graph_Plot_Line ; Description ...: draws straight line to x,y from previous point / starting point ; Syntax.........: _Graph_Plot_Line(ByRef $aGraphArray,$iX,$iY) ; Parameters ....: $aGraphArray - the array returned from _Graph_Create ; $iX - x value to draw to ; $iY - y value to draw to ; ======================================================================================== Func _Graph_Plot_Line(ByRef $aGraphArray, $iX, $iY) ;----- Draw line from previous point to new point ----- GUICtrlSetGraphic($aGraphArray[1], $GUI_GR_LINE, _ _Graph_Reference_Pixel("x", $iX, $aGraphArray[6], $aGraphArray[7], $aGraphArray[4]), _ _Graph_Reference_Pixel("y", $iY, $aGraphArray[8], $aGraphArray[9], $aGraphArray[5])) EndFunc ;==>_Graph_Plot_Line ; #FUNCTION# ============================================================================= ; Name...........: _Graph_Plot_Point ; Description ...: draws point at coords ; Syntax.........: _Graph_Plot_Point(ByRef $aGraphArray,$iX,$iY) ; Parameters ....: $aGraphArray - the array returned from _Graph_Create ; $iX - x value to draw at ; $iY - y value to draw at ; ======================================================================================== Func _Graph_Plot_Point(ByRef $aGraphArray, $iX, $iY) ;----- Draw point from previous point to new point ----- GUICtrlSetGraphic($aGraphArray[1], $GUI_GR_DOT, _ _Graph_Reference_Pixel("x", $iX, $aGraphArray[6], $aGraphArray[7], $aGraphArray[4]), _ _Graph_Reference_Pixel("y", $iY, $aGraphArray[8], $aGraphArray[9], $aGraphArray[5])) EndFunc ;==>_Graph_Plot_Point ; #FUNCTION# ============================================================================= ; Name...........: _Graph_Plot_Dot ; Description ...: draws single pixel dot at coords ; Syntax.........: _Graph_Plot_Dot(ByRef $aGraphArray,$iX,$iY) ; Parameters ....: $aGraphArray - the array returned from _Graph_Create ; $iX - x value to draw at ; $iY - y value to draw at ; ======================================================================================== Func _Graph_Plot_Dot(ByRef $aGraphArray, $iX, $iY) ;----- Draw point from previous point to new point ----- GUICtrlSetGraphic($aGraphArray[1], $GUI_GR_PIXEL, _ _Graph_Reference_Pixel("x", $iX, $aGraphArray[6], $aGraphArray[7], $aGraphArray[4]), _ _Graph_Reference_Pixel("y", $iY, $aGraphArray[8], $aGraphArray[9], $aGraphArray[5])) EndFunc ;==>_Graph_Plot_Dot ; #FUNCTION# ============================================================================= ; Name...........: _Graph_Set_Color ; Description ...: sets the color for the next drawing ; Syntax.........: _Graph_Set_Color(ByRef $aGraphArray,$hColor,$hBkGrdColor = $GUI_GR_NOBKCOLOR) ; Parameters ....: $aGraphArray - the array returned from _Graph_Create ; $hColor - the color of the next item ; $hBkGrdColor - the background color of the next item ; ======================================================================================== Func _Graph_Set_Color(ByRef $aGraphArray, $hColor, $hBkGrdColor = $GUI_GR_NOBKCOLOR) GUICtrlSetGraphic($aGraphArray[1], $GUI_GR_COLOR, $hColor, $hBkGrdColor) EndFunc ;==>_Graph_Set_Color ; #FUNCTION# ============================================================================= ; Name...........: _Graph_Set_PenSize ; Description ...: sets the pen for the next drawing ; Syntax.........: _Graph_Set_PenSize(ByRef $aGraphArray,$iSize = 1) ; Parameters ....: $aGraphArray - the array returned from _Graph_Create ; $iSize - size of pen line ; ======================================================================================== Func _Graph_Set_PenSize(ByRef $aGraphArray, $iSize = 1) GUICtrlSetGraphic($aGraphArray[1], $GUI_GR_PENSIZE, $iSize) EndFunc ;==>_Graph_Set_PenSize ; #FUNCTION# ============================================================================= ; Name...........: _Graph_Plot_Bar_X ; Description ...: Draws bar chart bar from the x axis ; Syntax.........: _Graph_Plot_Bar_X(ByRef $aGraphArray,$iStart,$iWidth,$nYValue,$hColor = 0x000000,$hBkGrdColor = $GUI_GR_NOBKCOLOR) ; Parameters ....: $aGraphArray - the array returned from _Graph_Create ; $iStart - the x axis value for start of bar (in x axis units) ; $iWidth - width of the bar (in x axis units) ; $nYValue - 'height' of the bar (in y axis units) ; $hColor - Bar border colour ; $hBkGrdColor - Bar fill colour ; ======================================================================================== Func _Graph_Plot_Bar_X(ByRef $aGraphArray, $iStart, $iWidth, $nYValue, $hColor = 0x000000, $hBkGrdColor = $GUI_GR_NOBKCOLOR) ;----- Draw Bar for BarChart Application ----- _Graph_Set_Color($aGraphArray, $hColor, $hBkGrdColor) GUICtrlSetGraphic($aGraphArray[1], $GUI_GR_RECT, _ _Graph_Reference_Pixel("x", $iStart, $aGraphArray[6], $aGraphArray[7], $aGraphArray[4]), _ ;x $aGraphArray[5] + 1, _ Round(_Graph_Reference_Pixel("x", $iStart + $iWidth, $aGraphArray[6], $aGraphArray[7], $aGraphArray[4]) - _ ;width _Graph_Reference_Pixel("x", $iStart, $aGraphArray[6], $aGraphArray[7], $aGraphArray[4]) + 1), _ -$aGraphArray[5] + _Graph_Reference_Pixel("y", $nYValue, $aGraphArray[8], $aGraphArray[9], $aGraphArray[5]) - 1) ;height ;- redraw axis in case coloured - _Graph_Set_Color($aGraphArray, $aGraphArray[14], $GUI_GR_NOBKCOLOR) GUICtrlSetGraphic($aGraphArray[1], $GUI_GR_RECT, 0, 0, $aGraphArray[4] + 1, $aGraphArray[5] + 1) ;- set colour back to default - _Graph_Set_Color($aGraphArray, 0x000000, $GUI_GR_NOBKCOLOR) EndFunc ;==>_Graph_Plot_Bar_X ; #FUNCTION# ============================================================================= ; Name...........: _Graph_Plot_Bar_Y ; Description ...: Draws bar chart bar from the y axis ; Syntax.........: _Graph_Plot_Bar_Y(ByRef $aGraphArray,$iStart,$iWidth,$nYValue,$hColor = 0x000000,$hBkGrdColor = $GUI_GR_NOBKCOLOR) ; Parameters ....: $aGraphArray - the array returned from _Graph_Create ; $iStart - the y axis value for start of bar (in y axis units) ; $iWidth - width of the bar (in y axis units) ; $nXValue - 'length' of the bar (in x axis units) ; $hColor - Bar border colour ; $hBkGrdColor - Bar fill colour ; ======================================================================================== Func _Graph_Plot_Bar_Y(ByRef $aGraphArray, $iStart, $iWidth, $nYValue, $hColor = 0x000000, $hBkGrdColor = $GUI_GR_NOBKCOLOR) ;----- Draw Bar for BarChart Application ----- _Graph_Set_Color($aGraphArray, $hColor, $hBkGrdColor) GUICtrlSetGraphic($aGraphArray[1], $GUI_GR_RECT, _ 0, _ ;x _Graph_Reference_Pixel("y", $iStart + $iWidth, $aGraphArray[8], $aGraphArray[9], $aGraphArray[5]), _ ;y _Graph_Reference_Pixel("x", $nYValue, $aGraphArray[6], $aGraphArray[7], $aGraphArray[4]) + 1, _ ;width _Graph_Reference_Pixel("y", $iStart, $aGraphArray[8], $aGraphArray[9], $aGraphArray[5]) - _ ;height _Graph_Reference_Pixel("y", $iStart + $iWidth, $aGraphArray[8], $aGraphArray[9], $aGraphArray[5]) + 1) ;- redraw axis in case coloured - _Graph_Set_Color($aGraphArray, $aGraphArray[14], $GUI_GR_NOBKCOLOR) GUICtrlSetGraphic($aGraphArray[1], $GUI_GR_RECT, 0, 0, $aGraphArray[4] + 1, $aGraphArray[5] + 1) ;- set colour back to default - _Graph_Set_Color($aGraphArray, 0x000000, $GUI_GR_NOBKCOLOR) EndFunc ;==>_Graph_Plot_Bar_Y ; #FUNCTION# ============================================================================= ; Name...........: _Graph_SetGrid_X ; Description ...: Adds X gridlines. ; Syntax.........: _Graph_SetGrid(ByRef $aGraphArray, $Ticks=1, $hColor=0xf0f0f0) ; Parameters ....: $aGraphArray - the array returned from _Graph_Create ; $Ticks - sets line at every nth unit assigned to axis ; $hColor - [optional] RGB value, defining color of grid. Default is a light gray ; ======================================================================================= Func _Graph_SetGrid_X(ByRef $aGraphArray, $Ticks = 1, $hColor = 0xf0f0f0) _Graph_Set_Color($aGraphArray, $hColor, $GUI_GR_NOBKCOLOR) Select Case $Ticks > 0 For $i = $aGraphArray[6] To $aGraphArray[7] Step $Ticks If $i = Number($aGraphArray[6]) Or $i = Number($aGraphArray[7]) Then ContinueLoop GUICtrlSetGraphic($aGraphArray[1], $GUI_GR_RECT, _ ;rectangle _Graph_Reference_Pixel("x", $i, $aGraphArray[6], $aGraphArray[7], $aGraphArray[4]), _ ;x 1, _ ;y 1, _ ;width $aGraphArray[5] - 1) ;height Next EndSelect _Graph_Set_Color($aGraphArray, 0x000000) EndFunc ;==>_Graph_SetGrid_X ; #FUNCTION# ============================================================================= ; Name...........: _Graph_SetGrid_Y ; Description ...: Adds Y gridlines. ; Syntax.........: _Graph_SetGrid(ByRef $aGraphArray, $Ticks=1, $hColor=0xf0f0f0) ; Parameters ....: $aGraphArray - the array returned from _Graph_Create ; $Ticks - sets line at every nth unit assigned to axis ; $hColor - [optional] RGB value, defining color of grid. Default is a light gray ; ======================================================================================= Func _Graph_SetGrid_Y(ByRef $aGraphArray, $Ticks = 1, $hColor = 0xf0f0f0) _Graph_Set_Color($aGraphArray, $hColor, $GUI_GR_NOBKCOLOR) Select Case $Ticks > 0 For $i = $aGraphArray[8] To $aGraphArray[9] Step $Ticks If $i = Number($aGraphArray[8]) Or $i = Number($aGraphArray[9]) Then ContinueLoop GUICtrlSetGraphic($aGraphArray[1], $GUI_GR_RECT, _ ;rectangle 1, _ ;x _Graph_Reference_Pixel("y", $i, $aGraphArray[8], $aGraphArray[9], $aGraphArray[5]), _ ;y $aGraphArray[4] - 1, _ ;width 1) ;height Next EndSelect _Graph_Set_Color($aGraphArray, 0x000000) EndFunc ;==>_Graph_SetGrid_Y ; #FUNCTION# ============================================================================= ; Name...........: _Graph_Refresh ; Description ...: refreshes the graphic ; Syntax.........: _Graph_Refresh(ByRef $aGraphArray) ; Parameters ....: $aGraphArray - the array returned from _Graph_Create ; ======================================================================================== Func _Graph_Refresh(ByRef $aGraphArray) GUICtrlSetGraphic($aGraphArray[1], $GUI_GR_REFRESH) EndFunc ;==>_Graph_Refresh ; #FUNCTION# ============================================================================= ; Name...........: _Graph_Reference_Pixel ; Description ...: INTERNAL FUNCTION - performs pixel reference calculations ; Syntax.........: _Graph_Reference_Pixel($iType,$iValue,$iLow,$iHigh,$iTotalPixels) ; Parameters ....: $iType - "x"=x axis pix, "y" = y axis pix, "p"=value from pixels ; $iValue - pixels reference or value ; $iLow - lower limit of axis ; $iHigh - upper limit of axis ; $iTotalPixels - total number of pixels in range (either width or height) ; ========================================================================================= Func _Graph_Reference_Pixel($iType, $iValue, $iLow, $iHigh, $iTotalPixels) ;----- perform pixel reference calculations ----- Switch $iType Case "x" Return (($iTotalPixels / ($iHigh - $iLow)) * (($iHigh - $iLow) * (($iValue - $iLow) / ($iHigh - $iLow)))) Case "y" Return ($iTotalPixels - (($iTotalPixels / ($iHigh - $iLow)) * (($iHigh - $iLow) * (($iValue - $iLow) / ($iHigh - $iLow))))) Case "p" Return ($iValue / ($iTotalPixels / ($iHigh - $iLow))) + $iLow EndSwitch EndFunc ;==>_Graph_Reference_Pixel
  8. Hi, I am in the process of writing a GDI+ graphic-heavy program using numerous pens and brushes. It is getting fairly difficult to keep up with what is created when the script is in use, so in some circumstances some components may not be disposed of properly. What are the repercussions of not correctly shutting down GDI+ and its components? In the past I've notiecd that task manager fills up with rundll.exe's if _GDIShutdown is not called. Is eating up memory the only downside, and will these rundll's dissappear eventually?? Thanks in advance Andy
  9. Hi, I know this is a bit retro, but here is a simple way to embed images into HTML files to give MHTML 'archive' files. For me, this is useful because I am often called on to create various types of reports which often include images (graphs etc). It's much easier to send/email someone a single file rather than the report HTML and its images separately. This script will prompt for an input HTML file which it will then scan through for images, convert them to Base64, and write out to a .MHT file. The MHT file will contain both the HTML and the embedded images. _HTML_To_MHTML(FileOpenDialog("", ".", "(*.html;*.htm)")) Func _HTML_To_MHTML($sFileName) Local $i, $aFile ;----- Prepare MHT Header ----- Local $sMHTHold = 'From:' & @CRLF & _ 'Subject:' & @CRLF & _ 'Date:' & @CRLF & _ 'MIME-Version:' & @CRLF & _ 'Content-Type: multipart/related; type="text/html"; boundary="----=_NextPart"' & @CRLF & _ 'X-MimeOLE:' & @CRLF & _ @CRLF & _ '------=_NextPart' & @CRLF & _ 'Content-Type: text/html; charset="Windows-1252"' & @CRLF & @CRLF ; ;----- Open HTML & Convert Images ----- Local $sHTML = FileRead($sFileName) $sHTML = StringReplace($sHTML,"%20"," ") Local $sHTMLtemp = StringStripCR($sHTML) Local $aIMGImages = StringRegExp($sHTMLtemp, "<(?:img|IMG) [^>]*>", 3) Local $sMHTPost = "" ;MHT Footer For $i = 0 To UBound($aIMGImages) - 1 $aFile = StringRegExp($aIMGImages[$i], 'src="([^"]*)"', 1) $sHTML = StringReplace($sHTML, $aFile[0], "cid:" & $aFile[0]) $sMHTPost &= '------=_NextPart' & @CRLF & _ 'Content-Type: image' & @CRLF & _ 'Content-ID: <' & $aFile[0] & '>' & @CRLF & _ 'Content-Transfer-Encoding: base64' & @CRLF & _ @CRLF & _ _Base64Encode(FileRead($aFile[0])) & @CRLF & _ @CRLF ; Next ;----- Combine Header, HTML, & Footer ----- $sMHTHold &= $sHTML & @CRLF & $sMHTPost ;----- Prompt to save ----- $sSaveFile = FileSaveDialog("Save File", ".", "(*.mht)", Default, StringMid($sFileName, 1, StringInStr($sFileName, ".", -1) - 1)) If @error < 1 Then FileWrite($sSaveFile & ".mht", $sMHTHold) EndFunc ;==>_HTML_To_MHTML Func _Base64Encode($sData) ;by TurboV21 Local $oXml = ObjCreate("Msxml2.DOMDocument") Local $oElement = $oXml.createElement("b64") $oElement.dataType = "bin.base64" $oElement.nodeTypedValue = Binary($sData) Local $sReturn = $oElement.Text Return $sReturn EndFunc ;==>_Base64Encode Some caveats: - The HTML and images must exist on your PC, it won't pull images straight from the net - The saved file must be created in the SAME directory as the original HTML file - If your HTML file contains the string "%20" it will be converted to WS - ONLY images are embedded, any CSS PHP etc will still be dependent on external files - It won't pull images from javascript tags, only HTML <img > tags Please don't rely on this to successfully convert anything other than very simple HMTL files, it is designed to put simple images into basic HTML files. Credits: TurboV21 - for the Base64 encoder, which I butchered.
  10. I think the first limitation you'll run into is AutoIT's limit of 65532 GUI controls. E.g. you couldn't create a table of 256x256 cells. There's an example of a sort-of scroll bar above, but you're welcome to make any improvements. Post it here if you're successful, I had a bash but it was too messy in the end.
  11. ooops, just re-read this, it should actually be "to the left". All changes made in one tile should be repeated in subsequent tiles. Don't worry I didn't think that for a minute! When I first got into these back in the 90's, I used to create them by hand using a pen and stencil. One of my mates was particularly good at it and could draw them completely freehand! Similarly to your example, the follwing example explains it quite well too... imagine a repeating background sequence: o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o Making a simple deletion in one line (the 2nd line) shifts the character upwards, but also shifts the next character downwards: o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o To correct this all subsequent characters need an equal shift: o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o Now we have a sinle raised character. Multiple levels can be achieved with multiple deletions: & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & This becomes more complicated when using 'tiles' of images or noise, because the shift left or right cannot be greater than the width of the tile itself. Glad someone else finds this fascinating too!!
  12. Excellent work! Since I wrote my 'noise' style stereogram script (see my sig), I've gotten much more used to GDI so I might have a look at a bitmap approach. Lucklily for us, the approach is exactly the same as you are doing here... 1) create a repeating pattern (can be any sort of image) 2) decide how much you need to horizontally shift each pixel based on your depth-map, ensuring your 'range' doesn't exceed the width of a tile 3) shift all pixels in current tile to the left 4) shift all pixels in subsequent tiles by an equal ammount to the right LEFT Sort of off-topic slightly, there's an interesting/fun phenomenon I've discovered as a result of working with stereograms. As you become more adept at controlling your eyes to 'manually' adjust your focal point, you'll be able to combine just about anything you see into a single focused image. If the two things you combine are totally different the focused image will be nonsense in dimensional terms and will not make 'sense' in your brain. This can actually be quite useful if you want to compare things to see if they are the same, and I often do this without thinking (e.g. comparing long numbers, long lines of text etc). As long as you can combine the two items with your eyes, any differences stand out as visual abberations. One fun aspect of this is easily being able to solve spot-the-difference puzzles. Take this for example. To solve this, a 'normal' person would scan each picture in turn trying to see the differences. My approach is to combine the two images with my eyes. The differences stand out immediately; solving the puzzle takes as long as it takes you to combine the images, perhaps less than a second. Quiz machines in pubs often have a spot the difference game which can be solved doing this. My mates think I am some sort of spot-the-difference god, but really it's all eye control!
  13. Ha! Excellent! Yeah, I guess yours doesn't need the initialize device...although, just make sure that it still gives results to 4 decimal places after turning the PC off and on again. I found that the "initialize device" only needed to be called once to set the correct precision, and then again after every re-boot. This may have been called on your PC by a different program (manufacturers software, UTAC, etc) whilst you were testing. I'll update my GetTemp.exe later to include what we've found. Thanks!
  14. Hmmm, so the Read Temperature doesn't fail when parameters aren't sent to the DLL. The Initialise Device was used to improve precision, so it may not matter that that fails just yet, we can deal with that later! Try this with just 1 device plugged in: $ghHidFTDll = DLLOpen("HidFTDll.dll") $a = DllCall($ghHidFTDll,"int:cdecl","EMyDetectDevice", 'long', 0) ConsoleWrite(@error & " " & $a[0] & @CRLF) ;----- read device 1 ------ $a = DllCall($ghHidFTDll,"none:cdecl","EMySetCurrentDev", 'int', 0) ConsoleWrite(@error & " " & $a[0] & @CRLF) $a = DllCall($ghHidFTDll,"double","EMyReadTemp") ConsoleWrite(@error & " " & $a[0] & @CRLF) This is just the same script as before, but using EMyReadTemp without passing parameters to the DLL. From your last post, this doesn't say it fails. Fingers crossed!
×
×
  • Create New...