Jump to content

Recommended Posts

This is a little tool that displays the contents of a DLL icon file. It shows how to use icons on buttons and as stand alone images. 

 

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.14.5
 Author:         Skysnake

 Script Function:
    Display content of DLL icon files

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>

;Local $rDLLpath = @SystemDir & "\Wmploc.dll"
;Local $rDLLpath = @SystemDir & "\imageres.dll"
;Local $rDLLpath = @SystemDir & "\shell32.dll"
;Local $rDLLpath = @SystemDir & "\pifmgr.dll"
;Local $rDLLpath = @SystemDir & "\explorer.exe"
;Local $rDLLpath = @SystemDir & "\accessibilitycpl.dll"
;Local $rDLLpath = @SystemDir & "\ddores.dll"
;Local $rDLLpath = @SystemDir & "\moricons.dll" ; ugly do not use
;Local $rDLLpath = @SystemDir & "\mmcndmgr.dll
;Local $rDLLpath = @SystemDir & "\netshell.dll"
;Local $rDLLpath = @SystemDir & "\ieframe.dll"
Local $rDLLpath = @SystemDir & "\wiashext.dll"

For $r = 0 To -50 Step -10
    ConsoleWrite($r & @CRLF)
    GUICreate("Show Icons")

    Local $lblShowRange = GUICtrlCreateLabel("Icons " & $r - 1 & " to " & $r - 10, 8, 8, 100, 25)

    Local $btnIcon1 = GUICtrlCreateButton("", 8, 25, 24, 24, $BS_ICON)
    GUICtrlSetImage($btnIcon1, $rDLLpath, $r - 1, 0)    ;
    GUICtrlCreateIcon($rDLLpath, $r - 1, 40, 25, 24, 24)

    ; 2nd
    Local $btnIcon2 = GUICtrlCreateButton("", 8, 50, 24, 24, $BS_ICON)
    GUICtrlSetImage($btnIcon2, $rDLLpath, $r - 2, 0)    ;
    GUICtrlCreateIcon($rDLLpath, $r - 2, 40, 50, 24, 24)

    ; 3rd
    Local $btnIcon3 = GUICtrlCreateButton("", 8, 75, 24, 24, $BS_ICON)
    GUICtrlSetImage($btnIcon3, $rDLLpath, $r - 3, 0)    ;
    GUICtrlCreateIcon($rDLLpath, $r - 3, 40, 75, 24, 24)

    ;4th
    Local $btnIcon4 = GUICtrlCreateButton("", 8, 100, 24, 24, $BS_ICON)
    GUICtrlSetImage($btnIcon4, $rDLLpath, $r - 4, 0)    ;
    GUICtrlCreateIcon($rDLLpath, $r - 4, 40, 100, 24, 24)

    ;5th
    Local $btnIcon5 = GUICtrlCreateButton("", 8, 125, 24, 24, $BS_ICON)
    GUICtrlSetImage($btnIcon5, $rDLLpath, $r - 5, 0)    ;
    GUICtrlCreateIcon($rDLLpath, $r - 5, 40, 125, 24, 24)

    ;6th
    Local $btnIcon6 = GUICtrlCreateButton("", 8, 150, 24, 24, $BS_ICON)
    GUICtrlSetImage($btnIcon6, $rDLLpath, $r - 6, 0)    ;
    GUICtrlCreateIcon($rDLLpath, $r - 6, 40, 150, 24, 24)

    ;7th
    Local $btnIcon7 = GUICtrlCreateButton("", 8, 175, 24, 24, $BS_ICON)
    GUICtrlSetImage($btnIcon7, $rDLLpath, $r - 7, 0)    ;
    GUICtrlCreateIcon($rDLLpath, $r - 7, 40, 175, 24, 24)

    ;8th
    Local $btnIcon8 = GUICtrlCreateButton("", 8, 200, 24, 24, $BS_ICON)
    GUICtrlSetImage($btnIcon8, $rDLLpath, $r - 8, 0)    ;
    GUICtrlCreateIcon($rDLLpath, $r - 8, 40, 200, 24, 24)

    ;9th
    Local $btnIcon9 = GUICtrlCreateButton("", 8, 225, 24, 24, $BS_ICON)
    GUICtrlSetImage($btnIcon9, $rDLLpath, $r - 9, 0)    ;
    GUICtrlCreateIcon($rDLLpath, $r - 9, 40, 225, 24, 24)

    ;10th
    Local $btnIcon10 = GUICtrlCreateButton("", 8, 250, 24, 24, $BS_ICON)
    GUICtrlSetImage($btnIcon10, $rDLLpath, $r - 10, 0)    ;
    GUICtrlCreateIcon($rDLLpath, $r - 10, 40, 250, 24, 24)





    ; Display the GUI.
    GUISetState(@SW_SHOW)
    Sleep(3000)
    GUIDelete()
Next

 

Edited by Skysnake

Skysnake

Why is the snake in the sky?

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Jemboy
      Recently I was working on a script with icons using GuiCtrkCreatIcon.
      I decided to change the sub folder name of the icons to a more meaning name, however made a typo.

      I tested the .exe on my test computer and it worked flawlessly (because both icon folder where on my test computer) 😁
      But after I installed the script on the intended computers , I got chaos!😵
      Zooming into the problem, I discovered, that because the icons could not be found, the ControlID were returned with a value of 0
      and thus played havoc within the GuiGetMsg() switch/case statement.
      I have been able to reproduce this  (see example)
      #include <GUIConstantsEx.au3> ;============================================================================================================ ; PLEASE, do not save this example in the example folder: C:\Program Files (x86)\AutoIt3\Examples\Helpfile ;============================================================================================================ Example() Func Example() GUICreate(" My GUI Icons", 250, 250) $Icon1 = GUICtrlCreateIcon("shell32.dll", 10, 20, 20) $Icon2 = GUICtrlCreateIcon(@ScriptDir & '\Extras\horse.ani', -1, 20, 40, 32, 32) $Icon3 = GUICtrlCreateIcon("shell32.dll", 7, 20, 75, 32, 32) GUISetState(@SW_SHOW) ;$Icon2 = -1 ; ==> When this line is uncommented the script "works", so -1 could be a potential fix. ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $Icon2 Beep (500,500) EndSwitch WEnd GUIDelete() EndFunc ;==>Example If you save the above script outside the Autoit example folder and run it, it will keep beeping because GuiCtrlCreatIcon did not find horse.ani and return $Icon2=0.
      At the moment GUICtrlCreateIcon () only returns the conntrolID on success and 0 on failure.
      I would like to propose a return of -1 on failure, so a existing and working script won't go awry when the icon can not be found.
       
    • By therks
      So if you embed an animated cursor on a GUI with GUICtrlCreateIcon the animation goes quite slow. Is there a way to speed it up?
       
      #include <GUIConstants.au3> GUICreate('', 64, 64) GUICtrlCreateIcon('C:\windows\cursors\aero_busy_l.ani', 0, 0, 0, 64, 64) GUISetState() While GUIGetMsg() <> $GUI_EVENT_CLOSE WEnd Edit: See attached .gif for an example of the difference. On the top is the cursor viewed in an image viewer, on the bottom is in an AutoIt GUI. Notice how much slower it is in AutoIt.

    • By Yirrlaar
      #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <TabConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("MyCommands", 406, 236, 610, 129) $Main = GUICtrlCreateTab(8, 8, 385, 217) $TabSheet1 = GUICtrlCreateTabItem("Main") $StopFunc = GUICtrlCreateButton("STOP", 17, 43, 150, 50) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") $StartFunc = GUICtrlCreateButton("Start", 17, 98, 150, 50) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") $Input0 = GUICtrlCreateInput("Input0", 267, 43, 75, 24, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER)) $Input1 = GUICtrlCreateInput("Input1"", 267, 73, 75, 24, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER)) $Input2 = GUICtrlCreateInput("Input2", 267, 103, 75, 24, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER)) $Input3 = GUICtrlCreateInput("Input3", 267, 133, 75, 24, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER)) $Input4 = GUICtrlCreateInput("Input4", 267, 163, 75, 24, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER)) $Input5 = GUICtrlCreateInput("Input5", 267, 195, 75, 24, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER)) $Label1 = GUICtrlCreateLabel("Label1", 215, 43, 50, 20, $SS_RIGHT) GUICtrlSetFont(-1, 9, 800, 0, "MS Sans Serif") $Label2 = GUICtrlCreateLabel("Label2", 215, 73, 50, 20, $SS_RIGHT) GUICtrlSetFont(-1, 9, 800, 0, "MS Sans Serif") $Label3 = GUICtrlCreateLabel("Label3", 215, 103, 50, 20, $SS_RIGHT) GUICtrlSetFont(-1, 9, 800, 0, "MS Sans Serif") $Label4 = GUICtrlCreateLabel("Label4", 215, 133, 50, 20, $SS_RIGHT) GUICtrlSetFont(-1, 9, 800, 0, "MS Sans Serif") $Label5 = GUICtrlCreateLabel("Label5", 215, 163, 50, 20, $SS_RIGHT) GUICtrlSetFont(-1, 9, 800, 0, "MS Sans Serif") $Label6 = GUICtrlCreateLabel("Label6", 191, 195, 74, 20, $SS_RIGHT) GUICtrlSetFont(-1, 9, 800, 0, "MS Sans Serif") $TabSheet2 = GUICtrlCreateTabItem("Individuals") $Button1 = GUICtrlCreateButton("Button1", 17, 43, 75, 25) GUICtrlCreateTabItem("") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit case $StartBOT letsdothis() Case $StopBOT END_This() EndSwitch WEnd func letsdothis() While 1 ;doing stuff ;doing more stuff if $StopFunc Then END_This() ;how do i detect if the button has been pressed if $Button1 Then Sleepy_Time() ;doing things ;doing more things WEnd EndFunc Func Sleepy_Time() while 1 sleep(10) if $Button1 Then ExitLoop ; detect button press and return to previous state Wend EndFunc Func END_This() Exit EndFunc For the LIFE of me I can't figure out, HOW ON EARTH to detect that a button has been pressed while a function is running?
      Can someone PLEASE point me in the right direction???
      Thanks
    • By John C.
      ;Adding $BS_DEFPUSHBUTTON doesn't work
              $idCopy_Data = GUICtrlCreateButton("Copy Data Only", $iButtonWidth_2, $aiGUISize[1] - $iButtonMargin, $iButtonWidth_2, 20, $BS_DEFPUSHBUTTON)
      ;Adding these two lines doesn't work either
               Local $aAccelKeys[2][2] = [["{enter}", $idCopy_Data], ["^{enter}", $idCopy_ID]]
              GUISetAccelerators($aAccelKeys)
       
    • By 232showtime
      Hi need some help with the space between two buttons, if I ran the script the space between two buttons is gone and when I maximized the gui, space between two button is showing,
      #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $hGUI1 = GUICreate("Test", 1090, 800, 200, 200, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_SIZEBOX, $WS_THICKFRAME, $WS_TABSTOP, $WS_HSCROLL, $WS_VSCROLL)) $TopRight1 = GUICtrlCreateButton("Test1", 800, 25, 70, 50) $TopRight2 = GUICtrlCreateButton("Test2", 850, 25, 70, 50) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd this is the first time I encounter this problem.
×
×
  • Create New...