MattyGibbard Posted January 20, 2009 Posted January 20, 2009 Hey everyone, I'm new to Autoit so bare with me a second. I have created a few simple programs but nothing overly amazing. One problem I keep coming across is setting Autoit to wait. I know there is a sleep function such as: "Sleep (1000)" but this pauses the whole script for that period of time so the user cannot exit or press another button. Is there a way to wait instead of sleep? Example: Let's say when I press a button, a picture shows. Easy huh? The picture only stays up for 5 seconds, and then vanishes again. So far so good. The only problem is, if I use 'Sleep' then the whole program will freeze for five seconds. Can anyone help? Thank you.
KaFu Posted January 20, 2009 Posted January 20, 2009 Maybe something like this? while winexists() sleep(20) wend ; or while processexists() sleep(20) wend OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16)
Bam Posted January 20, 2009 Posted January 20, 2009 (edited) maybe like a counter like $Count = 0 While $Count < 50 $Count += 1 Sleep(100) WEnd MsgBox(1, "Done", "sleept for 5 seconds") giving you a count of 50 after 5 seconds maybe (but might be longer then 5 seconds) Edited January 20, 2009 by Bam
SpookMeister Posted January 20, 2009 Posted January 20, 2009 Another way to do it is to use _Timer_Init() and _Timer_Diff() [u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]
MrCreatoR Posted January 20, 2009 Posted January 20, 2009 ....I know there is a sleep function such as:"Sleep (1000)"but this pauses the whole script for that period of time so the user cannot exit or press another button. Is there a way to wait instead of sleep?Example:Let's say when I press a button, a picture shows. Easy huh? The picture only stays up for 5 seconds, and then vanishes again. So far so good. The only problem is, if I use 'Sleep' then the whole program will freeze for five seconds.....What you need to wait for?P.SUsing timers or loops it's the same as Sleep(), unless you need to do something inside those loops/timer functions. Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team
FireFox Posted January 20, 2009 Posted January 20, 2009 @MrCreator not really... While 1 Sleep(2000) ;sleeping.... MsgBox(64, 'Timer', '2sec !') WEndoÝ÷ Ù«¢+ØÀÌØí¥¹¥ÐôQ¥µÉ%¹¥Ð ¤)]¡¥±Ä(ÀÌØí¥ôQ¥µÉ¥ ÀÌØí¥¹¥Ð¤)%ÀÌØí¥ÐìôÈÀÀÀÑ¡¸)5Í ½à ØÐ°ÌäíQ¥µÈÌäì°ÌäìÉÍÌÌìÌäì¤(ÀÌØí¥¹¥ÐôQ¥µÉ%¹¥Ð ¤)¹%)QÉåQ¥À ÌäíMÉ¥ÁÐÌäì°ÌäíÍÉ¥ÁÐ¥ÌÉÕ¹¹¥¹ÌÌìÌäì°Ä°Ä¤)]¹ Cheers, FireFox.
MrCreatoR Posted January 20, 2009 Posted January 20, 2009 not really...Not really what? You just showed what i said. Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team
FireFox Posted January 21, 2009 Posted January 21, 2009 (edited) @MrCreator ops missunderstood what you said Cheers, FireFox. Edited January 21, 2009 by FireFox
MattyGibbard Posted January 22, 2009 Author Posted January 22, 2009 Thanks everyone for the info. I'm still having trouble getting it into my code. Here is an example of what I'm doing: -I have a GUI, a button and an image -The image is of me -I want to be able to change that image every 5 seconds to a blink and back again (Really fast) -In the meantime, I still want my GUI to respond to the button press. Thank you for any more help.
BrettF Posted January 22, 2009 Posted January 22, 2009 (edited) $GUI = GUICreate ("Sample GUI", 200, 200) $pic = GUICtrlCreatePic ("open.jpg", 10, 10, 180, 180) GUISetState () $blink = False $timer = TimerInit () While 1 $nMsg = GUIGetMsg () Switch $nMsg Case - 3 Exit EndSwitch If TimerDiff($timer) >= 5000 Then;5 Seconds $timer = TimerInit() $blink = True ;Switch image GUICtrlSetImage ($pic, "close.jpg") ElseIf ($blink = True) And (TimerDiff($timer) >= 100) Then ;Switch Image Back GUICtrlSetImage ($pic, "open.jpg") $blink = False EndIf WEndMaybe like that? (Untested)EDIT:Changed example.You need the following images:I'm fairly happy with how this works too Open.JPGClose.JPG Edited January 22, 2009 by BrettF Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version!
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now