AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Can we tell Script Pass/Fail??

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
ansu832001



Joined: 05 May 2008
Posts: 18

PostPosted: Tue May 13, 2008 7:12 am    Post subject: Can we tell Script Pass/Fail?? Reply with quote

Hi All,

My Question is "how can we tell whether a script is passed or failed?" i.e based on lines executed in script.Let me explain in clear way,

suppose i have a script which has 10 lines of code,now while executing the script say at 4th line i got an exception in my application(not in script) so i will not be able to execute next 6 lines of code in my script, in this case my script is failed,so how can i handle this scenario.Like to track whether the script the script has executed all lines or not based on which i say whether script is passed or failed.

Best Regards.
Back to top
View user's profile Send private message
sinkfaze



Joined: 19 Mar 2008
Posts: 138

PostPosted: Tue May 13, 2008 7:24 am    Post subject: Reply with quote

You can always use ErrorLevel statements.
_________________
Have trouble searching the site for information? Try Quick Search for Autohotkey.
Back to top
View user's profile Send private message
ansu832001



Joined: 05 May 2008
Posts: 18

PostPosted: Tue May 13, 2008 7:31 am    Post subject: Reply with quote

Hi Sinkfaze,

firstly thank you for your reply,

but i failed to understand how can we use errorlevel for unwanted behavior happend in Application(not in script). Sorry for ignorance.

Best Regards.


Last edited by ansu832001 on Tue May 13, 2008 7:48 am; edited 2 times in total
Back to top
View user's profile Send private message
Z Gecko
Guest





PostPosted: Tue May 13, 2008 7:41 am    Post subject: Reply with quote

The fact, that something goes wrong elsewhere is not a failure of the script,
so ErrorLevel will be mostly no help.
You could, for instance, do something like this:
Code:
settimer, checkcmd, 1000
cmdnr++
somecommand...
cmdnr++
somecommand...
cmdnr++
somecommand...
cmdnr++
somecommand...
cmdnr++
somecommand...
return
checkcmd:
if cmdnr = oldcmdnr
   MsgBox, Script hangs at %cmdnr%
oldcmdnr := cmdnr


But if you show us no code, we can not really help, just guess.
Back to top
ansu832001



Joined: 05 May 2008
Posts: 18

PostPosted: Tue May 13, 2008 7:49 am    Post subject: Reply with quote

Thank you Z Gecko
Here is my code which records the events.

#SingleInstance, Force
SetTitleMatchMode, 2


ASWPath = C:\Program Files\AutoHotkey\AutoScriptWriter\AutoScriptWriter.exe
FILEPTH=D:\Sunil's\Projects\Windows Scripting\Auto Hot Key\Test
MOUSEDELAY=SetMouseDelay,50
i=0

F12::
Run, %ASWPath%,, Min ; or fully hidden
WinWaitActive, AutoScriptWriter II
; ControlClick, Button8, AutoScriptWriter II ; window text button
ControlClick, Button1, AutoScriptWriter II ; record button
Return

F11::
BlockInput, On
Control, Show,, Edit2, AutoScriptWriter II ; activate edit field
ControlGetText, RecordedCode, Edit2, AutoScriptWriter II ; get the code
BlockInput, Off
;MsgBox % RecordedCode ; for testing
if i=0
{
FileAppend,%MOUSEDELAY% `n, %FILEPTH%.ahk

i=1
}
FileAppend, %RecordedCode%, %FILEPTH%.ahk ; create file
WinClose, AutoScriptWriter II ; well ...
Return

^1::
Run %FILEPTH%.ahk
Return

Two Scenarios could be

Like while recording the script for my application which has a textbox which accepts only Unique numbers,once i enter a number i click ok button to go to next page. These are my steps to perform.


First Time : I enter Number in textbox clicked ok button,i go to next page.(This operation i have recorded).

Second Time :(Scrupt is rerun) This time same value is entered and Ok buuton clicked, a dialogbox pops up saying duplicate value,now my script will not be able to execute next lines of code beacuase of indifferent behavior. now in this scenario i want to write to kinda log saying script failed. Hope iam clear.



Best Regards
Back to top
View user's profile Send private message
Z Gecko
Guest





PostPosted: Tue May 13, 2008 8:20 am    Post subject: Reply with quote

1. Please put your code in Code-Tags [code]...[/code]

2. you didnīt show the code, that hangs,
you showed code
that uses the autoscriptwriter to produce some more code.

And this code, made by the autoscriptwriter, seems to be the one with the "hanging"-issue.
So since the autoscriptwriter has no option for your wish, you need to edit the script after it was recorded. Important is to make shure, not to break any If-statements.
Back to top
ansu832001



Joined: 05 May 2008
Posts: 18

PostPosted: Tue May 13, 2008 8:25 am    Post subject: Reply with quote

Z Gecko,Thank you again.my genrated code is


WinWait, MyApp ,
IfWinNotActive, MyApp , , WinActivate, MyApp ,
WinWaitActive, MyApp ,
MouseClick, left, 170, 63
Sleep, 100
MouseClick, left, 173, 64
Sleep, 100
MouseClick, left, 173, 86
Sleep, 100
WinWait, New Widget Manager,
IfWinNotActive, New Widget Manager, , WinActivate, New Widget Manager,
WinWaitActive, New Widget Manager,
Send, t
; after send t, Application hangs here (when i rerun the script,a dialogbox pops up saying name "t" already exist),so iam not able to perform next two lines.
MouseClick, left, 146, 109
Sleep, 100
Back to top
View user's profile Send private message
Z Gecko
Guest





PostPosted: Tue May 13, 2008 8:32 am    Post subject: Reply with quote

Again: Please use Code-Tags around your code!
Back to top
ansu832001



Joined: 05 May 2008
Posts: 18

PostPosted: Tue May 13, 2008 10:04 am    Post subject: Reply with quote

Sorry for the ignorance,

what does this Code-Tags mean,i don't have knowledge.

Best Regards.
Back to top
View user's profile Send private message
Z Gecko
Guest





PostPosted: Tue May 13, 2008 10:11 am    Post subject: Reply with quote

Code:
;this text is between the code tags
the tags are [code]anything in here will be displayed in a code box[/code]

it makes reading code way easier
and you can copy the whole code to the clipboard for easy testing.
Back to top
ansu832001



Joined: 05 May 2008
Posts: 18

PostPosted: Tue May 13, 2008 10:39 am    Post subject: Reply with quote

Z Gecko,thanks for that new thing

Code:
WinWait, MyApp ,
IfWinNotActive, MyApp , , WinActivate, MyApp ,
WinWaitActive, MyApp ,
MouseClick, left, 170, 63
Sleep, 100
MouseClick, left, 173, 64
Sleep, 100
MouseClick, left, 173, 86
Sleep, 100
WinWait, New Widget Manager,
IfWinNotActive, New Widget Manager, , WinActivate, New Widget Manager,
WinWaitActive, New Widget Manager,
Send, t
; after send t, Application hangs here (when i rerun the script,a dialogbox pops up saying name "t" already exist),so iam not able to perform next two lines.
MouseClick, left, 146, 109
Sleep, 100


But Z Gecko,how can u test my code ,u don't have my application rite??

Best Regards.
Back to top
View user's profile Send private message
Z Gecko
Guest





PostPosted: Tue May 13, 2008 11:03 am    Post subject: Reply with quote

In that case, i can not test your code,
but i can read it much better now.

To your case:
the script does not fail, it will continue, only the effect will be different.
So there can be no failure detected, because there is none.
The autoscriptwriter simply does not have the features you need. You will have to rethink your whole project, sorry.
Depending on the variety of scripts you want to create, you could either have predefined scripts beeing updated with some costum vars, or you need to write your own script-recorder.
Back to top
ansu832001



Joined: 05 May 2008
Posts: 18

PostPosted: Tue May 13, 2008 11:16 am    Post subject: Reply with quote

Thank you Z Gecko,i will try to do it in a different way.

Best Regards.
Back to top
View user's profile Send private message
sinkfaze



Joined: 19 Mar 2008
Posts: 138

PostPosted: Tue May 13, 2008 2:13 pm    Post subject: Reply with quote

Code:
WinWait, New Widget Manager,
IfWinNotActive, New Widget Manager, , WinActivate, New Widget Manager,
WinWaitActive, New Widget Manager,
Send, t
; after send t, Application hangs here (when i rerun the script,a dialogbox pops up saying name "t" already exist),so iam not able to perform next two lines.
MouseClick, left, 146, 109
Sleep, 100


Tell me what should be happening during this particular part of your code and then tell me what actually happens. What is "Send t" supposed to do to the program in question? Then what is the Mouse Click supposed to do?
_________________
Have trouble searching the site for information? Try Quick Search for Autohotkey.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group