Jump to content

Recommended Posts

Posted

I had to comment out some lines but I hope you get the message:

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Timers.au3>

$Windows = GUICreate("Windows 7™ Setup", 501, 401, -1, -1)
;GUISetIcon("X:\Setup.exe")
GUISetBkColor(0x808080)
$Install = GUICtrlCreateButton("Install Windows 7™ Unattended", 112, 8, 281, 33, 0)
GUICtrlSetTip(-1, "Start Windows 7™ Setup")
$win7custom = GUICtrlCreateButton("Install Windows 7 ( without any customization )", 112, 64, 281, 33, 0)
GUICtrlSetTip(-1, "Install Windows 7 like your normal windows 7 installation, no customization, no automation. Completely untouched os with latest updates!")
$Recovery = GUICtrlCreateButton("Windows Recovery Wizard ( Recovery Environment )", 112, 117, 281, 33, 0)
GUICtrlSetTip(-1, "Recovery wizard ")
$Command = GUICtrlCreateButton("Command Window", 23, 199, 177, 33, 0)
$taskmanager = GUICtrlCreateButton("Task Manager", 296, 200, 177, 33, 0)
$processxp = GUICtrlCreateButton("Process Explorer", 24, 256, 177, 33, 0)
$Processmon = GUICtrlCreateButton("Process Monitor", 296, 256, 177, 33, 0)
$netservice = GUICtrlCreateButton("Start Network Services", 24, 312, 177, 33, 0)
$notepad = GUICtrlCreateButton("Notepad", 296, 312, 177, 33, 0)
$Label2 = GUICtrlCreateLabel("", 370, 370, 130, 50)
;$Pic1 = GUICtrlCreatePic("X:\Windows\System32\setupback.jpg", 0, 0, 500, 400, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    GUICtrlSetData($Label2, "Seconds left: " & Int((30000 - _Timer_GetIdleTime()) / 1000))
    If _Timer_GetIdleTime() > 30000 Then
        ;run ("C:\Windows\System32\taskmgr.exe")
        MsgBox(0, "Test", "Run")
    EndIf
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Install
            ;Run ("X:\windows\system32\boot\en-us\startsetup.cmd" )
        Case $win7custom
            ;Run ("X:\windows\system32\boot\en-us\startsetupnormal.cmd" )
        Case $Recovery
            ;Run ("X:\sources\recovery\RecEnv.exe" )
        Case $Command
            ;Run ("X:\Windows\System32\cmd.exe" )
        Case $taskmanager
            ;Run ("X:\Windows\System32\taskmgr.exe" )
        Case $processxp
            ;Run ("X:\Windows\System32\procexp.exe" )
        Case $Processmon
            ;Run ("X:\Windows\System32\Procmon.exe" )
        Case $netservice
            ;Run ("X:\Windows\System32\net.exe start" )
        Case $notepad
            ;Run ("X:\Windows\System32\notepad.exe" )
    EndSwitch
WEnd

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted

#Include <GUIConstantsEx.au3>
#Include <StaticConstants.au3>
#Include <Timers.au3>

GUICreate('MyGUI', 400, 400)
$Label = GUICtrlCreateLabel('30 sec', 340, 380, 50, 14, $SS_RIGHT)
GUISetState()

Global $Msg, $Label, $Time = 0, $Prev = 0

While 1
    $Time = 30 - Int(_Timer_GetIdleTime() / 1000)
    If $Time <> $Prev Then
        GUICtrlSetData($Label, $Time & ' sec')
        $Prev = $Time
    EndIf
    If $Time <= 0 Then
        MouseMove(MouseGetPos(0), MouseGetPos(1), 0)
        Run(@WindowsDir & '\Notepad.exe')
    EndIf
    $Msg = GUIGetMsg()
    Switch $Msg
        Case $GUI_EVENT_CLOSE
            ExitLoop
    EndSwitch
WEnd

Posted

Thanks @Water and Yashied, both of your scripts work fine :D.

But now I realize another problem! It keeps setting timer back to 30 and begin countdown each time I left PC idle for a sec!

What I want is that once this timer loop should be end if user interacts with PC! I mean no countdown once there is some activity on PC.

Is this can be done by using following,

considering Yashied's script,

If $Time = 0 then

<end timer loop>

<hide label>

which command can end this loop and to hide lebel I dont know, is above idea correct for what I m asking?

Posted (edited)

I got it working!!

While 1

$Time = 5 - Int(_Timer_GetIdleTime() / 1000)

If $Time <> $Prev Then

GUICtrlSetData($Label, $Time & ' sec')

$Prev = $Time

EndIf

if _Timer_GetIdleTime() = 0 Then

GUICtrlSetState ( $Label, $GUI_HIDE )

ExitLoop

EndIf

If $Time <= 0 Then

Run ("X:\windows\system32\boot\en-us\startsetup.cmd" )

GUICtrlSetState ( $Label, $GUI_HIDE )

ExitLoop

EndIf

$Msg = GUIGetMsg()

Switch $Msg

Case $GUI_EVENT_CLOSE

ExitLoop

EndSwitch

WEnd

above worked fine :D.

Edited by AmitPatel

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
×
×
  • Create New...