Jump to content

Recommended Posts

  • Moderators
Posted (edited)

How can i use a delay for a long peroid of time and be able to close it, but have the delay work still and the following command?

Close what? ... Follow what?

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Posted

okay if you try the script some commands give the option for "delays" if you delay the script it will wait until that time is up to let's say make a msg box. If i click X on the program the command will stop. I want to be able to click X and have the "delay" still run.

[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

  • Moderators
Posted (edited)

If I understand you correctly... then why don't you just do an 'If / Then' statement?

After the $wait = InputBox() you could do:

Dim $DefaultDelay = 1
$wait = InputBox("Delay", "Enter the delay for the action 1000 = 1 second", 0)
If Not $wait <> '' Or StringIsDigit($wait) <> 1 Then $wait = $DefaultDelay

Added: StringIsDigit() as a failsafe in case someone tries to type alpha characters it will go to defaultdelay.

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Posted

thanks that did help but here i'll try to exaplain the best i can.

If you open the program

and select certain things

it asks for a action delay (Sleep $var)

let's say we gave the$var 20000

it will wait 20 seconds before it does the action

but you can't close the program before that 20000 is done or the system will shutdown (the program, not the computer)

because it makes a action que i belive it's called like processes on the computer, what ever is clicked first is done first.

I may of figured out a way to fix this, but it's not very efficient. in the code below.

#NoTrayIcon
#include <GuiConstants.au3>
$bLoop = 1
While $bLoop = 1
    $text = InputBox("Password", "Please type in the correct password...","","*")
    If @error = 1 Then
        Exit
    Else
    ; They clicked OK, but did they type the right thing?
        If $text <> "example" Then
            MsgBox(4096, "Error", "Wrong password try again...")
        Else
            $bLoop = 0; Exit the loop - ExitLoop would have been an alternative too :)
        EndIf
    EndIf
WEnd

; Print the success message
MsgBox(4096,"Password", "Password Accepted")

; Finished!


; Script generated by AutoBuilder 0.5 Prototype


;If Not IsDeclared('WS_CLIPSIBLINGS') Then Global $WS_CLIPSIBLINGS = 0x04000000

GuiCreate(" ", 200, 300,(@DesktopWidth-392)/2, (@DesktopHeight-316)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)

$pic = GUICtrlCreatePic("syc.bmp", 120, 60, 100, 225)
$m_s = GuiCtrlCreateButton("MsgBox", 10, 70, 80, 20)
$Button_1 = GuiCtrlCreateButton("File Tree", 10, 50, 60, 20)
$Exit = GuiCtrlCreateButton("Exit", 10, 10, 50, 20)
$cp = GUICtrlCreateButton("Open C prompt", 10, 30, 80, 20)
$internet = GUICtrlCreateButton("Run IE", 10, 90, 50, 20)
$notepad = GUICtrlCreateButton("Run Notepad", 10, 110, 90, 20)
$Print = GUICtrlCreateButton("Print", 10, 130, 50, 20)
$task = GUICtrlCreateButton("Open task manager", 10, 150, 100, 20)
$nac = GUICtrlCreateButton("Find Admin", 10, 170, 90, 20)
$mf = GUICtrlCreateButton("Set Time", 10, 190, 90, 20)
$np = GUICtrlCreateButton("New Process", 10, 210, 90, 20)
$Dic = GUICtrlCreateButton("Search", 10, 230, 90, 20)
GuiSetState()
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $msg = $Button_1
        $Path = FileSelectFolder("Choose a folder.", "")
        Run('Explorer.exe "' & $Path & '"', @WorkingDir, @SW_SHOW)
    Case $msg = $m_s
$number = InputBox("MsgBox", "Enter number of times to open msn box -1 = infinate it will auto add 1")
$answer = InputBox("MsgBox","What do you want the message box to say?","","",-1,-1,0,0) 
Dim $DefaultDelay = 1
$wait = InputBox("Delay", "Enter the delay for the action 1000 = 1 second", 0)
If Not $wait <> '' Or StringIsDigit($wait) <> 1 Then $wait = $DefaultDelay
$box_intrvals = InputBox("Timeout", "Enter the timeout for each box for the action 1000 = 1 second", 0)
    Sleep($wait)
    For $msgb1 = 0 to $number
        MsgBox(0, "", $answer, $box_intrvals)
;sleep(1000)
        Next 
 ; Case $msg = $Button_6
   ;   $m_s = 1
    Case $msg = $Exit
$wait_exit = InputBox("Delay", "Enter the delay for the action 1000 = 1 second", 0)
    Sleep($wait_exit)
    GUIDelete(" ")
;   WinClose(" ")
   ;this is better
;       ExitLoop
    Case $msg = $cp
      ;Run(@HomeDrive & "\WINDOWS\system32\command.com")
   ;i suggest you do this for the command prompt
        Run("cmd.exe")
    Case $msg = $internet
        Run("C:\Program Files\Internet Explorer\IEXPLORE.EXE")
    Case $msg = $notepad
        Run("notepad.exe")
    Case $msg = $Print
        Sleep(700)
$number2 = InputBox("Print", "Enter number of sheets to print...", 0)
Dim $DefaultDelay2 = 1
$wait = InputBox("Delay", "Enter the delay for the action 1000 = 1 second", 0)
If Not $wait <> '' Or StringIsDigit($wait) <> 1 Then $wait = $DefaultDelay
        Sleep($wait2)
        Run("notepad.exe")
        WinActivate("untitled")
        Send("^p")
        Send("!c")
        Send($number2)
        Send("{ENTER}")
    Case $msg = $task
        Run("taskmgr.exe")
    Case $msg = $nac
        If IsAdmin() Then MsgBox(0, "", "Admin rights detected")
    Case $msg = $mf
        Run("rundll32.exe")
    Case $msg = $np
$process = InputBox("New Process", "Enter new process in .exe format")
Dim $DefaultDelay3 = 1
$wait = InputBox("Delay", "Enter the delay for the action 1000 = 1 second", 0)
If Not $wait <> '' Or StringIsDigit($wait) <> 1 Then $wait = $DefaultDelay
$number3 = InputBox("Program", "Enter number of times to open program -1 = infinate it will auto add 1")
    Sleep($wait3)
    For $pro = 0 to $number3
        Run($process)
;Sleep(500)
        Next
    Case $msg = $Dic
$lkiu = InputBox("Search --BETA!--", "Enter word to search.")
        Run("C:\Program Files\Internet Explorer\IEXPLORE.EXE")
        ProcessWait("IEXPLORE.exe", 5)
        Send($lkiu)
        Send("{ENTER}")
EndSelect
WEnd

;now the the loop has been left because someone clicked exit, the program will now exit
Exit

EDIT: I may of figured it out i'll eidt this post with results.

[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

  • Moderators
Posted

Cool... Can you narrow down your specific problem in the code... I've been up all night and it all runs together for me... If not.. I'm sure one of the other guys will help if you still need it.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

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