I'm trying to implement a basic window manager using xcb library.
I managed to connect with X server, and grab some events, but i cannot figure how to launch an application and show it inside the current X session.
I'm trying to follow the xcb tutorial:
http://xcb.freedesktop.org/tutorial/
Basically i thought (and probaly i'm wrong) that once the session is started, with my "windowmanager", if i want to launch an application i just have to fork it, and launch the application, so for example:
int child = fork();
if(child==0) {
printf("Child");
execve("/usr/bin/xterm", NULL, NULL);
}
But it seems that didn't work.
I have no much code to show, since i'm trying just to modify che code in the tutorial pasted above (i added an infinite loop, and few other thing).
So how to launch an x application like xterm, pcmanfm and show it on the current x session?
And how i can draw an application inside a new window?
And a last question:
i tried to copy and paste the hello world window example of X tutorial, but it doesn't seem to load any window. The code is here:
http://www.x.org/releases/X11R7.7/doc/libxcb/tutorial/index.html#helloworld
You don't "draw an application inside a new window" - you just launch a process and it creates a window for itself. Check that DISPLAY variable is set correctly for your process.
To manage windows, you set SubstructureRedirect mask on a root window and respond to substructure/map request notifications from (new) application windows.
Related
I am writing a vignette for my Shiny application package. At the beginning of my vignette, I source a file called screenshots.R that produces nice screenshots of my application. I am producing them like so:
webshot::appshot(mypackage::run_datepicker_app(),
file = "man/figures/datepicker.png", vwidth = 500, vheight = 200)
This works great and it gives me a great screenshot of what is - in this case - a couple dateInput fields. However, I'd like to be able to get a screenshot of the dateInput in use (say, with the calendar selection exposed).
Is there a way to issue commands to the application object in a script so I can get screenshots of the application in use, rather than having to do it manually?
Have you tried using ShinyDriver from the shinytest package?
You can use shinytest to have a headless browser run the app, interact with it, and take screenshots programmatically. If you don't have phantomJS installed, you'll need to run shinytest::installDependencies() before using ShinyDriver. All you need to do is point it to a directory containing a shiny app (in my case, the folder is 'myApp').
install.packages("shinytest")
shinytest::installDependencies()
app <- shinytest::ShinyDriver$new("myApp")
app$takeScreenshot("screenshot1.png")
button <- app$findElement("#button")
button$click()
Sys.sleep(1)
app$takeScreenshot("screenshot2.png")
app$stop()
I am starting the app in a headless browser, taking a screenshot, finding the button with the id 'button', clicking it, and taking another screenshot, then closing the app. Navigate to specific elements using "#id", where id is just the id you gave the shiny input. You can specify a file path to a png file in the takeScreenshot calls, so that you can then use them in your code elsewhere. Note that you may need to use Sys.sleep to stop the screenshots from being taken before the UI updates.
I use this code to convert a video with xuggler:
http://www.jochenhebbrecht.be/site/2010-10-12/java/converting-resizing-videos-in-java-xuggler
The convertion works fine and the line:
reader.addListener(ToolFactory.makeViewer(true));
let me view two windows with video and statistics.The problem is, after converting the windows don't close automatically and I don't know how to do it.
I changed the above line into
IMediaListener imL=ToolFactory.makeViewer(IMediaViewer.Mode.FAST_VIDEO_ONLY,true);
reader.addListener(imL);
and after the while I insert
reader.removeListener(imL);
reader.close();
But the windows don't disappear after converting/ task finished.So I want to know how I can get access to this windows to achieve a simple stage.close().
EDIT: I'm using Java 8
EDIT2:
I now tried
StageHelper.getStages().size(); //-> 1
and
Iterator<Window> windows=Window.impl_getWindows();
String window_String="";
while(windows.hasNext()){
window_String+=" |-> "+
}
System.out.println("WINDOWS: ---->"+Window.impl_getWindows());
Both shows that there is just ONE window.It seems, that the windows from
"reader.addListener(ToolFactory.makeViewer(true));" are not in the list.
The Problem is that Xuggler uses Swing and not JavaFX so Window.impl_getWindows() and StageHelper.getStages() wont return the windows that are create with ToolFactory.makeViewer(true).
So the correct way is java.awt.Window.getWindows().
This error message keeps showing everytime I test the game:
NullReferenceException: Object reference not set to an instance of an object
SetupLocalPlayer.Start () (at Assets/Scripts/SetupLocalPlayer.cs:12)
and I'm trying to figure out how to enable my Wheeldrive script when I am the local player (When I spawn in) and it doesn't seem to be working, The Network Id is on the player prefab but the controller script is on the Sedan gameobject, since the Network identity is on the player prefab the disable script also has to go on it, so I don't think the script is able to find the controller script since its not on the same Gameobject. (Picture Below)
Any help is really appreciated :)
The Project + Code Picture
If the SetupLocalPlayer script is on the player prefab, You should be able to find the WheelDrive component using GetComponentInChildren<WheelDrive>() instead of GetComponent<WheelDrive>() (in line 12 of the SetupLocalPlayer.cs file)
Because the WheelDrive component is not enabled, GetComponent is unable to find it. Thus GetComponent<WheelDrive>() returns null, and you get the error in the console.
I've been working with RSelenium all day and still hitting road blocks here and there. My current issue is using the code WebElemReports$clickElement() which clicks a link and a new window opens. I tried to adjust Firefox settings in "about:config" so that it will not open a new window. It doesn't open a window in normal use, but using RSelenium, it opens a new window still. I also looked at this approach but couldn't follow the logic of how it worked:
How to clickElement() and open the link in the same tab
My next thought process was to use the switchToWindow() function along with getWindowHandles(). The code I wrote is as follows:
remDr$closeWindow()
windHand <- remDr$getWindowHandles()
remDr$switchToWindow(windHand)
My thinking is that I will close the current window so that there will only be one handle to reference and pass that handle to the switchToWindow function. I can't find much switchToWindow documentation for R. I receive the following error with using the code above:
Error: Summary: UnknownError
Detail: An unknown server-side error occurred while processing the command.
class: org.openqa.selenium.WebDriverException
Any help on this would be much appreciated--I tried to research this as much as possible so this won't get marked as a duplicate question like my last post. Many Thanks.
Actually you can't close main window, you can switch to child window as below :-
# get main window and store to switch back
currWindow <- remDr$getCurrentWindowHandle()
#gel all windows
windows <- remDr$getWindowHandles()
#loop through switching child window
for (window in windows[[1]]) {
if (window != currWindow[[1]])
remDr$switchToWindow(window)
}
#now do your stuff with child window
#now close your child window after doing all stuff
remDr$closeWindow()
#now switch back to main window for further stuff
remDr$switchToWindow(currWindow[[1]])
I wish to simulate a right click on a file. This is done by opening a Windows Explorer window and then right clicking on it.
The main issue is finding the location of the file in Windows Explorer. I am currently using Autoit v3.3.8.1.
My code 's first line:
RunWait (EXPLORER.EXE /n,/e,/select,<filepath>)
The next step is the problem. Finding the coordinates of the file.
After that, right clicking at that coordinates (it seems to me at this time) is not a problem....
Some background:
OS: Windows 7 64-bit
Software Languages: C#, Autoit (for scripting)
The Autoit script is called by a code similar to that below:
Process p = new Process();
p.StartInfo.FileName = "AutoItScript.exe";
p.StartInfo.UseShellExecute = false;
p.Start();
The code is compiled into a console class file which is run at startup. The autoit script runs as the explorer window opens up.
It seems as though you are taking the wrong approach to the problem, so I'll answer what you are asking and what you should be asking.
First up though, that line of code is not valid, and is not what you want either. You want to automate the explorer window, and RunWait waits for the program to finish. Furthermore you want those items to be strings, that code would never work.
Finding the item in explorer
The explorer window is just a listview, and so you can use normal listview messages to find the coordinates of an item. This is done most simply by AutoIt's GUIListView library:
#include<GUIListView.au3>
Local $filepath = "D:\test.txt"
Local $iPid = Run("explorer.exe /n,/e,/select," & $filepath)
ProcessWait($iPid)
Sleep(1000)
Local $hList = ControlGetHandle("[CLASS:CabinetWClass]", "", "[CLASS:SysListView32; INSTANCE:1]")
Local $aClient = WinGetPos($hList)
Local $aPos = _GUICtrlListView_GetItemPosition($hList, _GUICtrlListView_GetSelectedIndices($hList))
MouseClick("Right", $aClient[0] + $aPos[0] + 4, $aClient[1] + $aPos[1] + 4)
As has already been mentioned, sending the menu key is definitely a better way than having to move the mouse.
Executing a subitem directly
This is how it should be done. Ideally you should never need an explorer window open at all, and everything can be automated in the background. This should always be what you aim to achieve, as AutoIt is more than capable in most cases. It all depends on what item you want to click. If it is one of the first few items for opening the file in various programs, then it is as simple as either:
Using ShellExecute, setting the verb parameter to whatever it is you want to do.
Checking the registry to find the exact command line used by the program. For this you will need to look under HKCR\.ext where ext is the file extension, the default value will be the name of another key in HKCR which has the actions and icon associated with the filetype. This is pretty well documented online, so google it.
If the action is not one of the program actions (so is built into explorer) then it is a little more complex. Usually the best way will be to look at task manager when you start the program and see what it runs. Other things can be found online, for example (un)zipping. Actions like copy, delete, rename, create shortcut, send to... They can all be done directly from AutoIt with the various File* functions.
With more information, it would be possible to give you more specific help.
First, you might want to look at the Microsoft Active Accessibility SDK. In particular look at this interface...
http://msdn.microsoft.com/en-us/library/accessibility.iaccessible.aspx
You can use this to walk the items in the control and find the one with the file name you are looking for and its screen location.
From there, maybe try something like this for simulating the right click.
How can I use automation to right-click with a mouse in Windows 7?
Once you have done the right click, use accessibility again to find the right option on the context menu.
Maybe there's an easier way, you should be able to cobble something together like this if you don't find one. Good luck!
Suppose I have a file named test.txt on D drive. It needs to right click for opening Context Menu. To do this, the following code should work:
Local $filepath = "D:\test.txt"
Local $iPid = Run("explorer.exe /n,/e,/select," & $filepath)
ProcessWait($iPid)
Sleep(1000)
Send('+{F10}')