Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 07/04/2014 in all areas

  1. guinness

    ResourcesEx UDF.

    With all due respect please leave your opinion out of this discussion, as you are undermining my hard work of many hours. You clearly lack a basic understanding in programming and what the ternary operator is, because it's not just AutoIt where you can find it. All, For those who actually have an interest in programming, please test the UDF and leave unnecessary comments about the direction of AutoIt out of it.
    2 points
  2. guinness

    ResourcesEx UDF.

    So if you haven't noticed Zedna's Resources UDF has been a very popular UDF over the last 7 years and was last updated in 2011, but now is the time to bring the UDF up to date with the current AutoIt language syntax (v3.3.14.2). So with the blessing of Zedna may I present to you ResourcesEx. It's built using the UDF standards I have tried to enforce around here, with improved documentation and an overall UDF structure. I please ask that you try and break the UDF, criticise, educate, whatever, just play around with the functions and example. I do ask that you just don't say "you've missed the point" and leave at that. Provide an alternative or constructive reason as to why I have "missed the point". Thanks. IMPORTANT: You must be using SciTE4AutoIt3, as this comes included with AutoItWrapper Changes between Zedna's UDF and guinness' UDF. _ResourceGet() => _Resource_Get() _ResourceGetAsString() => _Resource_GetAsString() with an additional param of whether to return ANSI. _ResourceGetAsStringW() => _Resource_GetAsString() _ResourceGetAsBytes() => _Resource_GetAsBytes() _ResourceGetAsImage() => _Resource_GetAsImage() _ResourceGetAsBitmap() => _Resource_GetAsBitmap() _ResourceSaveToFile() => _Resource_SaveToFile() _ResourceSetImageToCtrl() => _Resource_SetToCtrlID() _SetBitmapToCtrl() => _Resource_SetBitmapToCtrlID() As to JFX's question of what makes this different... Known problems/limitations: (Taken for Zedna's Resources UDF) _ResourceGet() returns resource size (in bytes) in @extended macro but not for resource type RT_BITMAP [FIXED] _ResourceSetImageToCtrl() works with "static/button" type of controls (picture,label,icon,button,checkbox,radiobutton,groupbox) [NO_ISSUE] _ResourcePlaySound() plays only WAV files (not MP3 files) [FIXED] _ResourceGetAsBytes() doesn't work for RT_BITMAP type because _ResourceGet() returns hBitmap instead of memory pointer in this case there could be used _ResourceGetAsImage() as workaround _ResourceGet() has potential memory leak releasing of resources UnlockResource, FreeResource (opposite of LoadResource, LockResource) is not done because it must be done after using of resources at the end and not inside UDF [FIXED] _GDIPlus_Startup() is called once at start of whole include --> no _GDIPlus_Shutdown() is called [FIXED] Download the ZIP and play around with the Example/UDF. ResourcesEx.zip Jos: 15-9-2022 Updated version replaced $__WINVER with _WinAPI_GetVersion() Jos: 27-4-2023 updated script as they required extra #include: ResourcesEx.zip Changelog: 2015/09/26 Changed: Comments throughout the UDF, removing trailing dot Fixed: Various cosmetic changes 2015/01/12 Fixed: Example directive using double equals sign Fixed: Delete functions not being cast as a bool value. (Thanks Synix) Fixed: @error and @extended not be passed back in nested functions e.g. _Resource_GetAsRaw() 2014/07/19 Added: _Resource_SetBitmapToCtrlID() formely known as _Resource_SetImageToCtrlID() Added: Note about using #AutoIt3Wrapper_Res_Icon_Add to the example. (Thanks Zedna) Added: Passing a blank string to _Resource_SetToCtrlID() through the $sResNameOrID parameter, will delete the image and previous handle Changed: _Resource_SetImageToCtrlID() now accepts a hBitmap not a HBITMAP object Fixed: _Resource_GetAsBitmap() now works the same way as _ResourceGetAsBitmap() did, by converting a jpg, png etc... to HBITMAP Fixed: Memory management of some functions 2014/07/18 Fixed: Destroying a cursor Fixed: Regression from loading the current of external module. (Thanks UEZ) 2014/07/17 Added: Additonal checks to destroy cursors and icons Added: Checking if the dll or exe filepath has a valid extension Added: Example of using an icon and image on a button control Fixed: Icons and cursors (finally) being re-sized to a control Fixed: Using GUIGetStyle() on a non-AutoIt handle would cause issue with controls Fixed: Variable naming of $sDLL to $sDllOrExePath for improved clarity Removed: Workaround for setting icons to AutoIt controls 2014/07/17 Added: Commented workaround in the example for re-sizing an icon control Added: ResourcesEx_PE.au3 created by PreExpand for all you constant variable haters out there!!! Fixed: Changelog comments and source code comments Fixed: Re-sizing icons when the control was different to the icon's size. (Thanks czardas for the MSDN link and Jon.) Fixed: Re-sizing cursors and icons in general 2014/07/15 Added: Comments about using SOUND for wav files and RT_RCDATA for mp3 files. (Thanks Melba23) Added: Option to relevant functions to re-size the image based on the control's dimensions. (Requested by kinch: http://www.autoitscript.com/forum/topic/51103-resources-udf/?p=1147525) Added: Using _Resource_LoadFont() example. (Thanks UEZ) Changed: Certain example resources to now use those found in %AUTOITDIR%\Examples\Helpfile\Extras Changed: Constants and enums readability. (Thank mLipok) Changed: Internal functions for destroying resources Changed: Removed changes made from the previous version for loading resources multiple times. The design needs to be re-thought Changed: Setting styles of controls using native AutoIt functions Fixed: Destroying control resource images would fail to show if reinstated again Fixed: Documentation comments Fixed: Missing certain users who helped with creating this UDF Fixed: Outdated SciTE files 2014/07/14: Added: _Resource_GetAsCursor(), for the loading of animated cursors and standard cursors which can then be used with _WinAPI_SetCursor() Added: _Resource_GetAsIcon(), for loading icon resource types Added: _Resource_LoadFont(), which retrieves a font resource and adds to the current memory of the associated module Added: _Resource_SetCursorToCtrlID() and _Resource_SetIconToCtrlID() Added: Additional resource types to destroy on exit, including $RT_FONT, $RT_ICON and $RT_MENU Added: Playing Mp3s to _Resource_LoadSound(). (Thanks to UEZ and Melba23 with changes made by me.) Changed: _Resource_GetAsBitmap() returns a HTBITMAP handle without converting from hBitmap to HBITMAP Changed: _Resource_PlaySound() to _Resource_LoadSound() Changed: _Resource_SetBitmapToCtrlID() to _Resource_SetImageToCtrlID() Changed: _SendMessage() to GUICtrlSendMsg() Changed: Example files Changed: Setting $iError in the internal get function Changed: Signature of _Resource_Destroy() Changed: Updated example to reflect major changes to the ResourcesEx UDF Changed: Various UDF tweaks that I didn't document because I simply couldn't keep track of all the playing around I did in the last week Fixed: _Resource_GetAsImage() not returning an error when a bitmap couldn't be found in the resource table Fixed: Retrieving length of a string Fixed: Using the current module instead of zero in _Resource_LoadSound() Fixed: Various comment changes. (Thanks mLipok) Fixed: Loading resources multiple times. This is fixed thanks to using the internal storage array 2014/07/07: Added: _Resource_Destroy() and _Resource_DestroyAll() to destroy a particular resource name or all resources Added: Checking if the resource name of id value is empty Added: Descriptions, though could do with a little tweaking Changed: _Resource_Get() to _Resource_GetAsRaw() Changed: Internal workings of __Resource_Storage() Changed: Re-size the storage array when destroyed or on shutdown Fixed: _Resource_GetAsString() with default encoding of ANSI Fixed: Calltips API referencing Resources.au3 and not ResourcesEx.au3 Removed: _Resource_Shudown() due to the addition of _Resource_Destroy() and _Resource_DestroyAll() 2014/07/06: Added: _Resource_Shudown() to free up those resources which aren't loaded using _WinAPI_LockResource(). UnlockResource is obsolete Added: Support for using $RT_STRING Changed: _Resource_GetAsString() now works correctly for most encodings. (Thanks Jos) Changed: _Resource_GetAsString() will now load as a string if the resource type requested is $RT_STRING 2014/07/04: Added: #Regions. (Thanks mLipok) Added: #Tidy_Parameters=/sort_funcs /reel (Thanks mLipok) Added: All optional params now accept the default keyword Added: Link to this thread. (Thanks mLipok) Added: Main header. (Thanks mLipok) Changed: $f.... >> $b..... (Thanks mLipok) 2014/07/03: Initial release
    1 point
  3. llewxam

    2048 Game

    I have been addicted to the game 2048 by Estoty Entertainment Lab on my droid phone for a while, and decided that I had to try to code my own version. It was much harder than I thought it would be! To play the game (for those of you not yet addicted) you use the arrow keys to slide tiles across the board. When like tiles meet they merge and add, and another tile is added to the board in a random place. To win the game you have to create a tile worth 2048. Hopefully you have as much fun playing it as I do, and now I have to charge my phone much less often!! Enjoy Ian PS - post a screenshot if you beat my score (probably not too hard actually, got my high score during the 4 days of coding...) Updated 7/4/2014 - bug fix. Previous version downloaded 86 times 2048.au3
    1 point
  4. Mbee, This is a similar point to the one made here about _FileReadToArray - and the answer is unsurprisingly the same. It was a design decision to return a non-array variable if an error occurred from most of the functions which would return an array if successful. If an error is flagged, the user should have errorchecking code to determine what error occurred and how then to proceed - this code can then reset the return variable to whatever is required for the code to continue to run as desired. It is impossible to return a single return value which would suit every case - setting the error macro is the only reasonable thing to do as checking that single item allows each user to proceed as they wish. And a suggestion of such errorchecking: ; Run function Local $aFileList = _FileListToArray("C:\", "*.exe", 0) ; If no files found then reset array If @error = 4 Then Local $aFileList[1] = [0] Now you can be sure that the variable is an array declared as you want it. M23
    1 point
  5. Maybe something like this : #include <Constants.au3> #include <File.au3> Local $aEmpty[1] = [0] Local $aFileList = _FileListToArray("C:\", "*.exe", 0) If @error = 4 Then $aFileList = $aEmpty If IsArray($aFileList) Then MsgBox($MB_OK, "File Array Test", "FileList IS an array, with # " & $aFileList[0] & " elements") Else MsgBox($MB_OK, "File Array Test", "FileList is NOT an array!") EndIf
    1 point
  6. If you substitute this code with your WM_MENUSELECT function, you might be able to work with it. Func WM_MENUSELECT($hWnd, $iMsg, $iwParam, $ilParam) Local $index = _LoWord($iwParam) Local $flags = _HiWord($iwParam) _DebugPrint("index or identifier: " & $index) If BitAND($flags, $MF_BITMAP) Then _DebugPrint("$MF_BITMAP") If BitAND($flags, $MF_CHECKED) Then _DebugPrint("$MF_CHECKED") If BitAND($flags, $MF_DISABLED) Then _DebugPrint("$MF_DISABLED") If BitAND($flags, $MF_GRAYED) Then _DebugPrint("$MF_GRAYED") If BitAND($flags, $MF_HILITE) Then _DebugPrint("$MF_HILITE") If BitAND($flags, $MF_MOUSESELECT) Then _DebugPrint("$MF_MOUSESELECT") If BitAND($flags, $MF_OWNERDRAW) Then _DebugPrint("$MF_OWNERDRAW") If BitAND($flags, $MF_POPUP) Then _DebugPrint("$MF_POPUP") If BitAND($flags, $MF_SYSMENU) Then _DebugPrint("$MF_SYSMENU") If $ilParam Then _DebugPrint("Handle: " & $ilParam) Return $GUI_RUNDEFMSG EndFunc ; Helper functions. Func _HiWord($x) Return BitShift($x, 16) EndFunc ;==>_HiWord Func _LoWord($x) Return BitAND($x, 0xFFFF) EndFunc ;==>_LoWord Func _DebugPrint($s_text) $s_text = StringReplace(StringReplace($s_text, @CRLF, @LF), @LF, @LF & "!-->") ConsoleWrite( _ "+===========================================================" & @LF & _ "!-->" & $s_text & @LF & _ "+===========================================================" & @LF & @LF) EndFunc ;==>_DebugPrint
    1 point
  7. llewxam

    Computer Audit Tool

    I'd like to start by saying that this is not a network discovery tool, I keep wishing that it was and maybe through WMI I could accomplish that some day, but this tool is fast enough to execute that no users have ever minded a 10 second interruption in their workday as of yet. (I know some tools exist on the forum for domain environments, but many offices are workgroup and I have had no luck in using those...) Now that I have stated what it is not, what this tool does is gathers the following information: The computer's nameThe operating system, architecture, service pack level, and COAThe local usersIf MS Office is installed, gathers the version(s) and COAThe CPU name and speedInstalled RAM, free RAM, and swap file infoLocal drive letters, labels, total and free space, and percent fullNetwork drive letters, their UNC path, total and free space, and percent fullThe computer's IP addressOptional notes, such as "front desk PC" or "runs slow", whatever is helpful to know laterAll of that is bundled in to a CSV file, with the options of creating a new CSV for each machine named the same as the computer's name, an append mode that you can name after the site, or the cool part - there is an option to create a customized agent. In the customized mode, you pre-define the site name and a network path accessible by all machines, and the script will create a new customized script with those details hardcoded and compile it for you! Then all you have to do is get on to any networked pc and browse to the path, run the agent, and in 2 seconds you're done with that machine. Please pay attention to the files required to compile at the top of the script - I know it is a long list but only 2 are required to be downloaded from the forum, the rest are in the AutoIt install folder in Includes or aut2exe folders. I could have included the paths in the code, but found this was just.....nicer (for me). I have found this to be very helpful, and I even had one client thank me for doing it, as he realized the value of me having all of that information if he had a problem. Hopefully there are some other field techs out there, or folks in charge of their office's IT needs, who can also benefit from this. Another benefit for field techs is that with this list you can easily review it later and then call them up a few days later to tell them what upgrades they need and get a re-visit Enjoy Ian EDIT: Updated code to include a couple bug fixes Audit Tool.au3
    1 point
  8. GaryFrost

    WM_MENUSELECT

    Something I ran across, might be usefull to someone. #include <GuiConstants.au3> Global Const $WM_MENUSELECT = 0x11F Global Const $MF_BITMAP = 0x4 Global Const $MF_CHECKED = 0x8 Global Const $MF_DISABLED = 0x2 Global Const $MF_GRAYED = 0x1 Global Const $MF_HILITE = 0x80 Global Const $MF_MOUSESELECT = 0x8000 Global Const $MF_OWNERDRAW = 0x100 Global Const $MF_POPUP = 0x10 Global Const $MF_SYSMENU = 0x2000 GUICreate("My GUI", 500, 500, Default, Default, BitOR($WS_MINIMIZEBOX, $WS_MAXIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_SIZEBOX)) ; will create a dialog box that when displayed is centered $filemenu = GUICtrlCreateMenu("&File") $fileitem = GUICtrlCreateMenuitem("Open", $filemenu) GUICtrlSetState(-1, $GUI_DEFBUTTON) $helpmenu = GUICtrlCreateMenu("?") $saveitem = GUICtrlCreateMenuitem("Save", $filemenu) GUICtrlSetState(-1, $GUI_DISABLE) $infoitem = GUICtrlCreateMenuitem("Info", $helpmenu) $exititem = GUICtrlCreateMenuitem("Exit", $filemenu) $recentfilesmenu = GUICtrlCreateMenu("Recent Files", $filemenu, 1) $separator1 = GUICtrlCreateMenuitem("", $filemenu, 2) ; create a separator line $viewmenu = GUICtrlCreateMenu("View", -1, 1) ; is created before "?" menu $viewstatusitem = GUICtrlCreateMenuitem("Statusbar", $viewmenu) GUISetState(@SW_SHOW) ; will display an empty dialog box GUIRegisterMsg($WM_MENUSELECT, "WM_MENUSELECT_Events") ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd Func WM_MENUSELECT_Events($hWndGUI, $MsgID, $wParam, $lParam) Local $index = _LoWord($wParam) Local $flags = _HiWord($wParam) _DebugPrint("index or identifier: " & $index) If BitAND($flags, $MF_BITMAP) Then _DebugPrint("$MF_BITMAP") If BitAND($flags, $MF_CHECKED) Then _DebugPrint("$MF_CHECKED") If BitAND($flags, $MF_DISABLED) Then _DebugPrint("$MF_DISABLED") If BitAND($flags, $MF_GRAYED) Then _DebugPrint("$MF_GRAYED") If BitAND($flags, $MF_HILITE) Then _DebugPrint("$MF_HILITE") If BitAND($flags, $MF_MOUSESELECT) Then _DebugPrint("$MF_MOUSESELECT") If BitAND($flags, $MF_OWNERDRAW) Then _DebugPrint("$MF_OWNERDRAW") If BitAND($flags, $MF_POPUP) Then _DebugPrint("$MF_POPUP") If BitAND($flags, $MF_SYSMENU) Then _DebugPrint("$MF_SYSMENU") If $lParam Then _DebugPrint("Handle: " & $lParam) Return $GUI_RUNDEFMSG EndFunc ;==>WM_MENUSELECT_Events Func _HiWord($x) Return BitShift($x, 16) EndFunc ;==>_HiWord Func _LoWord($x) Return BitAND($x, 0xFFFF) EndFunc ;==>_LoWord Func _DebugPrint($s_text) $s_text = StringReplace(StringReplace($s_text, @CRLF, @LF), @LF, @LF & "!-->") ConsoleWrite( _ "+===========================================================" & @LF & _ "!-->" & $s_text & @LF & _ "+===========================================================" & @LF & @LF) EndFunc ;==>_DebugPrint
    1 point
×
×
  • Create New...