Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 01/04/2015 in all areas

  1. [NEW VERSION] - 2 Aug 18 Added: When specifying the icon to use, if the $vIcon parameter is set to the name of an ico or exe file, the main icon within will be displayed, but if a trailing "|" followed by the icon index is added to the name, that icon from within the file is used New UDF and example in the zip below. Details of previous versions: Changelog.txt A forum query about the small pop-ups that some apps produce from the systray led me to create my version of how this can be done. By the way, I call these small GUIs "Toasts" for obvious reasons! A zip containing the UDF, an example script and my StringSize UDF (which is also required): Toast.zip As always, kind comments and constructive criticisms welcome - particularly the former! M23
    1 point
  2. Here is the rewritten version of this UDF. See my comments HERE. Please test the shit out of this thing. It was a major headache, and I want to make sure I didn't miss something. Thanks! Update 2013/05/28 - Fixed missing @error return in _Zip_ItemExists - Clarified a few @error return value meanings - Added an additional check and @error code to _Zip_DeleteItem - Clarified some of the header notes, esp regarding behavior on XP Update 2011/12/08 - Fixed recursion in ListAll function Update 2011/12/07 - Fixed recursion error in CountAll function - updated objects to conform to new COM syntax (parenthesis req'd for methods) Update 2011/07/01 - Reverted change to AddItem function - **Adding an item directly to a sub folder on XP will FAIL Update 2011/06/30 - Fixed traversing namespaces on Windows XP - Added note that overwrite fails on XP Update 2011/01/13 - Fixed bug adding items to a subfolder that doesn't exist yet Update 2010/08/27 - Fixed bug with trailing 's Update 2010/07/16 - Better error reporting in _Zip_AddItem function Update 2010/07/02 - Added credits. - Added trancexxx's suggestion to remove any left over temporary directories. - Replaced some StringTrim calls with cleaner StringRegExpReplace calls. - Moved a few repetitive lines of code into functions. - Moved a few repetitive lines of code into functions. - Moved a few repetitive lines of code into functions. =========================== _Zip.au3
    1 point
  3. Yashied

    Skin UDF

    LAST VERSION - 0.2 03-Jan-15 Skin UDF allows you to create buttons from the predefined images (files, resources, etc.). I rewrote this library by using GDI+ (first version used GDI). This allowed add the many additional features and get rid of the problems related to the transparency. Nevertheless, the library has a beta status, so there is no detailed description of the functions. But I am sure that the example below gives complete information about the features of this library. I hope that many users will find it useful. If you will have any questions, please ask them in this thread. Available functions Skin Library v1.0 Skin.zip Example #Include <GUIConstantsEx.au3> #Include <Skin.au3> Global $Button[3] $hForm = GUICreate('MyGUI', 278, 106) GUICtrlCreatePic('background.bmp', 0, 0, 278, 106) GUICtrlSetState(-1, $GUI_DISABLE) ; Create buttons from PNG images (images should be located in the same folder as the script) $Button[0] = _Skin_AddButton(20 , 20, 66, 66, 'red_normal.png', 'red_hover.png', 'red_click.png', 'disable.png', 'alpha.png', 1) $Button[1] = _Skin_AddButton(106, 20, 66, 66, 'yellow_normal.png', 'yellow_hover.png', 'yellow_click.png', 'disable.png', 'alpha.png', 1) $Button[2] = _Skin_AddButton(192, 20, 66, 66, 'green_normal.png', 'green_hover.png', 'green_click.png', 'disable.png', 'alpha.png', 1) #cs ; Create buttons from GDI+ HBITMAP handles $Button[0] = _Skin_AddButtonEx(20 , 20, 64, 64, _GDIPlus_BitmapCreateFromFile('red_normal.png'), ..., 1, 1) $Button[1] = _Skin_AddButtonEx(104, 20, 64, 64, _GDIPlus_BitmapCreateFromFile('yellow_normal.png'), ..., 1, 1) $Button[2] = _Skin_AddButtonEx(188, 20, 64, 64, _GDIPlus_BitmapCreateFromFile('green_normal.png'), ..., 1, 1) #ce ; Disable "Yellow" button (Optional) _Skin_DisableButton($Button[1], 1) ; Enable keyboard input (Optional) _Skin_EnableKBInput(1) ; Set margins for dotted focus rectangle (Optional) For $i = 0 To 2 _Skin_SetFocusRect($Button[$i], 5, 5, 56, 56) Next ; Enable dotted focus rectangle (Optional) _Skin_EnableFocus(1) GUISetState() ; _Skin_Helper() must be called continuously in the main loop While 1 _Skin_Helper($hForm) $ID = GUIGetMsg() Switch $ID Case 0 ContinueLoop Case $GUI_EVENT_CLOSE ExitLoop Case $Button[0] ConsoleWrite('Red' & @CR) Case $Button[1] ConsoleWrite('Yellow' & @CR) Case $Button[2] ConsoleWrite('Green' & @CR) Case Else EndSwitch WEnd ; You must delete all created buttons before destroying the appropriate window ;~For $i = 0 To 2 ;~ _Skin_DeleteButton($Button[$i]) ;~Next
    1 point
  4. March 22, 2015 (NEW udf version in >post #12 . slight enhancement on index and multindex creation) March 21, 2015 (NEW udf version in >post #12 . slight enhancement on index creation) March 15, 2015 (NEW version in >post #9 below. It also allows creation of simple indexes) March 03, 2015 (NEW improved version in >post #7 below) This is a simple udf to manage 1D or 2D arrays by means of SQL query. I hope it can be useful both for simple educational and testing purposes about SQL that also for the management of arrays in general. New version (it makes use of the new "chain insertion" functionality of SQLite as suggested by jchd in post #5) ; save this as ArraySQL.au3 ; V2 #include-once #include <Array.au3> #include <SQLite.au3> #include <SQLite.dll.au3> ; Global Static $g__sSQliteDll = _SQLite_Startup() Global Static $g__hMemDb = _SQLite_Open() Global $g__sSQLiteError = "" ; will contains SQL error messages ; #FUNCTION# ==================================================================================================================== ; Name...........: _ArraySQL ; Description ...: Allows to execute SQL queryes against 1D or 2D arrays ; Syntax.........: _ArraySQL( ByRef $avArray, $sSQL_Query ) ; Parameters ....: $avArray - an 1D or 2D Array to be manage ; $sSQL_Query - a string containing the SQL query to execute against the array ; the passed array is referred as array as table name in the query ; the fields (column(s)) of the array are referred as column0, column1, column2 .... and so on ; ; Return values .: Success: An 1D or 2D array containing data resulting from the execution of the SQL query. ; ; Fillure: an empty string and the @error value is set as following ; 1 - First argument is not an array ; 2 - not a 1D or 2D array ; 3 - SQLite error. In this case the $g__sSQLiteError global variable contains the error description. ; =============================================================================================================================== Func _ArraySQL(ByRef $avArray, $sSQL_Query) Local $aResult, $iRows, $iColumns, $iRval, $iError $g__sSQLiteError = "" __ArrayToSqlTable($avArray) ; clone $avArray to a temporary sql db table (memory resident) ; name of the temp table will be array ; name of the filed(s) will be column0 column1 column2 columnN and so on .... ; If @error Then Return SetError(@error, 0, "") ; something went wrong ; now execute the SQL query $iRval = _SQLite_GetTable2d(-1, $sSQL_Query, $aResult, $iRows, $iColumns) If Not $iRval = $SQLITE_OK Then ; an SQLite error occurred $g__sSQLiteError = _SQLite_ErrMsg() _SQLite_Exec($g__hMemDb, "DROP TABLE array") ; delete the temporary table Return SetError(3, 0, "") Else $g__sSQLiteError = "" _SQLite_Exec($g__hMemDb, "DROP TABLE array") ; delete the temporary table Return SetError(0, 0, $aResult) EndIf EndFunc ;==>_ArraySQL ; ; #INTERNAL USE# ================================================================================================================ ; Name...........: __ArrayToSqlTable ; Description ...: clone $avArray to a temporary SQLite db table (memory resident) ; Syntax.........: __ArrayToSqlTable ( ByRef $avArray) ; Parameters ....: $avArray - Array to clone to the SQLite temporary table ; ; Remarks .......: For Internal Use Only ; =============================================================================================================================== Func __ArrayToSqlTable(ByRef $avArray) ; Pass an array to a temporary SQL table If Not IsArray($avArray) Then Return SetError(1, 0, 0) ; must be an array Local $iDimensions = UBound($avArray, 0) If $iDimensions > 2 Then Return SetError(2, 0, 0) ; must be an 1D or 2D array Local $aAutoItV = StringSplit(@AutoItVersion, ".", 2), $nAutoItVersion = StringFormat("%03i%03i%03i%03i", $aAutoItV[0], $aAutoItV[1], $aAutoItV[2], $aAutoItV[3]) Local $iStep = 10 ; the number of records we want to load in each chain <---- the chain length If $nAutoItVersion < 3003012000 Then $iStep = 1 ; if an older version of AutoIt then do not use the new SQLite "chain insertion" Local $sDBfields = "" ; will hold the names of the fields (column0, column1, column2......) (zero based) Local $vDBvalues = "" ; will hold the values of a field (1, 'aaa', 456) Local $vDBvaluesChain = "" ; will hold the chain of n values (1, 'aaa', 456), (2, 'bbb', 147), ... , (235, 'xyz', 999) Local $iRecords = UBound($avArray, 1) ; total number of rows in the array Local $iLastRecord = $iRecords - 1 Local $iChains = Ceiling($iRecords / $iStep) ; how many chains we will fill? Local $nRemainders = Mod($iRecords, $iStep) ; are there rmainders? (if so the last chain will be only partly full) Local $iFields = 0 ; we suppose an 1D array If $iDimensions = 2 Then ; if is a 2D array instead $iFields = UBound($avArray, 2) - 1 ; number of fields (columns) in the 2D array (zero based) EndIf For $x = 0 To $iFields $sDBfields &= "column" & String($x) & "," Next $sDBfields = StringTrimRight($sDBfields, 1) ; remove the last comma If Not _SQLite_Exec(-1, "CREATE TEMP TABLE array (" & $sDBfields & ");") = $SQLITE_OK Then $g__sSQLiteError = _SQLite_ErrMsg() ; _SQLite_Exec($g__hMemDb, "DROP TABLE array") ; delete the temporary table Return SetError(3, 0, "") Else #cs suggestion by jchd -> http://www.autoitscript.com/forum/topic/166536-manage-arrays-by-means-of-sql/?p=1216694 For maximizing efficiency of table population using INSERT, you can use the "chain insertion" new syntax: insert into mytable (a,b,c) values (1, 'aaa', 456), (2, 'bbb', 147), (3, 'ccc', 258), ... , (235, 'xyz', 999) You need to keep the query string under the size limit (depends on compile-time options) but you can get N-fold (for some value N) improvement on insert speed with that simple trick. #ce If Not $nRemainders Then ; there are no remainder records. ; then we can load all chains (with group of records) ; and we will have no residual records to manage For $x = 0 To $iLastRecord Step $iStep ; we read records in groups of $iStep $vDBvaluesChain = "" For $iRecord = $x To $x + $iStep - 1 $vDBvalues = "" ___BuildRecord($avArray, $iFields, $vDBvalues, $iRecord) ; build data record related to row $iRecord $vDBvaluesChain &= $vDBvalues & "),(" ; build the chain of records Next $vDBvaluesChain = StringTrimRight($vDBvaluesChain, 3) ; remove last "),(" ; insert chain to table ___InsertChain($sDBfields, $vDBvaluesChain) Next ; Else ; if we are here is because there are remainders, so: If $iChains - 1 Then ; if there are more than 1 chain (otherwise if records are less than $istep read only remainders) For $x = 0 To $iLastRecord - $nRemainders Step $iStep $vDBvaluesChain = "" For $iRecord = $x To $x + $iStep - 1 $vDBvalues = "" ___BuildRecord($avArray, $iFields, $vDBvalues, $iRecord) ; build data record related to row $iRecord $vDBvaluesChain &= $vDBvalues & "),(" ; build the chain of records Next $vDBvaluesChain = StringTrimRight($vDBvaluesChain, 3) ; remove last "),(" ___InsertChain($sDBfields, $vDBvaluesChain) Next EndIf ; -- now read remainders ----- $vDBvaluesChain = "" For $iRecord = $iLastRecord - $nRemainders + 1 To $iLastRecord ; Step $iStep $vDBvalues = "" ___BuildRecord($avArray, $iFields, $vDBvalues, $iRecord) ; build data record related to row $iRecord $vDBvaluesChain &= $vDBvalues & "),(" ; build the chain of records Next $vDBvaluesChain = StringTrimRight($vDBvaluesChain, 3) ; remove last "),(" ___InsertChain($sDBfields, $vDBvaluesChain) EndIf EndIf EndFunc ;==>__ArrayToSqlTable Func ___BuildRecord(ByRef $avArray, ByRef $iFields, ByRef $vDBvalues, ByRef $x) For $y = 0 To $iFields Switch $iFields Case 0 ; just 1 field (1D Array) If IsNumber($avArray[$x]) Then $vDBvalues &= $avArray[$x] & "," Else $vDBvalues &= _SQLite_FastEscape($avArray[$x]) & "," EndIf Case Else ; multi fields (2D Array) If IsNumber($avArray[$x][$y]) Then $vDBvalues &= $avArray[$x][$y] & "," Else $vDBvalues &= _SQLite_FastEscape($avArray[$x][$y]) & "," EndIf EndSwitch Next $vDBvalues = StringTrimRight($vDBvalues, 1) ; remove last comma EndFunc ;==>___BuildRecord Func ___InsertChain(ByRef $sDBfields, ByRef $vDBvaluesChain) If Not _SQLite_Exec(-1, "INSERT INTO array (" & $sDBfields & ") VALUES (" & $vDBvaluesChain & ");") = $SQLITE_OK Then $g__sSQLiteError = _SQLite_ErrMsg() _SQLite_Exec($g__hMemDb, "DROP TABLE array") ; delete the temporary table Return SetError(3, 0, "") EndIf EndFunc ;==>___InsertChain previous version is in the spoiler A simple example of use: #include <ArraySQL.au3> Local $x, $y, $sQuery, $aResult ; ------------------------------------------------------------ ; populate an array with random data to be managed for example Local $Array[1000][5] For $x = 0 To 999 For $y = 0 To 4 $Array[$x][$y] = Random(0, 100, 1) Next Next ; ------------------------------------------------------------ ; returns only rows where first column (column0) contains a value < 10 $sQuery = "SELECT * FROM array WHERE column0 < 10;" $aResult = _ArraySQL($Array, $sQuery) If Not @error Then _ArrayDisplay($aResult, "only data < 10 in column 0") Else MsgBox(0, "error", $g__sSQLiteError) EndIf ; ; returns all rows ordered by first column (column0) and then fourth by column (column3) $sQuery = "SELECT * FROM array ORDER BY column0,column3;" $aResult = _ArraySQL($Array, $sQuery) If Not @error Then _ArrayDisplay($aResult, "Ordered by column 0 and 3") Else MsgBox(0, "error", $g__sSQLiteError) EndIf P.S. improvements, corrections and suggestions are welcome
    1 point
  5. Ascend4nt

    GUI Fun!

    GUI Fun! Not enough posts here are about just plain fun stuff to do with AutoIt, at least not lately. So I figure, why not dig up one of my old UDFs, clean it up a bit, and throw it very emphatically at you lot of misfits! One way of mucking about with AutoIt and Windows that can be entertaining is creating shaped GUIs. Sure, GUIs with regions are nothing new here or in general on the Windows platform. But have you ever just wanted to stare at colorful shapes flying across your screen, for no apparent reason? Well, my friend, you've come to the right place. The first UDF I've put up pretty simple. Boxes, circles, triangles, diamonds, and stars are what I bring you, in technicolor wonder. I will probably add a few more examples when I find the time.. However, its my hope that more people add to this thread - and maybe provide links to other topics or posts where some nifty GUI fun is to be had! GUI related Threads & UDFs of Interest >GUI design concepts (started by Guinness) >Perforator - Perforated GUIs (and really anything GUI or GDI+-related by UEZ) >PNG as GUI >Multiple PNG images as GUI elements >FreeText - Text shape GUIs >Visible Controls on a Transparent Window >Layered Window without Image >AnyGUI - Extend the GUI of any Window >_UskinLibrary - Skinning w/DLL >XSkin - More GUI Skinning >GUIExtender, >GUIFrame, >Toast and other nice UDFs by Melba23 >GIF Animation >GDI+ Animated Waiting / Loading Screens My Examples I should point out other GUI manipulation UDF's I've uploaded in the past, as they too can provide some amusement. >GUIBox - Rubber-band GUIs >Full-screen Crosshairs >BarSweep (very simple example) >BoxSelection (another simple example) Okay, on to the new stuff! _GUIShapes is a UDF with functions to create GUI's shapes like Circles, Boxes, Triangles, Stars, and Diamonds. These GUI's have no interactive elements or controls and are click-through-able, meaning that a click on the GUI will pass through to whatever window is underneath. _LineTraverser is a UDF with functions to create a well, line traverser. Given a start and end point, it will allow you to step through a given line without needing to do any extra work on your behalf. This uses Bresenham's line algorithm to calculate the individual steps. I know this one isn't related to GUI, but its what I used for my second 'GUI fun' example below. Pacman Line-Traversing GUI (>static or >animated). That's right, I managed to animate a GUI! Check it! (now included in the ZIP) Examples that follow will be bundled with the ZIP. Have fun! Updates: GUIShapesExample - whacky shapes flying all over the screen!!! #include "_GUIShapes.au3" ;~ #include <WinAPI.au3> ; already included in <_GUIShapes.au3> ; ======================================================================================================== ; <GUIShapesExample.au3> ; ; Example use of <_GUIShapes.au3> UDF ; ; This example creates a bunch of random GUI shapes with random attributes, and moves ; everything around - randomly. ; ; Author: Ascend4nt ; ======================================================================================================== ; ---------------------- MAIN CODE ------------------------------- Local $iShapeGUIs = 20, $aShapeGUIs[$iShapeGUIs], $iTimer, $iRand, $aRet Local $iRandX, $iRandY, $iRandColor, $iRandLength Local $iTriangles = 0, $iCircles = 0, $iStars = 0, $iDiamonds = 0, $iBoxes = 0 For $i = 0 To $iShapeGUIs - 1 ; Everything random! $iRandX = Random(0, @DesktopWidth - 20, 1) $iRandY = Random(0, @DesktopHeight - 20, 1) $iRandLength = Random(12, 300, 1) $iRandColor = Random(0x111111, 0xFFFFFF, 1) ; Choose a GUI shape at random, with semi-random attributes Switch Random(0, 5, 1) Case 0 $aShapeGUIs[$i] = _TriangleGUICreate($iRandX, $iRandY, $iRandLength, BitAND($iTriangles, 1) * Random(1, 10, 1), Default, Mod($i, 4), $iRandColor) $iTriangles += 1 Case 1 $aShapeGUIs[$i] = _CircleGUICreate($iRandX, $iRandY, $iRandLength, BitAND($iCircles, 1) * Random(1, 10, 1), Default, $iRandColor) $iCircles += 1 Case 2 $aShapeGUIs[$i] = _StarGUICreate($iRandX, $iRandY, $iRandLength, BitAND($iStars, 1) * Random(1, 10, 1), $iRandColor) $iStars += 1 Case 3 $aShapeGUIs[$i] = _DiamondGUICreate($iRandX, $iRandY, $iRandLength, Default, BitAND($iDiamonds, 1) * Random(1, 10, 1), $iRandColor) $iDiamonds += 1 Case Else ; 4 $aShapeGUIs[$i] = _BoxGUICreate($iRandX, $iRandY, $iRandLength, BitAND($iBoxes, 1) * Random(1, 10, 1), Default, $iRandColor) $iBoxes += 1 EndSwitch ; Show the randomly created GUI GUISetState(@SW_SHOWNOACTIVATE, $aShapeGUIs[$i]) ; And set a random transparency too WinSetTrans($aShapeGUIs[$i], '', Random(50, 255, 1)) Next ConsoleWrite("GUI Totals: Triangles:" & $iTriangles & ", Circles:" & $iCircles & ", Stars:" & $iStars & ", Diamonds:" & $iDiamonds & ", Boxes:" & $iBoxes & @CRLF) ; Timer for moving shapes $iTimer = TimerInit() While 1 ; Exit on 'ESC' keypress (BitAND() test for down-state) If BitAND(_WinAPI_GetAsyncKeyState(0x1B), 0x8000) Then ExitLoop Sleep(10) ; Move a random GUI every 30+ms If TimerDiff($iTimer) >= 30 Then $iRand = Random(0, $iShapeGUIs - 1, 1) ; Set GUI above other windows WinSetOnTop($aShapeGUIs[$iRand], "", 1) ; Move to a random position WinMove($aShapeGUIs[$iRand], "", Random(0, @DesktopWidth - 20, 1), Random(0, @DesktopHeight - 20, 1), Default, Default, 2) ; Reset timer $iTimer = TimerInit() EndIf WEnd _ LineTraverserExample - Where's the ball? Huh, where is it, Fido?! Ooh, there it is! Fetch the ball! Gooood circle.. #include "_GUIShapes.au3" #include "_LineTraverser.au3" ;~ #include <WinAPI.au3> ; ======================================================================================================== ; <LineTraverserExample.au3> ; ; Simple Example of using the <_LineTraverser.au3> and <_GuiShapes.au3> UDF's ; ; A little red-ball will display, and a hollow ball will move towards it. ; A line will be drawn to show how the path from the hollow ball to the red-ball target should work, ; and then the hollow ball moves to it in $iStep increments. ; ; ; Author: Ascend4nt ; ======================================================================================================== Global Const $iStep = 2 Local $hHollowCircle, $hDestCircle, $iExt Local $iXTarget, $iYTarget, $aLineTraverser ; Create the 2 circle GUIs $hHollowCircle = _CircleGUICreate(Random(0, @DesktopWidth - 20, 1), Random(0, @DesktopHeight - 20, 1), 81, 10, Default, Random(0x111111, 0xFFFFFF, 1)) $hDestCircle = _CircleGUICreate(1, 1, 17, 0, 17, 0xFF0000) ; Set initial target point $iXTarget = Random(0, @DesktopWidth - 20, 1) $iYTarget = Random(0, @DesktopHeight - 20, 1) ; Source/Target are same to start off with $aLineTraverser = _LineTraverserCreate($iXTarget, $iYTarget, $iXTarget, $iYTarget) ; Move windows to start positions WinMove($hHollowCircle, '', $aLineTraverser[0], $aLineTraverser[1]) ; + Center of hollow circle, - half of target circle WinMove($hDestCircle, '', $iXTarget + 40 - 8, $iYTarget + 40 - 8) ; Transparency on 'seeker' circle WinSetTrans($hHollowCircle, '', 150) ; Show both GUIs, and put on top of all windows WinSetState($hDestCircle, '', @SW_SHOWNOACTIVATE) WinSetState($hHollowCircle, '', @SW_SHOWNOACTIVATE) WinSetOnTop($hHollowCircle, '', 1) WinSetOnTop($hDestCircle, '', 1) While 1 ; Exit on 'ESC' keypress (in down state) If BitAND(_WinAPI_GetAsyncKeyState(0x1B), 0x8000) Then ExitLoop ; < 10 ms sleep with an API call DllCall("kernel32.dll",'none','Sleep','dword',3) If Not _LineTraverserStep($aLineTraverser, $iStep) Then $iExt = @extended ; Was there movement? Then moooove If $iExt Then WinMove($hHollowCircle, '', $aLineTraverser[0], $aLineTraverser[1]) EndIf $aPos = WinGetPos($hHollowCircle) ; Debug check. Should never be hit, so long as Window is moved to each step (including any last steps - see @extended) If $iXTarget <> $aPos[0] Or $iYTarget <> $aPos[1] Then ConsoleWrite("Mismatch: TargetX:" & $iXTarget & ", TraverserX:" & $aLineTraverser[0] & ", Current X:" & $aPos[0] & _ ", TargetY:" & $iYTarget & ", TraverserY:" & $aLineTraverser[1] & ", Current Y:" & $aPos[1] & ", @extended:" & $iExt & @CRLF) EndIf ; A little extra sleep to make it clear we've reached our destination. DllCall("kernel32.dll",'none','Sleep','dword',6) ; Now we'll set a new destination (with a visible line) Dim $iXTarget = Random(0, @DesktopWidth - 20, 1), $iYTarget = Random(0, @DesktopHeight - 20, 1) ; Create a new Line-Traverser (no need to explicitly destroy the last one, it was just an array of numbers) $aLineTraverser = _LineTraverserCreate($aLineTraverser[0], $aLineTraverser[1], $iXTarget, $iYTarget) ; + Center of hollow circle, - center of target circle WinMove($hDestCircle, '', $iXTarget + 40 - 8, $iYTarget + 40 - 8) ;~ Draw the line on-screen to give a visual indicator of the path that the hollow circle should take ;~ (note that the line will be overwritten by ANY screen activity, but that's fine for the example) ; Get DC to screen $hDC = _WinAPI_GetDC(0) ; Create pen and select it into DC $hPen = _WinAPI_CreatePen(0, 3, 0xFFFFFF) $hPenOld = _WinAPI_SelectObject($hDC, $hPen) ; Note we add 40 (for the center of the hollow circle GUI) _WinAPI_DrawLine($hDC, $aPos[0] + 40 - 1, $aPos[1] + 40 - 1, $iXTarget + 40 - 1, $iYTarget + 40 - 1) ; Select the old pen back _WinAPI_SelectObject($hDC, $hPenOld) ; Clean up pen and then release DC _WinAPI_DeleteObject($hPen) _WinAPI_ReleaseDC(0, $hDC) ; What fun drawing with GDI is =| Else WinMove($hHollowCircle, '', $aLineTraverser[0], $aLineTraverser[1]) EndIf WEnd GUIShapesFun.zip ~prev downloads: 60
    1 point
  6. jreedmx, Ten minutes before the gannets arrive - just time to post this much improved version which I worked on during gaps in my busy wife-imposed schedule this morning: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiTreeView.au3> #include <Array.au3> ; Create flag to indicate TV item selection change Global $hTVItemSelected = False ; Create array to hold TV item data Global $aItems[17][3] ; Create GUI Global $hGUI = GUICreate("Test", 500, 500) ; Create TreeView Global $cTV = GUICtrlCreateTreeView(10, 10, 250, 350, BitOR($GUI_SS_DEFAULT_TREEVIEW, $TVS_CHECKBOXES)) ; Fill TreeView $aItems[0][2] = GUICtrlCreateTreeViewItem("Food", $cTV) $aItems[1][2] = GUICtrlCreateTreeViewItem("Fruit", $aItems[0][2]) $aItems[2][2] = GUICtrlCreateTreeViewItem("Apple", $aItems[1][2]) $aItems[3][2] = GUICtrlCreateTreeViewItem("Meat", $aItems[0][2]) $aItems[4][2] = GUICtrlCreateTreeViewItem("Steak", $aItems[3][2]) $aItems[5][2] = GUICtrlCreateTreeViewItem("Chicken", $aItems[3][2]) $aItems[6][2] = GUICtrlCreateTreeViewItem("Dairy", $aItems[0][2]) $aItems[7][2] = GUICtrlCreateTreeViewItem("Cheese", $aItems[6][2]) $aItems[8][2] = GUICtrlCreateTreeViewItem("Drinks", $cTV) $aItems[9][2] = GUICtrlCreateTreeViewItem("Water", $aItems[8][2]) $aItems[10][2] = GUICtrlCreateTreeViewItem("Fizzy", $aItems[8][2]) $aItems[11][2] = GUICtrlCreateTreeViewItem("Cola", $aItems[10][2]) $aItems[12][2] = GUICtrlCreateTreeViewItem("Juice", $aItems[8][2]) $aItems[13][2] = GUICtrlCreateTreeViewItem("Orange Juice", $aItems[12][2]) $aItems[14][2] = GUICtrlCreateTreeViewItem("Hot Drinks", $aItems[8][2]) $aItems[15][2] = GUICtrlCreateTreeViewItem("Tea", $aItems[14][2]) $aItems[16][2] = GUICtrlCreateTreeViewItem("Coffee", $aItems[14][2]) ; Set initial unchecked state and get item handles (needed for later code) For $i = 0 To UBound($aItems) - 1 $aItems[$i][1] = False $aItems[$i][0] = GUICtrlGetHandle($aItems[$i][2]) Next ; Expand TreeView _GUICtrlTreeView_Expand($cTV) ; Create buttons to set/clear all items Global $cSet = GUICtrlCreateButton("Set All", 300, 10, 80, 30) Global $cClear = GUICtrlCreateButton("Clear All", 300, 50, 80, 30) GUISetState() ; Register message to look for TV item selection change GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY") Global $bState, $iItemIndex While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cSet _Adjust_All() Case $cClear _Adjust_All(False) EndSwitch ; An item has been selected If $hTVItemSelected Then ; Determine checked state $bState = _GUICtrlTreeView_GetChecked($cTV, $hTVItemSelected) ; Find item in array $iItemIndex = _ArraySearch($aItems, $hTVItemSelected) ; If checked state has altered If $aItems[$iItemIndex][1] <> $bState Then ; Store new state $aItems[$iItemIndex][1] = $bState ; Adjust parents and children as required _Adjust_Parents($hTVItemSelected, $bState) _Adjust_Children($hTVItemSelected, $bState) EndIf ; Clear flag $hTVItemSelected = 0 EndIf WEnd Func _Adjust_All($bState = True) ; Loop through items For $i = 0 To UBound($aItems) - 1 ; Adjust item _GUICtrlTreeView_SetChecked($cTV, $aItems[$i][0], $bState) ; Adjust array $aItems[$i][1] = $bState Next EndFunc ;==>_Adjust_All Func _Adjust_Parents($hPassedItem, $bState = True) Local $iIndex ; Get the handle of the parent Local $hParent = _GUICtrlTreeView_GetParentHandle($cTV, $hPassedItem) If $hParent = 0 Then Return ; Assume parent is to be adjusted Local $bAdjustParent = True ; Need to confirm all siblings clear before clearing parent If $bState = False Then ; Check on number of siblings Local $iCount = _GUICtrlTreeView_GetChildCount($cTV, $hParent) ; If only 1 sibling then parent can be cleared - if more then need to look at them all If $iCount <> 1 Then ; Number of siblings checked Local $iCheckCount = 0 ; Move through previous siblings Local $hSibling = $hPassedItem While 1 $hSibling = _GUICtrlTreeView_GetPrevSibling($cTV, $hSibling) ; If found If $hSibling Then ; Is sibling checked) If _GUICtrlTreeView_GetChecked($cTV, $hSibling) Then ; Increase count if so $iCheckCount += 1 EndIf Else ; No point in continuing ExitLoop EndIf WEnd ; Move through later siblings $hSibling = $hPassedItem While 1 $hSibling = _GUICtrlTreeView_GetNextSibling($cTV, $hSibling) If $hSibling Then If _GUICtrlTreeView_GetChecked($cTV, $hSibling) Then $iCheckCount += 1 EndIf Else ExitLoop EndIf WEnd ; If at least one sibling checked then do not clear parent If $iCheckCount Then $bAdjustParent = False EndIf EndIf ; If parent is to be adjusted If $bAdjustParent Then ; Adjust the array $iIndex = _ArraySearch($aItems, $hParent) If @error Then Return $aItems[$iIndex][1] = $bState ; Adjust the parent _GUICtrlTreeView_SetChecked($cTV, $hParent, $bState) ; And now do the same for the generation above _Adjust_Parents($hParent, $bState) EndIf EndFunc ;==>_Check_Parents Func _Adjust_Children($hPassedItem, $bState = True) Local $iIndex ; Get the handle of the first child Local $hChild = _GUICtrlTreeView_GetFirstChild($cTV, $hPassedItem) If $hChild = 0 Then Return ; Loop through children While 1 ; Adjust the array $iIndex = _ArraySearch($aItems, $hChild) If @error Then Return $aItems[$iIndex][1] = $bState ; Adjust the child _GUICtrlTreeView_SetChecked($cTV, $hChild, $bState) ; And now do the same for the generation beow _Adjust_Children($hChild, $bState) ; Now get next child $hChild = _GUICtrlTreeView_GetNextChild($cTV, $hChild) ; Exit the loop if no more found If $hChild = 0 Then ExitLoop WEnd EndFunc ;==>_Adjust_Children Func _WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam ; Create NMTREEVIEW structure Local $tStruct = DllStructCreate("struct;hwnd hWndFrom;uint_ptr IDFrom;INT Code;endstruct;" & _ "uint Action;struct;uint OldMask;handle OldhItem;uint OldState;uint OldStateMask;" & _ "ptr OldText;int OldTextMax;int OldImage;int OldSelectedImage;int OldChildren;lparam OldParam;endstruct;" & _ "struct;uint NewMask;handle NewhItem;uint NewState;uint NewStateMask;" & _ "ptr NewText;int NewTextMax;int NewImage;int NewSelectedImage;int NewChildren;lparam NewParam;endstruct;" & _ "struct;long PointX;long PointY;endstruct", $lParam) Local $hWndFrom = DllStructGetData($tStruct, "hWndFrom") If $hWndFrom = GUICtrlGetHandle($cTV) Then Switch DllStructGetData($tStruct, "Code") Case $TVN_SELCHANGEDA, $TVN_SELCHANGEDW Local $hItem = DllStructGetData($tStruct, "NewhItem") ; Set flag to selected item handle If $hItem Then $hTVItemSelected = $hItem EndSwitch EndIf EndFunc I have not had much time to test it throughly - so if anyone else wants to try, feel free. But do not expect any replies for the next few hours - I will be on tea/coffee serving duties. > M23
    1 point
  7. remin, I have replicated the issue on my PC after several hours of use. Unfortunately I couldn't find the cause quickly. For this reason, I have logged a bug here: https://github.com/jvanegmond/hotstrings/issues/3 and will work on this issue once my schedule clears up.
    1 point
  8. I played with a similar/more hard coded concept: '?do=embed' frameborder='0' data-embedContent>>
    1 point
  9. UEZ

    WinApi Drawing "on top"

    Here a version to mark areas on desktop #include <Misc.au3> #Include <WinAPI.au3> #Include <WindowsConstants.au3> HotKeySet("{ESC}", "_Exit") Global Const $hFullScreen = WinGetHandle("Program Manager") Global Const $aFullScreen = WinGetPos($hFullScreen) Global Const $hGUI = GUICreate("Desktop Marker by UEZ 2011", $aFullScreen[2], $aFullScreen[3], $aFullScreen[0], $aFullScreen[1], $WS_POPUP, BitOR($WS_EX_LAYERED,$WS_EX_TRANSPARENT)) GuiSetBkColor(0xABCDEF) _WinAPI_SetLayeredWindowAttributes($hGUI, 0xABCDEF, 0xA0) WinSetOnTop($hGUI, "", 1) GuiSetState() Global Const $hDC = _WinAPI_GetWindowDC($hGUI) Global Const $hPen = _WinAPI_CreatePen($PS_SOLID, 20, 0x00FFFF) Global Const $obj_orig = _WinAPI_SelectObject($hDC, $hPen) Global Const $user32_dll = DllOpen("user32.dll") Global $mx, $mxo, $my, $myo While Sleep(50) $mxo = MouseGetPos(0) + Abs($aFullScreen[0]) $myo = MouseGetPos(1) + Abs($aFullScreen[1]) While _IsPressed("11", $user32_dll) * Sleep(10) $mx = MouseGetPos(0) + Abs($aFullScreen[0]) $my = MouseGetPos(1) + Abs($aFullScreen[1]) _WinAPI_DrawLine($hDC, $mx, $my, $mxo, $myo) $mxo = $mx $myo = $my WEnd Wend Func _Exit() DllClose($user32_dll) _WinAPI_SelectObject($hDC, $obj_orig) _WinAPI_DeleteObject($hPen) _WinAPI_ReleaseDC($hGUI, $hDC) Exit EndFunc Hold down the Ctrl key to draw on screen. Br, UEZ
    1 point
  10. #Include <WinAPI.au3> #Include <WindowsConstants.au3> Global $hDC, $hPen, $hWnd ; Needded to Dispose later HotKeySet("{ESC}", "_Exit") $GUI = GuiCreate("",@DesktopWidth,@DesktopHeight,0, 0,$WS_POPUP, bitor($WS_EX_LAYERED,$WS_EX_TRANSPARENT)) GuiSetBkColor(0x123456) _WinAPI_SetLayeredWindowAttributes($GUI,0x123456,255,0x01) WinSetOnTop($GUI, "", 1) GuiSetState() _DrawRectEx($GUI, @DesktopWidth/2-50, @DesktopHeight/2-50, @DesktopWidth/2+50, @DesktopHeight/2+50, 2, 0xFF) While 1 Sleep(10) Wend Func _DrawRectEx($hGUI, $LeftValue, $TopValue, $RightValue, $BottomValue, $RectWidth, $RectColour) ; Draws a rectangle around the given area, crossed out. Local $obj_orig $hWnd = $hGUI $hDC = _WinAPI_GetWindowDC($hWnd) $hPen = _WinAPI_CreatePen($PS_SOLID, $RectWidth, $RectColour) $obj_orig = _WinAPI_SelectObject($hDC, $hPen) _WinAPI_MoveTo($hDC, $LeftValue, $TopValue) ; move pen to the top-left _WinAPI_LineTo($hDC, $LeftValue, $BottomValue) ; draw line to the bottom left _WinAPI_LineTo($hDC, $RightValue, $BottomValue) ; draw line to the bottom right _WinAPI_LineTo($hDC, $RightValue, $TopValue) ; draw line to the top right _WinAPI_LineTo($hDC, $LeftValue, $TopValue) ; draw line to the top left _WinAPI_LineTo($hDC, $RightValue, $BottomValue) ; draw line to the bottom right (diagonal) _WinAPI_MoveTo($hDC, $RightValue, $TopValue) ; move pen to the top right _WinAPI_LineTo($hDC, $LeftValue, $BottomValue) ; draw line to the bottom left (diagonal) Return $hDC EndFunc ;==>DrawRectEx Func _Exit() ; You Forgot to releace resources... read the help file about it in the remarks ; section of _winapi_penCreate and _WinApi_GetWindowDC _WinAPI_DeleteObject($hPen) _WinAPI_ReleaseDC($hWnd, $hDC) Exit EndFunc By the way... Nice Code... i use the WS_EX_LAYERED style to use a color to be transparent using the _WinAPI_SetLayeredWindowAttributes function, the WS_EX_TRANPARENT style to avoid the GUI reciving any click, so you can click to any thing behind the tranparent GUI
    1 point
  11. cypher175, This one developed by me from the _FileListToArray function: #include-once ; #FUNCTION# ==================================================================================================== ================ ; Name...........: _RecFileListToArray ; Description ...: Lists files and\or folders in a specified path (Similar to using Dir with the /B Switch) ; Syntax.........: _RecFileListToArray($sPath[, $sFilter = "*"[, $iFlag = 0[, $iRecur = 0[, $iFullPath = 0]]]]) ; Parameters ....: $sPath - Path to generate filelist for. ; $sFilter - Optional the filter to use, default is *. Search the Autoit3 helpfile for the word "WildCards" For details. ; $iFlag - Optional: specifies whether to return files folders or both ; |$iFlag=0 (Default) Return both files and folders ; |$iFlag=1 Return files only ; |$iFlag=2 Return Folders only ; $iRecur - Optional: specifies whether to search in subfolders ; |$iRecur=0 (Default) Do not search in subfolders ; |$iRecur=1 Search in subfolders ; $iFullPath - Optional: specifies whether to include initial path in result string ; |$iFullPath=0 (Default) Do not include initial path ; |$iFullPath=1 Include initial path ; Return values .: @Error - 1 = Path not found or invalid ; |2 = Invalid $sFilter ; |3 = Invalid $iFlag ; |4 = Invalid $iRecur ; |5 = Invalid $iFullPath ; |6 = No File/Folder Found ; Author ........: SolidSnake <MetalGX91 at GMail dot com> ; Modified.......: 22 Jan 09 by Melba23 - added recursive search and full path options ; Remarks .......: The array returned is one-dimensional and is made up as follows: ; $array[0] = Number of Files\Folders returned ; $array[1] = 1st File\Folder ; $array[2] = 2nd File\Folder ; $array[3] = 3rd File\Folder ; $array[n] = nth File\Folder ; Related .......: ; Link ..........; ; Example .......; Yes ; ==================================================================================================== =========================== ;Special Thanks to Helge and Layer for help with the $iFlag update ; speed optimization by code65536 ;=============================================================================== Func _RecFileListToArray($sPath, $sFilter = "*", $iFlag = 0, $iRecur = 0, $iFullPath = 0) Local $asFileList[1], $sFullPath If Not FileExists($sPath) Then Return SetError(1, 1, "") If StringRight($sPath, 1) <> "\" Then $sPath = $sPath & "\" If (StringInStr($sFilter, "\")) Or (StringInStr($sFilter, "/")) Or (StringInStr($sFilter, ":")) Or (StringInStr($sFilter, ">")) Or (StringInStr($sFilter, "<")) Or (StringInStr($sFilter, "|")) Or (StringStripWS($sFilter, 8) = "") Then Return SetError(2, 2, "") If Not ($iFlag = 0 Or $iFlag = 1 Or $iFlag = 2) Then Return SetError(3, 3, "") If Not ($iRecur = 0 Or $iRecur = 1) Then Return SetError(4, 4, "") If $iFullPath = 0 Then $sFullPath = $sPath ElseIf $iFullPath = 1 Then $sFullPath = "" Else Return SetError(5, 5, "") EndIf _FLTA_Search($sPath, $sFilter, $iFlag, $iRecur, $sFullPath, $asFileList) If $asFileList[0] = 0 Then Return SetError(6, 6, "") Return $asFileList EndFunc ;==>_FileListToArray ; #INTERNAL_USE_ONLY#================================================================================= =========================== ; Name...........: _FLTA_Search ; Description ...: Searches folder for files and then recursively searches in subfolders ; Syntax.........: _FLTA_Search($sStartFolder, $sFilter, $iFlag, $iRecur, $sFullPath, ByRef $asFileList) ; Parameters ....: $sStartFolder - Value passed on from UBound($avArray) ; $sFilter - As set in _FileListToArray ; $iFlag - As set in _FileListToArray ; $iRecur - As set in _FileListToArray ; $sFullPath - $sPath as set in _FileListToArray ; $asFileList - Array containing found files/folders ; Return values .: None ; Author ........: Melba23 based on code from _FileListToArray by SolidSnake <MetalGX91 at GMail dot com> ; Modified.......: ; Remarks .......: This function is used internally by _FileListToArray. ; Related .......: ; Link ..........; ; Example .......; ; ==================================================================================================== =========================== Func _FLTA_Search($sStartFolder, $sFilter, $iFlag, $iRecur, $sFullPath, ByRef $asFileList) Local $hSearch, $sFile If StringRight($sStartFolder, 1) <> "\" Then $sStartFolder = $sStartFolder & "\" ; First look for filtered files/folders in folder $hSearch = FileFindFirstFile($sStartFolder & $sFilter) If $hSearch > 0 Then While 1 $sFile = FileFindNextFile($hSearch) If @error Then ExitLoop Switch $iFlag Case 0; Both files and folders If $iRecur And StringInStr(FileGetAttrib($sStartFolder & $sFile), "D") <> 0 Then ContinueLoop Case 1; Files Only If StringInStr(FileGetAttrib($sStartFolder & $sFile), "D") <> 0 Then ContinueLoop Case 2; Folders only If StringInStr(FileGetAttrib($sStartFolder & $sFile), "D") = 0 Then ContinueLoop EndSwitch If $iFlag = 1 And StringInStr(FileGetAttrib($sStartFolder & $sFile), "D") <> 0 Then ContinueLoop If $iFlag = 2 And StringInStr(FileGetAttrib($sStartFolder & $sFile), "D") = 0 Then ContinueLoop _FLTA_Add($asFileList, $sFullPath, $sStartFolder, $sFile) WEnd FileClose($hSearch) ReDim $asFileList[$asFileList[0] + 1] EndIf If $iRecur = 1 Then ; Now look for subfolders $hSearch = FileFindFirstFile($sStartFolder & "*.*") If $hSearch > 0 Then While 1 $sFile = FileFindNextFile($hSearch) If @error Then ExitLoop If StringInStr(FileGetAttrib($sStartFolder & $sFile), "D") And ($sFile <> "." Or $sFile <> "..") Then ; If folders needed, add subfolder to array If $iFlag <> 1 Then _FLTA_Add($asFileList, $sFullPath, $sStartFolder, $sFile) ; Recursive search of this subfolder _FLTA_Search($sStartFolder & $sFile, $sFilter, $iFlag, $iRecur, $sFullPath, $asFileList) EndIf WEnd FileClose($hSearch) EndIf EndIf EndFunc ; #INTERNAL_USE_ONLY#================================================================================= =========================== ; Name...........: _FLTA_Add ; Description ...: Searches folder for files and then recursively searches in subfolders ; Syntax.........: _FLTA_Add(ByRef $asFileList, $sFullPath, $sStartFolder, $sFile) ; Parameters ....: $asFileList - Array containing found files/folders ; $sFullPath - $sPath as set in _FileListToArray ; $sStartFolder - Value passed on from UBound($avArray) ; $sFile - Full path of file/folder to add to $asFileList ; Return values .: Function only changes $asFileList ByRef ; Author ........: Melba23 based on code from _FileListToArray by SolidSnake <MetalGX91 at GMail dot com> ; Modified.......: ; Remarks .......: This function is used internally by _FileListToArray. ; Related .......: ; Link ..........; ; Example .......; ; ==================================================================================================== =========================== Func _FLTA_Add(ByRef $asFileList, $sFullPath, $sStartFolder, $sFile) Local $sAddFolder $asFileList[0] += 1 If UBound($asFileList) <= $asFileList[0] Then ReDim $asFileList[UBound($asFileList) * 2] If $sFullPath = "" Then $sAddFolder = $sStartFolder Else $sAddFolder = StringReplace($sStartFolder, $sFullPath, "") EndIf $asFileList[$asFileList[0]] = $sAddFolder & $sFile EndFunc
    1 point
×
×
  • Create New...