alback Posted March 12, 2007 Share Posted March 12, 2007 I am having a strange problem. I develop and run scripts in standalone mode and they work fine. I then turned them into functions and call them from a master program and they fail. I haven't been able to determine the specific cause of the failure. Thanks Link to comment Share on other sites More sharing options...
seandisanti Posted March 12, 2007 Share Posted March 12, 2007 I am having a strange problem. I develop and run scripts in standalone mode and they work fine. I then turned them into functions and call them from a master program and they fail. I haven't been able to determine the specific cause of the failure.Thanksit would be easier to tell you where your issue is if you showed your code Link to comment Share on other sites More sharing options...
alback Posted March 12, 2007 Author Share Posted March 12, 2007 it would be easier to tell you where your issue is if you showed your codeOK, here is a routine that is giving me problems. I have the Func...EndFunc commented out to run standalone.Thanks;===============================================================================; Description: Import the DAU inventory into the database.; The Belize DAU inventory saved in the; Program Files\Ascend Geo\UltraSM\Projects\System\Import\DAU directory; is used for the test data.;===============================================================================#include "SysTestFunctions.au3"#include <GuiConstants.au3>#include <GuiListView.au3>Global $Filename, $DAUInventory, $ControlHandle;Func ImportDAUInventory() ;select the <Edit.Import DAUs> to open the Ascend Geo UltraSM - Import DAUs form WinMenuSelectItem("Ascend Geo Ultra Survey Manager", "", "&Edit", "&Import") ;wait for the Import DAUs window to open ActivateWindow ("Ascend Geo UltraSM - Import DAUs") ;select the file list from the default directory ControlClick("Ascend Geo UltraSM - Import DAUs", "", "WindowsForms10.BUTTON.app36") ;wait for the file selection list view window to open ActivateWindow ("Select the DAU file to be imported") ;select the filename from the list $Filename = GetSysiniValue ("ImportFilename", "$DAUInventory") MsgBox(0,"file name",$Filename) $ControlHandle = ControlGetHandle("Select the DAU file to be imported", "", "SysListView321") PickListViewItem ($ControlHandle, $Filename) ;choose the file from the list ;click the Open command button ControlClick("Select the DAU file to be imported", "", "Button2") ;wait for the main window to open ActivateWindow ("Ascend Geo UltraSM - Import DAUs") ;select the Import button ControlClick("Ascend Geo UltraSM - Import DAUs", "", "WindowsForms10.BUTTON.app32") ;wait for the import to finish, snapshot the database if asked Do $a = ControlCommand("Ascend Geo UltraSM - Import DAUs", "", "WindowsForms10.BUTTON.app31", "IsEnabled", "") If WinExists("Perform Database Snapshot?") Then If WinActive("Perform Database Snapshot?", "") Then ControlClick("Perform Database Snapshot?", "", "Button1") ;select Yes to perform a snapshot WinWaitClose("Perform Database Snapshot?", "", 1000) Else WinActivate("Perform Database Snapshot?") WinWaitActive("Perform Database Snapshot?") ControlClick("Perform Database Snapshot?", "", "Button1") ;select Yes to perform a snapshot WinWaitClose("Perform Database Snapshot?", "", 1000) EndIf EndIf Until $a = 1 ;select close to go back to the Ascend Geo Ultra Survey Manager window ControlClick("Ascend Geo UltraSM - Import DAUs", "", "WindowsForms10.BUTTON.app34");EndFunc ;==>ImportDAUInventoryAnd here is a subroutine that fails;===============================================================================; Title: PickListViewItem; Description: selects an entry in a list view control; Parameter(s): $ControlHandle handle for the list view control; $Filename name of the file to choose from the list;; Requirement(s): None; Return Value(s): Success returns 0; Failure returns 0 and sets @ERROR = 1;===============================================================================Func PickListViewItem($ControlHandle, $Filename) If _GUICtrlListViewSetItemSelState($ControlHandle, _GUICtrlListViewFindItem($ControlHandle, $Filename), 1, 1) = 0 Then MsgBox(0, "File Select Failure", $ControlHandle & @LF & $Filename, 3000) Exit ;leave the application EndIfEndFunc ;==>PickListViewItemThe MsgBox is displayed when I run it as a function and it works standalone.Thanks Link to comment Share on other sites More sharing options...
seandisanti Posted March 12, 2007 Share Posted March 12, 2007 when you turn it into a function, are you calling it at some point in your code? if it's not called (and i don't mean use call() just functionname()) it won't execute Link to comment Share on other sites More sharing options...
alback Posted March 12, 2007 Author Share Posted March 12, 2007 when you turn it into a function, are you calling it at some point in your code? if it's not called (and i don't mean use call() just functionname()) it won't executeYes, I turn the main routine into a function and then call it with a higher level routine that strings this and other routines together. The higher level routine is as follows:#include "SystemTestSetup.au3"#Include "ImportDAUInventory.au3"#Include "CreateNewProjectFunc.au3"#Include "EnterSystemID.au3"#Include "ExportFullDatabaseToSecondary.au3"#Include "UltraInstallFunc.au3"Opt("WinWaitDelay", 100)Opt("WinTitleMatchMode", 4)Opt("WinDetectHiddenText", 1)Opt("MouseCoordMode", 0)Opt("SendKeyDelay", 20)Opt("MouseClickDelay", 50);UltraInstall ();SystemTestSetup ()ImportDAUInventory ()CreateNewProject ()EnterSystemID (False)ExportFullDatabase () Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 12, 2007 Moderators Share Posted March 12, 2007 What's failing ... the controlclick? What's the error your getting? 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. Link to comment Share on other sites More sharing options...
seandisanti Posted March 12, 2007 Share Posted March 12, 2007 alright, and last question before i actually start going through code (sorry, alot of times that can be avoided with a question or two...) when you run it as a function, what behavior are you seeing? i mean is it not running at all, are you getting errors that you didn't get before, is it making your computer make funny smells? Link to comment Share on other sites More sharing options...
alback Posted March 12, 2007 Author Share Posted March 12, 2007 What's failing ... the controlclick? What's the error your getting?This subroutine defaults to the MsgBox indicating that it did not find the string in the listbox control.Func PickListViewItem($ControlHandle, $Filename) If _GUICtrlListViewSetItemSelState($ControlHandle, _GUICtrlListViewFindItem($ControlHandle, $Filename), 1, 1) = 0 Then MsgBox(0, "File Select Failure", $ControlHandle & @LF & $Filename, 3000) Exit ;leave the application EndIfEndFunc ;==>PickListViewItem Link to comment Share on other sites More sharing options...
alback Posted March 12, 2007 Author Share Posted March 12, 2007 alright, and last question before i actually start going through code (sorry, alot of times that can be avoided with a question or two...) when you run it as a function, what behavior are you seeing? i mean is it not running at all, are you getting errors that you didn't get before, is it making your computer make funny smells?Func PickListViewItem($ControlHandle, $Filename) If _GUICtrlListViewSetItemSelState($ControlHandle, _GUICtrlListViewFindItem($ControlHandle, $Filename), 1, 1) = 0 Then MsgBox(0, "File Select Failure", $ControlHandle & @LF & $Filename, 3000) Exit ;leave the application EndIfEndFunc ;==>PickListViewItemThe If statement is satisfied indicating that the $Filename string was not found in the listbox and the MsgBox is displayed. Running in standalone mode it finds and selects the string. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 12, 2007 Moderators Share Posted March 12, 2007 Wait... you're using AutoIt GUI functions on a Non-AutoIt GUI? May want to find PaulIA's Au3Lib.au3. 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. Link to comment Share on other sites More sharing options...
alback Posted March 12, 2007 Author Share Posted March 12, 2007 Wait... you're using AutoIt GUI functions on a Non-AutoIt GUI?May want to find PaulIA's Au3Lib.au3.OK, I recently found the library and have looked at some of the functions but did not go there because things were working. If you think I better take a closer look, I can certainly do that.Thanks Link to comment Share on other sites More sharing options...
seandisanti Posted March 12, 2007 Share Posted March 12, 2007 OK, I recently found the library and have looked at some of the functions but did not go there because things were working. If you think I better take a closer look, I can certainly do that.Thanksyeah, i think that would be the way to go, good catch on that one smoke.... Link to comment Share on other sites More sharing options...
alback Posted March 12, 2007 Author Share Posted March 12, 2007 yeah, i think that would be the way to go, good catch on that one smoke....OK, thanks guys. Link to comment Share on other sites More sharing options...
seandisanti Posted March 12, 2007 Share Posted March 12, 2007 OK, thanks guys.update and let us know if you got it working man, we're always glad to help Link to comment Share on other sites More sharing options...
alback Posted March 12, 2007 Author Share Posted March 12, 2007 update and let us know if you got it working man, we're always glad to helpWell, I'm getting closer. With the change to Auto3Lib functions I am able to run most of my routines as subroutines but now I get a memory error. The error dialog is as follows:_Mem_Init:_API_GwtWindowThreadProcessID: -1I think the Auto3Lib functions that it is trying to invoke are as follows:_Tab_SetCurFocus($MainTabMenuHandle,_Tab_FindTab ($MainTabMenuHandle, "Project"))_Tab_SetCurFocus($ChildTabMenuHandle,_Tab_FindTab ($ChildTabMenuHandle, "General"))Any ideas?Thanks Link to comment Share on other sites More sharing options...
PaulIA Posted March 16, 2007 Share Posted March 16, 2007 Well, I'm getting closer. With the change to Auto3Lib functions I am able to run most of my routines as subroutines but now I get a memory error. The error dialog is as follows:_Mem_Init:_API_GwtWindowThreadProcessID: -1I think the Auto3Lib functions that it is trying to invoke are as follows:_Tab_SetCurFocus($MainTabMenuHandle,_Tab_FindTab ($MainTabMenuHandle, "Project"))_Tab_SetCurFocus($ChildTabMenuHandle,_Tab_FindTab ($ChildTabMenuHandle, "General"))Any ideas?ThanksYou're not passing a valid window handle to the function(s). Don't fall into the trap of passing the result of one function to another function without checking the results first. Check the result of _Tab_FindTab before calling _Tab_SetCurFocus. Also, if you have problems with Auto3Lib, be sure to post in the Auto3Lib thread. I just happened to run onto this by accident. Auto3Lib: A library of over 1200 functions for AutoIt 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