I want to the following script work like this: I press number 7 on the numpad and it shows me coordinates of some red pixel in the current window.
#SingleInstance force
Numpad7::
{
PixelSearch Px, Py, 0, 0, 300, 250, 0x241ced
MsgBox %Px% %Py%
return
}
Tested in mspaint with a red dot in the upper-left corner on Windows 8.1
After pressing key 7 it doesn't do anything - after right-clicking on its taskbar icon nothing is displayed. When running the script again, the prompt "Could not close the previous instance of this script, keep waiting?" is displayed.
Probably some infinite loop, I need to kill the ahk process.
Any ideas how to make such a simple task work?
However, this script does work without any problem on my windows 7 machine.
I tried to add one additional parameter - fast mode
changed
PixelSearch Px, Py, 0, 0, 300, 250, 0x241ced
to:
PixelSearch Px, Py, 0, 0, 300, 250, 0x241ced , , fast
Now it works on my Windows 8.1 machine, too.
Related
I am trying to get the color of a pixel on my screen using node.js. I want it to be returned in RGB format, e.g. (255, 0, 0). My current solution is to use screenshot-desktop to screenshot my entire screen in JPG format, decode it to get the raw pixel data, and get the color of a given pixel. However, this lags out my entire computer for 1-2 seconds as it is taking the screenshot. This is unusable as I would like to do this multiple times per second. So my question is: How can I get the color of a given pixel on the screen, without taking a full screenshot?
I am using Linux with X11. There is an X11 library for node.js, so I asssume I should use that to get the pixel color, I'm just not sure how. If you could show me how to do it in C then I can easily use node.js to do the same thing.
Thanks!
Oh my gosh I just figured it out after posting this. I was using robotjs for reading the mouse position and I totally forgot it can do screen stuff too! So, the solution would be to do
var robot = require('robotjs');
var color = robot.getPixelColor(x, y);
X11 solution using x11 node library ( I am the author ):
query windows tree with QueryTree starting at the root window
get every child geometry using GetGeometry request
if your point is not inside any child, use current window id and get 1x1 pixmap from the current image: GetImage(format, currentWindow, x, y, 1, 1, planeMask) ( 2 for format and 0xffffffff for plane mask should work ). Make sure you calculate relative x y position as you travers windows tree.
if child window covers your point query children for that window and repeat again. Note that QueryTree returns windows in bottom to top stacking order so make sure you pick last one covering your point
Once you have 1x1 pixmap from the topmost window under your point - the buffer should contain only color bytes for your image, RGB order and bit mask might depend on red_mask, green_mask, blue_mask from display.screen[0].depths[visual].
If you cache "topmost window" between requests and only start from root when no match anymore the above solution might be much more performant then the one using robotjs ( although much more low level and complicated ) Good luck!
EDIT: Resolved by updating phaser from 2.4.0 to 2.4.6
I want a repeating background, so I tried to use a tile sprite of a 40x40 image. It works and scrolls fine aside from the green lines:
This is the code I'm using for it:
this.background = this.add.tileSprite(0, 0, this.game.world.width, this.game.world.height, 'space');
this.background.autoScroll(0, 30);
How do I get rid of those and the padding to the right and bottom of it?
I'm playing about with the most recent NSDocument in a Swift document-based-app. One thing that's a bit odd is that the starting location for a new window is near the bottom of the screen.
Playing with the Storyboard a bit, its not clear how to use the built-in settings to come up with a reasonable "near the top" selection - the setting moves up from the bottom, not down from the top, so the position would change depending on the screen size?
I assume there's a position mechanism I can hook, but it's not obvious in the shell code that's supplied. Any hints?
OS X coordinate system is flipped in contrast to iOS. So the 0,0 is the bottom left corner.
You can calculate the position of your window in similar manner (any screen size)
CGFloat width = NSWidth([self.window screen].frame);
CGFloat height = NSHeight([self.window screen].frame);
[self.window setFrame:NSMakeRect(100, height - 100, width, height) display:YES];
Most easiest is to set initial height to 900 and forget about it and enable window restoration -> this will cause to open the window where it previously was and this is where it user wants.
Select your window in Storyboard. And fill initial position coordinates
Is it possible to programmatically set the cursor position out of the current resolution?
OS: Ubuntu 14
Window manager: Compiz
Resolution: 1920 * 1080
XWarpPointer(display, None, None, 0, 0, 0, 0, 0, 1090);
The code above can only move cursor to the bottom edge.
XWarpPointer has at least one documented limitation (which may affect your program):
Note that you cannot use XWarpPointer() to move the pointer outside the confine_to window of an active pointer grab. An attempt to do so will only move the pointer as far as the closest edge of the confine_to window.
The likely reason for wanting to move the pointer off-screen is to hide it. An X application can define a cursor using XDefineCursor (which is used for displaying the pointer), and hide that. This is for a given window, of course.
xterm does that, for instance, since patch #230 ("hide the mouse pointer while user is typing").
Here are a few links using or discussing the technique:
LinuxMouse.cpp, source-code
Platform_Linux.cpp, source-code
How to hide the mouse pointer?, discussion on comp.windows.x
The Cursor, a set of slides for a class
Basic Graphics Programming With The Xlib Library - Part II
Looking through a few questions and answers i still am unable to find out what is wrong...
local myTextObject = display.newText( "Hello World!", 160, 240, "Arial", 60 )
This line of code - directly from the Corona Docs Guide is not displaying any text within my simulator. trying to figure out the problem i created a blank project and copy pasted this code and still nothing happens despite it being the only thing within the file.
Checking through iv used differnt fonts, used differnt methods of handling the string and still nothing will appear within the Corona Simulator - Even updating the SDK still doesnt solve this issue.
What am i doing wrong :S
thanks
local myText = display.newText( "Hello World!", 100, 200, native.systemFont, 16 )
myText:setFillColor( 1, 0, 0 )
Paste this code in the main.lua. Try this out it must work for sure.
Have you tried changing the font color?
text:setFillColor (200/255,0/255,2/255)
You said that you create a blank project so, Im expecting it as a black background, and creating text without changing the font color will make it look that it doesn't show any text