mutleey

Form printing with good quality

16 posts in this topic

Hello everybody, I have a problem here ... I need to generate a form of sale and print quality using the form I could do is not getting good, I created a window without borders with the fields I need, then use the function _ScreenCapture_CaptureWnd () to generate a print of this window and send the image to the printer using the UDF printMGv2.au3, the problem is that to get a good quality I would have to create a huge window to get the print, any suggestions to print this form with a good quality?
thank you...

example of the form it takes:

 

ImgTemp.jpg

Share this post


Link to post
Share on other sites



Hi,

I can imagine when printing a form via PrtScr you are not going to get the best quality..

Is there a possibility to go a different route, like creating a PDF or using excel to create a form?

I personally use excel to build forms as it allows for simpler form filling automation ...

Bill

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Thank you, to start the window was what I thought best, most had not considered the possibility of a PDF or Excel.

Still not getting good results with these methods mentioned, I think the best way would be to create the image (bmp or jpg) with GDI + however I'm picking up a lot ... maybe an experienced member in GDI + as the UEZ can shed some light.

Edited by mutleey

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Your uploaded image has a dim. of 624 x 796 pixels (96 dpi) -> 16.5 x 21.0 cm; 6.48 x 8.28 inches. On a DIN A4 paper and portrait format it takes approx. 66% of the paper.

When you print that image from an ext. program such as IrfanView for example, how is the print out quality?

 

From https://www.prepressure.com/library/paper-size/din-a4:

Quote

At 300 ppi (pixels per inch) the image needs to be 2480 x 3508 pixels. This is the required resolution for quality offset printing that will be viewed from a short distance (such as books, brochures, magazines, calenders,…). For photo books it is also the optimum resolution but a somewhat lower pixel count (250 dpi) is acceptable for great looking photographs.

At 150 ppi the image needs to be 1240 x 1754 pixels. This is the minimum resolution for newspapers or posters viewed from a fairly short distance.

 

 

Edited by UEZ
1 person likes this

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Even using IrfanView printing is too bad, as I mentioned above I created a GUI with the fields needed and used the _ScreenCapture_CaptureWnd() function to generate the bmp image and then sent to the printer, to be good like you even mentioned I would have create a huge window more thought into creating bmp using GDI + for then would have set a large image 2480 x 3508 pixels perhaps ... the problem is that I could not add the rectangles in the image created.

thanks for the answer.

Edited by mutleey

Share this post


Link to post
Share on other sites

mutleey,

Are you sure it is the document and not printer settings?

kylomas


Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites

kylomas,

Yes, as the UEZ comments the way I did the image is low resolution, and the way that I would have to create a huge GUI to get good results.

Share this post


Link to post
Share on other sites

Did you print the image with modifying the print size (e.g. best fit, stretch, ...) in the printer settings? 


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯

Share this post


Link to post
Share on other sites

...it is not depending on printer settings...

THIS

example printer.jpg

is the "original" picture-quality sended to the printer. Which printer in the world makes gold from shi* ???

If you want a more "clearer" (printable) Screenshot, try to change your windows settings of the font/cleartype. What looks "good" onto screen (cleartype) is not implicitly a good printout.

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

UEZ yes I used the stretch to fill the entire sheet so the image lost the quality, the window that generated the printscreen has 624x796 pixels.

AndyG yes is not the printer to determine the quality and the image already has a low resolution.

 

I do not have much experience with GDI+ one more push already help, for example create this GUI with these rectangles and labels.

 

ex.jpg

Edited by mutleey

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Can you post the test GUI code from post #1?

 

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯

Share this post


Link to post
Share on other sites

@ mutleey, did you read what i wrote? CLEARTYPE is the problem! It makes the font which you see onto your monitor/screen "smoother" and generates those "subpixels" where are responsible of the bad printout! Try to disable cleartype and show us the result.

http://www.thewindowsclub.com/disable-font-smoothing-windows

http://superuser.com/questions/297455/toggle-cleartype-windows-7

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

@Mutley, não é exatamente o que você queria, mas é disso que estou falando...

Criar uma imagem de fundo, e adicionar os controles necessários, esse exemplo é básico, mas pode ser o início de uma solução.

Após a composição da imagem, você pode imprimir normalmente.

A melhor ideia seria criar uma imagem pronta, com o formulário vazio, e imprimir na imagem apenas as informações, assim fica mais rápido também.

 

This example it is a toy, to create, move, resize, delete and set color to many Contols.

In this example, it work with GuiCtrlCreateLabel, but can be adapted to any control.

The Mod()'s function it's a attempt to move a Control to 8 to 8 pixels only, for example, not 1 to 1.

If you not want this way/recurse, only comment delete the lines have Mod() function.

If you want to improve this function, it's is welcome.

Use Secondary mouse button, to Add, Delete, Set Color and export to PNG.

Use Primary over the control to Move or Resize.

 

 

;~ #AutoIt3Wrapper_AU3Check_Parameters= -q -d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7
;~ #Tidy_Parameters=/sf
; #FUNCTION# ====================================================================================================================
; Name ..........: No name
; Description ...: Allow create, move, resize, delete and set color a GuiCtrlCreateLabel and export to PNG image
; Syntax ........: 
; Parameters ....: 
; Return values .: 
; Author ........: Luigi
; Example .......: 
; ===============================================================================================================================
#include-once
#include <Array.au3>
#include <GUIConstantsEx.au3>
#include <File.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <WinAPI.au3>
#include <GuiMenu.au3>
#include <WinAPIGdi.au3>
#include <Misc.au3>
#include <GDIPlus.au3>

OnAutoItExitRegister("OnExit")

Opt("GUIOnEventMode", 1)
Opt("GUIEventOptions", 1)
Opt("MustDeclareVars", 1)


Global $aGuiSize[2] = [800, 600]
Global $sGuiTitle = "GuiTitle"
Global $hGui
Global $hUm, $hDois
Global $aCursor, $aMouse[5], $aMove[6], $arr, $size
Global $iLimit = 6
Global $aCursor2, $aMouse2[5]
Global $SUM, $DX, $DY
Global $hDummy, $hDummyContext, $hDummyContextMenu
Global $focus

_GDIPlus_Startup()
Global $hBitmap
Global $hContext
Global $hBrush = _GDIPlus_BrushCreateSolid()
Global $hFormat, $hFamily, $hFont, $tLayout, $aInfo


Global $hPen
$hPen = _GDIPlus_PenCreate()



Global Const $UP = 1, $RIGHT = 2, $DOWN = 4, $LEFT = 8
Global Const $UP_RIGHT = $UP + $RIGHT, $UP_LEFT = $UP + $LEFT, $DOWN_RIGHT = $DOWN + $RIGHT, $DOWN_LEFT = $DOWN + $LEFT

$hGui = GUICreate($sGuiTitle, $aGuiSize[0], $aGuiSize[1], -1, -1)
GUISetOnEvent($GUI_EVENT_CLOSE, "Quit")
GUISetBkColor(0xFFFFFF, $hGui)

_CreateDummy($hDummy, $hDummyContext, $hDummyContextMenu, "Add=Context_Add;Del=Context_Del;Color=Context_Color;Image=Context_CreateImage")

Global $aNode[1] = [0]
Global $SID = IniRead("label.ini", "config", "id", 1)

Global $NODES = IniReadSection("label.ini", "objetos")
If IsArray($NODES) Then
    ReDim $NODES[UBound($NODES, 1)][3]
Else
    Global $NODES[1][3] = [[0]]
EndIf

If IsArray($NODES) Then
    For $ii = 1 To $NODES[0][0]
        NewObj($NODES[$ii][0], $NODES[$ii][1], $ii)
    Next
EndIf

Func NewObj($ID = 0, $input = 0, $ii = 0)
    If $ID Then
        $input = StringSplit($input, ",", 2)
        $NODES[$ii][2] = GUICtrlCreateLabel($ID, $input[0], $input[1], $input[2], $input[3], $SS_SUNKEN)
        GUICtrlSetBkColor($NODES[$ii][2], Number($input[4]))
    Else
        Local $color = NewColor()
        $aCursor = GUIGetCursorInfo($hGui)

        $aCursor[0] -= Mod($aCursor[0], 20) + 10
        $aCursor[1] -= Mod($aCursor[1], 20) + 10


        Local $new = GUICtrlCreateLabel($SID, $aCursor[0], $aCursor[1], 40, 40, $SS_SUNKEN)
        GUICtrlSetBkColor($new, $color)
        $SID += 1
        IniWrite("label.ini", "config", "id", $SID)
        IniWrite("label.ini", "objetos", $SID, ",,,," & $color)
        _ArrayAdd2d($NODES, $SID, "", $new)
    EndIf
EndFunc   ;==>NewObj

Func NewColor()
    Return "0x" & Hex(Random(0, 255, 1), 2) & Hex(Random(0, 255, 1), 2) & Hex(Random(0, 255, 1), 2)
EndFunc   ;==>NewColor

Func _ArrayAdd2d(ByRef $arr, $mOpt0 = Default, $mOpt1 = Default, $mOpt2 = Default, $mOpt3 = Default, $mOpt4 = Default, $mOpt5 = Default, $mOpt6 = Default, $mOpt7 = Default)
    $arr[0][0] = UBound($arr, 1)
    Local $iCol = UBound($arr, 2)
    ReDim $arr[$arr[0][0] + 1][$iCol]
    If @NumParams - 1 < $iCol Then $iCol = @NumParams - 1
    For $ii = 0 To $iCol - 1
        $arr[$arr[0][0]][$ii] = Eval("mOpt" & $ii)
    Next
EndFunc   ;==>_ArrayAdd2d

GUICtrlSetState($hUm, $GUI_ONTOP)
;~ _WinAPI_BringWindowToTop(GUICtrlGetHandle($hUm))

GUICtrlSetBkColor($hUm, 0x336633)
GUICtrlSetBkColor($hDois, 0x996633)

GUISetState(@SW_SHOW, $hGui)


While Sleep(25)
    $aCursor = GUIGetCursorInfo($hGui)
    If IsArray($aCursor) Then
        If $aCursor[3] Then
            _GUICtrlMenu_TrackPopupMenu($hDummyContextMenu, $hGui)
        EndIf
        $focus = $aCursor[4] ? $aCursor[4] : 0
        If $aCursor[2] Then
            If $aCursor[4] Then
                $aMouse[4] = $aCursor[4]
                $arr = ControlGetPos($hGui, "", $aCursor[4])
                $aMove[0] = $arr[0] - $aCursor[0]
                ConsoleWrite("[" & $aMove[0] & "] [" & $arr[0] & "] [" & $aCursor[0] & "]" & @LF)
                $aMove[1] = $arr[1] - $aCursor[1]

                $aCursor2 = GUIGetCursorInfo($hGui)

                Switch $SUM
                    Case $DOWN
                        GUISetCursor(11, 1, $hGui)
                        $DX = $aCursor2[1] - $arr[3]
                        While IsArray($aCursor2) And $aCursor2[2]
                            $aCursor2 = GUIGetCursorInfo($hGui)
                            If ($aCursor2[1] <> $aMouse2[1]) Then
                                ControlMove($hGui, "", $aCursor[4], $arr[0], $arr[1], $arr[2], $aCursor2[1] - $DX)
                                $aMouse2[1] = $aCursor2[1]
                                _WinAPI_RedrawWindow($hGui, 0, 0, $RDW_INVALIDATE)
                            EndIf
                        WEnd
                    Case $UP
                        GUISetCursor(11, 1, $hGui)
                        $aMouse2[1] = $aCursor2[1]
                        While IsArray($aCursor2) And $aCursor2[2]
                            $aCursor2 = GUIGetCursorInfo($hGui)
                            If ($aCursor2[1] <> $aMouse2[1]) Then
                                $size = $aMouse2[1] - $aCursor2[1]
                                $arr[1] -= $size
                                $arr[3] += $size
                                ControlMove($hGui, "", $aCursor[4], $arr[0], $arr[1], $arr[2], $arr[3])
                                $aMouse2[1] = $aCursor2[1]
                                _WinAPI_RedrawWindow($hGui, 0, 0, $RDW_INVALIDATE)
                            EndIf
                        WEnd
                    Case $RIGHT
                        GUISetCursor(13, 1, $hGui)
                        $DY = $aCursor2[0] - $arr[2]
                        While IsArray($aCursor2) And $aCursor2[2]
                            $aCursor2 = GUIGetCursorInfo($hGui)
                            If ($aCursor2[0] <> $aMouse2[0]) Then
                                ControlMove($hGui, "", $aCursor[4], $arr[0], $arr[1], $aCursor2[0] - $DY, $arr[3])
                                $aMouse2[0] = $aCursor2[0]
                                _WinAPI_RedrawWindow($hGui, 0, 0, $RDW_INVALIDATE)
                            EndIf
                        WEnd
                    Case $LEFT
                        GUISetCursor(13, 1, $hGui)
                        $aMouse2[0] = $aCursor2[0]
                        While IsArray($aCursor2) And $aCursor2[2]
                            $aCursor2 = GUIGetCursorInfo($hGui)
                            If ($aCursor2[0] <> $aMouse2[0]) Then
                                $size = $aMouse2[0] - $aCursor2[0]
                                $arr[0] -= $size
                                $arr[2] += $size
                                ControlMove($hGui, "", $aCursor[4], $arr[0], $arr[1], $arr[2], $arr[3])
                                $aMouse2[0] = $aCursor2[0]
                                _WinAPI_RedrawWindow($hGui, 0, 0, $RDW_INVALIDATE)
                            EndIf
                        WEnd
                    Case $UP_RIGHT
                        GUISetCursor(10, 1, $hGui)
                        $aMouse2[1] = $aCursor2[1]
                        $DY = $aCursor2[0] - $arr[2]
                        While IsArray($aCursor2) And $aCursor2[2]
                            $aCursor2 = GUIGetCursorInfo($hGui)
                            If ($aCursor2[1] <> $aMouse2[1]) Or ($aCursor2[0] <> $aMouse2[0]) Then
                                $size = $aMouse2[1] - $aCursor2[1]
                                $arr[1] -= $size
                                $arr[3] += $size
                                $arr[2] = $aCursor2[0] - $DY
                                ControlMove($hGui, "", $aCursor[4], $arr[0], $arr[1], $arr[2], $arr[3])
                                $aMouse2[0] = $aCursor2[0]
                                $aMouse2[1] = $aCursor2[1]
                                _WinAPI_RedrawWindow($hGui, 0, 0, $RDW_INVALIDATE)
                            EndIf
                        WEnd
                    Case $DOWN_RIGHT
                        GUISetCursor(12, 1, $hGui)
                        $DY = $aCursor2[0] - $arr[2]
                        $DX = $aCursor2[1] - $arr[3]
                        While IsArray($aCursor2) And $aCursor2[2]
                            $aCursor2 = GUIGetCursorInfo($hGui)
                            If ($aCursor2[0] <> $aMouse2[0]) Or ($aCursor2[1] <> $aMouse2[1]) Then
                                $arr[2] = $aCursor2[0] - $DY
                                ControlMove($hGui, "", $aCursor[4], $arr[0], $arr[1], $arr[2], $aCursor2[1] - $DX)
                                $aMouse2[0] = $aCursor2[0]
                                $aMouse2[1] = $aCursor2[1]
                                _WinAPI_RedrawWindow($hGui, 0, 0, $RDW_INVALIDATE)
                            EndIf
                        WEnd
                    Case $UP_LEFT
                        GUISetCursor(12, 1, $hGui)
                        $aMouse2[0] = $aCursor2[0]
                        $aMouse2[1] = $aCursor2[1]
                        While IsArray($aCursor2) And $aCursor2[2]
                            $aCursor2 = GUIGetCursorInfo($hGui)
                            If ($aCursor2[0] <> $aMouse2[0]) Or ($aCursor2[1] <> $aMouse2[1]) Then
                                $size = $aMouse2[1] - $aCursor2[1]
                                $arr[1] -= $size
                                $arr[3] += $size
                                $size = $aMouse2[0] - $aCursor2[0]
                                $arr[0] -= $size
                                $arr[2] += $size
                                ControlMove($hGui, "", $aCursor[4], $arr[0], $arr[1], $arr[2], $arr[3])
                                $aMouse2[0] = $aCursor2[0]
                                $aMouse2[1] = $aCursor2[1]
                                _WinAPI_RedrawWindow($hGui, 0, 0, $RDW_INVALIDATE)
                            EndIf
                        WEnd
                    Case $DOWN_LEFT
                        GUISetCursor(10, 1, $hGui)
                        $aMouse2[0] = $aCursor2[0]
                        $DX = $aCursor2[1] - $arr[3]
                        While IsArray($aCursor2) And $aCursor2[2]
                            $aCursor2 = GUIGetCursorInfo($hGui)
                            If ($aCursor2[0] <> $aMouse2[0]) Or ($aCursor2[1] <> $aMouse2[1]) Then
                                $size = $aMouse2[0] - $aCursor2[0]
                                $arr[0] -= $size
                                $arr[2] += $size
                                ControlMove($hGui, "", $aCursor[4], $arr[0], $arr[1], $arr[2], $aCursor2[1] - $DX)
                                $aMouse2[0] = $aCursor2[0]
                                $aMouse2[1] = $aCursor2[1]
                                _WinAPI_RedrawWindow($hGui, 0, 0, $RDW_INVALIDATE)
                            EndIf
                        WEnd
                    Case Else
                        GUISetCursor(9, 1, $hGui)
                        While IsArray($aCursor2) And $aCursor2[2]
                            $aCursor2 = GUIGetCursorInfo($hGui)
                            If ($aCursor2[0] <> $aMouse2[0]) Or ($aCursor2[1] <> $aMouse2[1]) Then
                                $aCursor2[0] = $aCursor2[0] - Mod($aCursor2[0], 20) ;+ $aMove[0]
                                ConsoleWrite("[" & $aCursor2[0] & "] [" & $aMove[0] & "] [" & $aCursor2[0] - Mod($aCursor2[0], 20) & "]" & @LF)
                                $aCursor2[1] = $aCursor2[1] - Mod($aCursor2[1], 20); + $aMove[1]
                                $aMouse2[0] = $aCursor2[0]
                                $aMouse2[1] = $aCursor2[1]

                                ControlMove($hGui, "", $aCursor[4], $aCursor2[0], $aCursor2[1], $arr[2], $arr[3])
                                _WinAPI_RedrawWindow($hGui, 0, 0, $RDW_INVALIDATE)
                            EndIf
                        WEnd
                EndSwitch

                GUISetCursor(6, 1, $hGui)
            Else

            EndIf
        Else
            If $aCursor[4] Then
                $arr = ControlGetPos($hGui, "", $aCursor[4])
                $aMove[0] = $arr[0] - $aCursor[0]
                $aMove[1] = $arr[1] - $aCursor[1]
                $SUM = 0

                If $aMove[0] <= 0 And $aMove[0] > -$iLimit Then $SUM += $LEFT
                If $aMove[0] <= -($arr[2] - $iLimit) And $aMove[0] >= -$arr[2] Then $SUM += $RIGHT
                If $aMove[1] <= 0 And $aMove[1] > -$iLimit Then $SUM += $UP
                If $aMove[1] <= -($arr[3] - $iLimit) And $aMove[1] >= -$arr[3] Then $SUM += $DOWN

                Switch $SUM
                    Case $UP
                        GUISetCursor(11, 1, $hGui)
                    Case $DOWN
                        GUISetCursor(11, 1, $hGui)
                    Case $RIGHT
                        GUISetCursor(13, 1, $hGui)
                    Case $UP_RIGHT
                        GUISetCursor(10, 1, $hGui)
                    Case $DOWN_RIGHT
                        GUISetCursor(12, 1, $hGui)
                    Case $LEFT
                        GUISetCursor(13, 1, $hGui)
                    Case $UP_LEFT
                        GUISetCursor(12, 1, $hGui)
                    Case $DOWN_LEFT
                        GUISetCursor(10, 1, $hGui)
                    Case Else
                        GUISetCursor(6, 1, $hGui)
                EndSwitch
            Else
                GUISetCursor(6, 1, $hGui)
            EndIf
        EndIf


    EndIf
WEnd

Func OnExit()
    For $ii = 1 To $NODES[0][0]
        IniWrite("label.ini", "objetos", $NODES[$ii][0], _ArrayToString(ControlGetPos($hGui, "", $NODES[$ii][2]), ",") & "," & GUICtrlGetBkColor($NODES[$ii][2]))
    Next
    _GDIPlus_GraphicsDispose($hContext)
    _GDIPlus_BitmapDispose($hBitmap)

    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_BrushDispose($hBrush)



    _GDIPlus_Shutdown()
    GUISetState($hGui, @SW_HIDE)
    GUIDelete($hGui)
EndFunc   ;==>OnExit

Func Quit()
    Exit
EndFunc   ;==>Quit


Func _CreateDummy(ByRef $dummy, ByRef $context, ByRef $menu, $cmd)
    Local $aDummy[1][3]
    _ArrayAdd($aDummy, $cmd, Default, "=", ";")
    $dummy = GUICtrlCreateDummy()
    $context = GUICtrlCreateContextMenu($dummy)
    $menu = GUICtrlGetHandle($context)
    For $ii = 1 To UBound($aDummy, 1) - 1
        $aDummy[$ii][2] = GUICtrlCreateMenuItem($aDummy[$ii][0], $context)
        If $aDummy[$ii][1] Then GUICtrlSetOnEvent($aDummy[$ii][2], $aDummy[$ii][1])
    Next
EndFunc   ;==>_CreateDummy

Func Context_Add()
    NewObj()
EndFunc   ;==>Context_Add

Func _box($hToGraphic, $iXX, $iYY, $iWW, $iHH, $iColor = 0, $bFill = False)
    ; _box3
    _GDIPlus_BrushSetSolidColor($hBrush, $iColor)
    If $iWW = 1 And $iHH = 1 Then
        If $iColor Then
            _GDIPlus_GraphicsFillRect($hToGraphic, $iXX, $iYY, $iWW, $iHH, $hBrush)
        Else
            _GDIPlus_GraphicsFillRect($hToGraphic, $iXX, $iYY, $iWW, $iHH)
        EndIf
    Else
        Local $aBox[5][2]
        $aBox[0][0] = 4
        $aBox[1][0] = $iXX
        $aBox[1][1] = $iYY
        $aBox[2][0] = $iXX + $iWW - 1
        $aBox[2][1] = $iYY
        $aBox[3][0] = $iXX + $iWW - 1
        $aBox[3][1] = $iYY + $iHH - 1
        $aBox[4][0] = $iXX
        $aBox[4][1] = $iYY + $iHH - 1
        If $iColor Then
            _GDIPlus_PenSetColor($hPen, $iColor)
            _GDIPlus_GraphicsFillPolygon($hToGraphic, $aBox, $hBrush)
            _GDIPlus_GraphicsDrawPolygon($hToGraphic, $aBox, $hPen)
        Else
            _GDIPlus_GraphicsDrawPolygon($hToGraphic, $aBox)
        EndIf
    EndIf
EndFunc   ;==>_box

Func _Text($hToGraphic, $sFont, $sText, $iSize, $iXX, $iYY, $iWW, $iHH, $iColor)
    _GDIPlus_BrushSetSolidColor($hBrush, $iColor)
    $hFormat = _GDIPlus_StringFormatCreate()
    $hFamily = _GDIPlus_FontFamilyCreate($sFont)
    $hFont = _GDIPlus_FontCreate($hFamily, $iSize, 0)
    $tLayout = _GDIPlus_RectFCreate($iXX, $iYY, $iWW, $iHH)
    $aInfo = _GDIPlus_GraphicsMeasureString($hToGraphic, $sText, $hFont, $tLayout, $hFormat)
    _GDIPlus_GraphicsDrawStringEx($hToGraphic, $sText, $hFont, $aInfo[0], $hFormat, $hBrush)

EndFunc   ;==>_Text

Func Context_CreateImage()
    ConsoleWrite("Context_CreateImage()" & @LF)
    Local $aControlGetPos, $iColor, $sText
    Local $iR, $iG, $iB
    $hBitmap = _GDIPlus_BitmapCreateFromScan0($aGuiSize[0], $aGuiSize[1])
    $hContext = _GDIPlus_ImageGetGraphicsContext($hBitmap)

    _GDIPlus_GraphicsSetSmoothingMode($hContext, 0)
    _GDIPlus_GraphicsClear($hContext, 0xFFFFFFFF)

    For $ii = 1 To $NODES[0][0]
        $aControlGetPos = ControlGetPos($hGui, "", $NODES[$ii][2])
        $iColor = GUICtrlGetBkColor($NODES[$ii][2])
        $iR = _WinAPI_GetRValue($iColor)
        $iG = _WinAPI_GetGValue($iColor)
        $iB = _WinAPI_GetBValue($iColor)
        $iColor = "0x99" & Hex(_WinAPI_RGB($iR, $iG, $iB), 6)
        _box($hContext, $aControlGetPos[0], $aControlGetPos[1], $aControlGetPos[2], $aControlGetPos[3], $iColor, True)
        $sText = GUICtrlRead($NODES[$ii][2])
        _Text($hContext, "Courier New", $sText, 10, $aControlGetPos[0], $aControlGetPos[1], $aControlGetPos[2], $aControlGetPos[3], 0xFF000000)
    Next

    Local $sFile = @TempDir & "\Test.png"
    FileDelete($sFile)
    _GDIPlus_ImageSaveToFile($hBitmap, $sFile) ;save bitmap to disk
    ShellExecute($sFile)
EndFunc   ;==>Context_CreateImage

Func Context_Del()
    Local $find = _ArraySearch($NODES, $focus, 1, Default, 0, 0, 0, 2)
    ConsoleWrite("$focus[" & $focus & "] $find[" & $find & "]" & @LF)
    If $find >= 0 Then
        GUICtrlDelete($focus)
        IniDelete("label.ini", "objetos", $NODES[$find][0])
        _ArrayDelete($NODES, $find)
        $aCursor = GUIGetCursorInfo($hGui)
    EndIf
    $NODES[0][0] = UBound($NODES, 1) - 1
EndFunc   ;==>Context_Del

Func Context_Color()
    If Not $focus Then Return
    Local $color = GUICtrlGetBkColor($focus)
    Local $NewColor = _ChooseColor(2, $color, 2, $hGui)
    If $NewColor = -1 Then Return
    GUICtrlSetBkColor($focus, $NewColor)
EndFunc   ;==>Context_Color

; #FUNCTION# ====================================================================================================================
; Name ..........: GUICtrlGetBkColor
; Description ...: Retrieves the RGB value of the control background.
; Syntax ........: GUICtrlGetBkColor($hWnd)
; Parameters ....: $hWnd                - Control ID/Handle to the control
; Return values .: Success - RGB value
;                  Failure - 0
; Author ........: guinness
; Example .......: Yes
; ===============================================================================================================================
Func GUICtrlGetBkColor($hWnd)
    If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
    Local $hDC = _WinAPI_GetDC($hWnd)
    Local $iColor = _WinAPI_GetPixel($hDC, 0, 0)
    _WinAPI_ReleaseDC($hWnd, $hDC)
    Return $iColor
EndFunc   ;==>GUICtrlGetBkColor

 

Edited by Luigi
1 person likes this

m(o.O)m

Share this post


Link to post
Share on other sites
4 hours ago, UEZ said:

Can you post the test GUI code from post #1?

 

#include <ScreenCapture.au3>
#include <GUIConstantsEx.au3>
#include 'printMGv2.au3'

ImprimePedido("Steve Jobs", "2350.20")

Func ImprimePedido($Str1, $Str2)
    Local $WS_POPUP = 0x80000000 ; Creates a pop-up window. This style cannot be used with the WS_CHILD style.
    Local $SS_CENTER = 0x01 ; Specifies a simple rectangle and centers the error value text in the rectangle. The control automatically wraps words that extend past the end of a line to the beginning of the next centered line.
    Local $Branco = 0xFFFFFF, $Cinza2 = 0xCCCCCC
    Local $rCli = FileReadToArray(@AppDataDir & "\GJA\Cli\" & $Str1)
    If @error Then Return

    Global $GuiPedido = GUICreate("Descrição de Pedidos", 624, 796, -1, -1, $WS_POPUP)
    GUISetBkColor($Branco)

    GUICtrlCreateLabel("Sales Description", 24, 34, 380, 34)
    GUICtrlSetFont(-1, 16, 400, 0, "Arial Black")

    GUICtrlCreateGroup(" Date ", 512, 42, 89, 33)
    GUICtrlCreateLabel(@MDAY & "/" & @MON & "/" & @YEAR, 518, 56, 80, 16, $SS_CENTER)
    GUICtrlSetFont(-1, 10, 400, 2, "", 5)

    GUICtrlCreateGroup(" Name ", 24, 82, 385, 33)
    GUICtrlCreateLabel($Str1, 30, 96, 372, 16)
    GUICtrlSetFont(-1, 10, 400, 2, "", 5)

    GUICtrlCreateGroup(" CPF/CNPJ ", 416, 82, 185, 33)
    If $rCli[29] = "none" Then $rCli[29] = ""
    GUICtrlCreateLabel($rCli[29], 422, 96, 172, 16, $SS_CENTER)
    GUICtrlSetFont(-1, 10, 400, 2, "", 5)

    GUICtrlCreateGroup(" Adddress ", 24, 122, 297, 33)

    Local $EndNum
    Select
        Case $rCli[0] <> "none" And $rCli[1] <> "none"
            $EndNum = $rCli[0] & ", " & $rCli[1]
        Case $rCli[0] <> "none" And $rCli[1] = "none"
            $EndNum = $rCli[0] & ", SN"
        Case Else
            $EndNum = ""
    EndSelect
    GUICtrlCreateLabel($EndNum, 30, 136, 284, 16)
    GUICtrlSetFont(-1, 10, 400, 2, "", 5)

    GUICtrlCreateGroup(" District ", 328, 122, 169, 33)
    If $rCli[2] = "none" Then $rCli[2] = ""
    GUICtrlCreateLabel($rCli[2], 332, 136, 160, 16, $SS_CENTER)
    GUICtrlSetFont(-1, 10, 400, 2, "", 5)

    GUICtrlCreateGroup(" Zip ", 504, 122, 97, 33)
    If $rCli[5] = "none" Then $rCli[5] = ""
    GUICtrlCreateLabel($rCli[5], 508, 136, 88, 16, $SS_CENTER)
    GUICtrlSetFont(-1, 10, 400, 2, "", 5)

    GUICtrlCreateGroup(" County ", 24, 162, 185, 33)
    If $rCli[3] = "none" Then $rCli[3] = ""
    GUICtrlCreateLabel($rCli[3], 30, 176, 174, 16, $SS_CENTER)
    GUICtrlSetFont(-1, 10, 400, 2, "", 5)

    GUICtrlCreateGroup(" UF ", 216, 162, 49, 33)
    If $rCli[4] = "none" Then $rCli[4] = ""
    GUICtrlCreateLabel($rCli[4], 220, 176, 40, 16, $SS_CENTER)
    GUICtrlSetFont(-1, 10, 400, 2, "", 5)

    GUICtrlCreateGroup(" Phone ", 272, 162, 129, 33)
    If $rCli[18] = "none" Then $rCli[18] = "    "
    If $rCli[19] = "none" Then $rCli[19] = "                  "
    GUICtrlCreateLabel("(" & $rCli[18] & ")" & "  " & $rCli[19], 276, 176, 120, 16, $SS_CENTER)
    GUICtrlSetFont(-1, 10, 400, 2, "", 5)

    GUICtrlCreateGroup(" State Registration ", 408, 162, 193, 33)
    GUICtrlSetFont(-1, 10, 400, 2, "", 5)

    GUICtrlCreateLabel("Quantity", 24, 234, 72, 16, $SS_CENTER)
    GUICtrlSetFont(-1, 9, 400, 0, "Calibri", 5)
    GUICtrlSetbkColor(-1, $Cinza2)

    GUICtrlCreateLabel("Weight", 102, 234, 55, 16, $SS_CENTER)
    GUICtrlSetFont(-1, 9, 400, 0, "Calibri", 5)
    GUICtrlSetbkColor(-1, $Cinza2)

    GUICtrlCreateLabel("Unit", 163, 234, 55, 16, $SS_CENTER)
    GUICtrlSetFont(-1, 9, 400, 0, "Calibri", 5)
    GUICtrlSetbkColor(-1, $Cinza2)

    GUICtrlCreateLabel("Description", 224, 234, 206, 16, $SS_CENTER)
    GUICtrlSetFont(-1, 9, 400, 0, "Calibri", 5)
    GUICtrlSetbkColor(-1, $Cinza2)

    GUICtrlCreateLabel("Unitary Value", 436, 234, 81, 16, $SS_CENTER)
    GUICtrlSetFont(-1, 9, 400, 0, "Calibri", 5)
    GUICtrlSetbkColor(-1, $Cinza2)

    GUICtrlCreateLabel("Total", 522, 234, 78, 16, $SS_CENTER)
    GUICtrlSetFont(-1, 9, 400, 0, "Calibri", 5)
    GUICtrlSetbkColor(-1, $Cinza2)

    GUICtrlCreateGroup("", 24, 248, 73, 444)
    GUICtrlCreateGroup("", 102, 248, 56, 444)
    GUICtrlCreateGroup("", 163, 248, 56, 444)
    GUICtrlCreateGroup("", 224, 248, 207, 444)
    GUICtrlCreateGroup("", 436, 248, 81, 444)
    GUICtrlCreateGroup("", 522, 248, 79, 444)
    GUICtrlCreateGroup("", 456, 704, 125, 33)

    GUICtrlCreateLabel("Value", 370, 715, 80, 17)
    GUICtrlSetFont(-1, 10, 600, 0, "Calibri", 5)
    GUICtrlCreateLabel("R$ " & StringFormat("%.2f", $Str2), 460, 714, 116, 17, $SS_CENTER)
    GUICtrlSetFont(-1, 10, 600, 0, "Calibri", 5)

    GUISetState(@SW_SHOW)
    Imprimir_Pedido()

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                GUIDelete()
                ExitLoop
        EndSwitch
    WEnd
EndFunc

; Captura o print da janela
Func Imprimir_Pedido()
    ; Variáveis usadas na impressão
    Local $hPrinter
    Local $Jpg = @ScriptDir & "\NotaIMG.jpg"
    Global $hDll = @ScriptDir & "\PrintMG.dll"; abre a DLL
    Local $pgwd = 2020; ; Largura da imagem
    Local $pght = 2880; Altura da imagem

    ; Capture window
    _ScreenCapture_CaptureWnd($Jpg, $GuiPedido, 0, 0, -1, -1, False)

    $hPrinter = _PrintDllStart($hDll); abre as funções da DLL em $hPrinter

    _PrintPageOrientation($hPrinter, 1) ; Define 0 horizontal ou 1 vertical
    _PrintStartPrint($hPrinter) ; Inicia a impressão
    _PrintImage($hPrinter, $Jpg, 0, 0, $pgwd, $pght) ; Imprime a imagem
    _PrintEndPrint($hPrinter) ; Finaliza a impressão
EndFunc

@Luigi Very good your example, it is basically what I do the same ... I will take a study in code. thank you.

 

@AndyG yes cleartype used in labels, did not know it was generating subpixels in the sources :(

Share this post


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

  • Similar Content

    • FrancescoDiMuro
      By FrancescoDiMuro
      Good evening guys ( almost good night here in Italy )  
      How are you? Hop you're fine  
      I'm trying to do a Login Form ( I did, but I'm missing something in the management ), that allows the user to login when the script is launched, and, when the main GUI is opened, the user can Logout and Login with another username and password.
      The username and password "checking" I do is done by a text file, which in there are username and password, crypted through _Crypt_EncryptData().
      The "issue" I'm having at the moment, is to manage the Login form when the user hasn't already done the login, and so, the main GUI is not visible, but is created...
      I create the main GUI after the Login form... I tried with WinActive, WinGetState, but nothing changed ( even at the first Login, the script says ( through a MsgBox ) that the Win does exists ( or is active... ) and, as I want, it is not shown again...

      I really don't know If I missed something, or, I don't know...
      I'm going crazy for this thing...
      If someone could help me, I'd really appreaciate it!
      Thanks for the reading
      #Region ### START Koda GUI section ### Form=C:\Users\Portatile-60\Documents\Documenti Lavoro\AutoIt\Gestione_Magazzino_v2\form_Login.kxf Global $form_Login = GUICreate("Effettua il Login per continuare:", 405, 120, @DesktopWidth/2 - 202.5, @DesktopHeight/2 - 150) ; 302, 218 GUISetOnEvent($GUI_EVENT_CLOSE, "GUIDeleteLogin") Global $combo_Username = GUICtrlCreateCombo("Di Muro Francesco", 104, 64, 217, 25) GUICtrlSetFont(-1, 10, 400, 0, "Arial") GUICtrlSetData($combo_Username, "somedata") Global $input_Password = GUICtrlCreateInput("", 104, 89, 217, 25, BitOR($GUI_SS_DEFAULT_INPUT,$ES_PASSWORD)) GUICtrlSetFont(-1, 10, 400, 0, "Arial") $button_VerificaDati = GUICtrlCreateButton("", 328, 66, 42, 42, $BS_ICON) GUICtrlSetImage(-1, "C:\Users\Portatile-60\Documents\Documenti Lavoro\AutoIt\Gestione_Magazzino_v2\Icone\icon_check.ico", -1) GUICtrlSetOnEvent($button_VerificaDati, "CheckLogin") $label_Titolo = GUICtrlCreateLabel("Login", 167, 14, 71, 33) GUICtrlSetFont(-1, 18, 800, 0, "Arial") $label_Username = GUICtrlCreateLabel("Username :", 24, 64, 76, 20) GUICtrlSetFont(-1, 10, 800, 0, "Arial") $label_Password = GUICtrlCreateLabel("Password :", 24, 89, 73, 20) GUICtrlSetFont(-1, 10, 800, 0, "Arial") #EndRegion ### END Koda GUI section ### Func CheckLogin() Local $sUsername = GUICtrlRead($combo_Username) Local $sPassword = GUICtrlRead($input_Password) MsgBox($MB_ICONINFORMATION, "", "Username: " & $sUsername & @CRLF & "Password: " & $sPassword) Local $sFileUtenti = @ScriptDir & "\utenti.txt" If @error Then MsgBox($MB_ICONERROR, "Errore!", "Errore durante la lettura del file!") Exit Else Local $hFileUtenti = FileOpen($sFileUtenti, $FO_READ) If @error Then MsgBox($MB_ICONERROR, "Errore!", "Errore durante l'apertura del file " & $sFileUtenti & "." & @CRLF & "Errore: " & @error) Else Local $sDatiUtente, $aDatiUtente Local $bUtenteTrovato = False Local $iLinea = 1 Local $sControlloWin = "" Local $sWin = WinGetState($form_GestioneMagazzino) MsgBox($MB_ICONINFORMATION, "", $sWin) If @error Then MsgBox($MB_ICONERROR, "Errore!", "Errore durante la verifica della GUI attiva." & @CRLF & "Errore: " & @error) EndIf If($sWin == 5) Then MsgBox($MB_ICONINFORMATION, "", "La GUI esiste!") Do $sDatiUtente = FileReadLine($hFileUtenti, $iLinea) $aDatiUtente = StringSplit($sDatiUtente, "|", $STR_NOCOUNT) If(BinaryToString(_Crypt_DecryptData($aDatiUtente[0], "CRYPT", $CALG_RC4)) = $sUsername And BinaryToString(_Crypt_DecryptData($aDatiUtente[1], "CRYPT", $CALG_RC4)) = $sPassword) Then $sControlloWin = "ESISTE" $bUtenteTrovato = True ExitLoop Else $iLinea+=1 If($sDatiUtente = "" And $bUtenteTrovato = False) Then MsgBox($MB_ICONWARNING, "Attenzione!", "Username o Password errati.") ExitLoop EndIf EndIf Until $bUtenteTrovato = True Else MsgBox($MB_ICONINFORMATION, "", "La GUI esiste!") Do $sDatiUtente = FileReadLine($hFileUtenti, $iLinea) $aDatiUtente = StringSplit($sDatiUtente, "|", $STR_NOCOUNT) If(BinaryToString(_Crypt_DecryptData($aDatiUtente[0], "CRYPT", $CALG_RC4)) = $sUsername And BinaryToString(_Crypt_DecryptData($aDatiUtente[1], "CRYPT", $CALG_RC4)) = $sPassword) Then $sControlloWin = "NON ESISTE" $bUtenteTrovato = True ExitLoop Else $iLinea+=1 If($sDatiUtente = "" And $bUtenteTrovato = False) Then MsgBox($MB_ICONWARNING, "Attenzione!", "Username o Password errati.") ExitLoop EndIf EndIf Until $bUtenteTrovato = True EndIf If($sControlloWin = "ESISTE") Then MsgBox($MB_ICONINFORMATION, "Login effettuato!", "Hai effettuato l'accesso come: " & @CRLF & $sUsername & ".") ; Setta come "non-cliccabile" il bottone di Login GUICtrlSetState($button_Login, $GUI_DISABLE) GUICtrlSetState($button_VisualizzaGiacenze, $GUI_ENABLE) GUICtrlSetState($button_AggiungiProdotto, $GUI_ENABLE) GUICtrlSetState($button_PrelevaProdotto, $GUI_ENABLE) GUICtrlSetState($button_RicercaProdotto, $GUI_ENABLE) GUICtrlSetState($button_CreaDDT, $GUI_ENABLE) GUICtrlSetState($button_MostraGiacenzeAZero, $GUI_ENABLE) GUICtrlSetState($combo_Magazzino, $GUI_ENABLE) GUICtrlSetState($button_Logout, $GUI_ENABLE) ; Setta come "non-cliccabile" il bottone di Login GUICtrlSetState($button_Login, $GUI_DISABLE) ; Setta l'utente che ha effettuato l'accesso nella label $label_CaptionUtente GUICtrlSetData($label_CaptionUtente, $sUsername) ; "Distruggi" la GUI Login GUIDelete($form_Login) FileClose($hFileUtenti) Else MsgBox($MB_ICONINFORMATION, "", "La GUI non esiste!") MsgBox($MB_ICONINFORMATION, "Login effettuato!", "Hai effettuato l'accesso come: " & @CRLF & $sUsername & ".") ; Mostra la GUI Principale GUISetState(@SW_SHOW, $form_GestioneMagazzino) ; Setta come "non-cliccabile" il bottone di Login GUICtrlSetState($button_Login, $GUI_DISABLE) ; Setta l'utente che ha effettuato l'accesso nella label $label_CaptionUtente GUICtrlSetData($label_CaptionUtente, $sUsername) ; "Distruggi" la GUI Login GUIDelete($form_Login) FileClose($hFileUtenti) EndIf EndIf EndIf EndFunc Func Logout() GUICtrlSetData($label_CaptionUtente, "") MsgBox($MB_ICONINFORMATION, "Logout effettuato!", "Effettua nuovamente il Login per utilizzare il programma.") ; Disabilita tutti i bottoni della GUI Principale GUICtrlSetState($button_VisualizzaGiacenze, $GUI_DISABLE) GUICtrlSetState($button_AggiungiProdotto, $GUI_DISABLE) GUICtrlSetState($button_PrelevaProdotto, $GUI_DISABLE) GUICtrlSetState($button_RicercaProdotto, $GUI_DISABLE) GUICtrlSetState($button_CreaDDT, $GUI_DISABLE) GUICtrlSetState($button_MostraGiacenzeAZero, $GUI_DISABLE) GUICtrlSetState($combo_Magazzino, $GUI_DISABLE) GUICtrlSetState($button_Logout, $GUI_DISABLE) ; Abilita il Login GUICtrlSetState($button_Login, $GUI_ENABLE) EndFunc EDIT:
      Solved, making an "integrated" Login form... 
    • Robdog1955
      By Robdog1955
      I am trying to use IE.au3 UDF to auto fill a webpage. All goes well until I get to an editbox that appears to be a javascript. I am attaching a pic of the editbox. (I would be glad to add any other information needed to help me past this last hurdle in my script. I'm just not sure what questions you have to help me with this.)

    • cookiemonster
      By cookiemonster
      Hi,
      I have a form which calls this function:
      Func HostToIP($Host, $Label) TCPStartup() Local $sIPAddress = TCPNameToIP($Host) If @error Then GUICtrlSetData ($Label, "Error code: " & @error) Else GUICtrlSetData ($Label, $sIPAddress) EndIf TCPShutdown() EndFunc But if it cannot resolve the host to an IP, the whole form freezes for a few seconds until the TCPNameToIP times out, how can I stop the form from freezing whilst it waits for the host to ip times out?
      TCPNameToIP is part of #include <_sql.au3>
    • Jefrey
      By Jefrey
      Taking the idea from @Melba23's (btw, thanks  ) ExtMsgBox and also making use of his StringSize UDF, I made a extended version of the InputBox function.
      From the README file:
      This UDF creates input boxes (just like native InputBox), but with multiple inputs.
      You can also set some inputs to be password-style, set the default texts for some of the edits and even set the label of the OK/cancel buttons.
      How to use
      _ExtInputBox($sTitle, $sTexts [ , $sDefaults = Null [ , $sPasswords = Null [ , $sBtnLabels = "OK|Cancel" [ , $iWidth = -1 [ , $iLeft = -1 [ , $iTop = -1 [ , $iTimeout = 0 [ , $hParent = 0 ] ] ] ] ] ] ] ] ) Arguments are:
      $sTitle (mandatory): The window title (e.g.: "Hello World") $sTexts (mandatory): The edit labels, separated by | (e.g.: "Your email|Your password") $sDefaults: The default input texts, separated by | (e.g.: "|you@us.com||" will tell that the first input will have nothing as default text, the second will have you@us.com as default text and the third and forth will also have nothing). Note that if you set the default value of 1 input, you must set the value of them all (even if it's nothing), otherwise all inputs will have no default value. Default is none. $sPasswords: One or more 1-based index of inputs, separated by anything that is not a number (pipeline - | - recommended), of the inputs that will receive password style (e.g.: "2|3" wíll tell that the second and third inputs are password-style, default is none) $sBtnLabels: The TWO label of the default OK/Cancel buttons (e.g.: "Submit|Close") $iWidth: Window width (default is the size of the longest string with the limit of 25% of the screen width). Obviously it's not possible to set the height as it's calculated automatically. $iLeft: Distance of the window from the left side of the screen (default is centered) $iTop: Distance of the window to the top of the screen (default is centered) $iTimeout: Time limit for filling the form data (default is none) $hParent: Parent form (default is none)  
      Return value
      Sucess: an 1-based array with the input values entered ($aArray[1] = 1st input value, $aArray[2] = 2nd input value, $aArray[n] = nth input value, whereas $aArray[0] = input count)
      Failure: False, and set @extended to 1 if the user clicked cancel, 2 if the user closed the window, or 3 if timeout ended.
       
      Examples (two of them)
       
       
       
      #include 'ExtInputBox.au3' $sData = _ExtInputBox("Login", "Username|Password", Null, "2") If $sData = False Then MsgBox(0, "", "You pressed cancel, exit or timeout ended.") Else MsgBox(0, "You entered:", "Username: " & $sData[1] & @CRLF & "Password: " & $sData[2]) EndIf #include 'ExtInputBox.au3' $sData = _ExtInputBox("Login", "Your full name|Your email|Your telephone|Choose an username|Choose a password|Repeat password", "Mr./Ms. ||+1 |admin||", "5,6", "Register|Cancel") If $sData = False Then Switch @extended Case 1 MsgBox(0, "", "You clicked Cancel") Case 2 MsgBox(0, "", "You closed the window.") Case 3 MsgBox(0, "", "Timeout ended (but we have no timeout on this example, so this will never happen)") EndSwitch Else MsgBox(0, "You entered:", "Full name: " & $sData[1] & @CRLF & _ "Email: " & $sData[2] & @CRLF & _ "Telephone:" & $sData[3] & @CRLF & _ "Username: " & $sData[4] & @CRLF & _ "Password: " & $sData[5] & @CRLF & _ "Password repeat: " & $sData[6]) EndIf  
      Download
       
      Download ZIP from GitHub
       
      Btw, fork me on Github
       
    • pranaynanda
      By pranaynanda
      I'm trying to run this code:
      #include <GuiListView.au3> #include <GUIConstants.au3> Dim $Services Dim $ServicesList #cs While 1 CheckService() Sleep(30000) ; sleep 30 seconds WEnd #ce ;#cs #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <TabConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 615, 438, 192, 124) $Tab1 = GUICtrlCreateTab(0, 48, 609, 385) $TabSheet1 = GUICtrlCreateTabItem("Running Services") $ListView1 = GUICtrlCreateListView("Service Name|Status", 8, 72, 593, 281, -1, BitOR($LVS_EX_GRIDLINES,$LVS_EX_CHECKBOXES,$LVS_EX_FULLROWSELECT)) GUICtrlSendMsg($ListView1, $LVM_SETCOLUMNWIDTH, 0, 300) GUICtrlSendMsg($ListView1, $LVM_SETCOLUMNWIDTH, 1, 288) $Button1 = GUICtrlCreateButton("Stop Services", 464, 376, 129, 33) $TabSheet2 = GUICtrlCreateTabItem("Stopped Services") GUICtrlSetState(-1,$GUI_SHOW) $ListView2 = GUICtrlCreateListView("Service Name|Status", 8, 72, 593, 281, -1, BitOR($LVS_EX_GRIDLINES,$LVS_EX_CHECKBOXES,$LVS_EX_FULLROWSELECT)) GUICtrlSendMsg($ListView2, $LVM_SETCOLUMNWIDTH, 0, 300) GUICtrlSendMsg($ListView2, $LVM_SETCOLUMNWIDTH, 1, 288) $Button2 = GUICtrlCreateButton("Start Services", 464, 376, 129, 33) GUICtrlCreateTabItem("") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd ;#ce ;$Tab1 = GUICtrlCreateTab(16, 8, 601, 377) ;$TabSheet1 = GUICtrlCreateTabItem("Running Services") ;$ListView1 = GUICtrlCreateListView("Service Name", 24, 40, 582, 334) ;_GUICtrlListView_SetExtendedListViewStyle($ListView1, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES, $LVS_EX_GRIDLINES)) ;$ServiceName = "wuauserv" Local $Services = ObjGet("winmgmts:\\" & @ComputerName & "\root\cimv2") Local $ServicesList = $Services.ExecQuery("SELECT * FROM Win32_Service") If IsObj($ServicesList) then For $Services in $ServicesList ;If $Services.Name = $ServiceName Then ; if $Services.State = "Running" Then MsgBox(8192,"Hello", $Services.Name & $Services.State,0,$Form1) ;GUICtrlCreateListViewItem( $Services.Name & "|" & $Services.State , $ListView1) ;Run (@ComSpec & " /c " & 'net stop wuauserv') ; EndIf ;EndIf Next EndIf ;EndFunc But the msgbox does turn up when GUI runs. However, if I comment the GUI section, it works perfectly fine. Please help.