Opening Another Application in R Then Hangs

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Opening Another Application in R Then Hangs

Sparks, John James
Hi R Helpers,

I am trying to open another application from within R and then work with it.

I can get the application to open, but R then hangs at that point (spinning blue circle in the middle of the screen) and my subsequent programming does not execute.

Does anybody know how to get R to unlock?

I am using Windows 10 and R4.0.

The example below freezes R on my machine.

Any guidance appreciated.  Thanks.
--John Sparks

setwd("C:/Users/JSparks/AppData/Roaming/Microsoft/Windows/Start Menu/Programs/Accessories")
system2("Notepad",invisible=FALSE)






        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Opening Another Application in R Then Hangs

Jeff Newmiller
Exit the application you started?

On July 5, 2020 3:06:52 PM PDT, "Sparks, John" <[hidden email]> wrote:

>Hi R Helpers,
>
>I am trying to open another application from within R and then work
>with it.
>
>I can get the application to open, but R then hangs at that point
>(spinning blue circle in the middle of the screen) and my subsequent
>programming does not execute.
>
>Does anybody know how to get R to unlock?
>
>I am using Windows 10 and R4.0.
>
>The example below freezes R on my machine.
>
>Any guidance appreciated.  Thanks.
>--John Sparks
>
>setwd("C:/Users/JSparks/AppData/Roaming/Microsoft/Windows/Start
>Menu/Programs/Accessories")
>system2("Notepad",invisible=FALSE)
>
>
>
>
>
>
> [[alternative HTML version deleted]]
>
>______________________________________________
>[hidden email] mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.

--
Sent from my phone. Please excuse my brevity.

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Opening Another Application in R Then Hangs

Sparks, John James
Hi Jeff,

Greatly appreciate your reply, but I don't quite understand it.

Perhaps I should give a little more detail.

For this example, I want to open notepad, then go to notepad and type something in.  So the program

library(KeyboardSimulator)
setwd("C:/Users/JSparks/AppData/Roaming/Microsoft/Windows/Start Menu/Programs/Accessories")
system2("Notepad",invisible=FALSE)
mouse.move(2423,236)
mouse.click()
keybd.type_string("Hello world!")

would do this, but it does not advance passed the system2 command.

Best wishes,
--JJS

________________________________
From: Jeff Newmiller <[hidden email]>
Sent: Sunday, July 5, 2020 5:08 PM
To: [hidden email] <[hidden email]>; Sparks, John <[hidden email]>; R-help <[hidden email]>
Subject: Re: [R] Opening Another Application in R Then Hangs

Exit the application you started?

On July 5, 2020 3:06:52 PM PDT, "Sparks, John" <[hidden email]> wrote:

>Hi R Helpers,
>
>I am trying to open another application from within R and then work
>with it.
>
>I can get the application to open, but R then hangs at that point
>(spinning blue circle in the middle of the screen) and my subsequent
>programming does not execute.
>
>Does anybody know how to get R to unlock?
>
>I am using Windows 10 and R4.0.
>
>The example below freezes R on my machine.
>
>Any guidance appreciated.  Thanks.
>--John Sparks
>
>setwd("C:/Users/JSparks/AppData/Roaming/Microsoft/Windows/Start
>Menu/Programs/Accessories")
>system2("Notepad",invisible=FALSE)
>
>
>
>
>
>
>       [[alternative HTML version deleted]]
>
>______________________________________________
>[hidden email] mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.

--
Sent from my phone. Please excuse my brevity.

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Opening Another Application in R Then Hangs

David Winsemius
This list is not the recommended location for support of that Windows
only package. The URL in the DESCRIPTION file has this to advise:

++++++++++++++++++


      This package doesn't work on my computer! How can I make it work?

Open aGitHub <https://github.com/ChiHangChen/KeyboardSimulator>issue and
let us know what version of Windows you are using and what keyboard and
mouse hardware you have connected.

++++++++++++++++++


-- David.

On 7/5/20 3:16 PM, Sparks, John wrote:

> Hi Jeff,
>
> Greatly appreciate your reply, but I don't quite understand it.
>
> Perhaps I should give a little more detail.
>
> For this example, I want to open notepad, then go to notepad and type something in.  So the program
>
> library(KeyboardSimulator)
> setwd("C:/Users/JSparks/AppData/Roaming/Microsoft/Windows/Start Menu/Programs/Accessories")
> system2("Notepad",invisible=FALSE)
> mouse.move(2423,236)
> mouse.click()
> keybd.type_string("Hello world!")
>
> would do this, but it does not advance passed the system2 command.
>
> Best wishes,
> --JJS
>
> ________________________________
> From: Jeff Newmiller <[hidden email]>
> Sent: Sunday, July 5, 2020 5:08 PM
> To: [hidden email] <[hidden email]>; Sparks, John <[hidden email]>; R-help <[hidden email]>
> Subject: Re: [R] Opening Another Application in R Then Hangs
>
> Exit the application you started?
>
> On July 5, 2020 3:06:52 PM PDT, "Sparks, John" <[hidden email]> wrote:
>> Hi R Helpers,
>>
>> I am trying to open another application from within R and then work
>> with it.
>>
>> I can get the application to open, but R then hangs at that point
>> (spinning blue circle in the middle of the screen) and my subsequent
>> programming does not execute.
>>
>> Does anybody know how to get R to unlock?
>>
>> I am using Windows 10 and R4.0.
>>
>> The example below freezes R on my machine.
>>
>> Any guidance appreciated.  Thanks.
>> --John Sparks
>>
>> setwd("C:/Users/JSparks/AppData/Roaming/Microsoft/Windows/Start
>> Menu/Programs/Accessories")
>> system2("Notepad",invisible=FALSE)
>>
>>
>>
>>
>>
>>
>>        [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
> --
> Sent from my phone. Please excuse my brevity.
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Opening Another Application in R Then Hangs

Rasmus Liland-3
In reply to this post by Sparks, John James
On 2020-07-05 22:16 +0000, Sparks, John wrote:
>
> For this example, I want to open notepad,
> then go to notepad and type something in.  

Dear John,

Perhaps start Notepad in the background is
what you mean?  Something like

        system2("START /B Notepad", invisible=FALSE)

Found it at [1].  I'm not on Windows ever, so
I can not test it.

What are you trying to achieve here?

Where would the things you type into Notepad
end up?  Will R read it.  It might be more
useful to take user input by calling

        readline(prompt="Enter something here at least: ")

Best,
Rasmus

[1] https://superuser.com/a/591084

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

signature.asc (849 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Opening Another Application in R Then Hangs

Jeff Newmiller
In reply to this post by Sparks, John James
If you open an app using the default settings for system2, R normally expects to let you know what the program's return value was, so if it was interactive you would need to terminate the program so there would be a result for system2 to return with. For what you actually appear to be doing you probably want to read ?system2.

On July 5, 2020 3:16:12 PM PDT, "Sparks, John" <[hidden email]> wrote:

>Hi Jeff,
>
>Greatly appreciate your reply, but I don't quite understand it.
>
>Perhaps I should give a little more detail.
>
>For this example, I want to open notepad, then go to notepad and type
>something in.  So the program
>
>library(KeyboardSimulator)
>setwd("C:/Users/JSparks/AppData/Roaming/Microsoft/Windows/Start
>Menu/Programs/Accessories")
>system2("Notepad",invisible=FALSE)
>mouse.move(2423,236)
>mouse.click()
>keybd.type_string("Hello world!")
>
>would do this, but it does not advance passed the system2 command.
>
>Best wishes,
>--JJS
>
>________________________________
>From: Jeff Newmiller <[hidden email]>
>Sent: Sunday, July 5, 2020 5:08 PM
>To: [hidden email] <[hidden email]>; Sparks, John
><[hidden email]>; R-help <[hidden email]>
>Subject: Re: [R] Opening Another Application in R Then Hangs
>
>Exit the application you started?
>
>On July 5, 2020 3:06:52 PM PDT, "Sparks, John" <[hidden email]> wrote:
>>Hi R Helpers,
>>
>>I am trying to open another application from within R and then work
>>with it.
>>
>>I can get the application to open, but R then hangs at that point
>>(spinning blue circle in the middle of the screen) and my subsequent
>>programming does not execute.
>>
>>Does anybody know how to get R to unlock?
>>
>>I am using Windows 10 and R4.0.
>>
>>The example below freezes R on my machine.
>>
>>Any guidance appreciated.  Thanks.
>>--John Sparks
>>
>>setwd("C:/Users/JSparks/AppData/Roaming/Microsoft/Windows/Start
>>Menu/Programs/Accessories")
>>system2("Notepad",invisible=FALSE)
>>
>>
>>
>>
>>
>>
>>       [[alternative HTML version deleted]]
>>
>>______________________________________________
>>[hidden email] mailing list -- To UNSUBSCRIBE and more, see
>>https://stat.ethz.ch/mailman/listinfo/r-help
>>PLEASE do read the posting guide
>>http://www.R-project.org/posting-guide.html
>>and provide commented, minimal, self-contained, reproducible code.
>
>--
>Sent from my phone. Please excuse my brevity.

--
Sent from my phone. Please excuse my brevity.

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Opening Another Application in R Then Hangs

Abby Spurdle
In reply to this post by Sparks, John James
shell ("Notepad", wait=FALSE)

On Mon, Jul 6, 2020 at 10:07 AM Sparks, John <[hidden email]> wrote:

>
> Hi R Helpers,
>
> I am trying to open another application from within R and then work with it.
>
> I can get the application to open, but R then hangs at that point (spinning blue circle in the middle of the screen) and my subsequent programming does not execute.
>
> Does anybody know how to get R to unlock?
>
> I am using Windows 10 and R4.0.
>
> The example below freezes R on my machine.
>
> Any guidance appreciated.  Thanks.
> --John Sparks
>
> setwd("C:/Users/JSparks/AppData/Roaming/Microsoft/Windows/Start Menu/Programs/Accessories")
> system2("Notepad",invisible=FALSE)
>
>
>
>
>
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Opening Another Application in R Then Hangs

Sparks, John James
For posterity, Abby's suggestion is spot on.

The small program below demonstrates the functionality.  May need to change numbers in mouse.move depending on where your copy of Notepad opens up.  You can find the position of your mouse on the screen using mouse.get_cursor()

Thanks to all, but especially to Abby.

--JJS


library(KeyboardSimulator)
setwd("C:/Users/JSparks/AppData/Roaming/Microsoft/Windows/Start Menu/Programs/Accessories")
shell ("Notepad", wait=FALSE)
Sys.sleep(3)
mouse.move(362,300)
mouse.click()
keybd.type_string("Hello world!")




________________________________
From: Abby Spurdle <[hidden email]>
Sent: Sunday, July 5, 2020 6:35 PM
To: Sparks, John <[hidden email]>
Cc: R-help <[hidden email]>
Subject: Re: [R] Opening Another Application in R Then Hangs

shell ("Notepad", wait=FALSE)

On Mon, Jul 6, 2020 at 10:07 AM Sparks, John <[hidden email]> wrote:

>
> Hi R Helpers,
>
> I am trying to open another application from within R and then work with it.
>
> I can get the application to open, but R then hangs at that point (spinning blue circle in the middle of the screen) and my subsequent programming does not execute.
>
> Does anybody know how to get R to unlock?
>
> I am using Windows 10 and R4.0.
>
> The example below freezes R on my machine.
>
> Any guidance appreciated.  Thanks.
> --John Sparks
>
> setwd("C:/Users/JSparks/AppData/Roaming/Microsoft/Windows/Start Menu/Programs/Accessories")
> system2("Notepad",invisible=FALSE)
>
>
>
>
>
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.