Jump to content

Search the Community

Showing results for tags 'panel'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • Forum FAQ
  • AutoIt

Calendars

  • Community Calendar

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 4 results

  1. This roundup of "virtual keyboards" (https://www.buttoncommander.com/en/input-devices/difference-between-hotkeyboard-devices-and-keyboard-devices/) inspired me to create this simple "LaunchPad" script. with this script you can easily create panels with buttons for starting programs, but not only, you can also associate macros, shortcuts, functions with the buttons ... In short, the $aTools 2D array contains the settings that determine the behavior of each "Button", namely 4 parameters for each row (for each button); [n][0] the tooltip of the button [n][1] path of an icon or a file containing icons [n][2] the number of the icon (if the previous parameter is a collection) [n][3] AutoIt command(s) to be executed directly on button click (or also the name of a function) (see the script for some examples of use) If you have ideas for new records for that array you are encouraged to post it here (thanks) You can easily change the buttons dimensions and the shape of the initial deck by changing the $iStep and $iNrPerLine variables in the script (deck is resizeable as well) Credits: This script makes use of some useful snippets kindly provided by @KaFu, @Danyfirex and @mikell (see the comments in the script for references) Tips (or ready made modifications) for improvements are as always welcome. have fun ; =============================================================================================================================== ; Title .........: LaunchPad ; Description ...: button deck to be used as an applications launcher (and not only) ; Author(s) .....: Chimp (Gianni Addiego) ; credits to @KaFu, @Danyfirex, @mikell (see comments for references) ; =============================================================================================================================== #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <WinAPI.au3> ; <WinAPISysWin.au3> #include <SendMessage.au3> #include <WinAPIFiles.au3> ;Turn off redirection for a 32-bit script on 64-bit system. If @OSArch = "X64" And Not @AutoItX64 Then _WinAPI_Wow64EnableWow64FsRedirection(False) ; https://docs.microsoft.com/en-us/windows/win32/winmsg/wm-sizing Global Const $WMSZ_LEFT = 1 Global Const $WMSZ_RIGHT = 2 Global Const $WMSZ_TOP = 3 Global Const $WMSZ_TOPLEFT = 4 Global Const $WMSZ_TOPRIGHT = 5 Global Const $WMSZ_BOTTOM = 6 Global Const $WMSZ_BOTTOMLEFT = 7 Global Const $WMSZ_BOTTOMRIGHT = 8 Global Enum $vButton_Tip = 0, $vButton_IconPath, $vButton_IconNumber, $vButton_Command #cs The following 2D array contains the settings that determine the behavior of each "Button" namely 4 parameters for each row (for each button); [n][0] the tooltip of the button [n][1] path of an icon or a file containing icons [n][2] the number of the icon (if the previous parameter is a collection) [n][3] AutoIt command(s) to be executed directly on button click (or also the name of a function) #ce Global Const $aTools[][] = [ _ ['Settings', 'SHELL32.dll', 177, 'run("explorer.exe shell:::{D20EA4E1-3957-11d2-A40B-0C5020524153}")'], _ ; 'Test()'], _ ; call a function 'Test()' ['Windows version', 'winver.exe', 1, 'run("explorer.exe shell:::{BB06C0E4-D293-4f75-8A90-CB05B6477EEE}")'], _ ; or "Run('winver.exe')" ['This computer', 'netcenter.dll', 6, 'run("explorer.exe shell:::{20D04FE0-3AEA-1069-A2D8-08002B30309D}")'], _ ['Devices and Printers', 'SHELL32.dll', 272, 'run("explorer.exe shell:::{A8A91A66-3A7D-4424-8D24-04E180695C7A}")'], _ ['Folder options', 'SHELL32.dll', 210, 'run("explorer.exe shell:::{6DFD7C5C-2451-11d3-A299-00C04F8EF6AF}")'], _ ['Command Prompt', @ComSpec, 1, 'Run(@ComSpec)'], _ ['Internet Explorer', @ProgramFilesDir & '\Internet Explorer\iexplore.exe', 1, "Run(@ProgramFilesDir & '\Internet Explorer\iexplore.exe')"], _ ['Media Player', @ProgramFilesDir & '\Windows media player\wmplayer.exe', 1, "Run(@ProgramFilesDir & '\Windows media player\wmplayer.exe')"], _ ['File browser', @WindowsDir & '\explorer.exe', 1, "Run(@WindowsDir & '\explorer.exe')"], _ ['Notepad', @SystemDir & '\notepad.exe', 1, "Run(@SystemDir & '\notepad.exe')"], _ ['Wordpad', @SystemDir & '\write.exe', 1, "Run(@SystemDir & '\write.exe')"], _ ['Registry editor', @SystemDir & '\regedit.exe', 1, "ShellExecute('regedit.exe')"], _ ['Connect to', 'netcenter.dll', 19, 'run("explorer.exe shell:::{38A98528-6CBF-4CA9-8DC0-B1E1D10F7B1B}")'], _ ['Calculator', @SystemDir & '\Calc.exe', 1, "Run(@SystemDir & '\calc.exe')"], _ ['Control panel', 'control.exe', 1, 'run("explorer.exe shell:::{5399E694-6CE5-4D6C-8FCE-1D8870FDCBA0}")'], _ ['Users manager', @SystemDir & '\Netplwiz.exe', 1, "ShellExecute('Netplwiz.exe')"], _ ; {7A9D77BD-5403-11d2-8785-2E0420524153} ['Run', 'SHELL32.dll', 25, 'Run("explorer.exe Shell:::{2559a1f3-21d7-11d4-bdaf-00c04f60b9f0}")'], _ ['Search files', 'SHELL32.dll', 135, 'run("explorer.exe shell:::{9343812e-1c37-4a49-a12e-4b2d810d956b}")'], _ ['On screen Magnifier', @SystemDir & '\Magnify.exe', 1, "ShellExecute('Magnify.exe')"], _ ['Paint', @SystemDir & '\mspaint.exe', 1, "Run(@SystemDir & '\mspaint.exe')"], _ ['Remote desktop', @SystemDir & '\mstsc.exe', 1, " Run('mstsc.exe')"], _ ['Resource monitoring', @SystemDir & '\resmon.exe', 1, "Run('resmon.exe')"], _ ['Device manager', 'SHELL32.dll', 13, 'Run("explorer.exe Shell:::{74246bfc-4c96-11d0-abef-0020af6b0b7a}")'], _ ['Audio', 'SndVol.exe', 1, 'Run("explorer.exe Shell:::{F2DDFC82-8F12-4CDD-B7DC-D4FE1425AA4D}")'], _ ; or 'run(@SystemDir & "\SndVol.exe")'] ['Task view', 'SHELL32.dll', 133, 'Run("explorer.exe shell:::{3080F90E-D7AD-11D9-BD98-0000947B0257}")'], _ ['Task Manager', @SystemDir & '\taskmgr.exe', 1, 'Send("^+{ESC}")'], _ ; "Run(@SystemDir & '\taskmgr.exe')"], _ ['On Screen Keyboard', 'osk.exe', 1, 'ProcessExists("osc.exe") ? False : ShellExecute("osk.exe")'], _ ; <-- ternary example ['... if Notepad is running' & @CRLF & 'Send F5 to it', 'SHELL32.dll', 167, ' WinExists("[CLASS:Notepad]") ? ControlSend("[CLASS:Notepad]", "", "", "{F5}") : MsgBox(16, ":(", "Notepad not found", 2)'] _ ; Check if Notepad is currently running ] ; Show desktop {3080F90D-D7AD-11D9-BD98-0000947B0257} ; Desktop Background {ED834ED6-4B5A-4bfe-8F11-A626DCB6A921} ; IE internet option {A3DD4F92-658A-410F-84FD-6FBBBEF2FFFE} ; ['Notes', 'StikyNot.exe', 1, "ShellExecute('StikyNot')"], _ Global $iStep = 38 ; button size Global $iNrPerLine = 2 Global $iNrOfLines = Ceiling(UBound($aTools) / $iNrPerLine) Global $GUI = GUICreate('LaunchPad', 10, 10, 20, 20, BitOR($WS_THICKFRAME, 0), BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST)) Global $aMyMatrix = _GuiControlPanel("Button", $iNrPerLine, $iNrOfLines, $iStep, $iStep, BitOR(0x40, 0x1000), -1, 0, 0, 0, 0, 0, 0, False, "") Global $iPreviousX = ($aMyMatrix[0])[1], $iPreviousY = ($aMyMatrix[0])[2] For $i = 1 To UBound($aMyMatrix) - 1 GUICtrlSetResizing($aMyMatrix[$i], $GUI_DOCKALL) ; (2+32+256+512) so the control will not move during resizing If $i <= UBound($aTools) Then GUICtrlSetImage($aMyMatrix[$i], $aTools[$i - 1][$vButton_IconPath], $aTools[$i - 1][$vButton_IconNumber]) GUICtrlSetTip($aMyMatrix[$i], $aTools[$i - 1][$vButton_Tip]) EndIf Next _WinSetClientSize($GUI, ($aMyMatrix[0])[11], ($aMyMatrix[0])[12]) ; thanks to KaFu GUISetState() ; https://devblogs.microsoft.com/oldnewthing/20110218-00/?p=11453 GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST") GUIRegisterMsg($WM_SIZING, "WM_SIZING") _MainLoop() Exit Func _MainLoop() Local $iDeltaX, $iDeltaY, $row, $col, $left, $top While 1 $Msg = GUIGetMsg() Switch $Msg Case -3 ; end Exit Case Else For $i = 1 To UBound($aMyMatrix) - 1 If $Msg = $aMyMatrix[$i] Then If $i <= UBound($aTools) Then $dummy = Execute($aTools[$i - 1][3]) EndIf EndIf Next EndSwitch ; check if any size has changed If $iPreviousX <> ($aMyMatrix[0])[1] Or $iPreviousY <> ($aMyMatrix[0])[2] Then ; calculate the variations $iDeltaX = Abs($iPreviousX - ($aMyMatrix[0])[1]) $iDeltaY = Abs($iPreviousY - ($aMyMatrix[0])[2]) ; if both dimensions changed at the same time, the largest variation prevails over the other If $iDeltaX >= $iDeltaY Then ; keep the new number of columns ; calculate and set the correct number of lines accordingly _SubArraySet($aMyMatrix[0], 2, Ceiling((UBound($aMyMatrix) - 1) / ($aMyMatrix[0])[1])) Else ; otherwise keep the new number of rows ; calculate and set the correct number of columns accordingly _SubArraySet($aMyMatrix[0], 1, Ceiling((UBound($aMyMatrix) - 1) / ($aMyMatrix[0])[2])) EndIf ; set client area new sizes _WinSetClientSize($GUI, ($aMyMatrix[0])[1] * $iStep, ($aMyMatrix[0])[2] * $iStep) ; remember the new panel settings $iPreviousX = ($aMyMatrix[0])[1] $iPreviousY = ($aMyMatrix[0])[2] ; rearrange the controls inside the panel For $i = 0 To UBound($aMyMatrix) - 2 ; coordinates 1 based $col = Mod($i, $iPreviousX) + 1 ; Horizontal position within the grid (column) $row = Int($i / $iPreviousX) + 1 ; Vertical position within the grid (row number) $left = ($aMyMatrix[0])[5] + (((($aMyMatrix[0])[3] + ($aMyMatrix[0])[9]) * $col) - ($aMyMatrix[0])[9]) - ($aMyMatrix[0])[3] + ($aMyMatrix[0])[7] $top = ($aMyMatrix[0])[6] + (((($aMyMatrix[0])[4] + ($aMyMatrix[0])[10]) * $row) - ($aMyMatrix[0])[10]) - ($aMyMatrix[0])[4] + ($aMyMatrix[0])[8] GUICtrlSetPos($aMyMatrix[$i + 1], $left, $top) Next EndIf WEnd EndFunc ;==>_MainLoop ; Allow/Disallow specific borders resizing ; thanks to Danyfirex ; --------- ; https://www.autoitscript.com/forum/topic/201464-partially-resizable-window-how-solved-by-danyfirex-%F0%9F%91%8D/?do=findComment&comment=1445748 Func WM_NCHITTEST($hwnd, $iMsg, $iwParam, $ilParam) If $hwnd = $GUI Then Local $iRet = _WinAPI_DefWindowProc($hwnd, $iMsg, $iwParam, $ilParam) ; https://docs.microsoft.com/en-us/windows/win32/inputdev/wm-nchittest If $iRet = $HTBOTTOM Or $iRet = $HTRIGHT Or $iRet = $HTBOTTOMRIGHT Then ; allowed resizing Return $iRet ; default process of border resizing Else ; resizing not allowed Return $HTCLIENT ; do like if cursor is in the client area EndIf EndIf Return $GUI_RUNDEFMSG EndFunc ;==>WM_NCHITTEST ; controls and process resizing operations in real time ; thanks to mikell ; ------ ; https://www.autoitscript.com/forum/topic/201464-partially-resizable-window-how-solved-by-danyfirex-%F0%9F%91%8D/?do=findComment&comment=1445754 Func WM_SIZING($hwnd, $iMsg, $wparam, $lparam) ; https://docs.microsoft.com/en-us/windows/win32/winmsg/wm-sizing Local $iCols = ($aMyMatrix[0])[1] Local $iRows = ($aMyMatrix[0])[2] Local $xClientSizeNew, $yClientSizeNew #cs $wparam The edge of the window that is being sized. $lparam A pointer to a RECT structure with the screen coordinates of the drag rectangle. To change the size or position of the drag rectangle, an application must change the members of this structure. Return value Type: LRESULT #ce $wparam $aPos = WinGetPos($GUI) #cs Success : a 4 - element array containing the following information : $aArray[0] = X position $aArray[1] = Y position $aArray[2] = Width #ce Success : a 4 - element array containing the following information : $aPos2 = WinGetClientSize($GUI) #cs Success: a 2-element array containing the following information: $aArray[0] = Width of window's client area #ce Success: a 2-element array containing the following information: ; https://docs.microsoft.com/en-us/previous-versions//dd162897(v=vs.85) Local $sRect = DllStructCreate("Int[4]", $lparam) ; outer dimensions (includes borders) Local $left = DllStructGetData($sRect, 1, 1) Local $top = DllStructGetData($sRect, 1, 2) Local $Right = DllStructGetData($sRect, 1, 3) Local $bottom = DllStructGetData($sRect, 1, 4) ; border width Local $iEdgeWidth = ($aPos[2] - $aPos2[0]) / 2 Local $iHeadHeigth = $aPos[3] - $aPos2[1] - $iEdgeWidth * 2 Local $aEdges[2] $aEdges[0] = $aPos[2] - $aPos2[0] ; x $aEdges[1] = $aPos[3] - $aPos2[1] ; y $xClientSizeNew = $Right - $left - $aEdges[0] $xClientSizeNew = Round($xClientSizeNew / $iStep) * $iStep $yClientSizeNew = $bottom - $top - $aEdges[1] $yClientSizeNew = Round($yClientSizeNew / $iStep) * $iStep Switch $wparam Case $WMSZ_RIGHT ; calculate the new position of the right border DllStructSetData($sRect, 1, $left + $xClientSizeNew + $aEdges[0], 3) Case $WMSZ_BOTTOM ; calculate the new position of the bottom border DllStructSetData($sRect, 1, $top + $yClientSizeNew + $aEdges[1], 4) Case $WMSZ_BOTTOMRIGHT ; calculate the new position of both borders DllStructSetData($sRect, 1, $left + $xClientSizeNew + $aEdges[0], 3) DllStructSetData($sRect, 1, $top + $yClientSizeNew + $aEdges[1], 4) EndSwitch #cs If DllStructGetData($sRect, 1, 3) > @DesktopWidth Then ; $Right DllStructSetData($sRect, 1, DllStructGetData($sRect, 1, 3) - $iStep, 3) $xClientSizeNew -= $iStep EndIf If DllStructGetData($sRect, 1, 4) > @DesktopHeight Then ; $bottom DllStructSetData($sRect, 1, DllStructGetData($sRect, 1, 4), 4) $yClientSizeNew -= $iStep #ce If DllStructGetData($sRect, 1, 3) > @DesktopWidth Then ; $Right ; check if number of rows has changed If $iRows <> $yClientSizeNew / $iStep Then _SubArraySet($aMyMatrix[0], 2, $yClientSizeNew / $iStep) EndIf ; check if number of columns has changed If $iCols <> $xClientSizeNew / $iStep Then _SubArraySet($aMyMatrix[0], 1, $xClientSizeNew / $iStep) EndIf Return $GUI_RUNDEFMSG EndFunc ;==>WM_SIZING ; set client area new sizes ; thanks to KaFu ; ---- ; https://www.autoitscript.com/forum/topic/201524-guicreate-and-wingetclientsize-mismatch/?do=findComment&comment=1446141 Func _WinSetClientSize($hwnd, $iW, $iH) Local $aWinPos = WinGetPos($hwnd) Local $sRect = DllStructCreate("int;int;int;int;") DllStructSetData($sRect, 3, $iW) DllStructSetData($sRect, 4, $iH) _WinAPI_AdjustWindowRectEx($sRect, _WinAPI_GetWindowLong($hwnd, $GWL_STYLE), _WinAPI_GetWindowLong($hwnd, $GWL_EXSTYLE)) WinMove($hwnd, "", $aWinPos[0], $aWinPos[1], $aWinPos[2] + (DllStructGetData($sRect, 3) - $aWinPos[2]) - DllStructGetData($sRect, 1), $aWinPos[3] + (DllStructGetData($sRect, 4) - $aWinPos[3]) - DllStructGetData($sRect, 2)) EndFunc ;==>_WinSetClientSize ; ; #FUNCTION# ==================================================================================================================== ; Name...........: _GuiControlPanel ; Description ...: Creates a rectangular panel with adequate size to contain the required amount of controls ; and then fills it with the same controls by placing them according to the parameters ; Syntax.........: _GuiControlPanel($ControlType, $nrPerLine, $nrOfLines, $ctrlWidth, $ctrlHeight, $style, $exStyle, $xPos = 0, $yPos = 0, $xBorder, $yBorder, $xSpace = 1, $ySpace = 1, $Group = false, , $sGrpTitle = "") ; Parameters ....: $ControlType - Type of controls to be generated ("Button"; "Text"; ..... ; $nrPerLine - Nr. of controls per line in the matrix ; $nrOfLines - Nr. of lines in the matrix ; $ctrlWidth - Width of each control ; $ctrlHeight - Height of each control ; $Style - Defines the style of the control ; $exStyle - Defines the extended style of the control ; $xPanelPos - x Position of panel in GUI ; $yPanelPos - y Position of panel in GUI ; $xBorder - distance from lateral panel's borders to the matrix (width of left and right margin) default = 0 ; $yBorder - distance from upper and lower panel's borders to the matrix (width of upper and lower margin) default = 0 ; $xSpace - horizontal distance between the controls ; $ySpace - vertical distance between the controls ; $Group - if you want to group the controls (true or false) ; $sGrpTitle - title of the group (ignored if above is false) ; Return values .: an 1 based 1d array containing references to each control ; element [0] contains an 1d array containing various parameters about the panel ; Author ........: Gianni Addiego (Chimp) ; Modified.......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: ; =============================================================================================================================== Func _GuiControlPanel($ControlType, $nrPerLine, $nrOfLines, $ctrlWidth, $ctrlHeight, $style = -1, $exStyle = -1, $xPanelPos = 0, $yPanelPos = 0, $xBorder = 0, $yBorder = 0, $xSpace = 1, $ySpace = 1, $Group = False, $sGrpTitle = "") Local Static $sAllowedControls = "|Label|Input|Edit|Button|CheckBox|Radio|List|Combo|Pic|Icon|Graphic|" If Not StringInStr($sAllowedControls, '|' & $ControlType & '|') Then Return SetError(1, 0, "Unkown control") Local $PanelWidth = (($ctrlWidth + $xSpace) * $nrPerLine) - $xSpace + ($xBorder * 2) Local $PanelHeight = (($ctrlHeight + $ySpace) * $nrOfLines) - $ySpace + ($yBorder * 2) Local $hGroup If $Group Then If $sGrpTitle = "" Then $xPanelPos += 1 $yPanelPos += 1 $hGroup = GUICtrlCreateGroup("", $xPanelPos - 1, $yPanelPos - 7, $PanelWidth + 2, $PanelHeight + 8) Else $xPanelPos += 1 $yPanelPos += 15 $hGroup = GUICtrlCreateGroup($sGrpTitle, $xPanelPos - 1, $yPanelPos - 15, $PanelWidth + 2, $PanelHeight + 16) EndIf EndIf ; create the controls Local $aGuiGridCtrls[$nrPerLine * $nrOfLines + 1] Local $aPanelParams[14] = [ _ $ControlType, $nrPerLine, $nrOfLines, $ctrlWidth, $ctrlHeight, _ $xPanelPos, $yPanelPos, $xBorder, $yBorder, $xSpace, $ySpace, $PanelWidth, $PanelHeight, $hGroup] For $i = 0 To $nrPerLine * $nrOfLines - 1 ; coordinates 1 based $col = Mod($i, $nrPerLine) + 1 ; Horizontal position within the grid (column) $row = Int($i / $nrPerLine) + 1 ; Vertical position within the grid (row) $left = $xPanelPos + ((($ctrlWidth + $xSpace) * $col) - $xSpace) - $ctrlWidth + $xBorder $top = $yPanelPos + ((($ctrlHeight + $ySpace) * $row) - $ySpace) - $ctrlHeight + $yBorder $text = $i + 1 ; "*" ; "." ; "(*)" ; create the control(s) $aGuiGridCtrls[$i + 1] = Execute("GUICtrlCreate" & $ControlType & "($text, $left, $top, $ctrlWidth, $ctrlHeight, $style, $exStyle)") Next If $Group Then GUICtrlCreateGroup("", -99, -99, 1, 1) ; close group $aGuiGridCtrls[0] = $aPanelParams Return $aGuiGridCtrls EndFunc ;==>_GuiControlPanel ; writes a value to an element of an array embedded in another array Func _SubArraySet(ByRef $aSubArray, $iElement, $vValue) $aSubArray[$iElement] = $vValue EndFunc ;==>_SubArraySet Func Test() MsgBox(0, 0, ":)", 1) EndFunc ;==>Test
  2. Often I need to create a panel to monitor a lot of things (users, files, items etc) so I use this piece of code to create a dynamic grid of buttons. The number of buttons is variable, and it's related to the size of the gui, the size of the buttons and the distance between buttons. Every "button" is a set of three with a real button stacked on the top of two labels, imagine reading a .CSV file or an array or a database and displaying all the things using the labels (Text and COLOR too) and clickin' on the relative button you can call further info on the item or call a particular function. So you can decide the number of the buttons, the width of the buttons, and also the distance between buttons. It's quick and dirty, simple and very improvable (I know..) so fell free to play with the code. ;TEST ;GOL-Grill ;Grill test/template ; (c) 2019 NSC ; V.0.6 #Region ;************ Includes ************ #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> #include <EditConstants.au3> #include <ProgressConstants.au3> #include <_GOLLOG.au3>; NSC first UDF #EndRegion ;************ Includes ************ Dim $agButton[1] Global $ButtonU, $rProgress, $form1, $labeltot, $ntotButtonS ; the number of buttons is variable based on the guisize, the button size and button distance, three examples.... ;Global $guiwidth = 850, $guiheight = 500, $buttonW = 150, $buttonHDistance = 10, $buttonVDistance = 20 ; SMALL GUI / BIG BUTTONS <- try it ! Global $guiwidth = 1500, $guiheight = 700, $buttonW = 90 , $buttonHDistance = 29, $buttonVDistance = 3; BIG GUI / SMALL BUTTONS ;Global $guiwidth = 1200, $guiheight = 800, $buttonW = 300, $buttonHDistance = 30, $buttonVDistance = 7; last two variables are horizontal and vertical distance between buttons Global $ver = "V.0.6" Gollog(">>>>> START") Dim $aResult[11] = [10, "a", "b", "c", "d", "e", "f", "g", "h", "i", "j"] ; this is an example, it can be an array, a DB, a .text file read in real time. Gui() Gollog("start analyzing...") Monitor() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE CLOSEClicked() Exit Case $ButtonU Monitor() Case Else For $i = 1 To $ntotButtonS If $nMsg = $agButton[$i] Then $Bhit = GUICtrlRead($agButton[$i]) infoB($Bhit) EndIf Next EndSwitch WEnd Func Gui() $form1 = GUICreate("Buttons on a grill " & $ver & " (c) NSC 2019", $guiwidth, $guiheight, 90, 10) $ButtonU = GUICtrlCreateButton("Update", 2, 2, 170, 50) $labeltot = GUICtrlCreateLabel("Total found", 5, 55) $Gollogedit = GUICtrlCreateEdit("", 2, $guiheight - 255, 180, 250, BitOR($ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_WANTRETURN, $WS_BORDER)) $rProgress = GUICtrlCreateProgress($guiwidth - 18, 5, 16, $guiheight - 7, BitOR($PBS_SMOOTH, $PBS_VERTICAL, $WS_BORDER)) GUICtrlSetColor(-1, 0x00FF00) GUICtrlSetBkColor(-1, 0x000000) GUISetState(@SW_SHOW) EndFunc ;==>Gui Func Monitor() GUIDelete($form1) Gui() $leftSTART = 186 ;left align $topSTART = 5 ;start from top $lineDOWN = 45 + $buttonVDistance ; vertical line distance 45 is buttons very near $extraHSTEP = 3 ; extra line distance $buttonSEMIH = 15 ; height of one of the 3 vertical impiled semibuttons $separatorSEMIH = 2 ;vertical distance between 3 semibuttons $separatorW = 2 ;aux horizontal distance ;---------- derived measures $rightLIMIT = $guiwidth - 123 ; right limit befor Carriage Return $leftINCREMENT = $buttonHDistance + $buttonW ; horizontal increment button after button $leftSTEP = $leftSTART ;incremental horizontal $topSTEP = $topSTART ;incremental vertical $foundB = $aResult[0] GUICtrlSetData($labeltot, "Found n°" & $foundB) $ntotButtonS = 0 $nomorebuttons = 0 For $i = 1 To $foundB Local $itemFound = $aResult[$i] ;\TA1000 Gollog($itemFound) GUICtrlCreateGroup('', $leftSTEP, $topSTEP - 3, $buttonW + 3, 50) ;______first-----------------------------_______line___________________UNO________11111_____\\\\\\\\\\------------ Local $textbutton = "button n°" & $i _ArrayAdd($agButton, GUICtrlCreateButton($textbutton, $leftSTEP + $separatorSEMIH, $topSTEP + $extraHSTEP, $buttonW, $buttonSEMIH, $BS_flat)) GUICtrlSetBkColor(-1, 0xccffcc) ;green, sort of GUICtrlSetFont(-1, 7, -1, -1, 'verdana') GUICtrlSetColor(-1, 0x000000) ;___second__________line___________________DUE ________222222-------------------------------------------------------------------- Local $textLINE2 = $itemFound GUICtrlCreateLabel($textLINE2, $leftSTEP + $separatorW, $topSTEP + $buttonSEMIH + $separatorSEMIH, $buttonW, $buttonSEMIH, BitOR($SS_CENTER, $SS_CENTERIMAGE)) GUICtrlSetBkColor(-1, 0xD2D7A8) GUICtrlSetFont(-1, 7, -1, -1, 'verdana') GUICtrlSetColor(-1, 0x000000) ; __third______line________tre___________________________________________________________333333-3333333-333333333-333333-33333-33333-3333-------------------------------- Local $textLINE3 = "line3" GUICtrlCreateLabel($textLINE3, $leftSTEP + $separatorW, $topSTEP + $buttonSEMIH + $buttonSEMIH + $separatorSEMIH, $buttonW, $buttonSEMIH, BitOR($SS_CENTER, $SS_CENTERIMAGE)) ; NSC modify GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetFont(-1, 7, -1, -1, 'verdana') GUICtrlSetColor(-1, 0x000000) $ntotButtonS += 1 GUICtrlSetData($rProgress, (100 * $ntotButtonS / $foundB)) If $leftSTEP + $buttonW < $rightLIMIT Then ; $leftSTEP += $leftINCREMENT ;53 Else $leftSTEP = $leftSTART $topSTEP += $lineDOWN If $topSTEP >= $guiheight - 50 Then $nomorebuttons = 1 Gollog("displayed " & $ntotButtonS & " buttons") Gollog("NO more buttons !") EndIf EndIf Sleep(100) ; REMOVE is only for demo Next While $nomorebuttons = 0 ; draw empty buttons (nice to do) $ntotButtonS += 1 _ArrayAdd($agButton, GUICtrlCreateButton("B-" & $ntotButtonS, $leftSTEP + $separatorSEMIH, $topSTEP + $extraHSTEP, $buttonW, $buttonSEMIH, $BS_flat)) If $leftSTEP + $buttonW < $rightLIMIT Then ; $leftSTEP += $leftINCREMENT Else $leftSTEP = $leftSTART $topSTEP += $lineDOWN If $topSTEP >= $guiheight - 50 Then $nomorebuttons = 1 Gollog("displayed " & $ntotButtonS & " buttons") Gollog("NO more buttons !") EndIf EndIf WEnd GUISetState(@SW_SHOW) EndFunc ;==>Monitor Func infoB($Bhit) ; this function act on the pressed button, it's an example so assign the task you need. gollog("infoB -> " & $Bhit) EndFunc ;==>infoB Func CLOSEClicked() MsgBox(64, "exit", "program exiting", 1) Gollog("<---STOP") Exit EndFunc ;==>CLOSEClicked You will need also the Include from this post for the LOG (Gollog) instructions, but you can also just remove the gollog and the EDIT box. Look at the screenshot, It's from an APP made using this code. 21/11/2019 V.0.6 Script lightly updated with better management of buttons size and distance.
  3. Hi Mate. Some times we need to launch a control panel item to users. So I Implemented an IOpenControlPanel Interface. It allows to launch control panel items easily. #include "ControlPanelConstants.au3" Global Const $sCLSID_OpenControlPanel = "{06622D85-6856-4460-8DE1-A81921B41C4B}" Global Const $sIID_IOpenControlPanel = "{D11AD862-66DE-4DF4-BF6C-1F5621996AF1}" Global Const $sTagIOpenControlPanel= "Open hresult(wstr;wstr;ptr);GetPath hresult(wstr;wstr;uint);GetCurrentView hresult(int*)" Local $oOpenControlPanel = ObjCreateInterface($sCLSID_OpenControlPanel, $sIID_IOpenControlPanel, $sTagIOpenControlPanel) $oOpenControlPanel.Open($MicrosoftAdministrativeTools,"",Null) $oOpenControlPanel.Open($MicrosoftDateAndTime,$AdditionalClocks,Null) $oOpenControlPanel.Open($MicrosoftDefaultPrograms,$pageDefaultProgram,Null) $oOpenControlPanel.Open($GUID_MicrosoftDeviceManager,"",Null) $oOpenControlPanel.Open($GUID_MicrosoftDevicesAndPrinters,"",Null) $oOpenControlPanel.Open($MicrosoftHomeGroup,"",Null) $oOpenControlPanel.Open($MicrosoftInternetOptions,$Connections,Null) $oOpenControlPanel.Open($MicrosoftPersonalization,$pageWallpaper,Null) $oOpenControlPanel=0;Free ControlPanelConstants.au3 Saludos
  4. Hi, I was wondering why there is no panel control in autoit, this can be useful for moving/hidding more than one control at time. I have made some searches and I found nothing on it so I decided to create an UDF on it. In order to do that, It creates child GUIs and you can manage it as real controls (coord mode based on the parent GUI and not on the screen), so I have made it to be really easy in use like any other ctrl. Preview : Example : #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include "GUIPanel_UDF.au3" Opt("GUIOnEventMode", 1) Global $sLogo4imgPath = @ProgramFilesDir & "\AutoIt3\Examples\GUI\logo4.gif" Global $iPanel1step = 0, $iPanel3step = 0 #region GUI $GUI = GUICreate("GUIPanel UDF - Example", 400, 350) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") GUICtrlCreateLabel("Label on the GUI", 300, 320) #region Panel1 $hPanel1 = _GUICtrlPanel_Create($GUI, "Coords", 10, 40, 200, 50) _GUICtrlPanel_SetBackground($hPanel1, 0xFF0000) GUICtrlCreateLabel("Label on the Panel1", 5, 5, 95, 13) $btnPanel1 = GUICtrlCreateButton("Swap with Panel4", 10, 20, 100, 22) GUICtrlSetOnEvent($btnPanel1, "_Panel1_BtnEvent") #endregion Panel1 #region Panel2 $hPanel2 = _GUICtrlPanel_Create($GUI, "BottomLeft", 0, 0, 200, 100, $WS_BORDER, @SW_SHOWNA, 0x00FF00) GUICtrlCreateLabel("Label on the Panel2", 5, 5, 95, 13) #region Panel2Sub $hPanel2Sub = _GUICtrlPanel_Create($hPanel2, "CenterRight", 0, 0, 120, 30, $WS_BORDER, @SW_SHOWNA) Global $aGUIPanelExample_Panel2SubPos = _GUICtrlPanel_GetPos($hPanel2Sub) GUICtrlCreateLabel("Pos (X, Y) : " & $aGUIPanelExample_Panel2SubPos[0] & ", " & $aGUIPanelExample_Panel2SubPos[1], 5, 8, 100, 13) #endregion #endregion Panel2 #region Panel3 $hPanel3 = _GUICtrlPanel_Create($GUI, "Centered", 0, 0, 169, 68, $WS_BORDER, @SW_SHOWNA, $sLogo4imgPath) $btnPanel3 = GUICtrlCreateButton("Move me", 10, 10, 70, 22) GUICtrlSetOnEvent($btnPanel3, "_Panel3_BtnEvent") GUICtrlCreateCheckbox("no event", 70, 55, 68, 13) GUICtrlSetBkColor(-1, 0xFFFFFF) #endregion Panel3 #region Panel4 $hPanel4 = _GUICtrlPanel_Create($GUI, "TopRight", 0, 0, 100, 50, $WS_BORDER) GUICtrlCreateCombo("Panel4", 10, 10, 80) #endregion Panel4 GUISetState(@SW_SHOW, $GUI) #endregion GUI While 1 Sleep(1000) WEnd Func _Panel3_BtnEvent() Switch $iPanel3step Case 0 _GUICtrlPanel_SetPos($hPanel3, "CenterRight") GUICtrlSetData($btnPanel3, "Hide me") Case 1 _GUICtrlPanel_SetState($hPanel3, @SW_HIDE) EndSwitch $iPanel3step += 1 EndFunc ;==>_Panel3_BtnEvent Func _Panel1_BtnEvent() Switch $iPanel1step Case 0 _GUICtrlPanel_SetPos($hPanel1, "TopRight") _GUICtrlPanel_SetPos($hPanel4, "Coords", 10, 40) GUICtrlSetData($btnPanel1, "Disable me") Case 1 _GUICtrlPanel_SetState($hPanel1, @SW_DISABLE) GUICtrlSetData($btnPanel1, "Disabled") EndSwitch $iPanel1step += 1 EndFunc ;==>_Panel1_BtnEvent Func _Exit() Exit EndFunc ;==>_Exit Attachments : GUIPanel_UDF.au3 (Previous: 279 downloads) GUIPanel_Example.au3 Enjoy !
×
×
  • Create New...