Jump to content

SQL Connection Error


Recommended Posts

Hello,

I've attempted a few examples on the forums but I'm not having any luck getting this to work.

I'm running Automation processes with a program on virtual machines and every so often it loses connection to the SQL Database and pops up a window that asks if you want to Exit the Application with "Yes/No" buttons. I'd like to be able to exit the application and then reopen the application from an icon on the desktop.

Right now the code that I tried is this below just to see if I can get it to exit the program but I can't even get that to work let alone to try and start the program after hitting the yes button.

$window=WinExists("SQL Error")
While 1
    $window=WinExists("SQL Error")
    If IsArray($window) Then
    ControlClick("SQL Error","","[CLASS:Button; INSTANCE:1]","Left",1);use the windowinfo tool from autoit
EndIf
Sleep(10)
WEnd

Not sure if this matters, but I know most popup windows will show up in the task manager and this popup doesn't show up in the task manager which may be the reason it's not detecting the window. The program I'm running was built in Power Builder if that matters.

Thanks for any assistance

Link to comment
Share on other sites

  • Moderators

Hi, Ubelmort, welcome to the forum. You should be able to do what you would like with AdlibRegister. Something like this perhaps (untested)

AdlibRegister("SqlError", 1000)

While 1
   Sleep(100);<------Do other stuff or add this While loop
Wend

Func SqlError()
If WinExists("SQL Error") Then ControlClick("SQL Error", "", "[CLASS:Button; INSTANCE:1]", "Left", 1)
EndFunc

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Thank you,

But that doesn't seem to work either :- Below is a screenshot of the error. I was thinking maybe could do a ImageSearch for the Red Circle X possibly but then I believe I'd need to run everything at the same resolution and when someone would Remote Desktop into that machine it would mess the resolution up and it wouldn't work anymore.

Posted Image

Link to comment
Share on other sites

  • Moderators

Have you attempted to add in some of the text in the error box, to see if that helps in locating the window?

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Yea I've attempted that as well, I believe the biggest issue is that all the popup windows for this application are internal popups and don't really create any outside process that would notify anything it's truly down other then someone physically seeing that it's down. I've done a ton of research today testing different programs to monitor program status but I came up with nothing that would detect that popup window other than an image finder that could do some mouse clicks, but I couldn't get that program to do a loop to always look for the crash.

So from doing the research on these forums, it looks like I may have to do a "ImageSearch" function in order to do what I really need it to do or maybe if I went as far as doing a memory dump of that application and seeing what code is being called during the crash to maybe write something to look for that memory, but I honestly don't want to go that far. I may just contact the developer of the application and request a feature be implemented into the software to not crash but to continue to try and reconnect to the Database.

At this point I'm running out of ideas if any of you may have any that would be great. This is my last post for the day until August 22 - 12:52PM. I will respond tomorrow if anyone posts any suggestions,

Thanks in advance.

Link to comment
Share on other sites

Granted, I haven't fully read your posts..... However, what I'd do is......

AutoItSetOption("WinTitleMatchMode", 2)
While 1

WinWait("SQL Error")
; When the error pops up, use the autoit window info tool to grab the
; control info for the button you want to have clicked and populate the option below
ControlClick("enter stuff here")

WEnd
Edited by Colyn1337
Link to comment
Share on other sites

  • Moderators

Granted, I haven't fully read your posts..

You should have. The OP states he has already attempted this. ;)

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

  • Moderators

Not quite...... There are differences, important ones too :)

I will be very surprised if setting the WinTitleMatchMode has any effect in this case as it is a powerbuilder app, but am open to hearing from the OP whether that solves it :)

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

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