Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 06/02/2014 in all areas

  1. guinness

    GUI design concepts.

    This is a place to post GUI examples that other users may find interesting. Try to code clearly and concisely please for example DON'T USE MAGIC NUMBERS! Splash Screen: #include <GUIConstantsEx.au3> #include <SendMessage.au3> #include <WindowsConstants.au3> Global Const $SC_DRAGMOVE = 0xF012 Example() ; Idea by prizm1 Func Example() Local $iHeight = 250, $iWidth = 400 Local $hGUI = GUICreate('', $iWidth, $iHeight, Default, Default, BitOR($WS_POPUP, $WS_BORDER), $WS_EX_TOPMOST) GUICtrlCreateGroup('', 0, -5, $iWidth, $iHeight + 5, $WS_THICKFRAME) GUICtrlCreateGroup('', -99, -99, 1, 1) Local $iClose = GUICtrlCreateButton('Close', $iWidth - 100, $iHeight - 40, 85, 25) GUISetState(@SW_SHOW, $hGUI) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $iClose ExitLoop Case $GUI_EVENT_PRIMARYDOWN _SendMessage($hGUI, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0) EndSwitch WEnd GUIDelete($hGUI) EndFunc ;==>Example
    1 point
  2. mmm, guess you are trying to make friends here. Topic closed and do not reopen a new topic unless you have an AutoIt3 question to ask and have something to show us. Jos
    1 point
  3. RoyGlanfield

    Printing RichEdit

    I have been experimenting with printing RichEdit formatted text. I use AutoIt script to produce a preview and send it to the chosen printer. Everything has been tested on an XP computer with an Epson printer. ;============================================================================================== ;--Name --------- _RTF_Print ;--Description --- Print from RichEdit control ;--Parameters -----$hPrintDc = Printer's device context ;-------------------$hwnd = handle of the RichEdit control ;-------------------$DocTitle = printer's job title ;-------------------$LeftMinMrgn = Minimum margin on the left ;-------------------$TopMinMrgn = Minimum margin on the Top ;-------------------$RightMinMrgn = Minimum margin on the Right ;-------------------$BottomMinMrgn = Minimum margin on the Bottom ;--Return values -- Success - 'Sent to the printer.' ;-------------------Failure - 'Printing aborted.' ;--Remarks ------Orientation, paper size, number of copies, and which printer ;---------------------are set when the Printer's device context is generated ;-------------------Unexpected results may be caused by ;------------------------ single line/paragaph orphin tags in the rtf ;--Author -------- RoyGlanfield ;============================================================================================== Func _RTF_Print($hPrintDc, $hwnd, $DocTitle, $LeftMinMrgn = 1, $TopMinMrgn = 1, $RightMinMrgn = 1, $BottomMinMrgn = 1) ;-----------convert the margins 0.1 inches to twips ;$TopMinMarg = $TopMinMarg * 144;--------eg 10*144 = 1440 which 1 inch ;$LeftMinMarg = $LeftMinMarg * 144;--------eg 10*144 = 1440 which 1 inch ;$PageMinMarg = $PageMinMarg * 144;--------eg 10*144 = 1440 which 1 inch ;$BottomMinMarg = $BottomMinMarg * 144;--------eg 10*144 = 1440 which 1 inch ;-----------convert the margins 1 cm to twips $TopMinMrgn = $TopMinMrgn * 567;--------eg 2.539cm * 567= ~1440 which 1 inch $LeftMinMrgn = $LeftMinMrgn * 567;--------eg 2.539cm * 567 = ~1440 which 1 inch $RightMinMrgn = $RightMinMrgn * 567;--------eg 2.539cm * 567 = ~1440 which 1 inch $BottomMinMrgn = $BottomMinMrgn * 567;-------eg 2.539cm * 567 = ~1440 which 1 inch ;$hPrintDc ;--------Divice Context handle----------- ;----dots per inch depends on the printer quality setting-------X and Y can be different! $dotInchX = _WinAPI_GetDeviceCaps($hPrintDc, 88);-----Const LOGPIXELSX = 88 $dotInchY = _WinAPI_GetDeviceCaps($hPrintDc, 90);-----Const LOGPIXELSY = 90 ;----printer dots per inch ;--------get the printable area [Page] and paper area [Paper] $PageW = _WinAPI_GetDeviceCaps($hPrintDc, 8);-----Const HORZRES= 8 $PageH = _WinAPI_GetDeviceCaps($hPrintDc, 10);-----Const VERTRES = 10 $PaperW = _WinAPI_GetDeviceCaps($hPrintDc, 110) ;-----Const PHYSICALWIDTH = 110 $PaperH = _WinAPI_GetDeviceCaps($hPrintDc, 111) ;-----Const PHYSICALHEIGHT = 111 ;----none printable margins $OffSetX = _WinAPI_GetDeviceCaps($hPrintDc, 112) ;-----Const PHYSICALOFFSETX = 112 $OffSetY = _WinAPI_GetDeviceCaps($hPrintDc, 113);-----Const PHYSICALOFFSETY = 113 $RightMrgn = $PaperW - $PageW - $OffSetX $BottomMrgn = $PaperH - $PageH - $OffSetY ;----conversion factors to use later----------- $TwipsInchX = $dotInchX / 1440;-----convert dots to twips [per inch] $TwipsInchY = $dotInchY / 1440;-----convert dots to twips [per inch] ;--------convert all measurments to twips $OffSetX = $OffSetX / $TwipsInchX ;-----convert Left dots to twips $OffSetY = $OffSetY / $TwipsInchY ;-----convert Left dots to twips $PageW = $PageW / $TwipsInchX ;-----convert Right dots to twips $PageH = $PageH / $TwipsInchY ;-----convert Right dots to twips $PaperW = $PaperW / $TwipsInchX ;-----convert Paper Width dots to twips $PaperH = $PaperH / $TwipsInchY ;-----convert Paper Width dots to twips ;----------Set the margins and keep everything in the printable area $Left1 = $LeftMinMrgn - $OffSetX If $Left1 < 0 Then $Left1 = 0;-----dont print before printable area starts $Top1 = $TopMinMrgn - $OffSetY If $Top1 < 0 Then $Top1 = 0;-----dont print before printable area starts $Right1 = $RightMinMrgn - $RightMrgn If $Right1 < 0 Then $Right1 = 0;-----dont print after printable area ends ;$Right1 = $PaperW - $Right1 - $OffSetX $Right1 = $PageW - $Right1 ;+$Left1;- $OffSetX $Bottom1 = $BottomMinMrgn - $BottomMrgn If $Bottom1 < 0 Then $Bottom1 = 0;-----dont print after printable area ends $Bottom1 = $PageH - $Bottom1;+$Top1 $z = _SendMessage($hwnd, $EM_SETTARGETDEVICE, 0);---0=wrap----anything else is 1 char per page!!!!! If $z = 0 Then Return 'Cant find RichEdit Control' If _GUICtrlRichEdit_GetTextLength($hwnd) < 1 Then Return 'Nothing to Print.' ;---------must have a selection on the richEdit control--------------- _SendMessage($hwnd, $EM_SETSEL, 0, -1);--ok----select all $pgTags = "int Left1;int Top1;int Right1;int Bottom1;int Left2;int Top2;int Right2;int Bottom2;" $rgTags = "LONG cpMin;LONG cpMax" $dcHTags = "HANDLE hdc;HANDLE hdcTarget;" ;------------create a structure for the printed page $strcPg = DllStructCreate($dcHTags & $pgTags & $rgTags) DllStructSetData($strcPg, "hdc", $hPrintDc);-------------printer DllStructSetData($strcPg, "Left1", $Left1);-----twip--------printer DllStructSetData($strcPg, "Right1", $Right1);-----twip--------printer DllStructSetData($strcPg, "Top1", $Top1);-----twip--------printer DllStructSetData($strcPg, "Bottom1", $Bottom1);-----twip--------printer ;-----next 7 lines seem to have, no effect or crash printer jobs queue---why??? ;--------"HANDLE hdc;" is the printer------- before conecting printer to rtf??? ;--------"HANDLE hdcTarget;" is the target RichEdit control that has the rtf ???? ;DllStructSetData($strcPg,"hdcTarget",$hPrintDc);---------------richEdit scource??? ;DllStructSetData($strcPg,"Left2",$Left1/$dotInchX*96/3);---------------------richEdit scource??? ;DllStructSetData($strcPg,"Top2",$Top1/$dotInchX*96/3);-----------------------richEdit scource??? ;DllStructSetData($strcPg,"Right2",$Page1/$dotInchX*96/3);-----twip------richEdit scource??? ;DllStructSetData($strcPg,"Bottom2",$Bottom1/$dotInchX*96/3);----twip-----richEdit scource??? ;---------get the pointer to all that will be printed??? {I think????????} $a = DllStructGetPtr($strcPg) + DllStructGetSize(DllStructCreate($dcHTags & $pgTags)) ;-----------use this pointer----------- _SendMessage($hwnd, $EM_EXGETSEL, 0, $a) ;-----------find the last char of the document to be printed $cpMax = DllStructGetData($strcPg, "cpMax") ;-----------set the 1st page start char----------- $cpMin = 0 $cpMin2 = -1 ;----------------------------------------------------------------------------------- ;--------create a Document structure for the print job title $strDocNm = DllStructCreate("char DocName[" & StringLen($DocTitle & Chr(0)) & "]") DllStructSetData($strDocNm, "DocName", $DocTitle & Chr(0)) $strDoc = DllStructCreate("int Size;ptr DocName;ptr Output;ptr Datatype;dword Type") DllStructSetData($strDoc, "Size", DllStructGetSize($strDoc)) ;---------------insert the document name structure into the document structure DllStructSetData($strDoc, "DocName", DllStructGetPtr($strDocNm)) DllCall("gdi32.dll", "long", "StartDoc", "hwnd", $hPrintDc, "ptr", DllStructGetPtr($strDoc)) ;----------------------------------------------------------------------------------- ;-----------make a loop to format each printed page and exit when----------- ;-----$cpMin reaches the $cpMax ;-----$cpMin is less than 0---{I have seen -1 but I forget when}--- ;----ALSO-- ExitLoop if $cpMin = $cpMin 2---if it stops finding the start of next page While $cpMax > $cpMin And $cpMin > -1 ;-----------start a new page----------- $StartPage = DllCall("Gdi32.dll", "int", "StartPage", "HANDLE", $hPrintDc) ;-----------increment page the count----------- ;-----------if not done now it will exit the loop before counting the last page ; ;-----------get the 1st char of the next page, {but how does it work ???} $cpMin2 = $cpMin $cpMin = _SendMessage($hwnd, $EM_FORMATRANGE, True, DllStructGetPtr($strcPg)) ;----ExitLoop when $cpMin = $cpMin 2---just in case it stops finding the start of next page If $cpMin2 = $cpMin Then ExitLoop;---get out of loop before more pages are added ; ;-----------set the next page start char----------- DllStructSetData($strcPg, "cpMin", $cpMin) ;------this sends it to the printer $EndPage = DllCall("Gdi32.dll", "int", "EndPage", "HANDLE", $hPrintDc) ;-----------end the page and loop again for the next page until the end of document WEnd _SendMessage($hwnd, $EM_FORMATRANGE, False, 0) If $EndPage[0] > 0 Then $r = 'Sent to the printer.' DllCall("Gdi32.dll", "int", "EndDoc", "HANDLE", $hPrintDc) Else $r = 'Printing aborted.' DllCall("Gdi32.dll", "int", "AbortDoc", "HANDLE", $hPrintDc) EndIf Return $r EndFunc ;==>_RTF_Print ;============================================================================================== Please see the zip file for a working example and a test .rtf file. I think there should be a better way of producing the preview. I would like your comments. ToAutoIT.zip
    1 point
  4. The address bar in Windows Explorer on Windows 7 seems to be a hot-track enabled toolbar menu with popup listviews and a combo box. The toolbar buttons shows the folders in the current path. The popup listviews shows the child folders. The toolbar menu can be implemented as a mixture of script 6 (split buttons) and 9 (popup windows) in Hot-Track Enabled and Custom Drawn Toolbar Menu. The combo box is implemented as a combination of an input box and a listview. The picture shows the last three folders in the path. The split part of AutoIt button is clicked to open a popup listview with child folders. The toolbar is hot-track enabled. If you move the mouse cursor over the neighbour buttons, the neighbour listviews opens automatically without the need to click the buttons. The listview for the leftmost button (without a folder name) contains the folders, which doesn't fit into the toolbar, because the window is too narrow. If you increase the width of the window, folders from this listview will be moved into the toolbar. If you decrease the width, folders from the toolbar will be moved into the listview. If you click a toolbar button or a folder in a listview, this folder will become the current folder. If you click in the empty area of the toolbar between the rightmost button and the combo button, the toolbar will be replaced by an input box. Paste the full path of a folder into the input box and press Enter to make this folder the current folder. If the folder is invalid, the Enter is canceled and the input box stays open. Press Escape or click the title bar or edit box to cancel the input box. Click the combo button to the right to open a listview with previous folders. Click a folder to make this folder the current folder. When you click the combo button, the input box is opened too. Press Escape or click the combo button again to close the listview and set focus to the input box. Press down arrow in the input box to open the listview. Click the title bar or edit box to cancel listview and input box. When the script is opened, or when you paste a folder into the input box and press Enter, or when you click a folder in the combo listview, all folders and child folders along the path are extracted. While the code is running the cursor is shown as an hourglass. You'll only be able to see the hourglass, if the cursor is over the title bar or the toolbar. If the cursor is over the edit box, you'll not see the hourglass. $sFolderPath contains the full path of the current folder. The zip contains two small DLL files, WSP.dll (6 KB) and WSP_x64.dll (10 KB), by Yashied to handle Enter key in listviews. See post 16 in this thread. Windows Explorer address bar.7z Testet on XP 32 bit and Win 7 32/64 bit. Run AddressBar.au3. Edit: $sFolderPath
    1 point
  5. Melba23

    Pause key and GUI

    gspot, While the script is paused you remain within the TogglePause function - this means that the script will no longer look for GUI events such as the Pausar button being pressed. But you can make the button active by looking for it being fired inside the function like this: Func TogglePause() $fPaused = Not $fPaused While $fPaused $nMsg = GUIGetMsg() Switch $nMsg Case $Button_Pausar $fPaused = Not $fPaused EndSwitch ToolTip('Script is "Paused"', 0, 0) WEnd ToolTip("") EndFunc ;==>TogglePause For more details see the Interrupting a running function tutorial in the Wiki. M23
    1 point
  6. "$someVariable = @extended" doesn't work? Just remember, just like @error, you have to read the macro immediately after the function you are calling or it gets reset by the function executed after it.
    1 point
  7. undefinedspace, You could look at my Notify UDF (the link is in my sig) or perhaps Yashied's NotifyBox. Or just use ConsoleWrite. M23
    1 point
  8. You could use ConsoleWrite. Also take a look at _DebugSetup and the related commands.
    1 point
  9. undefinedspace, That is because you do not try to access $a in the script. Add a line which does and you will see that the error happens on that line: HotKeySet("!a", "funca") While 1 Sleep(10) WEnd Func funca($a = 20, $b = 100000) $a += 1 $b = $b - 1 EndFunc ;==>funca M23
    1 point
  10. Oracle Connection Strings can be found here.
    1 point
  11. UEZ

    AutoIt Snippets

    Here a snipped how to colorize each character of a label text: GUICtrlCreateLabelColorized: #include <GDIPlus.au3> #include <GUIConstantsEx.au3> _GDIPlus_Startup() Global $hGUI = GUICreate("Test", 570, 100), $i GUISetBkColor(0xFFFFFF) Global $sText1 = "These chars were colorized separately" Global $aColors1[StringLen($sText1)] For $i = 0 To UBound($aColors1) - 1 $aColors1[$i] = Random(0x000000, 0x400000, 1) Next Global $aLabel1 = GUICtrlCreateLabelColorized($sText1, $aColors1, 10, 10, 18, "Comic Sans MS") Global $sText2 = "using " & Chr(203) & "label controls" & Chr(202) & " with " & Chr(201) & "bold" & Chr(200) & " words. ;-)" Global $aColors2[StringLen($sText2)] Global $aLabel2 = GUICtrlCreateLabelColorized($sText2, $aColors2, 18, 50, 26, "Times New Roman") GUISetState() Do ;~ For $i = 0 To UBound($aColors2) - 1 ;~ GUICtrlSetColor($aLabel2[$i][0], Random(0x000000, 0xD00000, 1)) ;~ Next ;~ Sleep(40) Until GUIGetMsg() = $GUI_EVENT_CLOSE _GDIPlus_Shutdown() Exit ; #FUNCTION# ==================================================================================================================== ; Name ..............: GUICtrlCreateLabelColorized ; Description ......: Creates a label with possibility to set different color to each character ; Syntax ............: GUICtrlCreateLabelColorized($sText, $aColors, $iX, $iY, $fFontSize, $sFont[, $iWeight = 400[, $iAttribute = 0[, ; $iFQuality = 0[, $fCorrection = 0.95]]]]) ; Parameters .....: $sText - A string value. Chr(200) = disable bold char, Chr(201) = enable bold char, ; Chr(202) = disable italic char, Chr(203) = enable italic char, ; $aColors - An array of color values in format RGB. ; $iX - An integer value - x position of the label. ; $iY - An integer value - y position of the label. ; $fFontSize - A floating point value - size of the font. ; $sFont - A string value - font name. ; $iWeight - [optional] An integer value. Default is 400. ; $iAttribute - [optional] An integer value. Default is 0. ; $iFQuality - [optional] An integer value. Default is 4 (checkout GUICtrlSetFont for more details about quality settings) ; $fCorrection - [optional] A floating point value. Default is 0.925. ; Return values .: An array with following values: ; [$i][0] = control id of the label ; [$i][1] = color value of the character in RGB format ; [$i][2] = x position of the character ; [$i][3] = y position of the character ; [$i][4] = width of the character ; [$i][5] = height of the character ; Version ..........: 0.95 build 2017-09-11 beta ; Author ...........: UEZ ; Modified ........: ; Remarks .......: AutoIt version 3.3.10.2 or higher is required, __MeasureString is an internal function to measure each character. ; Don't forget to start GDI+ before you call the function! ; Related .........: GUICtrlCreateLabel, _GDIPlus_StringFormatSetMeasurableCharacterRanges ; Link ..............: ; Example .......: Yes ; =============================================================================================================================== Func GUICtrlCreateLabelColorized($sText, $aColors, $iX, $iY, $fFontSize = 9.5, $sFont = "Arial", $iWeight = 400, $iAttribute = 0, $iFQuality = 4, $fCorrection = 0.925) If Not StringLen($sText) Then Return SetError(1, 0, 0) Local $aChars = StringSplit($sText, "", 2), $i, $aLabels[UBound($aChars)][6], $aCoord, $sChar, _ $bBold = 0, $bItalic = 0, $iBold = 700, $iItalic = 2, $iWeightPrev = $iWeight, $iItalicPrev = $iAttribute For $i = 0 To UBound($aChars) - 1 $sChar = $aChars[$i] If $sChar = " " Then $sChar = "." ;if char is space fill it up with . to calculate space between words Switch $sChar Case Chr(200) $bBold = 0 ContinueLoop Case Chr(201) $bBold = 1 ContinueLoop Case Chr(202) $bItalic = 0 ContinueLoop Case Chr(203) $bItalic = 1 ContinueLoop EndSwitch $aCoord = __MeasureString($sChar, $sFont, $fFontSize, $iAttribute + ($iWeight > 699) * 1) $aLabels[$i][1] = $aColors[$i] ;color $aLabels[$i][2] = ($iX - $aCoord[0]) * $fCorrection ;x pos $aLabels[$i][3] = $iY ;y pos $aLabels[$i][4] = $aCoord[2] ;width $aLabels[$i][5] = $aCoord[3] ;height $aLabels[$i][0] = GUICtrlCreateLabel($aChars[$i], $aLabels[$i][2], $aLabels[$i][3], $aLabels[$i][4], $aLabels[$i][5]) ;create label (char) control GUICtrlSetColor($aLabels[$i][0], $aLabels[$i][1]) ;set char color If $bBold Then $iWeight = $iBold Else $iWeight = $iWeightPrev EndIf If $bItalic Then $iAttribute = $iItalic Else $iAttribute = $iItalicPrev EndIf GUICtrlSetFont($aLabels[$i][0], $fFontSize, $iWeight, $iAttribute, $sFont, $iFQuality) ;set font for char $iX += $aCoord[1] ;calculate next x position Next Return $aLabels EndFunc ;==>GUICtrlCreateLabelColorized ; #INTERNAL_USE_ONLY# =========================================================================================================== ; Name ............: __MeasureString ; Description ....: Measures a string ; Syntax ..........: __MeasureString($sString, $sFont, $fFontSize[, $iAttribute = 0]) ; Parameters ...: $sString - A string value. ; $sFont - A string value. ; $fFontSize - A floating point value. ; $iAttribute - [optional] An integer value. Default is 0. ; Return values.: An array with x, y, width and height values of the string ; Version ..........: 2020-03-08 beta ; Author ...........: UEZ ; Modified ........: ; Remarks .......: AutoIt version 3.3.10.2 or higher is required ; Related .........: GDIPlus ; Link ..............: ; Example .......: Yes ; =============================================================================================================================== Func __MeasureString($sString, $sFont, $fFontSize, $iAttribute = 0) Local Const $hDC = _WinAPI_GetDC(0), $hGraphics = _GDIPlus_GraphicsCreateFromHDC($hDC), $tLayout = _GDIPlus_RectFCreate() Local Const $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($sFont), $hFont = _GDIPlus_FontCreate($hFamily, $fFontSize, $iAttribute) Local $aInfo = _GDIPlus_GraphicsMeasureString($hGraphics, $sString, $hFont, $tLayout, $hFormat) Local $aRanges[2][2] = [[1]] $aRanges[1][1] = StringLen($sString) _GDIPlus_StringFormatSetMeasurableCharacterRanges($hFormat, $aRanges) Local Const $aRegion = _GDIPlus_GraphicsMeasureCharacterRanges($hGraphics, $sString, $hFont, $aInfo[0], $hFormat) Local Const $aBounds = _GDIPlus_RegionGetBounds($aRegion[1], $hGraphics) _GDIPlus_RegionDispose($aRegion[1]) _GDIPlus_FontDispose($hFont) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_GraphicsDispose($hGraphics) _WinAPI_ReleaseDC(0, $hDC) Local $aDim[4] $aDim[0] = $aBounds[0] ;X coordinate of the upper-left corner of the rectangle $aDim[1] = $aBounds[2] ;Width of the rectangle for next char $aDim[2] = $aInfo[0].Width ;Width of the rectangle $aDim[3] = $aInfo[0].Height ;Height of the rectangle Return $aDim EndFunc ;==>__MeasureString Requires AutoIt version 3.3.10.2 or higher! Br, UEZ
    1 point
  12. Error handling is indeed what you need. If you exit the script, it is of course not naturally going to "pick up where you left off". If you would like to be able to pick it up at a specific function, you would have to code that in. For example, if you have three functions (Private1, Private2, Private3) and want to start at Private22, you can do something like this: If $CmdLine[1] = "/Private1" Then Private1() If $CmdLine[1] = "/Private2" Then Private2() If $CmdLine[1] = "/Private3" Then Private3() Func Private1() MsgBox(0, "Private1", "Private1") EndFunc Func Private2() MsgBox(0, "Private2", "Private2") EndFunc Func Private3() MsgBox(0, "Private3", "Private3") EndFunc At the command line, you would then run <scriptname>.exe /Private2
    1 point
  13. taietel

    GUI design concepts.

    I use this template in my projects: #include <GuiConstants.au3> #include <EditConstants.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> #region GLOBAL VARIABLES Global $iW = 600, $iH = 400, $iT = 52, $iB = 52, $iLeftWidth = 150, $iGap = 10, $hMainGUI #endregion GLOBAL VARIABLES _MainGui() Func _MainGui() Local $hFooter, $nMsg, $aPos Local $iLinks = 5 Local $sMainGuiTitle = "Sample Title" Local $sHeader = "Sample GUI" Local $sFooter = "2012 © AutoIt" Local $aLink[$iLinks], $aPanel[$iLinks] $aLink[0] = $iLinks - 1 $aPanel[0] = $iLinks - 1 $hMainGUI = GUICreate($sMainGuiTitle, $iW, $iH, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_TABSTOP)) GUISetIcon("shell32.dll", -58, $hMainGUI) GUICtrlCreateLabel($sHeader, 48, 8, $iW - 56, 32, $SS_CENTERIMAGE) GUICtrlSetFont(-1, 14, 800, 0, "Arial", 5) GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKTOP + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT) GUICtrlCreateIcon("shell32.dll", -131, 8, 8, 32, 32) GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKTOP + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT) GUICtrlCreateLabel("", 0, $iT, $iW, 2, $SS_SUNKEN);separator GUICtrlSetResizing(-1, $GUI_DOCKTOP + $GUI_DOCKLEFT + $GUI_DOCKRIGHT + $GUI_DOCKHEIGHT) GUICtrlCreateLabel("", $iLeftWidth, $iT + 2, 2, $iH - $iT - $iB - 2, $SS_SUNKEN);separator GUICtrlSetResizing(-1, $GUI_DOCKTOP + $GUI_DOCKLEFT + $GUI_DOCKBOTTOM + $GUI_DOCKWIDTH) GUICtrlCreateLabel("", 0, $iH - $iB, $iW, 2, $SS_SUNKEN);separator GUICtrlSetResizing(-1, $GUI_DOCKBOTTOM + $GUI_DOCKLEFT + $GUI_DOCKRIGHT + $GUI_DOCKHEIGHT) $hFooter = GUICtrlCreateLabel($sFooter, 10, $iH - 34, $iW - 20, 17, BitOR($SS_LEFT, $SS_CENTERIMAGE)) GUICtrlSetTip(-1, "AutoIt Forum", "Click to open...") GUICtrlSetCursor(-1, 0) GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKRIGHT + $GUI_DOCKBOTTOM + $GUI_DOCKHEIGHT) ;add links to the left side $aLink[1] = _AddNewLink("Link 1") $aLink[2] = _AddNewLink("Link 2", -167) $aLink[3] = _AddNewLink("Link 3", -222) $aLink[4] = _AddNewLink("Link 4", -22) ;and the corresponding GUI's $aPanel[1] = _AddNewPanel("Title for the panel 1") $aPanel[2] = _AddNewPanel("Title for the panel 2") $aPanel[3] = _AddNewPanel("Title for the panel 3") $aPanel[4] = _AddNewPanel("Title for the panel 4") ;add some controls to the panels _AddControlsToPanel($aPanel[1]) GUICtrlCreateEdit("", 10, 37, $iW - $iLeftWidth + 2 - 20 - 5, $iH - $iT - $iB - 40, BitOR($ES_AUTOVSCROLL, $ES_NOHIDESEL, $ES_WANTRETURN, $WS_VSCROLL), $WS_EX_STATICEDGE) Local $sTestTxt = "" For $i = 1 To 10 $sTestTxt &= @TAB & "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum felis lectus, pharetra vel laoreet nec, pulvinar nec justo. Donec malesuada, nunc eu faucibus sodales, diam sem tempor neque, id condimentum turpis nunc vel lacus. Nulla a nulla libero, eget eleifend dolor. Vivamus volutpat tincidunt ultricies. Vestibulum eu libero nisi, quis tincidunt nisi. Proin tincidunt, ipsum ullamcorper posuere venenatis, libero nulla venenatis enim, ultrices tincidunt ipsum arcu nec turpis. In at erat sed ipsum gravida mattis in at felis. Vivamus diam purus, dictum ut luctus vitae, sollicitudin ut velit. Maecenas velit mauris, fringilla ut condimentum bibendum, aliquam a neque. Nulla metus eros, commodo id dictum in, interdum sed ipsum. Vivamus feugiat, mi at auctor fringilla, libero lectus vulputate tortor, eu sollicitudin nulla lacus at neque." & @CRLF $sTestTxt &= @TAB & "Sed vel ante magna. Curabitur porttitor ante in tellus bibendum non tristique diam volutpat. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. In tellus lectus, ultrices in tempus eget, sollicitudin quis eros. Curabitur at arcu bibendum massa feugiat euismod at a felis. Nunc molestie, enim non ornare tincidunt, ipsum nisi tempus sapien, quis elementum elit velit ut neque. Suspendisse eu adipiscing risus. Nam tempor odio ut elit auctor rhoncus. Etiam viverra elit id felis feugiat pellentesque pretium porttitor dui. Vivamus eu quam non ante suscipit vehicula a nec eros. Phasellus congue massa sed libero interdum ullamcorper. Quisque fringilla massa ut lorem fringilla pulvinar eget ullamcorper eros. Praesent faucibus, erat at consequat tempus, nulla erat sodales mi, eget sagittis nibh erat nec nunc. Phasellus risus nibh, porta viverra pretium nec, vehicula eget nisi." & @CRLF $sTestTxt &= @TAB & "Sed vel neque vel urna elementum accumsan feugiat quis mauris. Sed mi nisl, consequat dapibus molestie ac, rutrum ut elit. Praesent sed risus sem. Mauris rutrum blandit magna nec tristique. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Suspendisse consequat iaculis odio nec cursus. Duis varius tincidunt ligula ac ultricies. Ut eget magna in nulla vulputate dapibus ut vel sem. Integer ac tempor risus." & @CRLF $sTestTxt &= @TAB & "Maecenas molestie semper turpis, id tristique nibh pharetra eget. Aliquam erat volutpat. In egestas, lorem quis varius vestibulum, enim diam porta lorem, quis dictum arcu ante a diam. Nullam vel nisi mauris. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Aliquam ut leo purus, eget vulputate augue. Fusce et est sagittis felis accumsan sollicitudin eget a lectus. Cras sapien sapien, rutrum eu tempor non, tempor nec velit. Vivamus interdum adipiscing felis in malesuada. Fusce quis purus est, eget molestie turpis. In hac habitasse platea dictumst." & @CRLF $sTestTxt &= @TAB & "Aenean eleifend risus vitae lorem laoreet facilisis. Suspendisse ac urna quam, vel rutrum sem. Sed bibendum porta tellus malesuada scelerisque. Vestibulum at ligula sed nulla sollicitudin tincidunt. Pellentesque mi magna, vulputate et aliquam a, auctor et nunc. Phasellus feugiat fringilla accumsan. Donec ultrices, elit id dapibus auctor, nunc odio viverra lorem, non commodo mi libero a libero. Cras vitae felis venenatis augue laoreet tincidunt scelerisque id odio. Proin lorem purus, molestie feugiat pretium nec, ornare aliquam turpis. " Next GUICtrlSetData(-1, $sTestTxt) GUICtrlSetResizing(-1, $GUI_DOCKTOP + $GUI_DOCKLEFT + $GUI_DOCKRIGHT + $GUI_DOCKBOTTOM) _AddControlsToPanel($aPanel[2]) GUICtrlCreateLabel("Label1", 8, 38, 36, 17) GUICtrlSetResizing(-1, $GUI_DOCKTOP + $GUI_DOCKLEFT + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT) Local $hInput1 = GUICtrlCreateInput("Input1", 56, 35, 121, 21) GUICtrlSetResizing(-1, $GUI_DOCKTOP + $GUI_DOCKLEFT + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT) Local $hButton1 = GUICtrlCreateButton("Button1", 200, 33, 75, 25) GUICtrlSetResizing(-1, $GUI_DOCKTOP + $GUI_DOCKLEFT + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT) _AddControlsToPanel($aPanel[3]) GUICtrlCreateList("", 8, 37, 121, 93, -1, 0) GUICtrlSetData(-1, "dfgdfg|ertert|kljlkj|poipoi|qweqwe") GUICtrlSetResizing(-1, $GUI_DOCKTOP + $GUI_DOCKLEFT + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT) _AddControlsToPanel($aPanel[4]) GUICtrlCreateGroup("Group1", 8, 35, 129, 90) GUICtrlSetResizing(-1, $GUI_DOCKTOP + $GUI_DOCKLEFT + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT) Local $aChkBox[4] For $i = 1 To 3 $aChkBox[$i] = GUICtrlCreateRadio("Some radio " & $i, 16, 56 + ($i - 1) * 20, 113, 17) GUICtrlSetResizing(-1, $GUI_DOCKTOP + $GUI_DOCKLEFT + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT) Next GUICtrlSetState(-1, $GUI_CHECKED) GUICtrlCreateGroup("", -99, -99, 1, 1) ;set default to Panel1 GUISwitch($aPanel[1]) ;show the main GUI GUISetState(@SW_SHOW, $hMainGUI) While 1 Sleep(10) $nMsg = GUIGetMsg(1) Switch $nMsg[1] Case $hMainGUI Switch $nMsg[0] Case $GUI_EVENT_CLOSE Exit Case $GUI_EVENT_MINIMIZE, $GUI_EVENT_MAXIMIZE, $GUI_EVENT_RESTORE $aPos = WinGetPos($hMainGUI) $iW = $aPos[2] $iH = $aPos[3] For $i = 0 To $aPanel[0] WinMove($aPanel[$i], "", $iLeftWidth + 2, $iT, $iW - $iLeftWidth + 2, $iH - $iT - $iB - 20) Next Case $aLink[1], $aLink[2], $aLink[3], $aLink[4] For $i = 1 To $aLink[0] If $nMsg[0] = $aLink[$i] Then GUISetState(@SW_SHOW, $aPanel[$i]) Else GUISetState(@SW_HIDE, $aPanel[$i]) EndIf Next Case $hFooter ShellExecute("http://www.autoitscript.com/forum/topic/146952-gui-design-concepts/") EndSwitch Case $aPanel[2] Switch $nMsg[0] Case $hButton1 MsgBox(32, "Test", "You have " & GUICtrlRead($hInput1) & "?") EndSwitch Case $aPanel[4] Switch $nMsg[0] Case $aChkBox[1], $aChkBox[2], $aChkBox[3] For $i = 1 To 3 If GUICtrlRead($aChkBox[$i]) = $GUI_CHECKED Then MsgBox(64, "Test", "You checked nr. " & $i & "!") Next EndSwitch EndSwitch WEnd EndFunc ;==>_MainGui Func _AddNewLink($sTxt, $iIcon = -44) Local $hLink = GUICtrlCreateLabel($sTxt, 36, $iT + $iGap, $iLeftWidth - 46, 17) GUICtrlSetCursor(-1, 0) GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKTOP + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT) GUICtrlCreateIcon("shell32.dll", $iIcon, 10, $iT + $iGap, 16, 16) GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKTOP + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT) $iGap += 22 Return $hLink EndFunc ;==>_AddNewLink Func _AddNewPanel($sTxt) Local $gui = GUICreate("", $iW - $iLeftWidth + 2, $iH - $iT - $iB, $iLeftWidth + 2, $iT, $WS_CHILD + $WS_VISIBLE, -1, $hMainGUI) GUICtrlCreateLabel($sTxt, 10, 10, $iW - $iLeftWidth - 20, 17, $SS_CENTERIMAGE) GUICtrlSetFont(-1, 9, 800, 4, "Arial", 5) GUICtrlSetResizing(-1, $GUI_DOCKTOP + $GUI_DOCKLEFT + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT) Return $gui EndFunc ;==>_AddNewPanel Func _AddControlsToPanel($hPanel) GUISwitch($hPanel) EndFunc ;==>_AddControlsToPanel
    1 point
  14. MKANET, here is an example using labels: #include <GUIConstantsEx.au3> #include <StaticConstants.au3> $bOn = True $hGUI = GUICreate("On/Off", 120, 45) GUICtrlCreateLabel("ON", 10, 10, 50, 25, BitOR($SS_CENTER, $SS_CENTERIMAGE)) GUICtrlSetFont(-1, 8, 800, 0, "Arial",5) GUICtrlSetColor(-1, 0xC0C0C0) GUICtrlSetBkColor(-1, 0x101010) GUICtrlSetState(-1, $GUI_DISABLE) GUICtrlCreateLabel("OFF", 60, 10, 50, 25, BitOR($SS_CENTER, $SS_CENTERIMAGE)) GUICtrlSetFont(-1, 8, 800, 0, "Arial",5) GUICtrlSetColor(-1, 0xC0C0C0) GUICtrlSetBkColor(-1, 0x101010) GUICtrlSetState(-1, $GUI_DISABLE) $hSwitch = GUICtrlCreateLabel("", 60, 10, 50, 25) GUICtrlSetFont(-1, 8, 800, 0, "Arial") GUICtrlSetBkColor(-1, 0xFF0000) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case -3 Exit Case $hSwitch $aPos = ControlGetPos($hGUI, "", $hSwitch) If $bOn Then For $i = 0 To 50 ControlMove($hGUI, "", $hSwitch, $aPos[0] - $i, $aPos[1]) Next $bOn = False Else For $i = 0 To 50 ControlMove($hGUI, "", $hSwitch, $aPos[0] + $i, $aPos[1]) Next $bOn = True EndIf EndSwitch WEnd
    1 point
  15. I don't know how to make the slide, but if you click on them, they move to the opposite side. Perhaps this will get you started in the right direction. #include <GUIConstants.au3> #include <GuiButton.au3> #include <GUIConstantsEx.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 172, 177) $Group1 = GUICtrlCreateGroup("", 8, 7, 130, 38) $Button1 = GUICtrlCreateButton("On", 16, 16, 51, 25, 0) GUICtrlCreateGroup("", -99, -99, 1, 1) $Group2 = GUICtrlCreateGroup("", 8, 55, 130, 38) $Button2 = GUICtrlCreateButton("Off", 81, 64, 51, 25, 0) GUICtrlCreateGroup("", -99, -99, 1, 1) $Group3 = GUICtrlCreateGroup("", 8, 103, 130, 38) $Button3 = GUICtrlCreateButton("On", 16, 112, 51, 25, 0) GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 _Group1() Case $Button2 _Group2() Case $Button3 _Group3() EndSwitch WEnd Func _Group1() $readButton = _GUICtrlButton_GetText($Button1) If $readButton = "On" Then GUICtrlSetPos($Button1, 81, 16, 51, 25) _GUICtrlButton_SetText($Button1, "Off") Else GUICtrlSetPos($Button1, 16, 16, 51, 25) _GUICtrlButton_SetText($Button1, "On") EndIf EndFunc Func _Group2() $readButton = _GUICtrlButton_GetText($Button2) If $readButton = "On" Then GUICtrlSetPos($Button2, 81, 64, 51, 25) _GUICtrlButton_SetText($Button2, "Off") Else GUICtrlSetPos($Button2, 16, 64, 51, 25) _GUICtrlButton_SetText($Button2, "On") EndIf EndFunc Func _Group3() $readButton = _GUICtrlButton_GetText($Button3) If $readButton = "On" Then GUICtrlSetPos($Button3, 81, 112, 51, 25) _GUICtrlButton_SetText($Button3, "Off") Else GUICtrlSetPos($Button3, 16, 112, 51, 25) _GUICtrlButton_SetText($Button3, "On") EndIf EndFunc
    1 point
  16. "..Or is there another way?.." Ok, found the other way in a script by Melba23. Reading the text like WinInfo seems not to be possible. best regards, Reinhard ;; by Melba23 #Include <GuiToolBar.au3> Global $hSysTray_Handle, $iSystray_ButtonNumber Global $sToolTipTitle = "" ; <<<<<<<<<<<<<<<< Enter some tooltip text for the icon you want here $iSystray_ButtonNumber = Get_Systray_Index($sToolTipTitle) If $iSystray_ButtonNumber = 0 Then MsgBox(16, "Error", "Icon not found in system tray") Exit Else Sleep(500) _GUICtrlToolbar_ClickButton($hSysTray_Handle, $iSystray_ButtonNumber, "right") EndIf Exit ;............ Func Get_Systray_Index($sToolTipTitle) ; Find systray handle $hSysTray_Handle = ControlGetHandle('[Class:Shell_TrayWnd]', '', '[Class:ToolbarWindow32;Instance:1]') If @error Then MsgBox(16, "Error", "System tray not found") Exit EndIf ; Get systray item count Local $iSystray_ButCount = _GUICtrlToolbar_ButtonCount($hSysTray_Handle) If $iSystray_ButCount = 0 Then MsgBox(16, "Error", "No items found in system tray") Exit EndIf ; Look for wanted tooltip For $iSystray_ButtonNumber = 0 To $iSystray_ButCount - 1 If StringInStr(_GUICtrlToolbar_GetButtonText($hSysTray_Handle, $iSystray_ButtonNumber), $sToolTipTitle) = 1 Then ExitLoop Next If $iSystray_ButtonNumber = $iSystray_ButCount Then Return 0 ; Not found Else Return $iSystray_ButtonNumber ; Found EndIf EndFunc ;;The script is not foolproof - sometimes it does not find the icon. ;;I have found that using the first word/words of the tooltip text gives the best results.
    1 point
×
×
  • Create New...