Jump to content

1% of the time script doesnt work properly


Recommended Posts

Hi,

I have written a script with which helps me to automate the use of a gui application for comparing video files but sometimes it doesnt work like it should and I dont know why.

The script has the task to write the filenames and paths in the proper places in the gui application , choose the proper settings and then to start the application's comparision process. Then the appIication compares the two videos and creates a logfile in the end. I have a lot of videos and need a lot of logfiles. So the script needs to run very often.. Unfortunately sometimes the script doesn't work properly anymore and it stops or goes "crazy" and tries to write in the wrong places. As it happens rarely and at different places, it doesn't seem that an error in logic of the script is the reason. Could interference of other programs be the reason?

What is probably the reason and what can I do?

pp

Edited by petepillow
Link to comment
Share on other sites

I can assure you it's a problem with the script, at least 99% of the time. There is likely a scenario you have overlooked. The method may be subject to interference from external processes, but that's a programmer's oversight.

Edited by czardas
Link to comment
Share on other sites

If it is writing files in a way you do not like; you are telling the computer to do it wrong.

If I can't see the script you wrote; I can't help you fix it, now can I?

It could be a case of a filename or file data that you are sampling, that your script cannot handle. Find the data you are sampling when the error starts.

I don't know.

Edited by Xandy
Link to comment
Share on other sites

Using the Send command?

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

I'm interested in how you calculated it fails only 1% of the time.

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

I had a similar problem once. My script was running like a charm the first 1-2 hours but then it was getting confused and doing other actions in other places...

After some research i found out that the problem was in my script. I had a main function with a While loop and i was calling other sub functions to do some actions. My problem is that instead of calling Return at the end of the sub function to return to the main function i was calling the main function.

Func Main()
While 1
Call("Sub1")
WEnd

Func Sub1()
;some staff here
;But instead of using
Return
;I was using it like this
Call("Main")
EndFunc
Edited by ileandros

I feel nothing.It feels great.

Link to comment
Share on other sites

instead of calling Return at the end of the sub function to return to the main function i was calling the main function.

There's a I thought there was a name for that, but I can't remember. It's a special case of recursion - where two functions both call each other. You have to watch for recursion limits if you do something like that.

Edit

Perhaps I made a mistake. I associated the term 'backtracking' with recursion, but I'm not sure if this has a special name, or if it's simply an example of use.

Edited by czardas
Link to comment
Share on other sites

I was checking allot of pictures with _ScreenCapture_CaptureV2(). It would work for hours and I would happily jump up and down. There would come a point however when the memory the function was leaking would cause corrupt checks within the script it'self and my entire system would suffer gross deformation due to hours of randomly misplaced memory. A system restart was the only solution I could muster to renew a stable system. As for the script, I had to assert that I indeed had a memory leak find and squish it.

Your script? No clue. I pour over close to 20,000 lines a day. Attach the code to your question and your chance of this forum returning success greatly improves. I think you have got a 5 or 10% chance right now. Add 50% to that by including the source.

Edited by Xandy
Link to comment
Share on other sites

ok, it seems to have to do with the send command. I reduced the use of Send to a minimum. Now in some rare cases when the script entered the first filename in the first text field and then tries to jump with Send(Tab), Send(Tab) to the second textfield to enter the second file name, my computer makes noises like if you pressed too much keyboard buttons.

Could it be the case that sometimes something in the background happens which causes that Send(Tab) is executed too slow and the in the next step the script is sending a filename to a button instead to a text field?

Edited by petepillow
Link to comment
Share on other sites

opt("SendKeyDelay", $delay)

Alters the length of the brief pause in between sent keystrokes. A value of 0 removes the delay completely.

Time in milliseconds to pause (default=5).

opt("SendKeyDownDelay", $delay)

Alters the length of time a key is held down before being released during a keystroke. For applications that take a while to register keypresses you may need to raise this value from the default. A value of 0 removes the delay completely.

Time in milliseconds to pause (default=5).

example.

#include <misc.au3>
_sendEx("{TAB}", 0, 0, 250, 25)
;when this function is called control, shift, and alt must be released before $ss keys are sent
;_SendEx($ss send string, $raw[0use symbols in string, 1display symbols and just how I like it], _
;$modup[negate the mod key release feature for a macro that needs to hold mods and send keys.
;$delaybetweenkeys delay in milliseconds before sending each key
;$keypressedtime time in milliseconds to hold each key pressed
func _SendEx($ss, $raw= 0, $modup= 0, $delaybetweenkeys= -1, $keypressedtime= -1)
     if $delaybetweenkeys> -1 then opt("SendKeyDelay", $delaybetweenkeys)
     if $keypressedtime> -1 then opt("SendKeyDownDelay", $keypressedtime)
     if $modup= 0 then
          while _ispressed("10") Or _ispressed("11") Or _ispressed("12")
               sleep(50);feed the cpu 50 milliseconds
          wend
     endif
     send($ss, $raw)
EndFunc;_SendEx()

You can modify the timings for keys sent. I've done this to work around problems automating windows.

Edited by Xandy
Link to comment
Share on other sites

With that solution the text gets written fast:

_sendEx("", 0, 0, 5, 5)

_sendEx('text1', 0, 0, 250, 25)

__sendEx('{TAB 4}', 0, 0, 250, 25)

_sendEx("", 0, 0, 5, 5)

_sendEx('text2', 0, 0, 250, 25)

Thanks for the help.

So my extended solved petepillow's issue. Maybe it will also work for somebody else.

BrewManNH called it. I solved it. With the help of AutoIt of course.

edit: I didn't mean any disrespect.

Wanted to call my solution the answer, and wanted to give BrewManNH credit for his very accurate guess.

Back to back though, I do not like the look of what I wrote.

Edited by Xandy
Link to comment
Share on other sites

I prefer the Default keyword over using -1 to indicate a default parameter. Default is classed similar to False.

SomeFunc(Default)
SomeFunc(True)
SomeFunc(False)

Func SomeFunc($fVar = Default)
    If $fVar Then
        MsgBox(4096, 'Param: ' & $fVar, 'This is True')
    Else
        MsgBox(4096, 'Param: ' & $fVar, 'This is False')
    EndIf
EndFunc   ;==>SomeFunc

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...