icadea Posted December 21, 2007 Share Posted December 21, 2007 hi all, Shown below is a working script that i made. The code and the vncviewer.exe are put into the same folder. The only problem with the script is if I were to use press test1 button at the test1 computer, i have an vncviewer error saying loop back not enabled...) After that if i were to click test2 button from the same computer the script does not work. I have to exit, start the script and press test2 button for it to work. Why is this error occurs? I have tried using if error Return/Exit but it still hangs the script. Please advise. thanks expandcollapse popup#include <GUIConstants.au3> $form1 = GUICreate("form1", 514, 106, 502, 605) GUISetBkColor(0xC0C0C0) $test1 = GUICtrlCreateButton("test1", 8, 72, 49, 25, 0) GUICtrlSetFont(-1, 8, 800, 0, "Verdana") GUICtrlSetColor(-1, 0xFFFFFF) GUICtrlSetBkColor(-1, 0x008000) $test2 = GUICtrlCreateButton("test2", 64, 72, 49, 25, 0) GUICtrlSetFont(-1, 8, 800, 0, "Verdana") GUICtrlSetColor(-1, 0xFFFFFF) GUICtrlSetBkColor(-1, 0x008000) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $test1 test1() Case $test2 test2() EndSwitch WEnd Func test1() ShellExecute("vncviewer.exe", "", @ScriptDir) WinWaitActive("VNC Viewer : Connection Details") ControlSend("VNC Viewer : Connection Details", "", 1001, "192.168.1.4") Sleep(100) ControlClick("VNC Viewer : Connection Details", "OK", 1) Sleep(100) WinWaitActive("VNC Viewer : Authentication [No Encryption]") ControlSend("VNC Viewer : Authentication [No Encryption]", "", 1000, "admin1") Sleep(100) ControlClick("VNC Viewer : Authentication [No Encryption]", "OK", 1) Sleep(100) EndFunc ;==>test1 Func test2() ShellExecute("vncviewer.exe", "", @ScriptDir) WinWaitActive("VNC Viewer : Connection Details") ControlSend("VNC Viewer : Connection Details", "", 1001, "192.168.1.5") Sleep(100) ControlClick("VNC Viewer : Connection Details", "OK", 1) Sleep(100) WinWaitActive("VNC Viewer : Authentication [No Encryption]") ControlSend("VNC Viewer : Authentication [No Encryption]", "", 1000, "admin1") Sleep(100) ControlClick("VNC Viewer : Authentication [No Encryption]", "OK", 1) Sleep(100) EndFunc ;==>test2 Link to comment Share on other sites More sharing options...
therks Posted December 21, 2007 Share Posted December 21, 2007 It's probably a problem with one of the WinWait()'s. Try adding the timeout parameter to them. Something likeFunc test1() ShellExecute("vncviewer.exe", "", @ScriptDir) If WinWaitActive("VNC Viewer : Connection Details", "", 5) Then ControlSend("[LAST]", "", 1001, "192.168.1.4") Sleep(100) ControlClick("[LAST]", "OK", 1) Sleep(100) If WinWaitActive("VNC Viewer : Authentication [No Encryption]", "", 5) Then ControlSend("[LAST]", "", 1000, "admin1") Sleep(100) ControlClick("[LAST]", "OK", 1) Sleep(100) Else MsgBox(16, "Error", "Could not find window 'VNC Viewer : Authentication [No Encryption]' in 5 seconds") EndIf Else MsgBox(16, "Error", "Could not find window 'VNC Viewer : Connection Details' in 5 seconds") EndIf EndFunc ;==>test1 My AutoIt Stuff | My Github Link to comment Share on other sites More sharing options...
icadea Posted December 21, 2007 Author Share Posted December 21, 2007 thanks for the help i'll check them out Link to comment Share on other sites More sharing options...
icadea Posted December 22, 2007 Author Share Posted December 22, 2007 thank for the help Saunders, it works fine. Link to comment Share on other sites More sharing options...
therks Posted December 22, 2007 Share Posted December 22, 2007 Glad I could help. My AutoIt Stuff | My Github 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