Announcement

Collapse
No announcement yet.

Windows 10 and WAITx Functions

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Windows 10 and WAITx Functions

    I'm trying PBCC with Windows 10 and have noticed a problem with using the CON.WAITx functions. I find CON.WAITKEY$ or WAITKEY$ to be useful when doing development. However, it appears that a pair of NULL characters (UNICODE NULL?) are periodically pushed into the keyboard buffer - I assume by the OS. This has not happened in earlier Windows versions (I typically use Windows 7). If a mask is not specified, then the WAITKEY$ function will complete and code execution will continue. Has anyone else seen this or am I missing something? It's not a show stopper for me, just an observation.

  • #2
    Is mouse event trapping enabled?
    Dale

    Comment


    • #3
      I have not explicitly disabled mouse event trapping (read this as I don't currently know how to do that) but I did notice that this only happens when the console window is in focus. I also determined that, if you select the Use Legacy Console option for console windows, the problem goes away. I guess I can dig a bit deeper on the behavior but, for now, am back in business.

      Comment


      • #4
        I have not explicitly disabled mouse event trapping (read this as I don't currently know how to do that)
        When I was developing Wait for key, click or clock for PB/WIN and PB/CC I found I had to specifically ENable mouse trapping when using PB/CC... ..

        Code:
            ' for some reason with PB/CC you have to use these MOUSE functions or the software
            ' does not respond to mouse clicks.
            #IF %DEF(%PB_CC32)
                 MOUSE 1, DOWN       ' look for left button down. But it fires on down anyway.
                 MOUSE ON
            #ENDIF
        This has nothing to do with "double $nul" AFAIK .

        Then again, "Allegedly failing code not shown" so that is probably an option worthy of exploration.

        MCM

        Michael Mattias
        Tal Systems (retired)
        Port Washington WI USA
        [email protected]
        http://www.talsystems.com

        Comment


        • #5
          Hmm, if what you mean by this..
          I find CON.WAITKEY$ or WAITKEY$ to be useful when doing development. However, it appears that a pair of NULL characters (UNICODE NULL?) are periodically pushed into the keyboard buffer
          .. is that the string variable returned is four characters with the last two being 0x0000 and you were only expecting two characters.. that would be explained by the help for the function..
          CON.WAITKEY$ returns a string of one or two characters if a key was pressed. It returns a string of four characters for a mouse event, but only if mouse event trapping is enabled
          Code not shown.

          CON.INPUT.FLUSH might be useful following WAITKEY$ after you have received the 'characters of interest.' or perhaps before you wait.

          Michael Mattias
          Tal Systems (retired)
          Port Washington WI USA
          [email protected]
          http://www.talsystems.com

          Comment


          • #6
            Thanks, MCM. I don't use WAITKEY$ (or CON.WAITKEY$) in production applications. Typically, I just use it for prototype and initial code development. It let's me execute some code, stop and take a look at some console output, and then keep going - including looking at final results before exiting. It's usually the last statement in the test code (actually, it's in my default PB/CC code template) so, normally, I don't set a mask or evaluate buffer data - just use the basic statement.

            The double $NUL (two characters returned) was of interest because it frustrates my simple "pause" methodology - unless I configure the console window as I mentioned earlier. I've also noticed that this behavior occurs in the PB/CC IDE (I use 6.04). If you scroll the code window so that the cursor is hidden, the code window will scroll back to the original position within 10 seconds. If the IDE is not in focus, this won't happen, but it will occur once the IDE is back in focus.

            The 10-second time doesn't seem to be relative to keyboard or mouse activity in the focused window. The null characters simply get triggered every 10 seconds - possibly targeting whatever console window is currently in focus. In any case, it's still not a show-stopper - just mildly annoying.

            Thanks,
            Jerry

            Comment


            • #7
              Well, instead of CON:WAITKEY$ you might put in your template the "Wait For key click or clock" routine linked in Post #4.

              As I just said in another thread, if CON.WAITKEY$ does not produce the desired behavior don't use CON.WAITKEY$, use something else.

              RE:
              The null characters simply get triggered every 10 seconds - possibly targeting whatever console window is currently in focus.
              That has nothing to do with the compiler. Either some other application is doing that (malware?) or your own code is doing that inadvertently.

              Failing code not shown; however, note that CON.WAITKEY$ will return on mouse activity unless you mask it off. (See help).
              Michael Mattias
              Tal Systems (retired)
              Port Washington WI USA
              [email protected]
              http://www.talsystems.com

              Comment


              • #8
                Thanks for feedback. Here is some code that demonstrates behavior. The nulls show up in the buffer every 10 seconds. I could use a mask for a specific character but then get a beep every 10 seconds

                Code:
                #COMPILE EXE
                #DIM ALL
                
                FUNCTION PBMAIN () AS LONG
                  LOCAL s AS STRING
                  LOCAL n AS LONG
                
                  DO
                    RESET s
                    CON.WAITKEY$ TO s
                    PRINT TIME$ "  Buffer count =" LEN(s) "  Chars = (";
                    FOR n = 1 TO LEN(s)
                      PRINT ASC(s, n);
                    NEXT n
                    PRINT ")"
                  LOOP UNTIL s = CHR$(27)   ' Press <Esc> key to exit
                
                END FUNCTION

                Comment


                • #9
                  PBCC 6.04 on Vista.

                  Nothing till hit a key with your post 8 code.

                  Running any code/settings to prevent screen saver/hibernate/sleep modes of Windows?
                  Dale

                  Comment


                  • #10
                    Hi Jerry,

                    Tried with PBCC 6.04 on Win10. Using New Console Featues or 'Legacy Console' setting. No unexpected behavior with your code here.

                    The fact that you see effects while using the IDE too, strongly suggests that some external process is injecting directly to the keyboard.
                    (Similar to what you would see if running a program that was accessing the Keybd_Event function).

                    See if you can eliminate the source by killing processes in Task Manager?
                    Rgds, Dave

                    Comment


                    • #11
                      Keybd_Event function
                      .

                      Or Mouse_Event()? (WAITKEY$ code not masking off mouse behavior.. also don't know if "[mask]" is supported by this legacy syntax.)
                      Michael Mattias
                      Tal Systems (retired)
                      Port Washington WI USA
                      [email protected]
                      http://www.talsystems.com

                      Comment


                      • #12
                        I agree that it may be some other process and not the OS (Win10) generating the characters. I've scanned a lot of on-line boards and found nothing about this. I also don't seem to recall that I saw the behavior right after I was "upgraded" to Win10 (wasn't paying close enough attention when M$ ran the automatic upgrade while I stepped away for coffee), so it may be something that was added recently. Other apps, like Notepad++, don't seem to be affected. I could dig in and try to isolate this but don't know that I want to waste a lot of MIPS. Will have to see how frustrated I get . I'll probably move primary development to another machine and keep this one for OS compatibility testing.

                        Comment


                        • #13
                          Well, it wasn't that difficult after all. I just remembered that I installed the Dish Network SlingPlayer application on this machine last week. When I uninstalled it a few minutes ago, the problem went away. Not a great loss - SlingPlayer is a pretty buggy app - at least running under Win10. Thanks for helping.

                          Comment

                          Working...
                          X