Obtain mouse position in OCTAVE - mouseevent

I am using OCTAVE on my PC for image processing and display. I am reading in a .pgl file and converting it from rgb to gray to obtain a simple 2D array. I then display this using imagesc(). What I'd like to do is use the mouse to click on a particular part of the image and return where the mouse was clicked in the array ((x,y) coordinates). I've tried using ginput() which I think should work if I understand the documentation correctly. But I can't get it to work. Usually I have to control C out once I type in [x,y] = ginput(1), for example, because the prompt never returns in my input window no matter how many mouse clicks I do in the display (or returns in the input window - I have to control C out). First is this do-able? or am I attempting something OCTAVE just can't do? If so, how?

This should work with ginput and the FLTK toolkit. What version of Octave are you using on which OS? To make sure you are using FLTK toolkit use
close all
graphics_toolkit fltk
at the beginning of your script.

The thing to remember with ginput() is that after clicking with the mouse in the plot window, you have to hit return key on the keyboard if the n parameter is not stated. After the return, the coordinates will be returned in the x,y vars. Also the button used to click will be returned when called with [x,y,buttons]=ginput(n). The 'n' argument controls the number of clicks to watch for before recording the coords. Works well in Octave 4.0.1.

Related

SAP GUI scripting - Button press fails

I am using a macro in an Excel file that runs the SAP GUI. There is a step where, when I click a button in SAP there will be another window that pops up.
For that I have written a code like this:
session.findbyid("wnd[0]/XX/btnXX").press
session.findbyid("wnd[1]/XX/btnXXX").press
There is a button (btnXXX) in the window (wnd[1]). But when I execute this query, I am getting an error object not found for findbyid.
When I keep the break point and execute it, it is throwing error on 2nd line in the above code. I try to pick the activewindow.name and it shows wnd[0] still. Here the issue is wnd[1] is not getting opened.
Does somebody know why the 2nd "button press" doesn't work?
You should be able to replace all mouse clicks with keyboard strokes.
Replace:
session.findbyid("wnd[0]/XX/btnXX").press
With:
session.findById("wnd[0]").sendVKey(N)
Where N is the linked hot-key ID.
To get the exact command, use SAP script recording and only use the keyboard to transition between views and windows. The easiest way to determine how is to hover your mouse over the buttons you would normally click to learn the hot-key then record the hot-key.
Note 1) So far I have found that btn[XX] always maps to sendVKey(XX), but I can't be certain this is always the case.
Note 2) sendVKey always appears to be referenced off the window (wnd[Y]) even if a button is another layer down (/tbar, /usr, etc.).

Sikuli click is not effect

I'm using SikulixIDE 1.1.0 to write a script playing Yugioh game (run on Windows 10 x64).
See the main screen:
I start the game manually and then run the script as below:
switchApp("Yu-Gi-Oh! PC")
click("1477213591920.png")
My expectation is that the link named "DUEL MODE" is clicked to go to the next screen. The cursor always moves to that link, but sometimes it works, sometimes does not.
I check the log and see that Sikuli has sent click command but for some reason, the game not accept it. This is the log:
[log] App.focus: [8020:Yu-Gi-Oh!]
[log] CLICK on L(687,488)#S(0)[0,0 1366x768]
I've already tried:
doubleClick instead of click
sleep a few seconds
hover and click
But all do not work, neither.
I would expect that some of the things you have tried will help but if that's not the case you will need to identify whether the button was actually triggered or not. To do that you have to capture the next screen or any part of it that uniquely identifies it. Then you will use it a loop with a predefined number of attempts and some wait time between them and click more than once if the click didn't work. So generally something like that (pseudo code):
attempts = 3
for attempt in attempts:
click(button)
if (nextScreen is available):
break
sleep(time)
I know it's been a while but I ran into a similar problem recently.
The image was found but the click didn't work.
I'm also working on Windows 10 x86_64.
The solution was simply to execute the program as administrator.
Don't know why but now it's working..
I also had to use the double click instead of simple click for some patterns.
In adition to Eugene S Answers, if you are using SikuliX, you can try to Run in Slow Motion. Also, if the image have some effects (like brightness), you can try to use Pattern inside of exists():
if exists(Pattern("DualMode.png").similar(0.6), time_in_seconds):
click(Pattern("DualMode.png").similar(0.6))
By default, the similar() value is 0.8, so if the image have some effect and for example, the color change every second, you can set a lower value between 0 and 1.
PS: Don't forget to put the pattern inside if exists and click, because if you don't put inside of click(), could throw an Image not found error message.

Passing taps to the filter using file in gnuradio

I'm trying to pass 2000 taps to the fft filter in gnuradio. How can i read file and pass it to the fft filter tap filed?
This cannot be done. However you can use the Filter Taps variables available in the GRC to produce the desired taps at the initialization of your flowgraph. Pass the ID of the variable at the taps field of your FFT filter block and you are done.
If your taps are very specific and cannot be constructed from the available filter taps variable, you could possibly edit the generated python file and use a python array to store them.
EDIT: As #Marcus noted you can use numpy to load taps from a file. Just use the Import element from the GRC to import numpy and then using a Variable element, use numpy.fromfile('filename') to load the desired taps.
I had good luck with this:
in Matlab create your vector of taps
if h is your vector with the taps, print them to a file with these instructions:
fileID = fopen('filter_taps.txt', 'w');`
fprintf(fileID, '[%5.3f]+', h);
fclose(fileID);
open the text file with a simple text editor and remove the last "+"
Now, go over to the gnuradio-companion and open an Interpolating FIR filter block
highlight and copy the taps from your text file [0.00]+[0.01]+... etc (I used control+c)
in the "taps" field of the GRC FIR block, paste the taps (I used control+v)
Disclosure: I run Matlab on my Windows laptop, and I run GRC on my Linux (Ubuntu) laptop.

Check if software keyboard is open in Windows Phone 8?

I want to check if the software keyboard is open in Windows Phone 8. I have found some sparse information that this is possible using CoreWindow.IsKeyboardInputEnabled, but I can't find any way to implement this. I have found sample code only for C++, which I don't understand at all.
I use VB, however I can read C# enough to figure it out if I can get a C# example.
Whatever I do I always get a null/nothing value. The following code compiles and runs, but c is 'nothing' when the app crashes at the if c.IsKeyboarInputEnabled... line.
Dim c as CoreWindow
c = CoreWindow.GetForCurrentThread
if c.IsKeyboardInputEnabled then...
I know I need to give 'c' a value, but can't figure out how. I've also tried:
Dim c as CoreWindow = New CoreWindow
which the editor flags as an error and thus won't compile.
If it's relevant, what I am trying to do is ensure my navigation is consistent. Currently, a tap on a particular screen element should close that element. However, if the keyboard is open, I want that tap to simply close the keyboard and leave the tapped item open. I believe this is the more intuitive and consistent approach for the user.
I think the only way to achieve this functionality is to know if the keyboard is open before determining what to do with any open panels.
e.g.
[when screen tapped and a popup is expanded]
If [keyboard visible] then [close keyboard] else [close tapped item]
I don't think there is any official API to detect the opening and closing of the SIP but one workaround might be to check if any of your TextBoxes have focus.
You can do this by overriding GetFocus and LostFocus for each TextBox.
To close keyboard, just set the focus to the ContentPanel(or any other grid).
Let me know if this works.

How to simulate mouse clicks?

I was wondering how to create a sort of auto clicker using VB.NET.
I would basicly have the click coordinates pre-defined and the clicks, which would have to be separated by delays I guess since I want more than one to happen periodically, would happen outside of the application window (I read this envolves extra system hooks?).
The only code I have been able to find is related to clicks on the application window, which is not what I am looking for.
In short: I want to click a button on the app window, which would initiate a number of clicks on certain pre-defined screen coordinates.
Thanks in advance :)
See this discussion on social.msdn: Simulate a mouse click in a program.
Uses winapi: SetCursorPos, GetCursorPos and mouse_event.
I believe you need to P/Invoke into Windows to accomplish this.
Have a look at the SendInput function.
If you are using automate the program,that program have some tabindex in order to relevant control.then you can use;
SendKeys.Send("{TAB}");
SendKeys.Send("{ENTER}");
it is more accurate on desktop application