Jump to content

Problem with variables


electrico
 Share

Recommended Posts

This is my gui conde. Dont be negative, I am just beginner. So, here it is

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiConstants.au3>
#include <Date.au3>
#include <EditConstants.au3>
#include <Inet.au3>
Local $drive, $mygui, $button1, $button2, $button5, $button4, $drive2, $drive3, $drive4,  $dateis, $button3, $shedit, $label1, $label3, $myip, $button6, $label_a, $label_b
Opt("GuiOnEventMode", 1)
Opt("MustDeclareVars", 1)
GuiCreate ("For You", 220, 230)
    GuiSetState (@SW_SHOW)
    GuiSetOnEvent($GUI_EVENT_CLOSE, "Close")
$label1 = GuiCtrlCreateLabel ("Check free space:", 20, 20)
GuiCtrlSetColor ($label1, 0xcc00cc)
$button1 = GuiCtrlCreateButton ("Drive E:", 20, 50)
GuiCtrlSetOnEvent ($button1, "checkfreespaceone")
$button2 = GuiCtrlCreateButton ("Drive D:", 90, 50)
GuiCtrlSetOnEvent ($button2, "checkfreespaceond")
$button5 = GuiCtrlCreateButton ("Drive C:", 20, 90)
GuiCtrlSetOnEvent ($button5, "checkfreespaceonc")
$button4 = GuiCtrlCreateButton ("Drive F:", 90, 90)
GuiCtrlSetOnEvent ($button4, "checkfreespaceonf")
$myip = _GetIP()
$dateis = _DateAdd ("d", 0, _NowCalcDate())
$label_a = GuiCtrlCreateLabel ("Today's date is:       " & $dateis, 20, 210)
$label_b = GuiCtrlCreateLabel ("Your IP adress is:     " & $myip, 20, 140)
$Label3 = GuiCtrlCreateLabel ("Turn off PC after: ", 20, 170)
$shedit = GuiCtrlCreateEdit ("", 130, 170, 30, 20)
$button3 = GuiCtrlCreateButton ("Set", 170, 170, 30, 20)
GuiCtrlSetOnEvent($button3 , "shutdowncpu")
$button6 = GuiCtrlCreateButton ("TEST SH", 180, 70)
GUICtrlSetOnEvent ($button6, "testnow")
Func testnow()
    MsgBox (0, "Only test", $button4)
EndFunc
Func shutdowncpu()
    $readstate = $shedit
    GuiCtrlSetState ($button1, $GUI_DISABLE)
    GuiCtrlSetState ($button2, $GUI_DISABLE)
    GuiCtrlSetState ($button3, $GUI_DISABLE)
    GuiCtrlSetState ($shedit, $GUI_DISABLE)
    GuiCtrlSetState ($label3, $GUI_DISABLE)
    GuiCtrlSetState ($button5, $GUI_DISABLE)
    GuiCtrlSetState ($button4, $GUI_DISABLE)
    GuiCtrlSetState ($label_a, $GUI_DISABLE)
    GuiCtrlSetState ($label_b, $GUI_DISABLE)
    Sleep (3000)
    GuiSetState (@SW_MINIMIZE)
    MsgBox (64, "Information:", "Computer will be turned off automatically after " & $readstate  & " minutes")
    Sleep ($readstate)
    MsgBox (0, "Test", "Cpu is off now")
EndFunc
Func checkfreespaceone()
    $drive = DriveSpaceFree ("E:\")
If $drive < 1000.0 Then
MsgBox (48, "Free space on drive E:", "There is only " & $drive & " MB free space." & @CRLF & "For normal CPU functioning you should have at least 1 GB free space.")
ElseIf $drive > 1000.0 Then
    MsgBox (64, "Free space on drive E:", "There is " & $drive & " MB free space.")
EndIf
EndFunc
Func checkfreespaceond()
    $drive2 = DriveSpaceFree ("D:\")
MsgBox (64, "Free space on drive D:", "There is " & $drive2 & " MB free space.")
EndFunc
Func Close()
    Exit
EndFunc
Func checkfreespaceonf()
    $drive3 = DriveSpaceFree ("F:\")
MsgBox (64, "Free space on drive F:", "There is " & $drive3 & " MB free space.")
EndFunc
Func checkfreespaceonc()
    $drive4 = DriveSpaceFree ("C:\")
MsgBox (64, "Free space on drive C:", "There is " & $drive4 & " MB free space.")
EndFunc
While 1
    sleep (10)
WEnd

And now please answer me, why when I calling varibale in message box, it shows me that variable $shedit = 11, but variable $button4 = 7 (????) What it is and how to make to read GuiCtrlCreateEdit as number and display written number in message box???

Link to comment
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
 Share

  • Recently Browsing   0 members

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