How do I receive user input for a dungeon crawler? - input

So, I am planning on designing a dungeon crawler (like Nethack), and I was wondering how I could get the user's input for moving the player. I originally planned to get a character input (W,S,A, or D) and then when the user presses enter, the movement takes place.
However, now I'd like to implement this without the mandatory enter press, so that merely pressing W would move the player forward by one space. I don't really need syntactically correct code, just pseudo-code of a concept would suffice.

Related

An extension for Apple's Look Up

I am learning French. Every time I use the Force Click on my Mac on a word I don't know, I get a dictionary entry and a translation to English.
But when I want to translate a whole sentence, I have to open Google Translate to do so. (1. Open Google Translate. 2. Copy sentence 3. Paste Sentence) It is pretty annoying to do that 20-30 times a day.
So is there a way to expand the capabilities of Force Click in Safari (or in the best case, in every application which allows "Look Up")?
Let me worry about how I can translate the sentences.
I am open for any kind of creative solution.
Here is the standard pop-up when I force touch
I don't think there is a documented way to achieve this on a force click, but you may want to look at Services.
Basically, you can create an application that provides a service, select some text, and then choose your application's Service menu item from the Services submenu in your Application Name menu (the one in bold where "Hide" etc. are).
The service will then receive a copy of the selection (in an NSPasteboard) and can do whatever it wants with that, or even change it.

How to test google search box (software testing)

Today I got this from an interviewer. I am not sure if anyone cell tell me what should be the right way. Thanks
Below is the question
Consider www.google.com's search box and the Google Search button.
Q: How would you test this functionality?
How would you design test automation for 1) above?
When you're testing something, you want to find the points where the function, webpage, application, etc. break. It's unlikely that the interviewer is asking you to test search box portion of the Google homepage itself, as that is fairly simple (it's little more than a text input and a couple submit inputs inside a form), but rather find potential edge cases in the code which takes that input and produces the search results.
So, consider edge cases for a text input and a submit button in a form using a GET action:
What happens if you submit the form with no input?
What happens if you submit the form with too much input? (Both server and browser may impose limits on the URL generated by the GET, and those limits may be different.)
What happens if you include characters which have special meaning in a GET query string such as & and =?
What happens if you circumvent the page entirely, creating a different <form> which submits to the same page as Google's search box? What if you do this with some input values missing?

How Can I Find Value is Come From Keyboard or Barcoder Reader in VB.NET

I have a Windows Application in VB.NET. I want to know if a value is entered by a user via the keyboard, or if it is coming from a barcode reader. I want to store values that come from
the keyboard in a different database than the ones the come from the barcode reader.
Option 1:
Get a barcode-scanner that is connected to a serial-port (raw serial device read by a COM port). As most barcode-scanners emulate keyboard strokes there is no way to directly distinguish a barcode scanner input from a keyboard input (see next option) without going low-level (see last update).
One connected to a serial port (or emulated one via USB as serial-ports are not so common anymore) gives you full control on where the input comes from.
Option 2:
Count number of chars typed by time. Barcode-scanners inject a sequence (line) pretty fast compared to typing. Measuring the time used in the textbox by counting key-presses (use CR+LF as a measure point as these are sent by the scanner as well) can give you one method to distinguish if a human is typing (unless there is one typing fast as f) or the content was injected. If timed-out just reject/clear the input.
In addition the checksum of the barcode (if you use one that contains that) can be used to do an extra validation in addition to time measurement.
(you can detect pasting by overriding the ctrl + v as in the next option).
Option 3:
Combine option 2 but instead of measure in the textbox tap into the ProcessCmdKey() function (by overriding it) and measure there if textbox has focus. This way you can first buffer input, measure time and if within a set time-out value, inject the line into the textbox.
Option 4:
This might be a good option as well:
http://nicholas.piasecki.name/blog/2009/02/distinguishing-barcode-scanners-from-the-keyboard-in-winforms/
Option 5: a non-technical approach -
Usability improvements: make it visually very clear that bar-codes must be entered with a scanner and not typed. I am including as an option as it is simple and if made correct also effective (there's no right answer of what is correct unfortunately).
Approached could include f.ex. a watermark in the textbox ("Don't type, scan!" or something in that order). Give it a different color, border, size etc. to distinguish it from normal textboxes, and have a help text associated and available at all time that improves clarity.

Windows Tablet on-screen keyboard covers most of share target window

I'm writing a Windows Store App. It is a share target that allows the user to update product photos that are used in the main application. When the user shares a photo from another app, and chooses my app as the target, it allows the user to select the products that they want to update, displays both the old photo and the new photo that was shared, then gives the user the option to replace the photo. The process of finding the product to update involves the user entering text in a TextBox.
There are a couple of problems. First, it seems that the page that I get to work with when used as a share target is only a flyout, not the full screen. So, right off the bat, I only have less than half the screen to work with (the left half).
The other problem is that the tablet's on screen keyboard immediately comes up and covers the lower half of the screen because the TextBox has focus. So now, only the upper left quarter of the screen is visible, which gives me very little real estate to work with.
Is this just a normal thing that I have to deal with, and does everyone just design their share target window to use only that tiny amount of space? Or does anyone have any other solutions?
Nothing prevents you from handling the presentation of the soft keyboard.
Windows.UI.ViewManagement.InputPane
.GetForCurrentView().Showing += (s, e) => { /* do something */ };
Moreover, nothing prevents you from adjusting your UI to account for the height of the soft keyboard so your UI remains completely usable.
var _KeyboardHeight = (int)e.OccludedRect.Height;
I know you would prefer this be handled by the operating system. It's not. I am sorry about that. It is what it is. At least we can account for it.
Best of luck!

Copy text to an external program, click somewhere on the screen, then save a screenshot

I picked vb.net for this question since it's the only prgramming language I am fairly familair with, but if C++ or something else is more suited for this, I am willing to learn something new.
What I am trying to do is:
Retrieve text from database (this already works in vb.net) and copy it to clipboard
Switch primary screen to the external application I want to work with (example: word or open office)
Emulate key-press Enter
Paste text and hit Enter again
Emulate key-press Ctrl and then emulate a click on a pre-defined spot on the screen (like 500pixels from left, 740pixels from top).
Save screenshot, using a second value from the database as the filename (the naming part should be easy)
Emulate another click on another pre-defined spot
Repeat for next text in database.
I wouldn't know where to start, though. I guess the most important part of what I'm trying to achieve is; switching focus to an external application and emulate keypresses and mouse clicks on it.
use http://www.autohotkey.com/
write a console app to get the value from the database
1 - get autohotkey to run the console app and put the return into the clipboard
then continue as described in your list.