Jump to content

checking returned dllcall variable causes script to close


Recommended Posts

Hiya!

Okay, this is pretty nebulous, but hopefully someone's got an idea. I'm basically looking for advice on how to do some good error checking for a rather strange issue. Okay, onto the issue: this is in regards to my splitmon app (see sig); I've noticed that after connecting remotely to my PC and then disconnecting my session (via rdp, in other words, I don't logoff, just lock the pc), when I come back to the pc and login physically/directly at it, half the time the splitmon app will just close down without an error. I've had it running from scite when it does this and it closes with an exit code of 0.

After a ton of testing, I finally found the line that's giving me trouble:

$EnumDisplays = DllCall($dll, "int", "EnumDisplayDevices", "ptr", 0, "int", $dev, "ptr", DllStructGetPtr($dd), "int", 0)oÝ÷ Øíã(+h¬ß [§rب¬Æ¥+ajÙbêîËaz|!zx­rËazö¥¹êÓ~éÊek+4×±Û(ºÝ÷ÞÅ©©â)ºÛazÇ­ÂbëzZ0¶nÞ)Þ¶"½é¶¬jëh×6$EnumDisplays = DllCall($dll, "int", "EnumDisplayDevices", "ptr", 0, "int", $dev, "ptr", DllStructGetPtr($dd), "int", 0)
ConsoleWrite(@ScriptLineNumber & ":error:" & @error & @CRLF)
ConsoleWrite(@ScriptLineNumber & ":$EnumDisplays[0]:" & $EnumDisplays[0] & @CRLF)

When the code runs and subsequently exits (after several attempts to get it to break), the console shows that it executed the first consolewrite line with an @error of 0, and then exited! As soon as it tries to read $EnumDisplays[0], it exits out without even an error.

Okay, that's a lot, but basically, I'm wondering what a good way to narrow down this problem would be. Is there something else I can do hear to check that DllCall without killing the app?

Link to comment
Share on other sites

I'd like to test, but I don't have a $dev variable, or a $dd variable. :P

I thought everyone has $dev and $dd var's! :whistle: The function itself is simple enough and will not fail when run normally... I think it has something to do with logging into a pc and running this when the pc isn't ready or something. Anyway, if you must know, $dev is just a number 0, 1, 2, etc... that is used to iterate through the attached devices. $dd is the struct where the data should go. You can look at the code if you'd like (in sig... still). Per microsoft, it returns nonzero if it succeeds, zero if it doesn't.

edit: like i said, I'm not really asking for testing, I can test just fine... I just need suggestions on better ways to test? How do you guys check for errors? Any better way than using the console?

I find it incredibly bizarre that checking the value of a variable would cause my autoit app to exit without error when it shouldn't...

Edited by fisofo
Link to comment
Share on other sites

edit: like i said, I'm not really asking for testing, I can test just fine...

Oh I know, I just agree with this:

I find it incredibly bizarre that checking the value of a variable would cause my autoit app to exit without error when it shouldn't...

And am wondering if it will happen the same on mine.

I do have one question, before I try anything, are you running through SciTe? Or with /ErrorStdOut on the command line to AutoIt in some way? If so, try without, cus there's a new error dialog that comes up (stack overflow or something, can't remember) with some dll calls, and it doesn't output error information to the stdOut pipe. Made diagnosing errors with some of my old dllcalls a little confusing.

Link to comment
Share on other sites

Oh I know, I just agree with this:

And am wondering if it will happen the same on mine.

I do have one question, before I try anything, are you running through SciTe? Or with /ErrorStdOut on the command line to AutoIt in some way? If so, try without, cus there's a new error dialog that comes up (stack overflow or something, can't remember) with some dll calls, and it doesn't output error information to the stdOut pipe. Made diagnosing errors with some of my old dllcalls a little confusing.

Okay, I wasn't totally sure with how you said it :whistle: I appreciate you being willing to test it!

I've actually never used /ErrorStdOut before :P But that would be something to try. However, the behavior occurs running compiled or running from SciTe. I wish I had a better way to test this thing...

I whipped up some code to try to emulate in a more simple manner what the code is doing and I've attached it to this post. For some reason It's not firing the GUIRegistermsg code like my other one does in Splitmon, I must be missing something... But anyway, I put in Windows+Space bar to fire off the relevant code. However, I haven't gotten this code to fail yet, probably because I can't get it to fire it's own events at login. I'll need to take a look at that, perhaps after some sleep.

Otherwise you can just run the full app from the Splitmon page, it's a lot more code to sift through though.

Thanks!

EDIT: I just thought of this... but do you have multiple monitors? I'm wondering if that effects this issue or not... I'll do some testing to find out when I get a chance. The pc where this code is running has multiple monitors, but I can try the scenario on my laptop.

_MonitorInfo.au3

Edited by fisofo
Link to comment
Share on other sites

I'll have to come back to this... I haven't been able to reproduce it on my secondary pc. I think I found a workaround though, putting in an initial delay before checking the monitor info seems to fix the problem. I'll open this back up if I need more help.

Thanks!

Link to comment
Share on other sites

For those interested, I figured it out!

The initial delay fixed the issue some of the time, but I continued to have issues... well, I found that I could check the $EnumDisplays variable by using IsArray without crashing the script! So now, it goes something like:

While Not IsArray($EnumDisplays)
    ; re-calc $EnumDisplays
Wend

Fun fun...

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