Jump to content

Search the Community

Showing results for tags 'winwait'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office


  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start



Member Title




Found 14 results

  1. Hello, I am trying to learn how this works. I want to be able to interrupt a running function with winwait.. In this example I want to start notepad and than the script needs to winwait for a specific window. But if that window does not appear then I want the user to be able to interrupt the function and start the next function (run nextprogram.exe") I found some examples and mentioned winwait, but I still could not make it work. I tried to adjust the tutorial https://www.autoitscript.com/wiki/Interrupting_a_running_function , but could not get this working either with a winwait I hope someone can put me in the right direction. Code below is just one of my many attempts... #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> AutoItSetOption("TrayIconDebug", 1) ;0-off ;AutoIt3Wrapper_Run_Debug_Mode=Y ; Set a HotKey HotKeySet("x", "_Interrupt") ; Declare a flag $fInterrupt = 0 $hGUI = GUICreate("Test", 500, 500) $hButton_1 = GUICtrlCreateButton("Func One", 10, 10, 80, 30) $hButton_2 = GUICtrlCreateButton("Func Two", 10, 50, 80, 30) ; Create a dummy control for the Accelerator to action when pressed $hAccelInterupt = GUICtrlCreateDummy() ; Set an Accelerator key to action the dummy control Dim $AccelKeys[1][2]=[ ["z", $hAccelInterupt] ] GUISetAccelerators($AccelKeys) GUISetState() ; Intercept Windows command messages with out own handler GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $hButton_1 _Func_1() _Func_3() Case $hButton_2 _Func_2() EndSwitch WEnd ; Use a wrapper function in place of the blocking function Func _Func_1() ; Make sure the flag is cleared $fInterrupt = 0 ;For $i = 1 To 20 run ("notepad") ConsoleWrite("-Func 1 Running" & @CRLF) ; Run a modified Sleep function which checks for the interrupt ;if _Interrupt_Sleep(1000) Then ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< if _Interrupt_Sleep(999999999999999999999999999999999) Then ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ; The flag was set Switch $fInterrupt Case 1 ConsoleWrite("!Func 1 interrrupted by Func 2" & @CRLF) Case 2 ConsoleWrite("!Func 1 interrrupted by HotKey" & @CRLF) Case 3 ConsoleWrite("!Func 1 interrrupted by Accelerator" & @CRLF) EndSwitch Return EndIf Sleep(100) ; Next ConsoleWrite(">Func 1 Ended" & @CRLF) EndFunc ;==>_Func_1 ; And here is the wrapper function itself Func _Interrupt_Sleep($iDelay) ; Get a timestamp Local $iBegin = TimerInit() ; And run a tight loop Do ; Use a minimum Sleep (could also be a WinWaitActive with a short timeout) ;Sleep(10) winwait("sdfdf","sdfsdf") ;<<<<<<----- the winwait for a window I want to skip ; Look for the interrrupt If $fInterrupt Then ; And return True immediately if set Return True EndIf Until TimerDiff($iBegin) > $iDelay ; Return False if timed out and no interrupt was set Return False EndFunc ;==>_Interrupt_Sleep Func _Func_2() ;For $i = 1 To 3 processclose("notepad.exe") ConsoleWrite("+Func 2 Running" & @CRLF) Sleep(100) ;Next ConsoleWrite(">Notepad killed!" & @CRLF) EndFunc Func _Func_3() run("nextprogam.exe") Endfunc Func _Interrupt() ; The HotKey was pressed so set the flag $fInterrupt = 2 EndFunc Func _WM_COMMAND($hWnd, $Msg, $wParam, $lParam) ; The Func 2 button was pressed so set the flag If BitAND($wParam, 0x0000FFFF) = $hButton_2 Then $fInterrupt = 1 ; The dummy control was actioned by the Accelerator key so set the flag If BitAND($wParam, 0x0000FFFF) = $hAccelInterupt Then $fInterrupt = 3 Return $GUI_RUNDEFMSG EndFunc ;==>_WM_COMMAND
  2. Hello, I'm having a problem whit winwait on firefoxscreens whit the same title and text. On mine quest on this forum and internet I've found some work around and solutions. unfortunaly This wasn't working for me. I've tried searching tru winlist or finding some unique text but wasn't finding any solution. Does anyone know how to get the wright handle? I just want to move the browser to the right place in the end whit WinMove. thnx in advanced. #include <Array.au3> Global $A_URL[4][2] = _ [["url1" , "same_title"] , _ ["url2", "same_title"] , _ ["url3" , "other_title" ] , _ ["url4" , "other_title" ]] ;~ _ArrayDisplay($A_URL) ;-----kill all firefox.exe ;~ Run("taskkill /IM firefox.exe /F", "", @SW_HIDE) ;Sleep(5000) For $i = 0 To 1 ConsoleWrite("running 1 : " & $i & @CRLF) Local $ID = ShellExecute("firefox.exe", "-new-window " & $A_URL[$i][0] ,"C:\Program Files\Mozilla Firefox" ) ConsoleWrite("$ID = " & $ID & @CRLF) Next sleep(200) ;~ Local $screen1HWND = WinWait($A_URL[0][1],"") ;~ If Not WinActive($screen1HWND) Then WinActivate($screen1HWND) ;~ ConsoleWrite("$screen1HWND = " & $screen1HWND & @CRLF) ;~ Local $screen2HWND = WinWait($A_URL[1][1],"") ;~ If Not WinActive($screen2HWND) Then WinActivate($screen2HWND) ;~ ConsoleWrite("$screen2HWND = " & $screen2HWND & @CRLF) $sWinTitle = $A_URL[0][1] $avWinList = WinList($sWinTitle) For $n = 1 to $avWinList[0][0] ConsoleWrite("Window " & $n & ": Text: " & WinGetText($avWinList[$n][1]) & @LF) Next For $i = 0 To 1 ;~ WinWait("title1", "", 10) ;~ WinActive("title1", "") ;~ WinMove ("title1", "", $i , $i ) Next
  3. OK, after days looking at my code, the help file and forums I come (again) for help on message windows. I'm having trouble trying to close window messages that appear. This is the code I'm using #include <MsgBoxConstants.au3> Local $obs_handler = 0 Opt("WinTitleMatchMode",2) While 1 $obs_handler = WinWait("C:\Users\", "", 1) If IsHWnd($obs_handler) then MsgBox($MB_OK, "Message", "handler: "&$obs_handler, 1) ;Sleep(100) $obs_handler = HWND($obs_handler) WinKill($obs_handler, "") ;<<<<< PROBLEM!!!!! Else MsgBox($MB_OK, "Message", "No handler", 1) EndIf Send("{ESC}") Sleep(2000) $obs_handler = 0 WEnd The problem is on the Winkill command, it won't just close the window! Winwait is capturing the handler, it checks as handler. Ii'm using the HWND() command just to be sure it is the correct variable type. I've also checked the message box info with the autoit window info tool and the handle value matches the one captured by the code. I've tried winkill, winclose, using wingethandle, moving the winkill command to Before the message box so it is not converted to a string, and now using the hwnd function to force the variable type of the handler. The use of the sleep command does not make any diference. As a side quest, I'd like to use classes to capture the windows instead of titles, just to keep things cleaner, but using the [CLASS:...] value for winwait is not working. I have the class name and number, am I missing something? Thanks!
  4. if ControlClick("[CLASS:MsiDialogCloseClass]"," ","[CLASS:SysTreeView32; INSTANCE:1]") Then $htreeview=ControlGetHandle($hwnd,"","[CLASS:SysTreeView32; INSTANCE:1]") ControlTreeView($hwnd," ",$htreeview,"Select","#4") The above code worked well to enable the martupgrade feature on windows 7. As part of our Installation Testing Automation before delivering the installer to end user.To confirm whether all the screens are working good. But it is not working on windows 10. $h= ControlTreeView($hwnd," ",$htreeview,"Select","#4") The $h is getting value 1,which means error.
  5. I have automated an install process by using the below code. Func _WinWaitActivate($title,$text,$timeout=0) WinWait($title,$text,$timeout) If Not WinActive($title,$text) Then WinActivate($title,$text) WinWaitActive($title,$text,$timeout) EndFunc $win1 = "Text 1" $win2 = "Text 2" _WinWaitActivate($win1,"WARNING: This progra") Send("{ALTDOWN}n{ALTUP}");Send("{SPACE}") _WinWaitActivate($win1,"I DISAGREE and &do n") Send("{UP}n") _WinWaitActivate($win1,"Customer Information") Send("{ALTDOWN}n{ALTUP}");Send("{TAB}{TAB}n") _WinWaitActivate($win1,"Click Next to instal") Send("{ALTDOWN}n{ALTUP}");Send("n") _WinWaitActivate($win1,"This feature require") Send("{ALTDOWN}n{ALTUP}");Send("{TAB}n") _WinWaitActivate($win1,"Ready to Install the") Send("{ALTDOWN}i{ALTUP}");Send("i") _WinWaitActivate($win1,"The InstallShield Wi") Send("{ALTDOWN}f{ALTUP}");Send("f") _WinWaitActivate($win2,"You must restart you") Send("{ALTDOWN}n{ALTUP}");Send("n") Now if any new screen comes in the middle of installation, like some VC++ installation error or like that. The AutoIT is waiting in the background. Is there any way to skip the new screens with just "enter" and continue the installation??
  6. Hello All! Longtime user of AutoIt - LOVE the language. Right now I'm running into a bit of an issue and I need some help. I'm attempting to automate some processes in an open-source 3D model software called meshlab (http://meshlab.sourceforge.net/) - It's quite processor intensive. Though I've run into an issue where my work computer is MUCH faster than my home computer. When I execute WinWait("MeshLab") it won't wait, nor will it wait when I run one of the 'filters' - Filters > Remeshing > Surface Reconstruction: VCG - WinWait("Surface Reconstruction: VCG") I found something called "ProcessWait" in the helpfile (never had to use it before) - but when I run ProcessWait("meshlab.exe") - it doesn't work! Is there an alternative method to check/poll the system ever X milliseconds to determine if the process is finished executing? Some of these filters I run on my CAD models can take minutes to execute, and it varies drastically from computer to computer. Here's what I'm making - I take my 3D models, and run them through a bunch of filters to create this effect, called a "Voronoi Tessellation"
  7. I have a small exe I created in AutoIt that seems to be causing some problems in OutLook when people go to save a PDF or Reply to emails. Here is my code. TraySetState(2) WinWait("[CLASS:#32770]", "Make sure that your sign-in address, user name, and password are correct and try again.", 0) WinClose( "Lync") So this works just fine, it closes these message prompts we are trying to suppress. But if the autoit executable is running when someone is using Outlook and they go to Save as PDF. When they click "Save As" and go to type in the name of the file to save, they can't type in the box. So if they close the autoit executable that's running only the code above, then they can use type in the name of the file. So we know the EXE is preventing users from saving documents. Now, I'm sure it could be the way I've written this code, but I'm new to AutoIt and I'm not sure what could be causing this. This little script seems like it' targeting the correct CLASS # and Window TItle and exact message. So I don't understand why it's interfering with other applications. Any ideas?
  8. Hi. i googled and searched a lot before posting this. thanks for any help. I need to locate a window that has no title or discernible text, BUT is always the same size. The autoit documentation says: "X \ Y \ W \ H - The position and size of a window One or more properties are used in the title parameter of a window command in the format: [PROPERTY1 : Value1; PROPERTY2:Value2]" However, i can't figure out exactly how to do that. i tried: Local $winAW = WinWait("[W:506;H:288]", "", 30); That didn't work. I couldn't find an example of the specific format I need to use. Can someone provide a proven working example? Maybe that example can be added to the documentation? Thanks!
  9. I'm looking possible ways to optimize sleep time in a script which has multiple sleep times for save, refresh etc. The sleep duration varies from 5 secs to 17 secs time to time (depending upon the record, computer performance etc). Currently I set max sleep duration. ie sleep(17000). I'm looking possible ways to dynamically change sleep duration rather than fixed maximum duration. Note: winwait is not helpful in my script. Thanks in advance for your responses
  10. I basically want to create a Windows 8 Training script for new users, so need a popup to show when they open the start menu. WinWait and WinWaitActive are never detecting on my Win8 64 bit computer when waiting for the new start screen window. I have used "Start menu" and "[CLASS:ImmersiveLauncher]" for the title, even "[CLASS:DirectUIHWND]" Below is the Window info the the Start Screen >>>> Window <<<< Title: Start menu Class: ImmersiveLauncher Position: 1920, 0 Size: 1920, 1080 Style: 0x96000000 ExStyle: 0x00200008 Handle: 0x0000000000010190 >>>> Control <<<< Class: DirectUIHWND Instance: 0 ClassnameNN: DirectUIHWND0 Name: Advanced (Class): [CLASS:DirectUIHWND; INSTANCE:0] ID: Text: Position: 0, 0 Size: 1920, 1080 ControlClick Coords: 138, 174 Style: 0x56000000 ExStyle: 0x00000000 Handle: 0x0000000000010192 >>>> Mouse <<<< Position: 2058, 174 Cursor ID: 0 Color: 0x180053 >>>> StatusBar <<<< >>>> ToolsBar <<<< >>>> Visible Text <<<< >>>> Hidden Text <<<< Explorer Browser Control I have this setup to run as a test when I press a hotkey: $title = WinGetTitle ("[ACTIVE]") $state = WinGetState ($title) ConsoleWrite ($title &" "& $state) I get "Start menu 0" its always 0 no matter what (it works correctly with other programs) I can get the PID of start menu but how can I then check when its active from that? Any help appreciated EDIT: I can only get the PID, Handle or anything else if the Start window is open. I cannot use win wait with any of this info though.
  11. Hello All, This is my test script i've been messing around with to get the syntax correct for my real script that I am working on. Simply, this script will: The problem that I am having is my loop that I have isn't waiting for a user to input new data into the "username" input box. How to replicate: 1. Input Project Name "TESTING-01A-Q1-2013" 2. Number of Projects Can be any number more than 1 3. Third input box is looking for a name "can be anything." 4. Click Next Project 5. When Next project button is dim click submit 6. Look in the script directory where you ran it from for "testing.txt" You will notice something similar to the following: Project TESTING-01A-Q1-2013 This is my username Project TESTING-01B-Q1-2013 This is my username TEST USER Project TESTING-01C-Q1-2013 This is my username TEST USER Project TESTING-01D-Q1-2013 This is my username TEST USER Project TESTING-01E-Q1-2013 This is my username TEST USER What needs to happen is the script will wait for the username input box to have data in it before filewrite. code is below #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> $Form1_1 = GUICreate("Test", 615, 438, 215, 170) $RDCNextProjectButton = GUICtrlCreateButton("Next Project", 183, 241, 99, 33) GUICtrlSetState(-1, $GUI_DISABLE) $ProjectNameInputBox = GUICtrlCreateInput("", 35, 104, 193, 21) $ProjectNameLabel = GUICtrlCreateLabel("Please Input Your Project Name", 27, 80, 200, 17) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") $NumberOfProjectsLabel = GUICtrlCreateLabel("Please Input The Number Of Projects You Have Of This Kind", 19, 160, 364, 17) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") $RDCNumberOfProjectsInput = GUICtrlCreateInput("", 49, 198, 193, 21) $RDCSubmitButton = GUICtrlCreateButton("Submit", 72, 240, 99, 33) GUICtrlSetState(-1, $GUI_ENABLE) Global $ProjectNameRead = GUICtrlRead($ProjectNameInputBox) $username = GUICtrlCreateInput("", 48, 290, 193, 21) GUISetState(@SW_SHOW) #endregion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $RDCNumberOfProjectsInput ;$RDCProjectSiteRead = GUICtrlRead ($ProjectSiteCombo) $RDCProjectNameRead = GUICtrlRead($ProjectNameInputBox) $RDCNumberOfProjectsRead = GUICtrlRead($RDCNumberOfProjectsInput) $usernameread = GUICtrlRead($username) If $RDCNumberOfProjectsRead > 1 Then GUICtrlSetState($RDCNextProjectButton, $GUI_ENABLE) GUICtrlSetState($RDCSubmitButton, $GUI_DISABLE) FileOpen("testing.txt", 1) FileWrite("testing.txt", @CRLF & @CRLF) FileWrite("testing.txt", "Project ") FileWrite("testing.txt", $RDCProjectNameRead & @CRLF) FileWrite("testing.txt", "This is my username " & $usernameread & @CRLF) FileClose("testing.txt") guictrlsetdata($username,"") ElseIf $RDCNumberOfProjectsRead = 1 Then GUICtrlSetState($RDCNextProjectButton, $GUI_DISABLE) GUICtrlSetState($RDCSubmitButton, $GUI_ENABLE) EndIf $CapacityInput = ($RDCNumberOfProjectsRead * 10) Case $RDCNextProjectButton $ProjectNameRead = GUICtrlRead($ProjectNameInputBox) $RDCNumberOfProjectsRead = GUICtrlRead($RDCNumberOfProjectsInput) $usernameread = GUICtrlRead($username) If guictrlread($username) = ("") Then MsgBox(0,"WAIT","Please Input A Name.") EndIf For $I = 1 To $RDCNumberOfProjectsRead - 1 FileOpen("testing.txt", 1) ConsoleWrite("'" & StringRegExpReplace($ProjectNameRead, "(?<=-\d{2})([A-Z])(?=-Q)", "' & Chr(Asc('$1') + $I) & '") & "'" & @LF) Local $soutput = Execute("'" & StringRegExpReplace($ProjectNameRead, "(?<=-\d{2})([A-Z])(?=-Q)", "' & Chr(Asc('$1') + $I) & '") & "'") GUICtrlSetData($ProjectNameInputBox, $soutput) FileWrite("testing.txt", @CRLF & @CRLF) FileWrite("testing.txt", "Project ") FileWrite("testing.txt", $soutput & @CRLF) FileWrite("testing.txt", "This is my username " & $usernameread & @CRLF) FileClose("testing.txt") guictrlsetdata($username,"") Next GUICtrlSetState($RDCNextProjectButton, $GUI_DISABLE) GUICtrlSetState($RDCSubmitButton, $GUI_ENABLE) Case $RDCSubmitButton MsgBox(0, "TESTING", "END OF SCRIPT") Exit EndSwitch WEnd Thanks to all for helping.
  12. Hi all, i have a weird problem, i have made a script that waits for a window to popup before continue, it works as a standalone but not inside the bigger script and i can´t figure out why. Here´s the standalone script: WinWait("Kampanj -- Webpage Dialog", "") If WinExists("Kampanj -- Webpage Dialog", "") Then MsgBox(0,"KAMPANJ!","Kampanjfönster öppet") WinActivate("Kampanj -- Webpage Dialog", "") Send("{ALTDOWN}s") Sleep(100) Send("{ALTUP}") Sleep(100) Send("{ALTDOWN}t") Sleep(100) Send("{ALTUP}") Sleep(100) EndIf And here´s the bigger script where this code just waits forever when it gets to the winwait: #include <IE.au3> #include <File.au3> #include <Misc.au3> #include <Excel.au3> $g_szVersion = "blob" If WinExists($g_szVersion) Then Exit ; do NOT run me again! AutoItWinSetTitle($g_szVersion) Global $kampanj Global $rownr Global $oIE Global $oFrame Global $ClipboardData $rownr = 1 $oIE = _IEAttach("GSM-AHS") WinActivate("GSM") Sleep(50) $kampanj = "KAM02370" $oIE.document.all.data.contentwindow.document.forms.CampaignForm.LIST.value = $kampanj Sleep(5000) $oFrame = _IEFrameGetCollection($oIE, 2) $ClipboardData = _IEPropertyGet($oFrame, "outerhtml") If StringInStr($ClipboardData, "selected value=KAM02370") Then $oIE.document.all.data.contentwindow.document.forms.CampaignForm.AddButton.disabled = False sleep(1000) $oIE.document.all.data.contentwindow.document.forms.CampaignForm.AddButton.click EndIf WinWait("Kampanj -- Webpage Dialog", "") If WinExists("Kampanj -- Webpage Dialog", "") Then ;MsgBox(0,"KAMPANJ!","Kampanjfönster öppet") WinActivate("Kampanj -- Webpage Dialog", "") Send("{ALTDOWN}s") Sleep(100) Send("{ALTUP}") Sleep(100) Send("{ALTDOWN}t") Sleep(100) Send("{ALTUP}") Sleep(100) EndIf Im planning on using it with various diffrent webapplications and local server programs and files, that´s why all thoose includes any thoughts?
  13. Is anyone else experiencing this issue with Windows 8 Release Preview & Consumer Preview: I have several scripts that automate info filling info into windows. They, of course, rely on AutoIT recognizing the windows by REGEXPTITLE & REGEXPCLASS (usually both, unless the title is blank). The scripts work fine for hours after restarting but they all eventually fail to "see" the windows even though they are visible. I am specifically working with Maxthon 3 (the Download Manager Window) and NetSetMan Pro. My understanding is that Windows 8 does not run explorer persistently & that may be an issue. I really just wanted wanted to see if anyone else has experienced this problem with the 2 "official" Windows 8 releases. I know that the software is Beta, so don't flame my post with that old chestnut. EDIT: This is a multi computer problem
  14. Hi guys, i'me testing this two function and i have made this script: AutoItSetOption("TrayIconDebug", 1) AutoItSetOption("SendKeyDelay", 10) Opt("WinTitleMatchMode", 2) Opt("WinDetectHiddenText",1) Global $Title = "Software Title" Global $Installer = @WorkingDir & "\setup.exe" Global $Language = "Select language" Global $Info = "Information" Global $Account = "Register" Run($Installer) TrayTip("", "Installation...", 5) WinWait($Language, "Select the language") ControlClick($Language, "", "[CLASS:TNewButton; INSTANCE:1]") WinWait($Title, "Welcome") ControlClick($Title, "&Next >", "[CLASS:TNewButton; INSTANCE:1]") TrayTip("", "Finish", 5) Sleep(2000) Exit Work fine, but i have a little question. somewere on this forum i have read that ControlClick / ControlSend work also if the windows is hide, so i have change the run command to this: Run($Installer, @SW_HIDE) But the script is stopped to the first WinWait. Where is my error? Thanks for support
  • Create New...