Jump to content

Recommended Posts

Posted

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?

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

qq

Posted

; ----------------------------------------------------------------------------
;
; 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.

Posted

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

qq

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

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...