Sign in to follow this  
Followers 0
dreamzboy

Help with Checkboxes Movement

4 posts in this topic

I have 2 phases to this.

Phase I - Stopping Windows Services. Checkbox will check off all the services that has been stopped from top to bottom.

Phase II - Starting Windows Services. I prefer the Checkbox to check off all the services that has been started from top to bottom (in the correct order), instead it checked from bottom to top.

See script below and further explanation.

#include <GuiConstants.au3>

Opt("TrayIconDebug", 1)
Opt("GUIOnEventMode", 1)

GUICreate ("Service Management", 310, 200, -1, -1)
GUISetOnEvent ($GUI_EVENT_CLOSE, "Exit_Program")

Global $CheckBoxes[5] = ["Checkbox 1", "Checkbox 2", "Checkbox 3", "[/color][/color][color="#ff0000"][color="#0000ff"]Checkbox 4[/color][/color][color="#ff0000"][color="#0000ff"]", "[/color][/color][color="#ff0000"][color="#0000ff"]Checkbox 5[/color][/color][color="#ff0000"][color="#0000ff"]"]
$CheckBoxes[0] = GUICtrlCreateCheckbox($CheckBoxes[0], 55, 44, 120, 20)
$CheckBoxes[1] = GUICtrlCreateCheckbox($CheckBoxes[1], 55, 74, 100, 20)
$CheckBoxes[2] = GUICtrlCreateCheckbox($CheckBoxes[2], 55, 104, 140, 20)
$CheckBoxes[3] = GUICtrlCreateCheckbox($CheckBoxes[3], 55, 134, 120, 20)
$CheckBoxes[4] = GUICtrlCreateCheckbox($CheckBoxes[4], 55, 164, 200, 20)

GUISetState (@SW_SHOW)

$Heading_Name = "Service is Stopping ..."
$tnr_Bold = "Times New Roman Bold"
$Heading = GUICtrlCreateLabel($Heading_Name, 0, 14, 310, 20, $SS_CENTER)
GUICtrlSetFont ($Heading, 11, 400, 0, $tnr_Bold)
GUICtrlSetColor($Heading, 0xff0000)

Sleep (2000)

For $i = 0 To 4 Step 1     
    GUICtrlSetState ($CheckBoxes[$i], $GUI_INDETERMINATE)
    GUICtrlSetState ($CheckBoxes[$i], $GUI_DISABLE)
    Sleep (1000)
Next
    MsgBox (0, "", "Services has stopped successfully", 2)

For $i = 0 To 4 Step 1
    GUICtrlSetState ($CheckBoxes[$i], $GUI_UNCHECKED)
    GUICtrlSetState ($CheckBoxes[$i], $GUI_ENABLE)
Next

$Heading_Name = "Service is Starting ..."
$Heading = GUICtrlCreateLabel($Heading_Name, 0, 14, 315, 20, $SS_CENTER)
GUICtrlSetFont ($Heading, 11, 400, 0, $tnr_Bold)
GUICtrlSetColor($Heading, 0x0000ff)

For $i = 0 To 4 Step 1
    GUICtrlSetState ($CheckBoxes[4-$i], $GUI_INDETERMINATE)
    GUICtrlSetState ($CheckBoxes[4-$i], $GUI_DISABLE)
    Sleep (1000)
Next
    MsgBox (0, "", "Services has started successfully", 2)

Func Exit_Program()
    Exit
EndFunc

In more detail, I prefer Checkbox 5 to be at the top of the list and then Checkbox 4 and so forth... when Starting Services. And of course the check would have to match with the services that it is starting. Just like how the Stopping Services work.

I do know one way is to create another list of Checkboxes in the Starting Service order that I wanted but that is inefficient since the Stopping Services Array is already made. Is there a way we can do this without creating unnecessary array?

Thank you all for the help! :)

Share this post


Link to post
Share on other sites



This is not good, so no one knows...?? :)

Share this post


Link to post
Share on other sites

Like this?

#include <GuiConstants.au3>

Opt("TrayIconDebug", 1)
Opt("GUIOnEventMode", 1)

GUICreate ("Service Management", 310, 200, -1, -1)
GUISetOnEvent ($GUI_EVENT_CLOSE, "Exit_Program")

Global $CheckBoxes[5] = ["Checkbox 1", "Checkbox 2", "Checkbox 3", "Checkbox 4", "Checkbox 5"]
$CheckBoxes[0] = GUICtrlCreateCheckbox($CheckBoxes[0], 55, 44, 120, 20)
$CheckBoxes[1] = GUICtrlCreateCheckbox($CheckBoxes[1], 55, 74, 100, 20)
$CheckBoxes[2] = GUICtrlCreateCheckbox($CheckBoxes[2], 55, 104, 140, 20)
$CheckBoxes[3] = GUICtrlCreateCheckbox($CheckBoxes[3], 55, 134, 120, 20)
$CheckBoxes[4] = GUICtrlCreateCheckbox($CheckBoxes[4], 55, 164, 200, 20)

GUISetState (@SW_SHOW)

$Heading_Name = "Service is Stopping ..."
$tnr_Bold = "Times New Roman Bold"
$Heading = GUICtrlCreateLabel($Heading_Name, 0, 14, 310, 20, $SS_CENTER)
GUICtrlSetFont ($Heading, 11, 400, 0, $tnr_Bold)
GUICtrlSetColor($Heading, 0xff0000)

Sleep (2000)

For $i = 0 To 4    
    GUICtrlSetState ($CheckBoxes[$i], $GUI_INDETERMINATE)
    GUICtrlSetState ($CheckBoxes[$i], $GUI_DISABLE)
    Sleep (1000)
Next
    MsgBox (0, "", "Services has stopped successfully", 2)

For $i = 0 To 4
    GUICtrlSetState ($CheckBoxes[$i], $GUI_UNCHECKED)
    GUICtrlSetState ($CheckBoxes[$i], $GUI_ENABLE)
Next

$Heading_Name = "Service is Starting ..."
$Heading = GUICtrlCreateLabel($Heading_Name, 0, 14, 315, 20, $SS_CENTER)
GUICtrlSetFont ($Heading, 11, 400, 0, $tnr_Bold)
GUICtrlSetColor($Heading, 0x0000ff)

;Re-align checkboxes
$x = 0
For $i = 164 to 44 step -30
    GUICtrlSetPos($CheckBoxes[$x],55,$i)
    $x += 1
Next

For $i = 4 to 0 step -1
    GUICtrlSetState ($CheckBoxes[$i], $GUI_INDETERMINATE)
    GUICtrlSetState ($CheckBoxes[$i], $GUI_DISABLE)
    Sleep (1000)
Next
    MsgBox (0, "", "Services has started successfully", 2)

Func Exit_Program()
    Exit
EndFunc

Share this post


Link to post
Share on other sites

Like this?

#include <GuiConstants.au3>

Opt("TrayIconDebug", 1)
Opt("GUIOnEventMode", 1)

GUICreate ("Service Management", 310, 200, -1, -1)
GUISetOnEvent ($GUI_EVENT_CLOSE, "Exit_Program")

Global $CheckBoxes[5] = ["Checkbox 1", "Checkbox 2", "Checkbox 3", "Checkbox 4", "Checkbox 5"]
$CheckBoxes[0] = GUICtrlCreateCheckbox($CheckBoxes[0], 55, 44, 120, 20)
$CheckBoxes[1] = GUICtrlCreateCheckbox($CheckBoxes[1], 55, 74, 100, 20)
$CheckBoxes[2] = GUICtrlCreateCheckbox($CheckBoxes[2], 55, 104, 140, 20)
$CheckBoxes[3] = GUICtrlCreateCheckbox($CheckBoxes[3], 55, 134, 120, 20)
$CheckBoxes[4] = GUICtrlCreateCheckbox($CheckBoxes[4], 55, 164, 200, 20)

GUISetState (@SW_SHOW)

$Heading_Name = "Service is Stopping ..."
$tnr_Bold = "Times New Roman Bold"
$Heading = GUICtrlCreateLabel($Heading_Name, 0, 14, 310, 20, $SS_CENTER)
GUICtrlSetFont ($Heading, 11, 400, 0, $tnr_Bold)
GUICtrlSetColor($Heading, 0xff0000)

Sleep (2000)

For $i = 0 To 4    
    GUICtrlSetState ($CheckBoxes[$i], $GUI_INDETERMINATE)
    GUICtrlSetState ($CheckBoxes[$i], $GUI_DISABLE)
    Sleep (1000)
Next
    MsgBox (0, "", "Services has stopped successfully", 2)

For $i = 0 To 4
    GUICtrlSetState ($CheckBoxes[$i], $GUI_UNCHECKED)
    GUICtrlSetState ($CheckBoxes[$i], $GUI_ENABLE)
Next

$Heading_Name = "Service is Starting ..."
$Heading = GUICtrlCreateLabel($Heading_Name, 0, 14, 315, 20, $SS_CENTER)
GUICtrlSetFont ($Heading, 11, 400, 0, $tnr_Bold)
GUICtrlSetColor($Heading, 0x0000ff)

;Re-align checkboxes
$x = 0
For $i = 164 to 44 step -30
    GUICtrlSetPos($CheckBoxes[$x],55,$i)
    $x += 1
Next

For $i = 4 to 0 step -1
    GUICtrlSetState ($CheckBoxes[$i], $GUI_INDETERMINATE)
    GUICtrlSetState ($CheckBoxes[$i], $GUI_DISABLE)
    Sleep (1000)
Next
    MsgBox (0, "", "Services has started successfully", 2)

Func Exit_Program()
    Exit
EndFunc
Thanks Covaks, I learned something new today. Simple but very clever. I like how you did it. :)

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
Sign in to follow this  
Followers 0