Sign in to follow this  
Followers 0
alback

standalone script OK, fails as function

16 posts in this topic

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

Share this post


Link to post
Share on other sites



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

it would be easier to tell you where your issue is if you showed your code

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

it would be easier to tell you where your issue is if you showed your code

OK, 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 ;==>ImportDAUInventory

And 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

EndIf

EndFunc ;==>PickListViewItem

The MsgBox is displayed when I run it as a function and it works standalone.

Thanks

Share this post


Link to post
Share on other sites

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


1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

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

Yes, 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 ()

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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?


1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

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

EndIf

EndFunc ;==>PickListViewItem

Share this post


Link to post
Share on other sites

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

EndIf

EndFunc ;==>PickListViewItem

The 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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

yeah, i think that would be the way to go, good catch on that one smoke....

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

yeah, i think that would be the way to go, good catch on that one smoke....

OK, thanks guys.

Share this post


Link to post
Share on other sites

OK, thanks guys.

update and let us know if you got it working man, we're always glad to help

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

update and let us know if you got it working man, we're always glad to help

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: -1

I 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

Share this post


Link to post
Share on other sites

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: -1

I 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

You'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

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0