• Pending keyboard input

    From Glenn Knickerbocker@21:1/5 to Steve DuBow on Fri Jan 5 18:54:33 2018
    On 1/5/2018 6:33 PM, Steve DuBow wrote:
    In Windows, is there a way to query pending keyboard input before
    issuing the PULL or LINEIN function so the program does not wait on
    input?
    The LINES() function will tell you if there are any lines in the input
    buffer. It can't tell you how *many* lines; it just returns 1 if there
    are any. Similarly, CHARS() will tell you if there are any characters in
    the buffer.

    ¬R

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Steve DuBow@21:1/5 to All on Fri Jan 5 15:33:15 2018
    Hello

    In Windows, is there a way to query pending keyboard input before issuing the PULL or LINEIN function so the program does not wait on input? I cannot find a REXX function that allows this. Do you have to use a Windows interface to accomplish this?
    Would appreciate any insight. Thank you.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Steve DuBow@21:1/5 to Glenn Knickerbocker on Tue Jan 9 13:04:50 2018
    On Friday, January 5, 2018 at 3:54:28 PM UTC-8, Glenn Knickerbocker wrote:
    On 1/5/2018 6:33 PM, Steve DuBow wrote:
    In Windows, is there a way to query pending keyboard input before
    issuing the PULL or LINEIN function so the program does not wait on
    input?
    The LINES() function will tell you if there are any lines in the input buffer. It can't tell you how *many* lines; it just returns 1 if there
    are any. Similarly, CHARS() will tell you if there are any characters in
    the buffer.

    ¬R

    Thank you for your reply. I've tried LINES() before and it didn't work. I have a SLEEP timer that runs for 15 seconds. During that period I enter data but when I come out of SLEEP and test LINES(), it's 0. This seems to mean that keyboard input is
    ignored during SysSleep.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Glenn Knickerbocker@21:1/5 to Steve DuBow on Tue Jan 9 21:24:26 2018
    On 1/9/2018 4:04 PM, Steve DuBow wrote:
    I've tried LINES() before and it didn't work. I have a SLEEP timer
    that runs for 15 seconds. During that period I enter data but when I
    come out of SLEEP and test LINES(), it's 0.
    Weird, I just tried it with ooRexx on Windows and had the opposite
    problem: If I type any characters but don't press ENTER, I still get
    LINES() = 1, where I expected LINES() = 0 and CHARS() = 1.

    I also lose the rest of the last line after reading the start of it with CHARIN(), and can't read it at all until I hit ENTER:

    1 *-* Trace A
    2 *-* say syssleep(1)
    0
    3 *-* say chars() lines()
    1 1
    4 *-* do i = 1 while chars()
    5 *-* say i charin()~c2x chars() lines()
    as
    1 61 1 1
    6 *-* end
    4 *-* do i = 1 while chars()
    5 *-* say i charin()~c2x chars() lines()
    2 73 1 1
    6 *-* end
    4 *-* do i = 1 while chars()
    5 *-* say i charin()~c2x chars() lines()
    3 0D 1 1
    6 *-* end
    4 *-* do i = 1 while chars()
    5 *-* say i charin()~c2x chars() lines()
    4 0A 1 1
    6 *-* end
    4 *-* do i = 1 while chars()
    5 *-* say i charin()~c2x chars() lines()
    df
    --- pauses here until I hit ENTER again ---
    5 64 0 0
    6 *-* end
    4 *-* do i = 1 while chars()
    7 *-* say i
    6

    Oh, I see, for input without ENTER there's SysGetKey:
    Reads and returns the next key from the keyboard buffer. If the
    keyboard buffer is empty, SysGetKey waits until a key is pressed.
    Unlike the CHARIN built-in function, SysGetKey does not wait until
    the Enter key is pressed.

    But since that waits for a key to be pressed, it's no good for testing
    for input without a wait.

    ¬R

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From LesK@21:1/5 to Glenn Knickerbocker on Tue Jan 9 22:00:17 2018
    On 1/9/2018 9:24 PM, Glenn Knickerbocker wrote:
    On 1/9/2018 4:04 PM, Steve DuBow wrote:
    I've tried LINES() before and it didn't work. I have a SLEEP timer
    that runs for 15 seconds. During that period I enter data but when I
    come out of SLEEP and test LINES(), it's 0.
    Weird, I just tried it with ooRexx on Windows and had the opposite
    problem: If I type any characters but don't press ENTER, I still get
    LINES() = 1, where I expected LINES() = 0 and CHARS() = 1.

    I also lose the rest of the last line after reading the start of it with CHARIN(), and can't read it at all until I hit ENTER:

    1 *-* Trace A
    2 *-* say syssleep(1)
    0
    3 *-* say chars() lines()
    1 1
    4 *-* do i = 1 while chars()
    5 *-* say i charin()~c2x chars() lines()
    as
    1 61 1 1
    6 *-* end
    4 *-* do i = 1 while chars()
    5 *-* say i charin()~c2x chars() lines()
    2 73 1 1
    6 *-* end
    4 *-* do i = 1 while chars()
    5 *-* say i charin()~c2x chars() lines()
    3 0D 1 1
    6 *-* end
    4 *-* do i = 1 while chars()
    5 *-* say i charin()~c2x chars() lines()
    4 0A 1 1
    6 *-* end
    4 *-* do i = 1 while chars()
    5 *-* say i charin()~c2x chars() lines()
    df
    --- pauses here until I hit ENTER again ---
    5 64 0 0
    6 *-* end
    4 *-* do i = 1 while chars()
    7 *-* say i
    6

    Oh, I see, for input without ENTER there's SysGetKey:
    Reads and returns the next key from the keyboard buffer. If the
    keyboard buffer is empty, SysGetKey waits until a key is pressed.
    Unlike the CHARIN built-in function, SysGetKey does not wait until
    the Enter key is pressed.

    But since that waits for a key to be pressed, it's no good for testing
    for input without a wait.

    ¬R

    Perhaps you could get the first character with SysGetKey and then start
    the Do While to get the rest of them?

    This is vaguely familiar from my micro-processor days in RAS.

    --

    Les (Change Arabic to Roman to email me)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Glenn Knickerbocker@21:1/5 to LesK on Wed Jan 10 19:59:44 2018
    On 1/9/2018 10:00 PM, LesK wrote:
    Perhaps you could get the first character with SysGetKey and then start
    the Do While to get the rest of them?

    But Steve wants to find out if there's anything there already *without*
    waiting for a key to be pressed. LINES() should do that, but he said it
    didn't work for him (he didn't say in which Rexx version).

    My problem comes in the step after that: In ooRexx on Windows, LINES()
    tells me that a key has been pressed, but doesn't tell me whether ENTER
    has been pressed. If I check LINES() and then try to pull the line, I
    might still wind up waiting for the user to press ENTER. Additionally,
    if I try to pull it byte by byte with CHARIN(), I lose all but the first character of the last line in the buffer.

    When LINES() works correctly, this does the job of pulling in whatever's already typed without waiting:

    line. = ''
    Do i = 1 While Lines() > 0
    char = ''
    Do While Lines() > 0 & char \= '0d'x
    char = SysGetKey()

    /* On carriage return, SysGetKey doesn't see or echo newline */
    If char = '0d'x Then Call LineOut , ''

    Else line.i = line.i || char
    End
    End
    line.0 = i - 1

    /* Did we have a last line with no carriage return? */
    pending = (line.0 > 0) & (char \= '0d'x)
    If pending Then Call LineOut , ''

    It took me a few tries to figure out the quirk of SysGetKey losing the
    newline characters that CharIn sees. Is that a Windows-only thing? If
    so, I'm not sure how you'd accommodate it in a platform-independent way.

    (I also had to look up the details of LineOut to be reminded that it
    needs a null string in the argument so it doesn't think you want to
    close the STDOUT file.)

    ¬R

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Garry Smithwick@21:1/5 to Steve DuBow on Thu Jan 11 05:15:48 2018
    On Friday, January 5, 2018 at 6:33:16 PM UTC-5, Steve DuBow wrote:
    Hello

    In Windows, is there a way to query pending keyboard input before issuing the PULL or LINEIN function so the program does not wait on input? I cannot find a REXX function that allows this. Do you have to use a Windows interface to accomplish this?
    Would appreciate any insight. Thank you.

    Put the Syskeyget in a separate rexx exec. When Syskeyget shows the data has come in put it in a .local variable. In another exec use RXWINEXEC to start the first exec and check the .local variable.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Steve DuBow@21:1/5 to Glenn Knickerbocker on Thu Jan 11 07:45:48 2018
    On Tuesday, January 9, 2018 at 6:24:27 PM UTC-8, Glenn Knickerbocker wrote:
    On 1/9/2018 4:04 PM, Steve DuBow wrote:
    I've tried LINES() before and it didn't work. I have a SLEEP timer
    that runs for 15 seconds. During that period I enter data but when I
    come out of SLEEP and test LINES(), it's 0.
    Weird, I just tried it with ooRexx on Windows and had the opposite
    problem: If I type any characters but don't press ENTER, I still get
    LINES() = 1, where I expected LINES() = 0 and CHARS() = 1.

    I also lose the rest of the last line after reading the start of it with CHARIN(), and can't read it at all until I hit ENTER:

    1 *-* Trace A
    2 *-* say syssleep(1)
    0
    3 *-* say chars() lines()
    1 1
    4 *-* do i = 1 while chars()
    5 *-* say i charin()~c2x chars() lines()
    as
    1 61 1 1
    6 *-* end
    4 *-* do i = 1 while chars()
    5 *-* say i charin()~c2x chars() lines()
    2 73 1 1
    6 *-* end
    4 *-* do i = 1 while chars()
    5 *-* say i charin()~c2x chars() lines()
    3 0D 1 1
    6 *-* end
    4 *-* do i = 1 while chars()
    5 *-* say i charin()~c2x chars() lines()
    4 0A 1 1
    6 *-* end
    4 *-* do i = 1 while chars()
    5 *-* say i charin()~c2x chars() lines()
    df
    --- pauses here until I hit ENTER again ---
    5 64 0 0
    6 *-* end
    4 *-* do i = 1 while chars()
    7 *-* say i
    6

    Oh, I see, for input without ENTER there's SysGetKey:
    Reads and returns the next key from the keyboard buffer. If the
    keyboard buffer is empty, SysGetKey waits until a key is pressed.
    Unlike the CHARIN built-in function, SysGetKey does not wait until
    the Enter key is pressed.

    But since that waits for a key to be pressed, it's no good for testing
    for input without a wait.

    ¬R

    Thank you again for you reply. I will try SysGetKey. Appreciate your suggestion.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Steve DuBow@21:1/5 to Garry Smithwick on Thu Jan 11 07:56:51 2018
    On Thursday, January 11, 2018 at 5:15:49 AM UTC-8, Garry Smithwick wrote:
    On Friday, January 5, 2018 at 6:33:16 PM UTC-5, Steve DuBow wrote:
    Hello

    In Windows, is there a way to query pending keyboard input before issuing the PULL or LINEIN function so the program does not wait on input? I cannot find a REXX function that allows this. Do you have to use a Windows interface to accomplish this?
    Would appreciate any insight. Thank you.

    Put the Syskeyget in a separate rexx exec. When Syskeyget shows the data has come in put it in a .local variable. In another exec use RXWINEXEC to start the first exec and check the .local variable.

    Interesting Tack. I'll try this. Many thanks.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Steve DuBow@21:1/5 to LesK on Thu Jan 11 07:46:05 2018
    On Tuesday, January 9, 2018 at 7:00:17 PM UTC-8, LesK wrote:
    On 1/9/2018 9:24 PM, Glenn Knickerbocker wrote:
    On 1/9/2018 4:04 PM, Steve DuBow wrote:
    I've tried LINES() before and it didn't work. I have a SLEEP timer
    that runs for 15 seconds. During that period I enter data but when I
    come out of SLEEP and test LINES(), it's 0.
    Weird, I just tried it with ooRexx on Windows and had the opposite
    problem: If I type any characters but don't press ENTER, I still get LINES() = 1, where I expected LINES() = 0 and CHARS() = 1.

    I also lose the rest of the last line after reading the start of it with CHARIN(), and can't read it at all until I hit ENTER:

    1 *-* Trace A
    2 *-* say syssleep(1)
    0
    3 *-* say chars() lines()
    1 1
    4 *-* do i = 1 while chars()
    5 *-* say i charin()~c2x chars() lines()
    as
    1 61 1 1
    6 *-* end
    4 *-* do i = 1 while chars()
    5 *-* say i charin()~c2x chars() lines()
    2 73 1 1
    6 *-* end
    4 *-* do i = 1 while chars()
    5 *-* say i charin()~c2x chars() lines()
    3 0D 1 1
    6 *-* end
    4 *-* do i = 1 while chars()
    5 *-* say i charin()~c2x chars() lines()
    4 0A 1 1
    6 *-* end
    4 *-* do i = 1 while chars()
    5 *-* say i charin()~c2x chars() lines()
    df
    --- pauses here until I hit ENTER again ---
    5 64 0 0
    6 *-* end
    4 *-* do i = 1 while chars()
    7 *-* say i
    6

    Oh, I see, for input without ENTER there's SysGetKey:
    Reads and returns the next key from the keyboard buffer. If the
    keyboard buffer is empty, SysGetKey waits until a key is pressed.
    Unlike the CHARIN built-in function, SysGetKey does not wait until
    the Enter key is pressed.

    But since that waits for a key to be pressed, it's no good for testing
    for input without a wait.

    ¬R

    Perhaps you could get the first character with SysGetKey and then start
    the Do While to get the rest of them?

    This is vaguely familiar from my micro-processor days in RAS.

    --

    Les (Change Arabic to Roman to email me)

    Thank you also Les.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Steve DuBow@21:1/5 to Glenn Knickerbocker on Thu Jan 11 07:54:59 2018
    On Tuesday, January 9, 2018 at 6:24:27 PM UTC-8, Glenn Knickerbocker wrote:
    On 1/9/2018 4:04 PM, Steve DuBow wrote:
    I've tried LINES() before and it didn't work. I have a SLEEP timer
    that runs for 15 seconds. During that period I enter data but when I
    come out of SLEEP and test LINES(), it's 0.
    Weird, I just tried it with ooRexx on Windows and had the opposite
    problem: If I type any characters but don't press ENTER, I still get
    LINES() = 1, where I expected LINES() = 0 and CHARS() = 1.

    I also lose the rest of the last line after reading the start of it with CHARIN(), and can't read it at all until I hit ENTER:

    1 *-* Trace A
    2 *-* say syssleep(1)
    0
    3 *-* say chars() lines()
    1 1
    4 *-* do i = 1 while chars()
    5 *-* say i charin()~c2x chars() lines()
    as
    1 61 1 1
    6 *-* end
    4 *-* do i = 1 while chars()
    5 *-* say i charin()~c2x chars() lines()
    2 73 1 1
    6 *-* end
    4 *-* do i = 1 while chars()
    5 *-* say i charin()~c2x chars() lines()
    3 0D 1 1
    6 *-* end
    4 *-* do i = 1 while chars()
    5 *-* say i charin()~c2x chars() lines()
    4 0A 1 1
    6 *-* end
    4 *-* do i = 1 while chars()
    5 *-* say i charin()~c2x chars() lines()
    df
    --- pauses here until I hit ENTER again ---
    5 64 0 0
    6 *-* end
    4 *-* do i = 1 while chars()
    7 *-* say i
    6

    Oh, I see, for input without ENTER there's SysGetKey:
    Reads and returns the next key from the keyboard buffer. If the
    keyboard buffer is empty, SysGetKey waits until a key is pressed.
    Unlike the CHARIN built-in function, SysGetKey does not wait until
    the Enter key is pressed.

    But since that waits for a key to be pressed, it's no good for testing
    for input without a wait.

    ¬R

    I remember why I didn't use SysGetKey before. Like PULL, it wait for a key to be entered. What I'm trying to do is avoid issuing PULL until I know that input is pending. I'll keep researching.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Garry Smithwick@21:1/5 to Steve DuBow on Fri Jan 12 04:53:26 2018
    On Thursday, January 11, 2018 at 10:56:52 AM UTC-5, Steve DuBow wrote:
    On Thursday, January 11, 2018 at 5:15:49 AM UTC-8, Garry Smithwick wrote:
    On Friday, January 5, 2018 at 6:33:16 PM UTC-5, Steve DuBow wrote:
    Hello

    In Windows, is there a way to query pending keyboard input before issuing the PULL or LINEIN function so the program does not wait on input? I cannot find a REXX function that allows this. Do you have to use a Windows interface to accomplish this?
    Would appreciate any insight. Thank you.

    Put the Syskeyget in a separate rexx exec. When Syskeyget shows the data has come in put it in a .local variable. In another exec use RXWINEXEC to start the first exec and check the .local variable.

    Interesting Tack. I'll try this. Many thanks.

    I have used this approach for other things. Let me know if it works for you. Hey, I might need to check input like this someday. :-)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Steve DuBow@21:1/5 to Garry Smithwick on Sun Jan 14 10:31:11 2018
    On Friday, January 12, 2018 at 4:53:28 AM UTC-8, Garry Smithwick wrote:
    On Thursday, January 11, 2018 at 10:56:52 AM UTC-5, Steve DuBow wrote:
    On Thursday, January 11, 2018 at 5:15:49 AM UTC-8, Garry Smithwick wrote:
    On Friday, January 5, 2018 at 6:33:16 PM UTC-5, Steve DuBow wrote:
    Hello

    In Windows, is there a way to query pending keyboard input before issuing the PULL or LINEIN function so the program does not wait on input? I cannot find a REXX function that allows this. Do you have to use a Windows interface to accomplish
    this? Would appreciate any insight. Thank you.

    Put the Syskeyget in a separate rexx exec. When Syskeyget shows the data has come in put it in a .local variable. In another exec use RXWINEXEC to start the first exec and check the .local variable.

    Interesting Tack. I'll try this. Many thanks.

    I have used this approach for other things. Let me know if it works for you. Hey, I might need to check input like this someday. :-)

    Hello Garry

    I've tried a number of things including what you suggested. The problem using the environment variable approach is that these variables (as I understand) can be shared by methods running under the same process but not inter-process. I also tried using
    a file to save input. The 'read' exec that pulls the input writes it into the file using LINEOUT(fid). The other exec that launched the read exec tests for input using the LINES command when it wakes up from SysSleep. If LINES(fid)>0, it uses LINEIN(
    fid) to read the input from the file. The problem I found is that LINES(fid)=1 even before anything is put in the file by the read exec so the SysSleep exec always tries to read the file. Further, once the file is read, subsequent LINEOUT(fid) fail (RC=
    1) due to a sharing violation. I've tried to force sharing using the stream commands:

    MyStream = .stream~new(fid)
    RC = MyStream~command("OPEN BOTH SHARED")

    RC=READY is returned from command but the LINEOUT still fails after LINEIN is entered. From what I've read, OPEN is not required to open a file. LINEOUT and LINEIN automatically open a file if it is closed for read and write. However, I am not aware
    of another way to set the SHARED file option for inter-process communication. I have, in the past, used the same file for input and output but always within the same exec. I'm still lokking at other approaches. I'd be intrested in hearing your
    thoughts. Thank you for your time.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Steve DuBow@21:1/5 to Garry Smithwick on Wed Jan 17 13:57:36 2018
    On Friday, January 12, 2018 at 4:53:28 AM UTC-8, Garry Smithwick wrote:
    On Thursday, January 11, 2018 at 10:56:52 AM UTC-5, Steve DuBow wrote:
    On Thursday, January 11, 2018 at 5:15:49 AM UTC-8, Garry Smithwick wrote:
    On Friday, January 5, 2018 at 6:33:16 PM UTC-5, Steve DuBow wrote:
    Hello

    In Windows, is there a way to query pending keyboard input before issuing the PULL or LINEIN function so the program does not wait on input? I cannot find a REXX function that allows this. Do you have to use a Windows interface to accomplish
    this? Would appreciate any insight. Thank you.

    Put the Syskeyget in a separate rexx exec. When Syskeyget shows the data has come in put it in a .local variable. In another exec use RXWINEXEC to start the first exec and check the .local variable.

    Interesting Tack. I'll try this. Many thanks.

    I have used this approach for other things. Let me know if it works for you. Hey, I might need to check input like this someday. :-)


    I haven't been able to get the sharded file or environment variable approach to work by I was able to use WindowsClipboard to solve my inter-process communication issue. Thanks for your help.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Garry Smithwick@21:1/5 to All on Thu Jan 18 05:21:11 2018
    You are right. Using the .local variable may not work in the case of using rxwinexec to start the second exec. What if, you start the second exec with rxwinxec and the first exec will have the PID of the task rxwinexec started. Pass the PID to the
    second exec and use it as a variable name and when the second exec gets data it stores the data in an ini file (using sysini). The second exec could monitor the ini file using the PID. Maybe store each key in the ini file as "pid,key.1", "pid,key.2",
    etc. PIDs are reused, so be sure the clear the ini file before you start. Sounds funky, I know. But might work. If I have time I will try some things. Good luck.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Garry Smithwick@21:1/5 to All on Thu Jan 18 05:22:18 2018
    If you do use rxwinexec as part of the solution. You might find this interesting: https://groups.google.com/forum/#!topic/comp.lang.rexx/05scQJKaa3k

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Garry Smithwick@21:1/5 to All on Thu Jan 18 08:12:14 2018
    Steve, can you give us a description of what you are trying to accomplish? After reading the updates, not clear on what you are trying to do. Other options that might apply. Have the sysgetkey exec create a file in a special folder and have another
    exec use monitor events to do whatever you want to do when a new folder is created.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Garry Smithwick@21:1/5 to All on Sat Jan 20 04:35:12 2018
    This might help.

    Exec 1:

    ----------------------------------------------------------------------------- folder = Directory()'\'Time('T')

    Call SysRmDir folder

    Call SysMkDir folder

    file = folder'\KeyData'

    program = 'C:\Rexx\My Tools\ReadKeys.rex'

    rexx = 'C:\Program Files\oorexx\rexxpaws.exe'

    pid = RxWinExec(rexx '"'program'"' '"'file'"')

    crlf = '0d0a'x

    WaitTime = 5

    Say '--> Monitor folder:' Folder crlf

    objWMIService = .oleObject~GetObject("winmgmts:\\.\root\cimv2")

    wmipath = Folder~changestr('\','\\\\')

    colMonitoredEvents = objWMIService~ExecNotificationQuery("SELECT * FROM",
    "__InstanceOperationEvent",
    "WITHIN" WaitTime "WHERE Targetinstance ISA 'CIM_DirectoryContainsFile' and ",
    "TargetInstance.GroupComponent= 'Win32_Directory.Name="""wmipath"""'")

    Do Forever
    Say Date('S') Time('C') '- Waiting Up To' WaitTime 'Seconds For The Next Event'crlf
    objEventObject = colMonitoredEvents~NextEvent()
    result = objEventObject~GetObjectText_
    target = objEventObject~TargetInstance~PartComponent
    Parse Var target .'='target
    target = target~changestr('\\','\')~strip(,'"')
    Select
    When result~pos("__InstanceCreationEvent") > 0 Then Do
    Say Date('S') Time('C') '--> New file created:' target crlf
    Keydata = Linein(target)
    Call Lineout target
    Call Sysfiledelete target
    Say 'Key data:' Keydata crlf
    End
    When result~pos("__InstanceDeletionEvent") > 0 Then Say Date('S') Time() '--> File deleted:' target crlf
    Otherwise Say Date('S') Time('C') '--> Unknown event:' target crlf
    End
    End

    Call SysRmDir folder

    Exit

    --------------------------------------------------------------------------

    Exec 2 (started by exec 1 using rxwinexec):

    --------------------------------------------------------------------------

    path = Arg(1)

    If path = '' Then Exit

    if rxfuncquery('SYSLoadFuncs')=1 then ,
    if rxfuncadd('SYSLoadFuncs','regutil','SYSLoadFuncs') > 0 then exit
    call sysloadfuncs

    Do n = 1 to 100
    Say Date('S') Time('C') 'Waiting for keyboard input...' '0d0a'x

    data = Sysgetkey()

    file = path'-'n'.dat'

    Call Sysfiledelete file
    Call Lineout file, data
    Call Lineout file
    End

    Exit

    ---------------------------------------------------------------------------

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From LesK@21:1/5 to Garry Smithwick on Sat Jan 20 18:17:19 2018
    On 1/20/2018 7:35 AM, Garry Smithwick wrote:
    This might help.

    Exec 1:

    ----------------------------------------------------------------------------- folder = Directory()'\'Time('T')

    Call SysRmDir folder

    Call SysMkDir folder

    file = folder'\KeyData'

    program = 'C:\Rexx\My Tools\ReadKeys.rex'

    rexx = 'C:\Program Files\oorexx\rexxpaws.exe'

    pid = RxWinExec(rexx '"'program'"' '"'file'"')

    crlf = '0d0a'x

    WaitTime = 5

    Say '--> Monitor folder:' Folder crlf

    objWMIService = .oleObject~GetObject("winmgmts:\\.\root\cimv2")

    wmipath = Folder~changestr('\','\\\\')

    colMonitoredEvents = objWMIService~ExecNotificationQuery("SELECT * FROM",
    "__InstanceOperationEvent",
    "WITHIN" WaitTime "WHERE Targetinstance ISA 'CIM_DirectoryContainsFile' and ",
    "TargetInstance.GroupComponent= 'Win32_Directory.Name="""wmipath"""'")

    Do Forever
    Say Date('S') Time('C') '- Waiting Up To' WaitTime 'Seconds For The Next Event'crlf
    objEventObject = colMonitoredEvents~NextEvent()
    result = objEventObject~GetObjectText_
    target = objEventObject~TargetInstance~PartComponent
    Parse Var target .'='target
    target = target~changestr('\\','\')~strip(,'"')
    Select
    When result~pos("__InstanceCreationEvent") > 0 Then Do
    Say Date('S') Time('C') '--> New file created:' target crlf
    Keydata = Linein(target)
    Call Lineout target
    Call Sysfiledelete target
    Say 'Key data:' Keydata crlf
    End
    When result~pos("__InstanceDeletionEvent") > 0 Then Say Date('S') Time() '--> File deleted:' target crlf
    Otherwise Say Date('S') Time('C') '--> Unknown event:' target crlf
    End
    End

    Call SysRmDir folder

    Exit

    --------------------------------------------------------------------------

    Exec 2 (started by exec 1 using rxwinexec):

    --------------------------------------------------------------------------

    path = Arg(1)

    If path = '' Then Exit

    if rxfuncquery('SYSLoadFuncs')=1 then ,
    if rxfuncadd('SYSLoadFuncs','regutil','SYSLoadFuncs') > 0 then exit
    call sysloadfuncs

    Do n = 1 to 100
    Say Date('S') Time('C') 'Waiting for keyboard input...' '0d0a'x

    data = Sysgetkey()

    file = path'-'n'.dat'

    Call Sysfiledelete file
    Call Lineout file, data
    Call Lineout file
    End

    Exit

    ---------------------------------------------------------------------------

    I think the underlying problem is being fixed. Please see:

    https://sourceforge.net/p/oorexx/bugs/1520/

    --

    Les (Change Arabic to Roman to email me)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)