Sign in to follow this  
Followers 0
Googler24022

Button Question

6 posts in this topic

I have a button and i was wandering how i could get a button to do a certain thing, for instance. i have a reboot button, so how would i make it reboot the comp when i press it?


Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Shutdown ( code )

The shutdown code is a combination of the following values:
0 = Logoff
1 = Shutdown
2 = Reboot
4 = Force
8 = Power down
32= Suspend
64= Hibernate

Add the required values together. To shutdown and power down, for example, the code would be 9 (shutdown + power down = 1 + 8 = 9).

Standby or hibernate are ignored if other codes are set. They are also ignored under Win9x.

Straight out the help file, eg Code.

While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    If $msg = $button Then
      Shutdown (6)
   EndIf
Wend
Edited by burrup

[u]Old Projects:[/u]A3MORGB2Hex[u]Old Functions:[/u]_TimeAdd/_TimeSub_AddComma_BubbleSort _RippleSort "He who does not understand your silence will probably not understand your words." - Elbert Hubbard.

Share this post


Link to post
Share on other sites

Thank you, i will try to do this.


Share this post


Link to post
Share on other sites

; ----------------------------------------------------------------------------
;
; AutoIt Version: 3.1.0
; Author:        A.N.Other <myemail@nowhere.com>
;
; Script Function:
;   Template AutoIt script.
;
; ----------------------------------------------------------------------------

; Script Start - Add your code below here

    ProgressOn("", "Loading Program.......", "0 percent")

For $i = 0 to 100 step 1

    sleep(100)

    ProgressSet( $i, $i & " percent")

Next

ProgressSet(100 , "Load Successful", "")

sleep(500)

ProgressOff()

#include <GUIConstants.au3>

GUICreate("Computer Utility", 271, 30) ; will create a dialog box that when displayed is centered

Opt("GUICoordMode",1)

GUICtrlCreateButton ("Shutdown",  1, 1, 90, 30)

GUICtrlCreateButton("Reboot",  91, 1, 90, 30) 

GUICtrlCreateButton("Hibernate",  181, 1, 90, 30) 

GUISetState ()    ; will display an  dialog box with 2 button

; Run the GUI until the dialog is closed

TrayTip("Welcome", "This is my first Program, its a simple computer utility.", 10, 1)

Sleep(5000)

Theres my code, please can you enlighten me on how to finish it.


Share this post


Link to post
Share on other sites

You need to assign your buttons :). Try the following.

BEWARE if you click the reset or shutdown button it will reset lol.

#include <GUIConstants.au3>

ProgressOn("", "Loading Program.......", "0 percent")

For $i = 0 to 99 step 1
    sleep(100)
    ProgressSet( $i, $i & " percent")
   If $i = 100 Then
      ProgressSet(100 , "Load Successful", "")
      sleep(500)
   EndIf
Next

ProgressOff()

GUICreate("Computer Utility", 271, 30)

Opt("GUICoordMode",1)

$Shutdown = GUICtrlCreateButton ("Shutdown",  1, 1, 90, 30)
$Reboot = GUICtrlCreateButton("Reboot",  91, 1, 90, 30) 
$Hibernate = GUICtrlCreateButton("Hibernate",  181, 1, 90, 30) 

GUISetState ()

TrayTip("Welcome", "This is my first Program, its a simple computer utility.", 10, 1)

While 1
   $msg = GUIGetMsg()
   Select 
      Case $msg = $GUI_EVENT_CLOSE 
         ExitLoop
      Case $msg = $Shutdown
         Shutdown(1)
      Case $msg = $Reboot
         Shutdown(2)
      Case $msg = $Hibernate
         Shutdown(64)
   EndSelect
Wend

[u]Old Projects:[/u]A3MORGB2Hex[u]Old Functions:[/u]_TimeAdd/_TimeSub_AddComma_BubbleSort _RippleSort "He who does not understand your silence will probably not understand your words." - Elbert Hubbard.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Thank you so much!

Now that i have done this, is there a function which can be used so when my mouse is over a button it will display the information about it?

Edited by Googler24022

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