anixon Posted October 16, 2010 Share Posted October 16, 2010 This code starts a scheduled task called RealVNC which produces a Window with the Title 'VNC Server Status (Service - Mode)'Button 1 on that Window is titled 'Configure' and Button 2 'Close'. The effect of 'Close' is to close the Window with the program left running.In this condition the programs Icon is displayed in the Notification Area of the Task Bar. After starting the program this is the condition I wish to achieve. In the code listed below the ControlCommand returns 1 as 'Configure' is the active button on which the default focus is set.When this Window is open I simply want to send a command that clicks the 'Close' button.In the code ControlFocus does not appear to set the focus to Button 2 in which case the Send 'Enter' command does not cause the Window to close.By way of background I am launching the program based on a scheduled task using Schtasks.exe this is so that I can run the program in a Windows Vista environment with the highest privileges./run and /tn is schtasks.exe command line instructions /run runs the task and /tn relates to the task name which is this case is RealVNC.Run(@SystemDir & "\" & "schtasks.exe /run /tn RealVNC") Sleep(500) WinActivate("VNC Server Status") If ControlCommand("VNC Server Status", "", "Button1", "IsEnabled") Then ControlFocus("VNC Server Status", "", "[CLASS:Button; INSTANCE:2]") Sleep(500) Send("{ENTER}") Sleep(500) EndIfAny assistance would be greatly appreciated Ant.. Link to comment Share on other sites More sharing options...
Varian Posted October 16, 2010 Share Posted October 16, 2010 Have you tried to simply click on the button?ControlClick("VNC Server Status", "", "[CLASS:Button; INSTANCE:2]")You may also fiddle around with the speed of Window recognition and "status" checkingOpt("WinWaitDelay", 100) Do Sleep(50) Until ControlCommand("VNC Server Status", "", "[CLASS:Button; INSTANCE:2]", "IsEnabled", "") Do Local $Success = ControlClick("VNC Server Status", "", "[CLASS:Button; INSTANCE:2]") Sleep(50) Until $Success = 1 Link to comment Share on other sites More sharing options...
anixon Posted October 16, 2010 Author Share Posted October 16, 2010 (edited) Have you tried to simply click on the button?ControlClick("VNC Server Status", "", "[CLASS:Button; INSTANCE:2]")You may also fiddle around with the speed of Window recognition and "status" checkingOpt("WinWaitDelay", 100) Do Sleep(50) Until ControlCommand("VNC Server Status", "", "[CLASS:Button; INSTANCE:2]", "IsEnabled", "") Do Local $Success = ControlClick("VNC Server Status", "", "[CLASS:Button; INSTANCE:2]") Sleep(50) Until $Success = 1 Thanks for your help unfortunately neither of your solutions work. It passes the Until ControlCommand so it must be reporting that the button is enabled it also produces the $Success value = 1 however the routine does not Close the window. I have noted that after the routine finishes the focus is still on the 'Configure' button Ant.. Edit: I am guessing but I think that this Window does not response to AutoIT commands because of Windows Vista UAC. When launching this program you get a UAC Pop-up informing the user that the Program needs permission to continue after permission the programs Status Window presents and this is the Window which does not respond to AutoIT commands other than making it the active window. To avoid the UAC Pop-up I am launching the program as a schedule task with the task set at the highest privileges which takes you directly to the program status Window the one that does not respond to AutoIT. What is also of interest is when 'Quiting' this program you always get the UAC Pop-up which as previously mentioned requires the user that the Program needs permission to continue. Comments and/or a solution would be appreciated Edited October 16, 2010 by anixon Link to comment Share on other sites More sharing options...
anixon Posted October 16, 2010 Author Share Posted October 16, 2010 Thanks for your help unfortunately neither of your solutions work. It passes the Until ControlCommand so it must be reporting that the button is enabled it also produces the $Success value = 1 however the routine does not Close the window. I have noted that after the routine finishes the focus is still on the 'Configure' button Ant.. Edit:I am guessing but I think that this Window does not response to AutoIT commands because of Windows Vista UAC. When launching this program you get a UAC Pop-up informing the user that the Program needs permission to continue after permission the programs Status Window presents and this is the Window which does not respond to AutoIT commands other than making it the active window. To avoid the UAC Pop-up I am launching the program as a schedule task with the task set at the highest privileges which takes you directly to the program status Window the one that does not respond to AutoIT. What is also of interest is when 'Quiting' this program you always get the UAC Pop-up which as previously mentioned requires the user that the Program needs permission to continue. Comments and/or a solution would be appreciated Bump Link to comment Share on other sites More sharing options...
anixon Posted October 23, 2010 Author Share Posted October 23, 2010 Bump The solution was the scheduler tasks command arguments -showstatus=0 -start expandcollapse popup<?xml version="1.0" encoding="UTF-16"?> <Task version="1.2" xmlns="[url="http://schemas.microsoft.com/windows/2004/02/mit/task"]http://schemas.microsoft.com/windows/2004/02/mit/task[/url]"> <RegistrationInfo> <Date>2010-10-16T14:02:27.9404537</Date> <Author>Study-PC\Anthony</Author> </RegistrationInfo> <Triggers /> <Principals> <Principal id="Author"> <RunLevel>HighestAvailable</RunLevel> <UserId>Study-PC\Anthony</UserId> <LogonType>InteractiveToken</LogonType> </Principal> </Principals> <Settings> <IdleSettings> <StopOnIdleEnd>true</StopOnIdleEnd> <RestartOnIdle>false</RestartOnIdle> </IdleSettings> <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy> <DisallowStartIfOnBatteries>true</DisallowStartIfOnBatteries> <StopIfGoingOnBatteries>true</StopIfGoingOnBatteries> <AllowHardTerminate>true</AllowHardTerminate> <StartWhenAvailable>false</StartWhenAvailable> <RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable> <AllowStartOnDemand>true</AllowStartOnDemand> <Enabled>true</Enabled> <Hidden>false</Hidden> <RunOnlyIfIdle>false</RunOnlyIfIdle> <WakeToRun>false</WakeToRun> <ExecutionTimeLimit>P3D</ExecutionTimeLimit> <Priority>7</Priority> </Settings> <Actions Context="Author"> <Exec> <Command>"C:\Program Files\RealVNC\VNC4\winvnc4.exe"</Command> <Arguments>-showstatus=0 -start</Arguments> </Exec> </Actions> </Task> Link to comment Share on other sites More sharing options...
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