12345...10...


UI Events KeyboardEvent code Values – World Wide Web …

1. Introduction

This document provides an overview of the various keyboard layouts andspecifies the KeyboardEvent.code values that should beused for each of the keys. Unlike the key values describedin [UIEvents-key], the code values are based only on thekeys physical location on the keyboard and do not vary based on the userscurrent locale.

This specification was formerly titled DOM Level 3 KeyboardEvent code Values.

This specification uses the following conventions:

This section is non-normative.

Alphanumeric keyboards are the most common way for users to generatekeyboard events. This section provides an overview of standard keyboards andtheir physical layouts.

This section describes the physical layouts found on commonly availablekeyboards.

When discussing keyboard layouts, it is convenient to divide thestandard keyboard into distinct sections and to label each row.

These keyboard sections are:

The alphanumeric section is the main part of thekeyboard and is where most of the keyboard variation occurs.When a user selects a keyboard layout, it is the keys in thissections that are most affected.

The control pad and arrow pad sections contain the arrow keys and other editing keys.

The numpad (also known as the “numeric keypad”or “number pad”) contains number and math keys to make it easierto enter numeric data.

And finally, the function section containsmiscellaneous function keys and special keys like Escape.

To make it easier to identify keys, the rows on the keyboard arenamed starting with “A” for the bottom row up to “E” for the toprow. The row of keys in the function section are considered to be inrow “K”. These row names are consistent with those given in [ISO9995-1].

Note that many keyboards (both modern and legacy) have extra keysthat do not fit neatly into the above sections. Some of these keysare covered in 3.1.6 Media Keys.

The standard “101” keyboard (commonly referred to as the “USlayout”) is the only layout that has a “Backslash” key (labeled |) above a single-row Enter key. All the otherlayouts omit this key and expand the Enter key tooccupy two-rows.

Modern standard “101”-layout keyboards actually contain 104 keys: 61keys in the alphanumeric section and 43 keys in the numpad, control pad, arrow pad and function sections.The “101” name for this keyboard layout dates to thetime when this standard keyboard did in fact contain 101 keys. Thetwo Meta keys (commonly given an OS-specific label), and the Menu key were added later to bring the total to 104 keys.

The alternate “101” keyboard has a large Enter key andshrinks the Backspace key to make room for the “IntlYen” key (which replaces the “Backslash” key found in the standard101 layout). The “IntlYen” name comes from the Japanese layoutwhere this is the (yen) key in the Russianlayout shown below this key maps to a /.

Modern alternate “101”-layout keyboards contain 104 keys: 61 keys inthe alphanumeric section and 43 keys in the numpad, control pad, arrow pad and function sections.

The standard “102” keyboard is common throughout Europe and adds akey that doesnt exist on the “101” layouts: The “IntlBackslash” key (labelled | on a UK keyboard) next to the left shiftkey.

A second key is also added (labelled #~ on a UKkeyboard) which is partially tucked under the Enter key.This key is encoded as “Backslash”, using the same code as the | key found on the “101” keyboard layout.According to [USB-HID], the US | and UK #~ areactually two separate keys (named “Keyboard and |” and “KeyboardNon-US # and ~”), but since these two keys never co-occur on thesame keyboard most platforms use the same scancode for both keys,making them difficult to distinguish. It is for this reason that thecode “Backslash” is used for both of these keys.

Modern “102”-layout keyboards contain 105 keys: 62 keys in the alphanumeric section and 43 keys in the numpad, control pad, arrow pad and function sections.

The Korean “103” keyboard is based on the alternate 101 layout andadds two additional keys (one on each side of the spacebar) tohandle Korean-specific input modes. These keys are “Lang2” (“Hanja”, labelled hanja)and “Lang1” (“HangulMode”, labelled / han/yeong).

Modern “103”-layout keyboards contain 106 keys: 63 keys in the alphanumeric section and 43 keys in the numpad, control pad, arrow pad and function sections.

The “104” layout used in Brazil adds 4 new keys: two keysfrom the “102” layout (“Backslash” and “IntlBackslash”) plusthe “IntlRo” key (next to the right shift key) and an extra keyon the numpad. This new numpad key is called “NumpadComma” because it represents the thousands separator. Onthe Brazilian key layout, this key is labelled . and the “NumpadDecimal” key is labelled ,.

Modern “104”-layout keyboards contain 107 keys: 63 keys in the alphanumeric section and 44 keys in the numpad, control pad, arrow pad and function sections.Some Brazilian keyboards lack the extra numpad key and haveonly 106 keys.

The Japanese “106” keyboard layout adds 3 new keys: “IntlYen” (labelled _), “Backslash” (labelled ])and “IntlRo” (labelled ).It also shrinks the spacebar to make room for 3 input mode keys: “NonConvert” (labelled muhenkan), “Convert” (labelled henkan)and “KanaMode” (labelled // katakana/hiragana/romaji).

Modern “106”-layout keyboards contain 109 keys: 66 keys in the alphanumeric section and 43 keys in the numpad, control pad, arrow pad and function sections.

In general, Apple keyboards follow the same layout as PC keyboards,but there are some differences as noted in the following figure.

In this figure, the green keys are those that have been moved to anew location while the blue keys indicate keys that have been added.

The limited space available on laptop keyboards often means that thephysical key layout needs to be adjusted to fit all the requiredkeys. The writing system keys in the alphanumericsection tend to remain intact, but the other keyboard sectionsare usually combined with other keys or removed altogether.

In this Apple laptop keyboard, the right control key has beenremoved to make room for half-height arrow keys and a Fn keyis added on the left.

PC laptop keyboards vary considerably, but this sample keyboarddemonstrates some commonly found aspects. The control pad keys are added along the right-hand side with the arrow pad keys tucked in along the bottom. The right Shift key isoften shrunk to make room for the up arrow key and the right Meta key is typically removed altogether.

In the case where a content author wishes to rely on the mechanicallayout of a mobile keypad, this specification suggests the keyboardconfiguration specified in [ISO9995-8], which defines a numeric keypadlayout and secondary assignment of Unicode characters in the range U+0061 … U+007A (“a” – “z”) to the number keys 2 through 9, as a common layout appropriate to someinternational uses.

This keypad layout, and in particular the distribution of letters is forEnglish devices, and will not match the keypads or configurations ofmany users. Content authors cannot rely upon any particularconfiguration, and are expected to create content in aninternationalized and localizable manner.

Many keyboards contain special keys to control media functions.Increasingly, many media devices, especially televisions, areWeb-enabled. Hybrid keyboard/remote-control devices are becoming morecommon. To meet the needs of these hybrid Web/media devices, thisspecification defines keys that are common as remote control buttons, inaddition to traditional keyboard keys.

Because of the smaller form factor, keys (or buttons) on a remotecontrol will often be modal, with one key performing different functionsbased on the context of the on-screen content. Additionally, many keysserve as toggles, to change back and forth between two or more states(see toggling keys). These remote control buttons typically do not havemodifier states so each button is assigned a single function (like Play, Pause, Up, Menu or Exit).

Virtual keyboards are software-based sets of keys, in a variety ofdifferent arrangements, commonly found on touch-screen devices. They areoften modal, with the ability to switch between different dynamic setsof keys, such as alphabetic, numeric, or symbolic keys. Because of thelack of physical constraints, these keyboards MAY present the widestrange of characters, including emoticons and other symbols. Wherever possible,however, virtual keyboards SHOULD produce the normal range of keyboard eventsand values, for ease of authoring and compatibility with existing content.

Chording keyboards, also known as chorded keysets or chord keyboards, arekey input devices which produce values by pressing several keys incombination or sequence, normally to simulate a full range of charactersor commands on a reduced set of keys, often for single-handed use.Achording keyboard MAY have additional mode keys to switch between keyvalues, and the number and type of keys pressed to produce a key valuewill vary, but the final key values produced by such keyboards SHOULDmatch the range of key values described in this specification.

For these and other alternative modal keyboards, the key values “Alphanumeric”, “CapsLock”, “NumLock”,and “SymbolLock” are RECOMMENDED for the keys which switch between different modes.

A key code attribute value is any of the values given in the=KeyboardEvent.code= column of any of the tables in this section of thespecification.

A conforming implementation of the KeyboardEvent interface MUST supportthis set of values for use in the code attributes,although not all values MAY be available on all platforms or devices.

This section defines a list of code values whichimplementations MUST support.

Future versions of this specification MAY include code values not includedhere, which have become common since the publication of this specification.

Note: While every attempt has been made to make this list of values as complete as possible,new values will periodically need to be defined as new input devices are introduced.Rather than allowing user agents to define their own key code attribute values (which are unlikely to be consistent across multiple user agents), bugs SHOULD befiled so that this specification can be updated.

This section describes the various keyboard sections in more detail anddefines the code values that should be used for eachkey.

The alphanumeric section is the main section of the keyboard. Itcontains keys that fall into two generalcategories: writing system keys whose meaningchanges based on the current keyboard layout, and functional keys which are (mostly) the same for alllayouts.

The writing system keys are those that changemeaning (i.e., they produce different key values) based on the current locale and keyboard layout.

This figure shows a hypothetical keyboard that combines all the writing system keys (shown in blue and green) found on thevarious keyboards. Blue keys are present on all standardkeyboards while green keys are only available on some keyboards.

The name shown on each key is the code assigned to that key. Wherever possible, the code names are based on the name for the USkey in that position (i.e., they are based on the US keyboardlayout). For keys that dont exist on the US keyboard, namesfrom the UK or Japanese layouts are used instead.

Note that there are two “Backslash” keys in this figure: alarge one at the end of Row D on the 101-key layout, and asmaller one between “Quote” and “Enter” on Row C of the102-, 104- and 106-key layouts. Only one “Backslash” keymay be present on a keyboard layout.

The functional keys (not to be confused with the function keys described later) are those keys in the alphanumeric section that provide general editingfunctions that are common to all locales (like Shift, Tab, Enter and Backspace). With a fewexceptions, these keys do not change meaning based on thecurrent keyboard layout.

The “AltRight” key (highlighted in green) is the only functional key that does not generate the same key value for every locale. In some locales itproduces “Alt” while in others it produces “AltGraph”.

On some keyboards (notably Japanese and Korean) the spacebar isreduced in size to make room for extra keys on the bottom row (Row A).These keys typically allow the users to change the current inputmode. Note that even though some of these Japanese and Koreankeys occupy the same physical location on the keyboard, they usedifferent code values.

On Apple keyboards, some keys on the bottom row are omitted andothers are arranged in a different order.

The control pad section of the keyboard is the set of (usually 6) keysthat perform navigating and editing operations, for example, Home, PageUp and Insert.

The code for the Fn key (found on someApple keyboards) is defined below in the function section.

The arrow pad contains the 4 arrow keys. The keys are commonlyarranged in an “upside-down T” configuration.

The numpad section is the set of keys on the keyboard arranged ina grid like a calculator or mobile phone. This section contains numeric andmathematical operator keys. Often this section will contain a NumLock key which causes the keys to switch between the standard numeric functionsand mimicking the keys of the control pad and arrow pad.Laptop computers and compact keyboards will commonly omit thesekeys to save space.

A keypad is an alternate term for numpad.

The code values in this section should also beused for phone keypads and remote control devices thatarrange number keys in a grid.

The standard numpad is sometimes extended with additional keys forparentheses, operators, hexadecimal symbols, or calculator functions(like Backspace). Some of the commonly added keys are listedin the table below.

For numpads that provide keys not listed here, a code value string should be created by startingwith “Numpad” and appending an appropriate description of the key.

The function section runs along the top of the keyboard (abovethe alphanumeric section) andcontains the function keys and a few additional special keys(for example, Esc and Print Screen).

A function key is any of the keys labelled F1 … F12 that an application or operating system can associate with a custom functionor action.

On some keyboards (especially those found on laptops or otherportable computers), the function keys (F1 … F12) are defined to have other primary functions (likecontrolling display brightness or audio volume) and require that aseparate Fn key be pressed to make them act as functionkeys. Unfortunately, the primary functions assigned to these keysvaries widely from one manufacturer to the next. Because of this,the code is always set to the function key name.

For keyboards that provide more than 12 function keys, the code value follows the pattern shown above with”F” followed by the function key number – “F13”, “F14”, “F15”, and so on.

Apple keyboards may have Eject or Power keys in the function section. The code values for thesekeys are defined in 3.1.6 Media Keys.

Media keys are extra keys added to a keyboard that provide media related functionality like play, pause or volume control. These keys do nothave a standard location on the keyboard so keyboards from differentmanufacturers are likely to have a different arrangement of keys or acompletely different sets of keys.

Media keys are often distinct fromnormal typing keys in appearance and may be recessed in thekeyboard.

On laptop keyboards, these keys are often merged with the function keys, with the media key interpretation beingthe primary function of the key and the function key interpretation requiring the Fn key to be pressed at thesame time. In this configuration the code shouldbe set to match the function key (“F1” … “F12”).When the keys are merged in this fashion, the code values are taken from the function key value because the media key value is not consistent across keyboards.

These keys are not found on modern standard keyboards. They arelisted here for reference purposes.

The following keys may be found on non-standard international keyboards.

And finally, the following code value should onlybe used when the corresponding key does not correspond to any of the code values given elsewhere in this specification.This value is appropriate for use with virtual keyboards that do nothave their keys arranged in a way that corresponds to those on aphysical keyboard.

Conforming implementations MUST only use “Unidentified” as a key codewhen there is no way for the implementation to determine the key code.Exposing only this value MUST NOT indicate a conforming implementation.

Considerable thanks are due to the following participants of the WebAppsWorking Group for providing substantial material contributions in theprocess of developing this specification.

Gary Kacmarcik (Google),Masayuki Nakano (Mozilla)

See the original post here:

UI Events KeyboardEvent code Values – World Wide Web …

Automate the Boring Stuff with Python

Knowing various Python modules for editing spreadsheets, downloading files, and launching programs is useful, but sometimes there just arent any modules for the applications you need to work with. The ultimate tools for automating tasks on your computer are programs you write that directly control the keyboard and mouse. These programs can control other applications by sending them virtual keystrokes and mouse clicks, justpython3- as if you were sitting at your computer and interacting with the applications yourself. This technique is known as graphical user interface automation, or GUI automation for short. With GUI automation, your programs can do anything that a human user sitting at the computer can do, except spill coffee on the keyboard.

Think of GUI automation as programming a robotic arm. You can program the robotic arm to type at your keyboard and move your mouse for you. This technique is particularly useful for tasks that involve a lot of mindless clicking or filling out of forms.

The pyautogui module has functions for simulating mouse movements, button clicks, and scrolling the mouse wheel. This chapter covers only a subset of PyAutoGUIs features; you can find the full documentation at http://pyautogui.readthedocs.org/.

The pyautogui module can send virtual keypresses and mouse clicks to Windows, OS X, and Linux. Depending on which operating system youre using, you may have to install some other modules (called dependencies) before you can install PyAutoGUI.

On Windows, there are no other modules to install.

On OS X, run sudo pip3 install pyobjc-framework-Quartz, sudo pip3 install pyobjc-core, and then sudo pip3 install pyobjc.

On Linux, run sudo pip3 install python3-xlib, sudo apt-get install scrot, sudo apt-get install python3-tk, and sudo apt-get install python3-dev. (Scrot is a screenshot program that PyAutoGUI uses.)

After these dependencies are installed, run pip install pyautogui (or pip3 on OS X and Linux) to install PyAutoGUI.

Appendix A has complete information on installing third-party modules. To test whether PyAutoGUI has been installed correctly, run import pyautogui from the interactive shell and check for any error messages.

Before you jump in to a GUI automation, you should know how to escape problems that may arise. Python can move your mouse and type keystrokes at an incredible speed. In fact, it might be too fast for other programs to keep up with. Also, if something goes wrong but your program keeps moving the mouse around, it will be hard to tell what exactly the program is doing or how to recover from the problem. Like the enchanted brooms from Disneys The Sorcerers Apprentice, which kept fillingand then overfillingMickeys tub with water, your program could get out of control even though its following your instructions perfectly. Stopping the program can be difficult if the mouse is moving around on its own, preventing you from clicking the IDLE window to close it. Fortunately, there are several ways to prevent or recover from GUI automation problems.

Perhaps the simplest way to stop an out-of-control GUI automation program is to log out, which will shut down all running programs. On Windows and Linux, the logout hotkey is CTRL-ALT-DEL. On OS X, it is -SHIFT-OPTION-Q. By logging out, youll lose any unsaved work, but at least you wont have to wait for a full reboot of the computer.

You can tell your script to wait after every function call, giving you a short window to take control of the mouse and keyboard if something goes wrong. To do this, set the pyautogui.PAUSE variable to the number of seconds you want it to pause. For example, after setting pyautogui.PAUSE = 1.5, every PyAutoGUI function call will wait one and a half seconds after performing its action. Non-PyAutoGUI instructions will not have this pause.

PyAutoGUI also has a fail-safe feature. Moving the mouse cursor to the upper-left corner of the screen will cause PyAutoGUI to raise the pyautogui.FailSafeException exception. Your program can either handle this exception with try and except statements or let the exception crash your program. Either way, the fail-safe feature will stop the program if you quickly move the mouse as far up and left as you can. You can disable this feature by setting pyautogui.FAILSAFE = False. Enter the following into the interactive shell:

Here we import pyautogui and set pyautogui.PAUSE to 1 for a one-second pause after each function call. We set pyautogui.FAILSAFE to True to enable the fail-safe feature.

In this section, youll learn how to move the mouse and track its position on the screen using PyAutoGUI, but first you need to understand how PyAutoGUI works with coordinates.

The mouse functions of PyAutoGUI use x- and y-coordinates. Figure18-1 shows the coordinate system for the computer screen; its similar to the coordinate system used for images, discussed in Chapter17. The origin, where x and y are both zero, is at the upper-left corner of the screen. The x-coordinates increase going to the right, and the y-coordinates increase going down. All coordinates are positive integers; there are no negative coordinates.

Figure18-1.The coordinates of a computer screen with 19201080 resolution

Your resolution is how many pixels wide and tall your screen is. If your screens resolution is set to 19201080, then the coordinate for the upper-left corner will be (0, 0), and the coordinate for the bottom-right corner will be (1919, 1079).

The pyautogui.size() function returns a two-integer tuple of the screens width and height in pixels. Enter the following into the interactive shell:

pyautogui.size() returns (1920, 1080) on a computer with a 19201080 resolution; depending on your screens resolution, your return value may be different. You can store the width and height from pyautogui.size() in variables like width and height for better readability in your programs.

Now that you understand screen coordinates, lets move the mouse. The pyautogui.moveTo() function will instantly move the mouse cursor to a specified position on the screen. Integer values for the x- and y-coordinates make up the functions first and second arguments, respectively. An optional duration integer or float keyword argument specifies the number of seconds it should take to move the mouse to the destination. If you leave it out, the default is 0 for instantaneous movement. (All of the duration keyword arguments in PyAutoGUI functions are optional.) Enter the following into the interactive shell:

This example moves the mouse cursor clockwise in a square pattern among the four coordinates provided a total of ten times. Each movement takes a quarter of a second, as specified by the duration=0.25 keyword argument. If you hadnt passed a third argument to any of the pyautogui.moveTo() calls, the mouse cursor would have instantly teleported from point to point.

The pyautogui.moveRel() function moves the mouse cursor relative to its current position. The following example moves the mouse in the same square pattern, except it begins the square from wherever the mouse happens to be on the screen when the code starts running:

pyautogui.moveRel() also takes three arguments: how many pixels to move horizontally to the right, how many pixels to move vertically downward, and (optionally) how long it should take to complete the movement. A negative integer for the first or second argument will cause the mouse to move left or upward, respectively.

You can determine the mouses current position by calling the pyautogui.position() function, which will return a tuple of the mouse cursors x and y positions at the time of the function call. Enter the following into the interactive shell, moving the mouse around after each call:

Of course, your return values will vary depending on where your mouse cursor is.

Being able to determine the mouse position is an important part of setting up your GUI automation scripts. But its almost impossible to figure out the exact coordinates of a pixel just by looking at the screen. It would be handy to have a program that constantly displays the x- and y-coordinates of the mouse cursor as you move it around.

At a high level, heres what your program should do:

This means your code will need to do the following:

Call the position() function to fetch the current coordinates.

Erase the previously printed coordinates by printing b backspace characters to the screen.

Handle the KeyboardInterrupt exception so the user can press CTRL-C to quit.

Open a new file editor window and save it as mouseNow.py.

Start your program with the following:

The beginning of the program imports the pyautogui module and prints a reminder to the user that they have to press CTRL-C to quit.

You can use an infinite while loop to constantly print the current mouse coordinates from mouse.position(). As for the code that quits the program, youll need to catch the KeyboardInterrupt exception, which is raised whenever the user presses CTRL-C. If you dont handle this exception, it will display an ugly traceback and error message to the user. Add the following to your program:

To handle the exception, enclose the infinite while loop in a try statement. When the user presses CTRL-C, the program execution will move to the except clause and Done. will be printed in a new line .

The code inside the while loop should get the current mouse coordinates, format them to look nice, and print them. Add the following code to the inside of the while loop:

Using the multiple assignment trick, the x and y variables are given the values of the two integers returned in the tuple from pyautogui.position(). By passing x and y to the str() function, you can get string forms of the integer coordinates. The rjust() string method will right-justify them so that they take up the same amount of space, whether the coordinate has one, two, three, or four digits. Concatenating the right-justified string coordinates with ‘X: ‘ and ‘ Y: ‘ labels gives us a neatly formatted string, which will be stored in positionStr.

At the end of your program, add the following code:

This actually prints positionStr to the screen. The end=” keyword argument to print() prevents the default newline character from being added to the end of the printed line. Its possible to erase text youve already printed to the screenbut only for the most recent line of text. Once you print a newline character, you cant erase anything printed before it.

To erase text, print the b backspace escape character. This special character erases a character at the end of the current line on the screen. The line at uses string replication to produce a string with as many b characters as the length of the string stored in positionStr, which has the effect of erasing the positionStr string that was last printed.

For a technical reason beyond the scope of this book, always pass flush=True to print() calls that print b backspace characters. Otherwise, the screen might not update the text as desired.

Since the while loop repeats so quickly, the user wont actually notice that youre deleting and reprinting the whole number on the screen. For example, if the x-coordinate is 563 and the mouse moves one pixel to the right, it will look like only the 3 in 563 is changed to a 4.

When you run the program, there will be only two lines printed. They should look like something like this:

The first line displays the instruction to press CTRL-C to quit. The second line with the mouse coordinates will change as you move the mouse around the screen. Using this program, youll be able to figure out the mouse coordinates for your GUI automation scripts.

Now that you know how to move the mouse and figure out where it is on the screen, youre ready to start clicking, dragging, and scrolling.

To send a virtual mouse click to your computer, call the pyautogui.click() method. By default, this click uses the left mouse button and takes place wherever the mouse cursor is currently located. You can pass x- and y-coordinates of the click as optional first and second arguments if you want it to take place somewhere other than the mouses current position.

If you want to specify which mouse button to use, include the button keyword argument, with a value of ‘left’, ‘middle’, or ‘right’. For example, pyautogui.click(100, 150, button=’left’) will click the left mouse button at the coordinates (100, 150), while pyautogui.click(200, 250, button=’right’) will perform a right-click at (200, 250).

Enter the following into the interactive shell:

You should see the mouse pointer move to near the top-left corner of your screen and click once. A full click is defined as pushing a mouse button down and then releasing it back up without moving the cursor. You can also perform a click by calling pyautogui.mouseDown(), which only pushes the mouse button down, and pyautogui.mouseUp(), which only releases the button. These functions have the same arguments as click(), and in fact, the click() function is just a convenient wrapper around these two function calls.

As a further convenience, the pyautogui.doubleClick() function will perform two clicks with the left mouse button, while the pyautogui.rightClick() and pyautogui.middleClick() functions will perform a click with the right and middle mouse buttons, respectively.

Dragging means moving the mouse while holding down one of the mouse buttons. For example, you can move files between folders by dragging the folder icons, or you can move appointments around in a calendar app.

PyAutoGUI provides the pyautogui.dragTo() and pyautogui.dragRel() functions to drag the mouse cursor to a new location or a location relative to its current one. The arguments for dragTo() and dragRel() are the same as moveTo() and moveRel(): the x-coordinate/horizontal movement, the y-coordinate/vertical movement, and an optional duration of time. (OS X does not drag correctly when the mouse moves too quickly, so passing a duration keyword argument is recommended.)

To try these functions, open a graphics-drawing application such as Paint on Windows, Paintbrush on OS X, or GNU Paint on Linux. (If you dont have a drawing application, you can use the online one at http://sumopaint.com/.) I will use PyAutoGUI to draw in these applications.

With the mouse cursor over the drawing applications canvas and the Pencil or Brush tool selected, enter the following into a new file editor window and save it as spiralDraw.py:

When you run this program, there will be a five-second delay for you to move the mouse cursor over the drawing programs window with the Pencil or Brush tool selected. Then spiralDraw.py will take control of the mouse and click to put the drawing program in focus . A window is in focus when it has an active blinking cursor, and the actions you takelike typing or, in this case, dragging the mousewill affect that window. Once the drawing program is in focus, spiralDraw.py draws a square spiral pattern like the one in Figure18-2.

Figure18-2.The results from the pyautogui.dragRel() example

The distance variable starts at 200, so on the first iteration of the while loop, the first dragRel() call drags the cursor 200 pixels to the right, taking 0.2 seconds . distance is then decreased to 195 , and the second dragRel() call drags the cursor 195 pixels down . The third dragRel() call drags the cursor 195 horizontally (195 to the left) , distance is decreased to 190, and the last dragRel() call drags the cursor 190 pixels up. On each iteration, the mouse is dragged right, down, left, and up, and distance is slightly smaller than it was in the previous iteration. By looping over this code, you can move the mouse cursor to draw a square spiral.

You could draw this spiral by hand (or rather, by mouse), but youd have to work slowly to be so precise. PyAutoGUI can do it in a few seconds!

You could have your code draw the image using the pillow modules drawing functionssee Chapter17 for more information. But using GUI automation allows you to make use of the advanced drawing tools that graphics programs can provide, such as gradients, different brushes, or the fill bucket.

The final PyAutoGUI mouse function is scroll(), which you pass an integer argument for how many units you want to scroll the mouse up or down. The size of a unit varies for each operating system and application, so youll have to experiment to see exactly how far it scrolls in your particular situation. The scrolling takes place at the mouse cursors current position. Passing a positive integer scrolls up, and passing a negative integer scrolls down. Run the following in IDLEs interactive shell while the mouse cursor is over the IDLE window:

Youll see IDLE briefly scroll upwardand then go back down. The downward scrolling happens because IDLE automatically scrolls down to the bottom after executing an instruction. Enter this code instead:

This imports pyperclip and sets up an empty string, numbers. The code then loops through 200 numbers and adds each number to numbers, along with a newline. After pyperclip.copy(numbers), the clipboard will be loaded with 200 lines of numbers. Open a new file editor window and paste the text into it. This will give you a large text window to try scrolling in. Enter the following code into the interactive shell:

On the second line, you enter two commands separated by a semicolon, which tells Python to run the commands as if they were on separate lines. The only difference is that the interactive shell wont prompt you for input between the two instructions. This is important for this example because we want to the call to pyautogui.scroll() to happen automatically after the wait. (Note that while putting two commands on one line can be useful in the interactive shell, you should still have each instruction on a separate line in your programs.)

After pressing ENTER to run the code, you will have five seconds to click the file editor window to put it in focus. Once the pause is over, the pyautogui.scroll() call will cause the file editor window to scroll up after the five-second delay.

Your GUI automation programs dont have to click and type blindly. PyAutoGUI has screenshot features that can create an image file based on the current contents of the screen. These functions can also return a Pillow Image object of the current screens appearance. If youve been skipping around in this book, youll want to read Chapter17 and install the pillow module before continuing with this section.

On Linux computers, the scrot program needs to be installed to use the screenshot functions in PyAutoGUI. In a Terminal window, run sudo apt-get install scrot to install this program. If youre on Windows or OS X, skip this step and continue with the section.

To take screenshots in Python, call the pyautogui.screenshot() function. Enter the following into the interactive shell:

The im variable will contain the Image object of the screenshot. You can now call methods on the Image object in the im variable, just like any other Image object. Enter the following into the interactive shell:

Pass getpixel() a tuple of coordinates, like (0, 0) or (50, 200), and itll tell you the color of the pixel at those coordinates in your image. The return value from getpixel() is an RGB tuple of three integers for the amount of red, green, and blue in the pixel. (There is no fourth value for alpha, because screenshot images are fully opaque.) This is how your programs can see what is currently on the screen.

Say that one of the steps in your GUI automation program is to click a gray button. Before calling the click() method, you could take a screenshot and look at the pixel where the script is about to click. If its not the same gray as the gray button, then your program knows something is wrong. Maybe the window moved unexpectedly, or maybe a pop-up dialog has blocked the button. At this point, instead of continuingand possibly wreaking havoc by clicking the wrong thingyour program can see that it isnt clicking on the right thing and stop itself.

PyAutoGUIs pixelMatchesColor() function will return True if the pixel at the given x- and y-coordinates on the screen matches the given color. The first and second arguments are integers for the x- and y-coordinates, and the third argument is a tuple of three integers for the RGB color the screen pixel must match. Enter the following into the interactive shell:

After taking a screenshot and using getpixel() to get an RGB tuple for the color of a pixel at specific coordinates , pass the same coordinates and RGB tuple to pixelMatchesColor() , which should return True. Then change a value in the RGB tuple and call pixelMatchesColor() again for the same coordinates . This should return false. This method can be useful to call whenever your GUI automation programs are about to call click(). Note that the color at the given coordinates must exactly match. If it is even slightly differentfor example, (255, 255, 254) instead of (255, 255, 255)then pixelMatchesColor() will return False.

You could extend the mouseNow.py project from earlier in this chapter so that it not only gives the x- and y-coordinates of the mouse cursors current position but also gives the RGB color of the pixel under the cursor. Modify the code inside the while loop of mouseNow.py to look like this:

Now, when you run mouseNow.py, the output will include the RGB color value of the pixel under the mouse cursor.

This information, along with the pixelMatchesColor() function, should make it easy to add pixel color checks to your GUI automation scripts.

But what if you do not know beforehand where PyAutoGUI should click? You can use image recognition instead. Give PyAutoGUI an image of what you want to click and let it figure out the coordinates.

For example, if you have previously taken a screenshot to capture the image of a Submit button in submit.png, the locateOnScreen() function will return the coordinates where that image is found. To see how locateOnScreen() works, try taking a screenshot of a small area on your screen; then save the image and enter the following into the interactive shell, replacing ‘submit. png’ with the filename of your screenshot:

The four-integer tuple that locateOnScreen() returns has the x-coordinate of the left edge, the y-coordinate of the top edge, the width, and the height for the first place on the screen the image was found. If youre trying this on your computer with your own screenshot, your return value will be different from the one shown here.

If the image cannot be found on the screen, locateOnScreen() will return None. Note that the image on the screen must match the provided image perfectly in order to be recognized. If the image is even a pixel off, locateOnScreen() will return None.

If the image can be found in several places on the screen, locateAllOnScreen() will return a Generator object, which can be passed to list() to return a list of four-integer tuples. There will be one four-integer tuple for each location where the image is found on the screen. Continue the interactive shell example by entering the following (and replacing ‘submit.png’ with your own image filename):

Each of the four-integer tuples represents an area on the screen. If your image is only found in one area, then using list() and locateAllOnScreen() just returns a list containing one tuple.

Once you have the four-integer tuple for the area on the screen where your image was found, you can click the center of this area by passing the tuple to the center() function to return x- and y-coordinates of the areas center. Enter the following into the interactive shell, replacing the arguments with your own filename, four-integer tuple, and coordinate pair:

Once you have center coordinates from center(), passing the coordinates to click() should click the center of the area on the screen that matches the image you passed to locateOnScreen().

PyAutoGUI also has functions for sending virtual keypresses to your computer, which enables you to fill out forms or enter text into applications.

The pyautogui.typewrite() function sends virtual keypresses to the computer. What these keypresses do depends on what window and text field have focus. You may want to first send a mouse click to the text field you want in order to ensure that it has focus.

As a simple example, lets use Python to automatically type the words Hello world! into a file editor window. First, open a new file editor window and position it in the upper-left corner of your screen so that PyAutoGUI will click in the right place to bring it into focus. Next, enter the following into the interactive shell:

Notice how placing two commands on the same line, separated by a semicolon, keeps the interactive shell from prompting you for input between running the two instructions. This prevents you from accidentally bringing a new window into focus between the click() and typewrite() calls, which would mess up the example.

Python will first send a virtual mouse click to the coordinates (100, 100), which should click the file editor window and put it in focus. The typewrite() call will send the text Hello world! to the window, making it look like Figure18-3. You now have code that can type for you!

Figure18-3.Using PyAutogGUI to click the file editor window and type Hello world! into it

By default, the typewrite() function will type the full string instantly. However, you can pass an optional second argument to add a short pause between each character. This second argument is an integer or float value of the number of seconds to pause. For example, pyautogui.typewrite(‘Hello world!’, 0.25) will wait a quarter-second after typing H, another quarter-second after e, and so on. This gradual typewriter effect may be useful for slower applications that cant process keystrokes fast enough to keep up with PyAutoGUI.

For characters such as A or !, PyAutoGUI will automatically simulate holding down the SHIFT key as well.

Not all keys are easy to represent with single text characters. For example, how do you represent SHIFT or the left arrow key as a single character? In PyAutoGUI, these keyboard keys are represented by short string values instead: ‘esc’ for the ESC key or ‘enter’ for the ENTER key.

Instead of a single string argument, a list of these keyboard key strings can be passed to typewrite(). For example, the following call presses the A key, then the B key, then the left arrow key twice, and finally the X and Y keys:

Because pressing the left arrow key moves the keyboard cursor, this will output XYab. Table18-1 lists the PyAutoGUI keyboard key strings that you can pass to typewrite() to simulate pressing any combination of keys.

You can also examine the pyautogui.KEYBOARD_KEYS list to see all possible keyboard key strings that PyAutoGUI will accept. The ‘shift’ string refers to the left SHIFT key and is equivalent to ‘shiftleft’. The same applies for ‘ctrl’, ‘alt’, and ‘win’ strings; they all refer to the left-side key.

Table18-1.PyKeyboard Attributes

Keyboard key string

Meaning

Link:

Automate the Boring Stuff with Python

UI Events KeyboardEvent code Values – World Wide Web …

1. Introduction

This document provides an overview of the various keyboard layouts andspecifies the KeyboardEvent.code values that should beused for each of the keys. Unlike the key values describedin [UIEvents-key], the code values are based only on thekeys physical location on the keyboard and do not vary based on the userscurrent locale.

This specification was formerly titled DOM Level 3 KeyboardEvent code Values.

This specification uses the following conventions:

This section is non-normative.

Alphanumeric keyboards are the most common way for users to generatekeyboard events. This section provides an overview of standard keyboards andtheir physical layouts.

This section describes the physical layouts found on commonly availablekeyboards.

When discussing keyboard layouts, it is convenient to divide thestandard keyboard into distinct sections and to label each row.

These keyboard sections are:

The alphanumeric section is the main part of thekeyboard and is where most of the keyboard variation occurs.When a user selects a keyboard layout, it is the keys in thissections that are most affected.

The control pad and arrow pad sections contain the arrow keys and other editing keys.

The numpad (also known as the “numeric keypad”or “number pad”) contains number and math keys to make it easierto enter numeric data.

And finally, the function section containsmiscellaneous function keys and special keys like Escape.

To make it easier to identify keys, the rows on the keyboard arenamed starting with “A” for the bottom row up to “E” for the toprow. The row of keys in the function section are considered to be inrow “K”. These row names are consistent with those given in [ISO9995-1].

Note that many keyboards (both modern and legacy) have extra keysthat do not fit neatly into the above sections. Some of these keysare covered in 3.1.6 Media Keys.

The standard “101” keyboard (commonly referred to as the “USlayout”) is the only layout that has a “Backslash” key (labeled |) above a single-row Enter key. All the otherlayouts omit this key and expand the Enter key tooccupy two-rows.

Modern standard “101”-layout keyboards actually contain 104 keys: 61keys in the alphanumeric section and 43 keys in the numpad, control pad, arrow pad and function sections.The “101” name for this keyboard layout dates to thetime when this standard keyboard did in fact contain 101 keys. Thetwo Meta keys (commonly given an OS-specific label), and the Menu key were added later to bring the total to 104 keys.

The alternate “101” keyboard has a large Enter key andshrinks the Backspace key to make room for the “IntlYen” key (which replaces the “Backslash” key found in the standard101 layout). The “IntlYen” name comes from the Japanese layoutwhere this is the (yen) key in the Russianlayout shown below this key maps to a /.

Modern alternate “101”-layout keyboards contain 104 keys: 61 keys inthe alphanumeric section and 43 keys in the numpad, control pad, arrow pad and function sections.

The standard “102” keyboard is common throughout Europe and adds akey that doesnt exist on the “101” layouts: The “IntlBackslash” key (labelled | on a UK keyboard) next to the left shiftkey.

A second key is also added (labelled #~ on a UKkeyboard) which is partially tucked under the Enter key.This key is encoded as “Backslash”, using the same code as the | key found on the “101” keyboard layout.According to [USB-HID], the US | and UK #~ areactually two separate keys (named “Keyboard and |” and “KeyboardNon-US # and ~”), but since these two keys never co-occur on thesame keyboard most platforms use the same scancode for both keys,making them difficult to distinguish. It is for this reason that thecode “Backslash” is used for both of these keys.

Modern “102”-layout keyboards contain 105 keys: 62 keys in the alphanumeric section and 43 keys in the numpad, control pad, arrow pad and function sections.

The Korean “103” keyboard is based on the alternate 101 layout andadds two additional keys (one on each side of the spacebar) tohandle Korean-specific input modes. These keys are “Lang2” (“Hanja”, labelled hanja)and “Lang1” (“HangulMode”, labelled / han/yeong).

Modern “103”-layout keyboards contain 106 keys: 63 keys in the alphanumeric section and 43 keys in the numpad, control pad, arrow pad and function sections.

The “104” layout used in Brazil adds 4 new keys: two keysfrom the “102” layout (“Backslash” and “IntlBackslash”) plusthe “IntlRo” key (next to the right shift key) and an extra keyon the numpad. This new numpad key is called “NumpadComma” because it represents the thousands separator. Onthe Brazilian key layout, this key is labelled . and the “NumpadDecimal” key is labelled ,.

Modern “104”-layout keyboards contain 107 keys: 63 keys in the alphanumeric section and 44 keys in the numpad, control pad, arrow pad and function sections.Some Brazilian keyboards lack the extra numpad key and haveonly 106 keys.

The Japanese “106” keyboard layout adds 3 new keys: “IntlYen” (labelled _), “Backslash” (labelled ])and “IntlRo” (labelled ).It also shrinks the spacebar to make room for 3 input mode keys: “NonConvert” (labelled muhenkan), “Convert” (labelled henkan)and “KanaMode” (labelled // katakana/hiragana/romaji).

Modern “106”-layout keyboards contain 109 keys: 66 keys in the alphanumeric section and 43 keys in the numpad, control pad, arrow pad and function sections.

In general, Apple keyboards follow the same layout as PC keyboards,but there are some differences as noted in the following figure.

In this figure, the green keys are those that have been moved to anew location while the blue keys indicate keys that have been added.

The limited space available on laptop keyboards often means that thephysical key layout needs to be adjusted to fit all the requiredkeys. The writing system keys in the alphanumericsection tend to remain intact, but the other keyboard sectionsare usually combined with other keys or removed altogether.

In this Apple laptop keyboard, the right control key has beenremoved to make room for half-height arrow keys and a Fn keyis added on the left.

PC laptop keyboards vary considerably, but this sample keyboarddemonstrates some commonly found aspects. The control pad keys are added along the right-hand side with the arrow pad keys tucked in along the bottom. The right Shift key isoften shrunk to make room for the up arrow key and the right Meta key is typically removed altogether.

In the case where a content author wishes to rely on the mechanicallayout of a mobile keypad, this specification suggests the keyboardconfiguration specified in [ISO9995-8], which defines a numeric keypadlayout and secondary assignment of Unicode characters in the range U+0061 … U+007A (“a” – “z”) to the number keys 2 through 9, as a common layout appropriate to someinternational uses.

This keypad layout, and in particular the distribution of letters is forEnglish devices, and will not match the keypads or configurations ofmany users. Content authors cannot rely upon any particularconfiguration, and are expected to create content in aninternationalized and localizable manner.

Many keyboards contain special keys to control media functions.Increasingly, many media devices, especially televisions, areWeb-enabled. Hybrid keyboard/remote-control devices are becoming morecommon. To meet the needs of these hybrid Web/media devices, thisspecification defines keys that are common as remote control buttons, inaddition to traditional keyboard keys.

Because of the smaller form factor, keys (or buttons) on a remotecontrol will often be modal, with one key performing different functionsbased on the context of the on-screen content. Additionally, many keysserve as toggles, to change back and forth between two or more states(see toggling keys). These remote control buttons typically do not havemodifier states so each button is assigned a single function (like Play, Pause, Up, Menu or Exit).

Virtual keyboards are software-based sets of keys, in a variety ofdifferent arrangements, commonly found on touch-screen devices. They areoften modal, with the ability to switch between different dynamic setsof keys, such as alphabetic, numeric, or symbolic keys. Because of thelack of physical constraints, these keyboards MAY present the widestrange of characters, including emoticons and other symbols. Wherever possible,however, virtual keyboards SHOULD produce the normal range of keyboard eventsand values, for ease of authoring and compatibility with existing content.

Chording keyboards, also known as chorded keysets or chord keyboards, arekey input devices which produce values by pressing several keys incombination or sequence, normally to simulate a full range of charactersor commands on a reduced set of keys, often for single-handed use.Achording keyboard MAY have additional mode keys to switch between keyvalues, and the number and type of keys pressed to produce a key valuewill vary, but the final key values produced by such keyboards SHOULDmatch the range of key values described in this specification.

For these and other alternative modal keyboards, the key values “Alphanumeric”, “CapsLock”, “NumLock”,and “SymbolLock” are RECOMMENDED for the keys which switch between different modes.

A key code attribute value is any of the values given in the=KeyboardEvent.code= column of any of the tables in this section of thespecification.

A conforming implementation of the KeyboardEvent interface MUST supportthis set of values for use in the code attributes,although not all values MAY be available on all platforms or devices.

This section defines a list of code values whichimplementations MUST support.

Future versions of this specification MAY include code values not includedhere, which have become common since the publication of this specification.

Note: While every attempt has been made to make this list of values as complete as possible,new values will periodically need to be defined as new input devices are introduced.Rather than allowing user agents to define their own key code attribute values (which are unlikely to be consistent across multiple user agents), bugs SHOULD befiled so that this specification can be updated.

This section describes the various keyboard sections in more detail anddefines the code values that should be used for eachkey.

The alphanumeric section is the main section of the keyboard. Itcontains keys that fall into two generalcategories: writing system keys whose meaningchanges based on the current keyboard layout, and functional keys which are (mostly) the same for alllayouts.

The writing system keys are those that changemeaning (i.e., they produce different key values) based on the current locale and keyboard layout.

This figure shows a hypothetical keyboard that combines all the writing system keys (shown in blue and green) found on thevarious keyboards. Blue keys are present on all standardkeyboards while green keys are only available on some keyboards.

The name shown on each key is the code assigned to that key. Wherever possible, the code names are based on the name for the USkey in that position (i.e., they are based on the US keyboardlayout). For keys that dont exist on the US keyboard, namesfrom the UK or Japanese layouts are used instead.

Note that there are two “Backslash” keys in this figure: alarge one at the end of Row D on the 101-key layout, and asmaller one between “Quote” and “Enter” on Row C of the102-, 104- and 106-key layouts. Only one “Backslash” keymay be present on a keyboard layout.

The functional keys (not to be confused with the function keys described later) are those keys in the alphanumeric section that provide general editingfunctions that are common to all locales (like Shift, Tab, Enter and Backspace). With a fewexceptions, these keys do not change meaning based on thecurrent keyboard layout.

The “AltRight” key (highlighted in green) is the only functional key that does not generate the same key value for every locale. In some locales itproduces “Alt” while in others it produces “AltGraph”.

On some keyboards (notably Japanese and Korean) the spacebar isreduced in size to make room for extra keys on the bottom row (Row A).These keys typically allow the users to change the current inputmode. Note that even though some of these Japanese and Koreankeys occupy the same physical location on the keyboard, they usedifferent code values.

On Apple keyboards, some keys on the bottom row are omitted andothers are arranged in a different order.

The control pad section of the keyboard is the set of (usually 6) keysthat perform navigating and editing operations, for example, Home, PageUp and Insert.

The code for the Fn key (found on someApple keyboards) is defined below in the function section.

The arrow pad contains the 4 arrow keys. The keys are commonlyarranged in an “upside-down T” configuration.

The numpad section is the set of keys on the keyboard arranged ina grid like a calculator or mobile phone. This section contains numeric andmathematical operator keys. Often this section will contain a NumLock key which causes the keys to switch between the standard numeric functionsand mimicking the keys of the control pad and arrow pad.Laptop computers and compact keyboards will commonly omit thesekeys to save space.

A keypad is an alternate term for numpad.

The code values in this section should also beused for phone keypads and remote control devices thatarrange number keys in a grid.

The standard numpad is sometimes extended with additional keys forparentheses, operators, hexadecimal symbols, or calculator functions(like Backspace). Some of the commonly added keys are listedin the table below.

For numpads that provide keys not listed here, a code value string should be created by startingwith “Numpad” and appending an appropriate description of the key.

The function section runs along the top of the keyboard (abovethe alphanumeric section) andcontains the function keys and a few additional special keys(for example, Esc and Print Screen).

A function key is any of the keys labelled F1 … F12 that an application or operating system can associate with a custom functionor action.

On some keyboards (especially those found on laptops or otherportable computers), the function keys (F1 … F12) are defined to have other primary functions (likecontrolling display brightness or audio volume) and require that aseparate Fn key be pressed to make them act as functionkeys. Unfortunately, the primary functions assigned to these keysvaries widely from one manufacturer to the next. Because of this,the code is always set to the function key name.

For keyboards that provide more than 12 function keys, the code value follows the pattern shown above with”F” followed by the function key number – “F13”, “F14”, “F15”, and so on.

Apple keyboards may have Eject or Power keys in the function section. The code values for thesekeys are defined in 3.1.6 Media Keys.

Media keys are extra keys added to a keyboard that provide media related functionality like play, pause or volume control. These keys do nothave a standard location on the keyboard so keyboards from differentmanufacturers are likely to have a different arrangement of keys or acompletely different sets of keys.

Media keys are often distinct fromnormal typing keys in appearance and may be recessed in thekeyboard.

On laptop keyboards, these keys are often merged with the function keys, with the media key interpretation beingthe primary function of the key and the function key interpretation requiring the Fn key to be pressed at thesame time. In this configuration the code shouldbe set to match the function key (“F1” … “F12”).When the keys are merged in this fashion, the code values are taken from the function key value because the media key value is not consistent across keyboards.

These keys are not found on modern standard keyboards. They arelisted here for reference purposes.

The following keys may be found on non-standard international keyboards.

And finally, the following code value should onlybe used when the corresponding key does not correspond to any of the code values given elsewhere in this specification.This value is appropriate for use with virtual keyboards that do nothave their keys arranged in a way that corresponds to those on aphysical keyboard.

Conforming implementations MUST only use “Unidentified” as a key codewhen there is no way for the implementation to determine the key code.Exposing only this value MUST NOT indicate a conforming implementation.

Considerable thanks are due to the following participants of the WebAppsWorking Group for providing substantial material contributions in theprocess of developing this specification.

Gary Kacmarcik (Google),Masayuki Nakano (Mozilla)

Read the original here:

UI Events KeyboardEvent code Values – World Wide Web …

atheism | Definition, Philosophy, & Comparison to …

Atheism, in general, the critique and denial of metaphysical beliefs in God or spiritual beings. As such, it is usually distinguished from theism, which affirms the reality of the divine and often seeks to demonstrate its existence. Atheism is also distinguished from agnosticism, which leaves open the question whether there is a god or not, professing to find the questions unanswered or unanswerable.

The dialectic of the argument between forms of belief and unbelief raises questions concerning the most perspicuous delineation, or characterization, of atheism, agnosticism, and theism. It is necessary not only to probe the warrant for atheism but also carefully to consider what is the most adequate definition of atheism. This article will start with what have been some widely accepted, but still in various ways mistaken or misleading, definitions of atheism and move to more adequate formulations that better capture the full range of atheist thought and more clearly separate unbelief from belief and atheism from agnosticism. In the course of this delineation the section also will consider key arguments for and against atheism.

A central, common core of Judaism, Christianity, and Islam is the affirmation of the reality of one, and only one, God. Adherents of these faiths believe that there is a God who created the universe out of nothing and who has absolute sovereignty over all his creation; this includes, of course, human beingswho are not only utterly dependent on this creative power but also sinful and who, or so the faithful must believe, can only make adequate sense of their lives by accepting, without question, Gods ordinances for them. The varieties of atheism are numerous, but all atheists reject such a set of beliefs.

Atheism, however, casts a wider net and rejects all belief in spiritual beings, and to the extent that belief in spiritual beings is definitive of what it means for a system to be religious, atheism rejects religion. So atheism is not only a rejection of the central conceptions of Judaism, Christianity, and Islam; it is, as well, a rejection of the religious beliefs of such African religions as that of the Dinka and the Nuer, of the anthropomorphic gods of classical Greece and Rome, and of the transcendental conceptions of Hinduism and Buddhism. Generally atheism is a denial of God or of the gods, and if religion is defined in terms of belief in spiritual beings, then atheism is the rejection of all religious belief.

It is necessary, however, if a tolerably adequate understanding of atheism is to be achieved, to give a reading to rejection of religious belief and to come to realize how the characterization of atheism as the denial of God or the gods is inadequate.

To say that atheism is the denial of God or the gods and that it is the opposite of theism, a system of belief that affirms the reality of God and seeks to demonstrate his existence, is inadequate in a number of ways. First, not all theologians who regard themselves as defenders of the Christian faith or of Judaism or Islam regard themselves as defenders of theism. The influential 20th-century Protestant theologian Paul Tillich, for example, regards the God of theism as an idol and refuses to construe God as a being, even a supreme being, among beings or as an infinite being above finite beings. God, for him, is being-itself, the ground of being and meaning. The particulars of Tillichs view are in certain ways idiosyncratic, as well as being obscure and problematic, but they have been influential; and his rejection of theism, while retaining a belief in God, is not eccentric in contemporary theology, though it may very well affront the plain believer.

Second, and more important, it is not the case that all theists seek to demonstrate or even in any way rationally to establish the existence of God. Many theists regard such a demonstration as impossible, and fideistic believers (e.g., Johann Hamann and Sren Kierkegaard) regard such a demonstration, even if it were possible, as undesirable, for in their view it would undermine faith. If it could be proved, or known for certain, that God exists, people would not be in a position to accept him as their sovereign Lord humbly on faith with all the risks that entails. There are theologians who have argued that for genuine faith to be possible God must necessarily be a hidden God, the mysterious ultimate reality, whose existence and authority must be accepted simply on faith. This fideistic view has not, of course, gone without challenge from inside the major faiths, but it is of sufficient importance to make the above characterization of atheism inadequate.

Finally, and most important, not all denials of God are denials of his existence. Believers sometimes deny God while not being at all in a state of doubt that God exists. They either willfully reject what they take to be his authority by not acting in accordance with what they take to be his will, or else they simply live their lives as if God did not exist. In this important way they deny him. Such deniers are not atheists (unless we wish, misleadingly, to call them practical atheists). They are not even agnostics. They do not question that God exists; they deny him in other ways. An atheist denies the existence of God. As it is frequently said, atheists believe that it is false that God exists, or that Gods existence is a speculative hypothesis of an extremely low order of probability.

Yet it remains the case that such a characterization of atheism is inadequate in other ways. For one it is too narrow. There are atheists who believe that the very concept of God, at least in developed and less anthropomorphic forms of Judeo-Christianity and Islam, is so incoherent that certain central religious claims, such as God is my creator to whom everything is owed, are not genuine truth-claims; i.e., the claims could not be either true or false. Believers hold that such religious propositions are true, some atheists believe that they are false, and there are agnostics who cannot make up their minds whether to believe that they are true or false. (Agnostics think that the propositions are one or the other but believe that it is not possible to determine which.) But all three are mistaken, some atheists argue, for such putative truth-claims are not sufficiently intelligible to be genuine truth-claims that are either true or false. In reality there is nothing in them to be believed or disbelieved, though there is for the believer the powerful and humanly comforting illusion that there is. Such an atheism, it should be added, rooted for some conceptions of God in considerations about intelligibility and what it makes sense to say, has been strongly resisted by some pragmatists and logical empiricists.

While the above considerations about atheism and intelligibility show the second characterization of atheism to be too narrow, it is also the case that this characterization is in a way too broad. For there are fideistic believers, who quite unequivocally believe that when looked at objectively the proposition that God exists has a very low probability weight. They believe in God not because it is probable that he existsthey think it more probable that he does notbut because belief is thought by them to be necessary to make sense of human life. The second characterization of atheism does not distinguish a fideistic believer (a Blaise Pascal or a Soren Kierkegaard) or an agnostic (a T.H. Huxley or a Sir Leslie Stephen) from an atheist such as Baron dHolbach. All believe that there is a God and God protects humankind, however emotionally important they may be, are speculative hypotheses of an extremely low order of probability. But this, since it does not distinguish believers from nonbelievers and does not distinguish agnostics from atheists, cannot be an adequate characterization of atheism.

It may be retorted that to avoid apriorism and dogmatic atheism the existence of God should be regarded as a hypothesis. There are no ontological (purely a priori) proofs or disproofs of Gods existence. It is not reasonable to rule in advance that it makes no sense to say that God exists. What the atheist can reasonably claim is that there is no evidence that there is a God, and against that background he may very well be justified in asserting that there is no God. It has been argued, however, that it is simply dogmatic for an atheist to assert that no possible evidence could ever give one grounds for believing in God. Instead, atheists should justify their unbelief by showing (if they can) how the assertion is well-taken that there is no evidence that would warrant a belief in God. If atheism is justified, the atheist will have shown that in fact there is no adequate evidence for the belief that God exists, but it should not be part of his task to try to show that there could not be any evidence for the existence of God. If the atheist could somehow survive the death of his present body (assuming that such talk makes sense) and come, much to his surprise, to stand in the presence of God, his answer should be, Oh! Lord, you didnt give me enough evidence! He would have been mistaken, and realize that he had been mistaken, in his judgment that God did not exist. Still, he would not have been unjustified, in the light of the evidence available to him during his earthly life, in believing as he did. Not having any such postmortem experiences of the presence of God (assuming that he could have them), what he should say, as things stand and in the face of the evidence he actually has and is likely to be able to get, is that it is false that God exists. (Every time one legitimately asserts that a proposition is false one need not be certain that it is false. Knowing with certainty is not a pleonasm.) The claim is that this tentative posture is the reasonable position for the atheist to take.

An atheist who argues in this manner may also make a distinctive burden-of-proof argument. Given that God (if there is one) is by definition a very recherch realitya reality that must be (for there to be such a reality) transcendent to the worldthe burden of proof is not on the atheist to give grounds for believing that there is no reality of that order. Rather, the burden of proof is on the believer to give some evidence for Gods existencei.e., that there is such a reality. Given what God must be, if there is a God, the theist needs to present the evidence, for such a very strange reality. He needs to show that there is more in the world than is disclosed by common experience. The empirical method, and the empirical method alone, such an atheist asserts, affords a reliable method for establishing what is in fact the case. To the claim of the theist that there are in addition to varieties of empirical facts spiritual facts or transcendent facts, such as it being the case that there is a supernatural, self-existent, eternal power, the atheist can assert that such facts have not been shown.

It will, however, be argued by such atheists, against what they take to be dogmatic aprioristic atheists, that the atheist should be a fallibilist and remain open-minded about what the future may bring. There may, after all, be such transcendent facts, such metaphysical realities. It is not that such a fallibilistic atheist is really an agnostic who believes that he is not justified in either asserting that God exists or denying that he exists and that what he must reasonably do is suspend belief. On the contrary, such an atheist believes that he has very good grounds indeed, as things stand, for denying the existence of God. But he will, on the second conceptualization of what it is to be an atheist, not deny that things could be otherwise and that, if they were, he would be justified in believing in God or at least would no longer be justified in asserting that it is false that there is a God. Using reliable empirical techniques, proven methods for establishing matters of fact, the fallibilistic atheist has found nothing in the universe to make a belief that God exists justifiable or even, everything considered, the most rational option of the various options. He therefore draws the atheistical conclusion (also keeping in mind his burden-of-proof argument) that God does not exist. But he does not dogmatically in a priori fashion deny the existence of God. He remains a thorough and consistent fallibilist.

Such a form of atheism (the atheism of those pragmatists who are also naturalistic humanists), though less inadequate than the first formation of atheism, is still inadequate. God in developed forms of Judaism, Christianity, and Islam is not, like Zeus or Odin, construed in a relatively plain anthropomorphic way. Nothing that could count as God in such religions could possibly be observed, literally encountered, or detected in the universe. God, in such a conception, is utterly transcendent to the world; he is conceived of as pure spirit, an infinite individual who created the universe out of nothing and who is distinct from the universe. Such a realitya reality that is taken to be an ultimate mysterycould not be identified as objects or processes in the universe can be identified. There can be no pointing at or to God, no ostensive teaching of God, to show what is meant. The word God can only be taught intralinguistically. God is taught to someone who does not understand what the word means by the use of descriptions such as the maker of the universe, the eternal, utterly independent being upon whom all other beings depend, the first cause, the sole ultimate reality, or a self-caused being. For someone who does not understand such descriptions, there can be no understanding of the concept of God. But the key terms of such descriptions are themselves no more capable of ostensive definition (of having their referents pointed out) than is God, where that term is not, like Zeus, construed anthropomorphically. (That does not mean that anyone has actually pointed to Zeus or observed Zeus but that one knows what it would be like to do so.)

In coming to understand what is meant by God in such discourses, it must be understood that God, whatever else he is, is a being that could not possibly be seen or be in any way else observed. He could not be anything material or empirical, and he is said by believers to be an intractable mystery. A nonmysterious God would not be the God of Judaism, Christianity, and Islam.

This, in effect, makes it a mistake to claim that the existence of God can rightly be treated as a hypothesis and makes it a mistake to claim that, by the use of the experimental method or some other determinate empirical method, the existence of God can be confirmed or disconfirmed as can the existence of an empirical reality. The retort made by some atheists, who also like pragmatists remain thoroughgoing fallibilists, is that such a proposed way of coming to know, or failing to come to know, God makes no sense for anyone who understands what kind of reality God is supposed to be. Anything whose existence could be so verified would not be the God of Judeo-Christianity. God could not be a reality whose presence is even faintly adumbrated in experience, for anything that could even count as the God of Judeo-Christianity must be transcendent to the world. Anything that could actually be encountered or experienced could not be God.

At the very heart of a religion such as Christianity there stands a metaphysical belief in a reality that is alleged to transcend the empirical world. It is the metaphysical belief that there is an eternal, ever-present creative source and sustainer of the universe. The problem is how it is possible to know or reasonably believe that such a reality exists or even to understand what such talk is about.

It is not that God is like a theoretical entity in physics such as a proton or a neutrino. They are, where they are construed as realities rather than as heuristically useful conceptual fictions, thought to be part of the actual furniture of the universe. They are not said to be transcendent to the universe, but rather are invisible entities in the universe logically on a par with specks of dust and grains of sand, only much, much smaller. They are on the same continuum; they are not a different kind of reality. It is only the case that they, as a matter of fact, cannot be seen. Indeed no one has an understanding of what it would be like to see a proton or a neutrinoin that way they are like Godand no provision is made in physical theory for seeing them. Still, there is no logical ban on seeing them as there is on seeing God. They are among the things in the universe, and thus, though they are invisible, they can be postulated as causes of things that are seen. Since this is so it becomes at least logically possible indirectly to verify by empirical methods the existence of such realities. It is also the case that there is no logical ban on establishing what is necessary to establish a causal connection, namely a constant conjunction of two discrete empirical realities. But no such constant conjunction can be established or even intelligibly asserted between God and the universe, and thus the existence of God is not even indirectly verifiable. God is not a discrete empirical thing or being, and the universe is not a gigantic thing or process over and above the things and processes in the universe of which it makes sense to say that the universe has or had a cause. But then there is no way, directly or indirectly, that even the probability that there is a God could be empirically established.

Follow this link:

atheism | Definition, Philosophy, & Comparison to …

atheism r/atheism – reddit: the front page of the internet

This happened around last year when they just found out that i was an atheist. My parents sat down with me (and for some reason they roped my brother in too) to kinda talk it out with them, the why and how and all that.

So my father was talking about how god had blessed him and his family with a luxurious and comfortable life. I, thinking that my parents would hear me out since they got out of their own way just to talk about religion with us, told them that i believed that they worked hard and earned the money themselves.

Surprisingly enough, my father immediately blew his top off and yelled at me, insisting that it was by god’s grace that we are now able to live such a good life. He then, for some reason told me that my ability to draw was a god-given talent. Naturally, i was pissed. After all, i went to years and years of art class just to be able to draw like i do now, though it only looks nice in my family’s standards since i’m the only one in my family that can draw. But i didn’t say anything back since i don’t want to start another war with m parents.

Seriously, if it really was just god’s grace that allowed my family to live comfortably, why have i never seen god just bestow upon my father a paycheck? Why is it that he’s so happy about having all his hard work credited to an invisible sky daddy? Call me greedy or selfish, but if someone took all the credit to my hard work i’d be bloody pissed. But hey, thanks for reading this.

See original here:

atheism r/atheism – reddit: the front page of the internet

Atheism | CARM.org

Atheism is a lack of belief in any God and deities as well as a total denial of the existence of any god. It is a growing movement that is becoming more aggressive, more demanding, and less tolerant of anything other than itself – as is exemplified by its adherents. Is atheism a sound philosophical system as a worldview or is it ultimately self-defeating? Is the requirement of empirical evidence for God a mistake in logic or is it a fair demand? Can we prove that God exists or is that impossible? Find out more about atheism, its arguments, and its problems here at CARM. Learn how to deal with the arguments raised against the existence of God that seek to replace Him with naturalism, materialism, and moral relativism.

More here:

Atheism | CARM.org

Atheism – Simple English Wikipedia, the free encyclopedia

Atheism is rejecting the belief in a god or gods. It is the opposite of theism, which is the belief that at least one god exists.A person who rejects belief in gods is called an atheist.Theism is the belief in one or more gods. Adding an a, meaning “without”, before the word theism results in atheism, or literally, “without theism”.. Atheism is not the same as agnosticism: agnostics say that …

View original post here:

Atheism – Simple English Wikipedia, the free encyclopedia

AltLeft.com "The Left of the AltRight"

Of all the mental shortcuts embedded in human languages which impede understanding of mindless processes (such as natural selection), few are more obnoxious than because. From this comes a tendency to anthropomorphise, and read all outcomes in nature as if they were ordained by something approximating an intention. Religion has to be an adaptation, because the religious (currently) outbreed the irreligious. The second clause in that sentence is (currently) correct, but the because makes it sound as though the current religious selection advantage represents some design feature with the desired (by what?) end of promoting reproductive fitness (adaptation). And fitness is where the matter rests. Contrast with the following sentence:

Under current conditions in which the religious outbreed the irreligious, religion is adaptive. This statement is of course tautologous, since to say that a trait or behaviour is adaptive means merely that under condition X it gives one a reproductive edge. The term adaptation, though, is often applied to traits or behaviours which are selectively neutral or even counter-adaptive in particular environments. Genes which contribute to an overzealous appetite may be fitness-neutral to a subsistence farmer but become obesogenic in the modern world of easily available food. The genes carrier still exercises this adaptation, but it is no longer adaptive, reproductively useful, except in an environment full of fat-fetishists.

Human society has changed so dramatically in the last two centuries that it would be hasty to say the least to assume that everything with a current selective disadvantage is an illness (due to pathogens, mutational load, or whatever). Just as equally, one cannot assume that something with a current advantage exists having evolved by resolving an adaptive problem. Religion was ubiquitous across cultures before the 20th century, yet now the religious fraction represent an ever tinier percentage of the population in many countries, and it remains to be seen just how tiny the genetic hard core of religiosity will get before the trend is reversed. If the presence of religion were explicable in terms of fitness benefit, why are the genes not already more widespread? This alone should be enough to tell you that genes (and thus, adaptation) per se had little to do with religions evolution.

But apparently this is not obvious to some. Many people are inclined to view adaptations as intricate mechanisms, which by dint of their intricacy are delicate and susceptible to dysfunction, rather like the springs and levers of a pocket-watch. All analogies are imperfect, but this is a useless one. Some traits, and indeed behaviours, are more prone to changing by exogenous insults than others. For instance, a particularly naive person might imagine that in a pandemic of severe endometriosis, whereby female beauty and youth cease to be predictive as indicators of fertility, males would be disincentivised from their sexual attraction to these traits because the attraction would no longer perform its original functions. Needless to say, this would not happen. Male callogamy (attention to beauty) has proven so reliably fitness-enhancing over the eons, since even before the human species, that it is extraordinarily resilient to any incentive change: selection will always favour a deterministic developmental pathway for such consistently valuable traits. General intelligence is yet another example: the current dysgenic trend is a product of the last few generations and on the order of ~1 point per generation despite ramping up of mutational load globally (well see how long it can last), and almost no non-genetic factors seem capable of depressing its expression to any appreciable degree. Lead looked plausible at some point, but then you remember that Victorians liked to use mercury in their make-up, and yet the 19th century was the most intellectually productive in human history.

Viewed under this light, the religion as adaptation thesis looks all the more dubious. Evolutionary forces selection, mutation, drift, etc are just as capable of acting on general intelligence and other psychological traits as anything else, hence the well-documented evolved changes in the European peoples since around AD1000: declines in violence, and probably gains in intelligence, culminating ultimately in the zenith of the 19th century. Evolution can indeed happen fast, but not that fast. The bulk of these changes took place over a period of, at minimum, 20 generations, not 2-3, and our intelligence has more or less survived the last 2-3 generations intact. Religion has not. It has none of the hallmarks of an adaptation, but all the hallmarks of a complex socially learned behaviour, maintained by powerful norm-enforcers and epistemic authorities, which has lost currency in recent decades for a variety of reasons, the most commonsense explanation being that it no longer appeals to the educated because the answers it gives are inferior to those of other epistemic authorities, i.e. scientists.

The human capacity for cultural transmission through language makes a nonsense of the notion that anything which is not adaptive, even across all environments, should be impossible to sustain. The most obvious example in Christian cultures is the vow of celibacy, and there are numerous others such as taboos against eating highly nutrient-dense foods, which persist among the undernourished tribes of Papua New Guinea. So too with the European wars of religion, which resulted in millions of young men dying childless in their haste to protect a non-existent natural resource, i.e. Gods favour.

Group selection is another temptation when formulating theories about the origin of religion the idea that even a behaviour which reduces fitness at the individual level can persist if it provides some advantage at the level of the social group. It is a neat idea, but clearly unworkable in practice. Suppose some cohort of ones country likes spreading the word of God through warfare call this behaviour X. They can seize new territory in Gods name and provide new land for others in their group who are not quite so zealous, and this may look like a success to the people who reap those rewards, but at the end of the day: the behaviour is still going to diminish because everyone who engages in it is at a massively elevated risk of dying before reproduction. Evolution does not care about states or dominions.

It is understandable why post hoc stories about religion as adaptation are popular, even among well-informed people. Intelligence is not a good predictor of having sensible views where political matters are concerned, since politics is about group loyalty more than anything else. This is why the number of US Democrats who thought immigration was an important social issue declined precipitously in the 2010s when it became the issue of the right; what mattered was showing solidarity against rival political coalitions (i.e. the right) rather than the truth. Adaptive stories about religion seem to appeal an awful lot to European traditionalist-nationalists who are hoping to use Christianity as the conduit for some kind of renewed ethnocentrism to uplift the European spirit. The Chinese do not seem to need it, oddly enough. Nor even the Czechs, much closer to home. It did not work for Rome, and it sure as fuck wont for us.

Like Loading…

Continued here:

AltLeft.com "The Left of the AltRight"

Column editing (Alt+Left mouse click and drag) is not …

Using remote desktop (in a citrix env), I dialed into my desktop from my laptop and opened a file in the Notepad++. I am not able to use the column editing feature in that scenario, however it works very well if I use it directly on the desktop (sorry, I dont have enough reputation to post a screenshot.)

In the remote desktop scenario, when I press Alt+click and drag, if I am in windowed mode, the window will start moving. In case of fullscreen mode, nothing happens.

Can someone please help me?

See more here:

Column editing (Alt+Left mouse click and drag) is not …

Andrew Yang Rejects Support From White Nationalists …

$1,000 a month or mainstream conservatism? It focuses the mind like a laser:

Theres no indication that the campaign has courted that support, and when reached by The Verge, Yang unequivocally rejected it. I denounce and disavow hatred, bigotry, racism, white nationalism, anti-Semitism and the alt-right in all its many forms. Full stop, Yang said in a statement. For anyone with this agenda, we do not want your support. We do not want your votes. You are not welcome in this campaign.

As one of the first Asian American candidates for President in our history and the son of immigrants, I see racism and white nationalism as a threat to the core ideals of what it means to be an American, Yang continued. I have two young children who will grow up in this country. I know what that means.

There are some people who are mad about this.

Im not one of those people. Why on earth would I be mad about this? The GOP Congress has condemned White Nationalists at least three times since Charlottesville. If memory serves, I believe they have done it last week and at least twice so far this year alone. Donald Trump even said after the shooting in Pittsburgh that those seeking the Jews destruction, we will seek their destruction.

Im under no illusions that Andrew Yang, an Asian Democrat running in a Democratic primary, is a White Nationalist or Alt-Right candidate. He is a Green Nationalist. He wants to give everyone $1,000 a month. Im on board with that. And let me tell you, Green Nationalism is sounding a whole lot more attractive right now than four more years of cuckservatism.

I voted for Donald Trump because of immigration, trade, foreign policy and political correctness. Ive watched him and graded him every day for over two years. He has failed across the board on all of those issues. He has also repeatedly shown that he is untrustworthy. What ever came of his promises to end birthright citizenship, social media censorship or Antifa violence? Does he not realize what a massive bait and switch it was to endorse RAISING legal immigration?

Now, I am thinking less about trying to reform the GOP and save America the last two years has shown that Republicans are utterly unwilling to so much as even try to amend their legislative agenda to make it more populist than what I can get out of the rotten system. Im now going to vote on the basis on issues like bills, health care, student loan debt and the costs of education. Thats what I want to hear about. Everyone has those concerns, not just White Nationalists.

I dont want to hear the 1,000th podcast about Robert Mueller or the 5,000th episode of Hannity about Peter Strzok. I dont want to read or listen to anymore copes about how Trump can still turn this around or wildly unrealistic 4D Chess scenarios about how Trump is going to do this or that at some point in the future. In 2020, I want candidates to explain to me in clear, unambiguous language what they can do to improve the material standard of living of White Americans.

The GOP isnt going to build the border wall. It isnt even going to deport the illegal aliens that are already here. It isnt going to do anything about cultural decay. It certainly isnt going to end abortion. None of the social issues that conservatives run on are real. The only thing that matters is rewarding donors with the policies they wanted like tax cuts, deregulation, criminal justice reform, etc. Cuckservatism has nothing going for it.

Im so over pretending that anyone in Republican politics or mainstream conservatism shares my values. Look around and you will find that the Trump entourage from top to bottom is nothing but uninspiring grifters with stale rhetoric: Charlie Kirk, Candace Owens, Diamond and Silk, Mike Huckabee, Seb Gorka, etc. If you watched CPAC and still believe that any of these types are going to somehow turn the country around, I got a 30 foot Mexican border wall to sell you!

When the GOP is running in 2020 on Democrats are the real anti-Semites and theyre gonna take away our cheeseburgers, literal Burger Nationalism which went from being a meme last year into their actual messaging, it is best to just step aside and take the Yang bucks.

Note: I dont even believe we will get those Yang bucks. I just think it is a better idea than anything that I saw at CPAC.

See more here:

Andrew Yang Rejects Support From White Nationalists …

Automate the Boring Stuff with Python

Knowing various Python modules for editing spreadsheets, downloading files, and launching programs is useful, but sometimes there just arent any modules for the applications you need to work with. The ultimate tools for automating tasks on your computer are programs you write that directly control the keyboard and mouse. These programs can control other applications by sending them virtual keystrokes and mouse clicks, justpython3- as if you were sitting at your computer and interacting with the applications yourself. This technique is known as graphical user interface automation, or GUI automation for short. With GUI automation, your programs can do anything that a human user sitting at the computer can do, except spill coffee on the keyboard.

Think of GUI automation as programming a robotic arm. You can program the robotic arm to type at your keyboard and move your mouse for you. This technique is particularly useful for tasks that involve a lot of mindless clicking or filling out of forms.

The pyautogui module has functions for simulating mouse movements, button clicks, and scrolling the mouse wheel. This chapter covers only a subset of PyAutoGUIs features; you can find the full documentation at http://pyautogui.readthedocs.org/.

The pyautogui module can send virtual keypresses and mouse clicks to Windows, OS X, and Linux. Depending on which operating system youre using, you may have to install some other modules (called dependencies) before you can install PyAutoGUI.

On Windows, there are no other modules to install.

On OS X, run sudo pip3 install pyobjc-framework-Quartz, sudo pip3 install pyobjc-core, and then sudo pip3 install pyobjc.

On Linux, run sudo pip3 install python3-xlib, sudo apt-get install scrot, sudo apt-get install python3-tk, and sudo apt-get install python3-dev. (Scrot is a screenshot program that PyAutoGUI uses.)

After these dependencies are installed, run pip install pyautogui (or pip3 on OS X and Linux) to install PyAutoGUI.

Appendix A has complete information on installing third-party modules. To test whether PyAutoGUI has been installed correctly, run import pyautogui from the interactive shell and check for any error messages.

Before you jump in to a GUI automation, you should know how to escape problems that may arise. Python can move your mouse and type keystrokes at an incredible speed. In fact, it might be too fast for other programs to keep up with. Also, if something goes wrong but your program keeps moving the mouse around, it will be hard to tell what exactly the program is doing or how to recover from the problem. Like the enchanted brooms from Disneys The Sorcerers Apprentice, which kept fillingand then overfillingMickeys tub with water, your program could get out of control even though its following your instructions perfectly. Stopping the program can be difficult if the mouse is moving around on its own, preventing you from clicking the IDLE window to close it. Fortunately, there are several ways to prevent or recover from GUI automation problems.

Perhaps the simplest way to stop an out-of-control GUI automation program is to log out, which will shut down all running programs. On Windows and Linux, the logout hotkey is CTRL-ALT-DEL. On OS X, it is -SHIFT-OPTION-Q. By logging out, youll lose any unsaved work, but at least you wont have to wait for a full reboot of the computer.

You can tell your script to wait after every function call, giving you a short window to take control of the mouse and keyboard if something goes wrong. To do this, set the pyautogui.PAUSE variable to the number of seconds you want it to pause. For example, after setting pyautogui.PAUSE = 1.5, every PyAutoGUI function call will wait one and a half seconds after performing its action. Non-PyAutoGUI instructions will not have this pause.

PyAutoGUI also has a fail-safe feature. Moving the mouse cursor to the upper-left corner of the screen will cause PyAutoGUI to raise the pyautogui.FailSafeException exception. Your program can either handle this exception with try and except statements or let the exception crash your program. Either way, the fail-safe feature will stop the program if you quickly move the mouse as far up and left as you can. You can disable this feature by setting pyautogui.FAILSAFE = False. Enter the following into the interactive shell:

Here we import pyautogui and set pyautogui.PAUSE to 1 for a one-second pause after each function call. We set pyautogui.FAILSAFE to True to enable the fail-safe feature.

In this section, youll learn how to move the mouse and track its position on the screen using PyAutoGUI, but first you need to understand how PyAutoGUI works with coordinates.

The mouse functions of PyAutoGUI use x- and y-coordinates. Figure18-1 shows the coordinate system for the computer screen; its similar to the coordinate system used for images, discussed in Chapter17. The origin, where x and y are both zero, is at the upper-left corner of the screen. The x-coordinates increase going to the right, and the y-coordinates increase going down. All coordinates are positive integers; there are no negative coordinates.

Figure18-1.The coordinates of a computer screen with 19201080 resolution

Your resolution is how many pixels wide and tall your screen is. If your screens resolution is set to 19201080, then the coordinate for the upper-left corner will be (0, 0), and the coordinate for the bottom-right corner will be (1919, 1079).

The pyautogui.size() function returns a two-integer tuple of the screens width and height in pixels. Enter the following into the interactive shell:

pyautogui.size() returns (1920, 1080) on a computer with a 19201080 resolution; depending on your screens resolution, your return value may be different. You can store the width and height from pyautogui.size() in variables like width and height for better readability in your programs.

Now that you understand screen coordinates, lets move the mouse. The pyautogui.moveTo() function will instantly move the mouse cursor to a specified position on the screen. Integer values for the x- and y-coordinates make up the functions first and second arguments, respectively. An optional duration integer or float keyword argument specifies the number of seconds it should take to move the mouse to the destination. If you leave it out, the default is 0 for instantaneous movement. (All of the duration keyword arguments in PyAutoGUI functions are optional.) Enter the following into the interactive shell:

This example moves the mouse cursor clockwise in a square pattern among the four coordinates provided a total of ten times. Each movement takes a quarter of a second, as specified by the duration=0.25 keyword argument. If you hadnt passed a third argument to any of the pyautogui.moveTo() calls, the mouse cursor would have instantly teleported from point to point.

The pyautogui.moveRel() function moves the mouse cursor relative to its current position. The following example moves the mouse in the same square pattern, except it begins the square from wherever the mouse happens to be on the screen when the code starts running:

pyautogui.moveRel() also takes three arguments: how many pixels to move horizontally to the right, how many pixels to move vertically downward, and (optionally) how long it should take to complete the movement. A negative integer for the first or second argument will cause the mouse to move left or upward, respectively.

You can determine the mouses current position by calling the pyautogui.position() function, which will return a tuple of the mouse cursors x and y positions at the time of the function call. Enter the following into the interactive shell, moving the mouse around after each call:

Of course, your return values will vary depending on where your mouse cursor is.

Being able to determine the mouse position is an important part of setting up your GUI automation scripts. But its almost impossible to figure out the exact coordinates of a pixel just by looking at the screen. It would be handy to have a program that constantly displays the x- and y-coordinates of the mouse cursor as you move it around.

At a high level, heres what your program should do:

This means your code will need to do the following:

Call the position() function to fetch the current coordinates.

Erase the previously printed coordinates by printing b backspace characters to the screen.

Handle the KeyboardInterrupt exception so the user can press CTRL-C to quit.

Open a new file editor window and save it as mouseNow.py.

Start your program with the following:

The beginning of the program imports the pyautogui module and prints a reminder to the user that they have to press CTRL-C to quit.

You can use an infinite while loop to constantly print the current mouse coordinates from mouse.position(). As for the code that quits the program, youll need to catch the KeyboardInterrupt exception, which is raised whenever the user presses CTRL-C. If you dont handle this exception, it will display an ugly traceback and error message to the user. Add the following to your program:

To handle the exception, enclose the infinite while loop in a try statement. When the user presses CTRL-C, the program execution will move to the except clause and Done. will be printed in a new line .

The code inside the while loop should get the current mouse coordinates, format them to look nice, and print them. Add the following code to the inside of the while loop:

Using the multiple assignment trick, the x and y variables are given the values of the two integers returned in the tuple from pyautogui.position(). By passing x and y to the str() function, you can get string forms of the integer coordinates. The rjust() string method will right-justify them so that they take up the same amount of space, whether the coordinate has one, two, three, or four digits. Concatenating the right-justified string coordinates with ‘X: ‘ and ‘ Y: ‘ labels gives us a neatly formatted string, which will be stored in positionStr.

At the end of your program, add the following code:

This actually prints positionStr to the screen. The end=” keyword argument to print() prevents the default newline character from being added to the end of the printed line. Its possible to erase text youve already printed to the screenbut only for the most recent line of text. Once you print a newline character, you cant erase anything printed before it.

To erase text, print the b backspace escape character. This special character erases a character at the end of the current line on the screen. The line at uses string replication to produce a string with as many b characters as the length of the string stored in positionStr, which has the effect of erasing the positionStr string that was last printed.

For a technical reason beyond the scope of this book, always pass flush=True to print() calls that print b backspace characters. Otherwise, the screen might not update the text as desired.

Since the while loop repeats so quickly, the user wont actually notice that youre deleting and reprinting the whole number on the screen. For example, if the x-coordinate is 563 and the mouse moves one pixel to the right, it will look like only the 3 in 563 is changed to a 4.

When you run the program, there will be only two lines printed. They should look like something like this:

The first line displays the instruction to press CTRL-C to quit. The second line with the mouse coordinates will change as you move the mouse around the screen. Using this program, youll be able to figure out the mouse coordinates for your GUI automation scripts.

Now that you know how to move the mouse and figure out where it is on the screen, youre ready to start clicking, dragging, and scrolling.

To send a virtual mouse click to your computer, call the pyautogui.click() method. By default, this click uses the left mouse button and takes place wherever the mouse cursor is currently located. You can pass x- and y-coordinates of the click as optional first and second arguments if you want it to take place somewhere other than the mouses current position.

If you want to specify which mouse button to use, include the button keyword argument, with a value of ‘left’, ‘middle’, or ‘right’. For example, pyautogui.click(100, 150, button=’left’) will click the left mouse button at the coordinates (100, 150), while pyautogui.click(200, 250, button=’right’) will perform a right-click at (200, 250).

Enter the following into the interactive shell:

You should see the mouse pointer move to near the top-left corner of your screen and click once. A full click is defined as pushing a mouse button down and then releasing it back up without moving the cursor. You can also perform a click by calling pyautogui.mouseDown(), which only pushes the mouse button down, and pyautogui.mouseUp(), which only releases the button. These functions have the same arguments as click(), and in fact, the click() function is just a convenient wrapper around these two function calls.

As a further convenience, the pyautogui.doubleClick() function will perform two clicks with the left mouse button, while the pyautogui.rightClick() and pyautogui.middleClick() functions will perform a click with the right and middle mouse buttons, respectively.

Dragging means moving the mouse while holding down one of the mouse buttons. For example, you can move files between folders by dragging the folder icons, or you can move appointments around in a calendar app.

PyAutoGUI provides the pyautogui.dragTo() and pyautogui.dragRel() functions to drag the mouse cursor to a new location or a location relative to its current one. The arguments for dragTo() and dragRel() are the same as moveTo() and moveRel(): the x-coordinate/horizontal movement, the y-coordinate/vertical movement, and an optional duration of time. (OS X does not drag correctly when the mouse moves too quickly, so passing a duration keyword argument is recommended.)

To try these functions, open a graphics-drawing application such as Paint on Windows, Paintbrush on OS X, or GNU Paint on Linux. (If you dont have a drawing application, you can use the online one at http://sumopaint.com/.) I will use PyAutoGUI to draw in these applications.

With the mouse cursor over the drawing applications canvas and the Pencil or Brush tool selected, enter the following into a new file editor window and save it as spiralDraw.py:

When you run this program, there will be a five-second delay for you to move the mouse cursor over the drawing programs window with the Pencil or Brush tool selected. Then spiralDraw.py will take control of the mouse and click to put the drawing program in focus . A window is in focus when it has an active blinking cursor, and the actions you takelike typing or, in this case, dragging the mousewill affect that window. Once the drawing program is in focus, spiralDraw.py draws a square spiral pattern like the one in Figure18-2.

Figure18-2.The results from the pyautogui.dragRel() example

The distance variable starts at 200, so on the first iteration of the while loop, the first dragRel() call drags the cursor 200 pixels to the right, taking 0.2 seconds . distance is then decreased to 195 , and the second dragRel() call drags the cursor 195 pixels down . The third dragRel() call drags the cursor 195 horizontally (195 to the left) , distance is decreased to 190, and the last dragRel() call drags the cursor 190 pixels up. On each iteration, the mouse is dragged right, down, left, and up, and distance is slightly smaller than it was in the previous iteration. By looping over this code, you can move the mouse cursor to draw a square spiral.

You could draw this spiral by hand (or rather, by mouse), but youd have to work slowly to be so precise. PyAutoGUI can do it in a few seconds!

You could have your code draw the image using the pillow modules drawing functionssee Chapter17 for more information. But using GUI automation allows you to make use of the advanced drawing tools that graphics programs can provide, such as gradients, different brushes, or the fill bucket.

The final PyAutoGUI mouse function is scroll(), which you pass an integer argument for how many units you want to scroll the mouse up or down. The size of a unit varies for each operating system and application, so youll have to experiment to see exactly how far it scrolls in your particular situation. The scrolling takes place at the mouse cursors current position. Passing a positive integer scrolls up, and passing a negative integer scrolls down. Run the following in IDLEs interactive shell while the mouse cursor is over the IDLE window:

Youll see IDLE briefly scroll upwardand then go back down. The downward scrolling happens because IDLE automatically scrolls down to the bottom after executing an instruction. Enter this code instead:

This imports pyperclip and sets up an empty string, numbers. The code then loops through 200 numbers and adds each number to numbers, along with a newline. After pyperclip.copy(numbers), the clipboard will be loaded with 200 lines of numbers. Open a new file editor window and paste the text into it. This will give you a large text window to try scrolling in. Enter the following code into the interactive shell:

On the second line, you enter two commands separated by a semicolon, which tells Python to run the commands as if they were on separate lines. The only difference is that the interactive shell wont prompt you for input between the two instructions. This is important for this example because we want to the call to pyautogui.scroll() to happen automatically after the wait. (Note that while putting two commands on one line can be useful in the interactive shell, you should still have each instruction on a separate line in your programs.)

After pressing ENTER to run the code, you will have five seconds to click the file editor window to put it in focus. Once the pause is over, the pyautogui.scroll() call will cause the file editor window to scroll up after the five-second delay.

Your GUI automation programs dont have to click and type blindly. PyAutoGUI has screenshot features that can create an image file based on the current contents of the screen. These functions can also return a Pillow Image object of the current screens appearance. If youve been skipping around in this book, youll want to read Chapter17 and install the pillow module before continuing with this section.

On Linux computers, the scrot program needs to be installed to use the screenshot functions in PyAutoGUI. In a Terminal window, run sudo apt-get install scrot to install this program. If youre on Windows or OS X, skip this step and continue with the section.

To take screenshots in Python, call the pyautogui.screenshot() function. Enter the following into the interactive shell:

The im variable will contain the Image object of the screenshot. You can now call methods on the Image object in the im variable, just like any other Image object. Enter the following into the interactive shell:

Pass getpixel() a tuple of coordinates, like (0, 0) or (50, 200), and itll tell you the color of the pixel at those coordinates in your image. The return value from getpixel() is an RGB tuple of three integers for the amount of red, green, and blue in the pixel. (There is no fourth value for alpha, because screenshot images are fully opaque.) This is how your programs can see what is currently on the screen.

Say that one of the steps in your GUI automation program is to click a gray button. Before calling the click() method, you could take a screenshot and look at the pixel where the script is about to click. If its not the same gray as the gray button, then your program knows something is wrong. Maybe the window moved unexpectedly, or maybe a pop-up dialog has blocked the button. At this point, instead of continuingand possibly wreaking havoc by clicking the wrong thingyour program can see that it isnt clicking on the right thing and stop itself.

PyAutoGUIs pixelMatchesColor() function will return True if the pixel at the given x- and y-coordinates on the screen matches the given color. The first and second arguments are integers for the x- and y-coordinates, and the third argument is a tuple of three integers for the RGB color the screen pixel must match. Enter the following into the interactive shell:

After taking a screenshot and using getpixel() to get an RGB tuple for the color of a pixel at specific coordinates , pass the same coordinates and RGB tuple to pixelMatchesColor() , which should return True. Then change a value in the RGB tuple and call pixelMatchesColor() again for the same coordinates . This should return false. This method can be useful to call whenever your GUI automation programs are about to call click(). Note that the color at the given coordinates must exactly match. If it is even slightly differentfor example, (255, 255, 254) instead of (255, 255, 255)then pixelMatchesColor() will return False.

You could extend the mouseNow.py project from earlier in this chapter so that it not only gives the x- and y-coordinates of the mouse cursors current position but also gives the RGB color of the pixel under the cursor. Modify the code inside the while loop of mouseNow.py to look like this:

Now, when you run mouseNow.py, the output will include the RGB color value of the pixel under the mouse cursor.

This information, along with the pixelMatchesColor() function, should make it easy to add pixel color checks to your GUI automation scripts.

But what if you do not know beforehand where PyAutoGUI should click? You can use image recognition instead. Give PyAutoGUI an image of what you want to click and let it figure out the coordinates.

For example, if you have previously taken a screenshot to capture the image of a Submit button in submit.png, the locateOnScreen() function will return the coordinates where that image is found. To see how locateOnScreen() works, try taking a screenshot of a small area on your screen; then save the image and enter the following into the interactive shell, replacing ‘submit. png’ with the filename of your screenshot:

The four-integer tuple that locateOnScreen() returns has the x-coordinate of the left edge, the y-coordinate of the top edge, the width, and the height for the first place on the screen the image was found. If youre trying this on your computer with your own screenshot, your return value will be different from the one shown here.

If the image cannot be found on the screen, locateOnScreen() will return None. Note that the image on the screen must match the provided image perfectly in order to be recognized. If the image is even a pixel off, locateOnScreen() will return None.

If the image can be found in several places on the screen, locateAllOnScreen() will return a Generator object, which can be passed to list() to return a list of four-integer tuples. There will be one four-integer tuple for each location where the image is found on the screen. Continue the interactive shell example by entering the following (and replacing ‘submit.png’ with your own image filename):

Each of the four-integer tuples represents an area on the screen. If your image is only found in one area, then using list() and locateAllOnScreen() just returns a list containing one tuple.

Once you have the four-integer tuple for the area on the screen where your image was found, you can click the center of this area by passing the tuple to the center() function to return x- and y-coordinates of the areas center. Enter the following into the interactive shell, replacing the arguments with your own filename, four-integer tuple, and coordinate pair:

Once you have center coordinates from center(), passing the coordinates to click() should click the center of the area on the screen that matches the image you passed to locateOnScreen().

PyAutoGUI also has functions for sending virtual keypresses to your computer, which enables you to fill out forms or enter text into applications.

The pyautogui.typewrite() function sends virtual keypresses to the computer. What these keypresses do depends on what window and text field have focus. You may want to first send a mouse click to the text field you want in order to ensure that it has focus.

As a simple example, lets use Python to automatically type the words Hello world! into a file editor window. First, open a new file editor window and position it in the upper-left corner of your screen so that PyAutoGUI will click in the right place to bring it into focus. Next, enter the following into the interactive shell:

Notice how placing two commands on the same line, separated by a semicolon, keeps the interactive shell from prompting you for input between running the two instructions. This prevents you from accidentally bringing a new window into focus between the click() and typewrite() calls, which would mess up the example.

Python will first send a virtual mouse click to the coordinates (100, 100), which should click the file editor window and put it in focus. The typewrite() call will send the text Hello world! to the window, making it look like Figure18-3. You now have code that can type for you!

Figure18-3.Using PyAutogGUI to click the file editor window and type Hello world! into it

By default, the typewrite() function will type the full string instantly. However, you can pass an optional second argument to add a short pause between each character. This second argument is an integer or float value of the number of seconds to pause. For example, pyautogui.typewrite(‘Hello world!’, 0.25) will wait a quarter-second after typing H, another quarter-second after e, and so on. This gradual typewriter effect may be useful for slower applications that cant process keystrokes fast enough to keep up with PyAutoGUI.

For characters such as A or !, PyAutoGUI will automatically simulate holding down the SHIFT key as well.

Not all keys are easy to represent with single text characters. For example, how do you represent SHIFT or the left arrow key as a single character? In PyAutoGUI, these keyboard keys are represented by short string values instead: ‘esc’ for the ESC key or ‘enter’ for the ENTER key.

Instead of a single string argument, a list of these keyboard key strings can be passed to typewrite(). For example, the following call presses the A key, then the B key, then the left arrow key twice, and finally the X and Y keys:

Because pressing the left arrow key moves the keyboard cursor, this will output XYab. Table18-1 lists the PyAutoGUI keyboard key strings that you can pass to typewrite() to simulate pressing any combination of keys.

You can also examine the pyautogui.KEYBOARD_KEYS list to see all possible keyboard key strings that PyAutoGUI will accept. The ‘shift’ string refers to the left SHIFT key and is equivalent to ‘shiftleft’. The same applies for ‘ctrl’, ‘alt’, and ‘win’ strings; they all refer to the left-side key.

Table18-1.PyKeyboard Attributes

Keyboard key string

Meaning

Continue reading here:

Automate the Boring Stuff with Python

UI Events KeyboardEvent code Values – World Wide Web …

1. Introduction

This document provides an overview of the various keyboard layouts andspecifies the KeyboardEvent.code values that should beused for each of the keys. Unlike the key values describedin [UIEvents-key], the code values are based only on thekeys physical location on the keyboard and do not vary based on the userscurrent locale.

This specification was formerly titled DOM Level 3 KeyboardEvent code Values.

This specification uses the following conventions:

This section is non-normative.

Alphanumeric keyboards are the most common way for users to generatekeyboard events. This section provides an overview of standard keyboards andtheir physical layouts.

This section describes the physical layouts found on commonly availablekeyboards.

When discussing keyboard layouts, it is convenient to divide thestandard keyboard into distinct sections and to label each row.

These keyboard sections are:

The alphanumeric section is the main part of thekeyboard and is where most of the keyboard variation occurs.When a user selects a keyboard layout, it is the keys in thissections that are most affected.

The control pad and arrow pad sections contain the arrow keys and other editing keys.

The numpad (also known as the “numeric keypad”or “number pad”) contains number and math keys to make it easierto enter numeric data.

And finally, the function section containsmiscellaneous function keys and special keys like Escape.

To make it easier to identify keys, the rows on the keyboard arenamed starting with “A” for the bottom row up to “E” for the toprow. The row of keys in the function section are considered to be inrow “K”. These row names are consistent with those given in [ISO9995-1].

Note that many keyboards (both modern and legacy) have extra keysthat do not fit neatly into the above sections. Some of these keysare covered in 3.1.6 Media Keys.

The standard “101” keyboard (commonly referred to as the “USlayout”) is the only layout that has a “Backslash” key (labeled |) above a single-row Enter key. All the otherlayouts omit this key and expand the Enter key tooccupy two-rows.

Modern standard “101”-layout keyboards actually contain 104 keys: 61keys in the alphanumeric section and 43 keys in the numpad, control pad, arrow pad and function sections.The “101” name for this keyboard layout dates to thetime when this standard keyboard did in fact contain 101 keys. Thetwo Meta keys (commonly given an OS-specific label), and the Menu key were added later to bring the total to 104 keys.

The alternate “101” keyboard has a large Enter key andshrinks the Backspace key to make room for the “IntlYen” key (which replaces the “Backslash” key found in the standard101 layout). The “IntlYen” name comes from the Japanese layoutwhere this is the (yen) key in the Russianlayout shown below this key maps to a /.

Modern alternate “101”-layout keyboards contain 104 keys: 61 keys inthe alphanumeric section and 43 keys in the numpad, control pad, arrow pad and function sections.

The standard “102” keyboard is common throughout Europe and adds akey that doesnt exist on the “101” layouts: The “IntlBackslash” key (labelled | on a UK keyboard) next to the left shiftkey.

A second key is also added (labelled #~ on a UKkeyboard) which is partially tucked under the Enter key.This key is encoded as “Backslash”, using the same code as the | key found on the “101” keyboard layout.According to [USB-HID], the US | and UK #~ areactually two separate keys (named “Keyboard and |” and “KeyboardNon-US # and ~”), but since these two keys never co-occur on thesame keyboard most platforms use the same scancode for both keys,making them difficult to distinguish. It is for this reason that thecode “Backslash” is used for both of these keys.

Modern “102”-layout keyboards contain 105 keys: 62 keys in the alphanumeric section and 43 keys in the numpad, control pad, arrow pad and function sections.

The Korean “103” keyboard is based on the alternate 101 layout andadds two additional keys (one on each side of the spacebar) tohandle Korean-specific input modes. These keys are “Lang2” (“Hanja”, labelled hanja)and “Lang1” (“HangulMode”, labelled / han/yeong).

Modern “103”-layout keyboards contain 106 keys: 63 keys in the alphanumeric section and 43 keys in the numpad, control pad, arrow pad and function sections.

The “104” layout used in Brazil adds 4 new keys: two keysfrom the “102” layout (“Backslash” and “IntlBackslash”) plusthe “IntlRo” key (next to the right shift key) and an extra keyon the numpad. This new numpad key is called “NumpadComma” because it represents the thousands separator. Onthe Brazilian key layout, this key is labelled . and the “NumpadDecimal” key is labelled ,.

Modern “104”-layout keyboards contain 107 keys: 63 keys in the alphanumeric section and 44 keys in the numpad, control pad, arrow pad and function sections.Some Brazilian keyboards lack the extra numpad key and haveonly 106 keys.

The Japanese “106” keyboard layout adds 3 new keys: “IntlYen” (labelled _), “Backslash” (labelled ])and “IntlRo” (labelled ).It also shrinks the spacebar to make room for 3 input mode keys: “NonConvert” (labelled muhenkan), “Convert” (labelled henkan)and “KanaMode” (labelled // katakana/hiragana/romaji).

Modern “106”-layout keyboards contain 109 keys: 66 keys in the alphanumeric section and 43 keys in the numpad, control pad, arrow pad and function sections.

In general, Apple keyboards follow the same layout as PC keyboards,but there are some differences as noted in the following figure.

In this figure, the green keys are those that have been moved to anew location while the blue keys indicate keys that have been added.

The limited space available on laptop keyboards often means that thephysical key layout needs to be adjusted to fit all the requiredkeys. The writing system keys in the alphanumericsection tend to remain intact, but the other keyboard sectionsare usually combined with other keys or removed altogether.

In this Apple laptop keyboard, the right control key has beenremoved to make room for half-height arrow keys and a Fn keyis added on the left.

PC laptop keyboards vary considerably, but this sample keyboarddemonstrates some commonly found aspects. The control pad keys are added along the right-hand side with the arrow pad keys tucked in along the bottom. The right Shift key isoften shrunk to make room for the up arrow key and the right Meta key is typically removed altogether.

In the case where a content author wishes to rely on the mechanicallayout of a mobile keypad, this specification suggests the keyboardconfiguration specified in [ISO9995-8], which defines a numeric keypadlayout and secondary assignment of Unicode characters in the range U+0061 … U+007A (“a” – “z”) to the number keys 2 through 9, as a common layout appropriate to someinternational uses.

This keypad layout, and in particular the distribution of letters is forEnglish devices, and will not match the keypads or configurations ofmany users. Content authors cannot rely upon any particularconfiguration, and are expected to create content in aninternationalized and localizable manner.

Many keyboards contain special keys to control media functions.Increasingly, many media devices, especially televisions, areWeb-enabled. Hybrid keyboard/remote-control devices are becoming morecommon. To meet the needs of these hybrid Web/media devices, thisspecification defines keys that are common as remote control buttons, inaddition to traditional keyboard keys.

Because of the smaller form factor, keys (or buttons) on a remotecontrol will often be modal, with one key performing different functionsbased on the context of the on-screen content. Additionally, many keysserve as toggles, to change back and forth between two or more states(see toggling keys). These remote control buttons typically do not havemodifier states so each button is assigned a single function (like Play, Pause, Up, Menu or Exit).

Virtual keyboards are software-based sets of keys, in a variety ofdifferent arrangements, commonly found on touch-screen devices. They areoften modal, with the ability to switch between different dynamic setsof keys, such as alphabetic, numeric, or symbolic keys. Because of thelack of physical constraints, these keyboards MAY present the widestrange of characters, including emoticons and other symbols. Wherever possible,however, virtual keyboards SHOULD produce the normal range of keyboard eventsand values, for ease of authoring and compatibility with existing content.

Chording keyboards, also known as chorded keysets or chord keyboards, arekey input devices which produce values by pressing several keys incombination or sequence, normally to simulate a full range of charactersor commands on a reduced set of keys, often for single-handed use.Achording keyboard MAY have additional mode keys to switch between keyvalues, and the number and type of keys pressed to produce a key valuewill vary, but the final key values produced by such keyboards SHOULDmatch the range of key values described in this specification.

For these and other alternative modal keyboards, the key values “Alphanumeric”, “CapsLock”, “NumLock”,and “SymbolLock” are RECOMMENDED for the keys which switch between different modes.

A key code attribute value is any of the values given in the=KeyboardEvent.code= column of any of the tables in this section of thespecification.

A conforming implementation of the KeyboardEvent interface MUST supportthis set of values for use in the code attributes,although not all values MAY be available on all platforms or devices.

This section defines a list of code values whichimplementations MUST support.

Future versions of this specification MAY include code values not includedhere, which have become common since the publication of this specification.

Note: While every attempt has been made to make this list of values as complete as possible,new values will periodically need to be defined as new input devices are introduced.Rather than allowing user agents to define their own key code attribute values (which are unlikely to be consistent across multiple user agents), bugs SHOULD befiled so that this specification can be updated.

This section describes the various keyboard sections in more detail anddefines the code values that should be used for eachkey.

The alphanumeric section is the main section of the keyboard. Itcontains keys that fall into two generalcategories: writing system keys whose meaningchanges based on the current keyboard layout, and functional keys which are (mostly) the same for alllayouts.

The writing system keys are those that changemeaning (i.e., they produce different key values) based on the current locale and keyboard layout.

This figure shows a hypothetical keyboard that combines all the writing system keys (shown in blue and green) found on thevarious keyboards. Blue keys are present on all standardkeyboards while green keys are only available on some keyboards.

The name shown on each key is the code assigned to that key. Wherever possible, the code names are based on the name for the USkey in that position (i.e., they are based on the US keyboardlayout). For keys that dont exist on the US keyboard, namesfrom the UK or Japanese layouts are used instead.

Note that there are two “Backslash” keys in this figure: alarge one at the end of Row D on the 101-key layout, and asmaller one between “Quote” and “Enter” on Row C of the102-, 104- and 106-key layouts. Only one “Backslash” keymay be present on a keyboard layout.

The functional keys (not to be confused with the function keys described later) are those keys in the alphanumeric section that provide general editingfunctions that are common to all locales (like Shift, Tab, Enter and Backspace). With a fewexceptions, these keys do not change meaning based on thecurrent keyboard layout.

The “AltRight” key (highlighted in green) is the only functional key that does not generate the same key value for every locale. In some locales itproduces “Alt” while in others it produces “AltGraph”.

On some keyboards (notably Japanese and Korean) the spacebar isreduced in size to make room for extra keys on the bottom row (Row A).These keys typically allow the users to change the current inputmode. Note that even though some of these Japanese and Koreankeys occupy the same physical location on the keyboard, they usedifferent code values.

On Apple keyboards, some keys on the bottom row are omitted andothers are arranged in a different order.

The control pad section of the keyboard is the set of (usually 6) keysthat perform navigating and editing operations, for example, Home, PageUp and Insert.

The code for the Fn key (found on someApple keyboards) is defined below in the function section.

The arrow pad contains the 4 arrow keys. The keys are commonlyarranged in an “upside-down T” configuration.

The numpad section is the set of keys on the keyboard arranged ina grid like a calculator or mobile phone. This section contains numeric andmathematical operator keys. Often this section will contain a NumLock key which causes the keys to switch between the standard numeric functionsand mimicking the keys of the control pad and arrow pad.Laptop computers and compact keyboards will commonly omit thesekeys to save space.

A keypad is an alternate term for numpad.

The code values in this section should also beused for phone keypads and remote control devices thatarrange number keys in a grid.

The standard numpad is sometimes extended with additional keys forparentheses, operators, hexadecimal symbols, or calculator functions(like Backspace). Some of the commonly added keys are listedin the table below.

For numpads that provide keys not listed here, a code value string should be created by startingwith “Numpad” and appending an appropriate description of the key.

The function section runs along the top of the keyboard (abovethe alphanumeric section) andcontains the function keys and a few additional special keys(for example, Esc and Print Screen).

A function key is any of the keys labelled F1 … F12 that an application or operating system can associate with a custom functionor action.

On some keyboards (especially those found on laptops or otherportable computers), the function keys (F1 … F12) are defined to have other primary functions (likecontrolling display brightness or audio volume) and require that aseparate Fn key be pressed to make them act as functionkeys. Unfortunately, the primary functions assigned to these keysvaries widely from one manufacturer to the next. Because of this,the code is always set to the function key name.

For keyboards that provide more than 12 function keys, the code value follows the pattern shown above with”F” followed by the function key number – “F13”, “F14”, “F15”, and so on.

Apple keyboards may have Eject or Power keys in the function section. The code values for thesekeys are defined in 3.1.6 Media Keys.

Media keys are extra keys added to a keyboard that provide media related functionality like play, pause or volume control. These keys do nothave a standard location on the keyboard so keyboards from differentmanufacturers are likely to have a different arrangement of keys or acompletely different sets of keys.

Media keys are often distinct fromnormal typing keys in appearance and may be recessed in thekeyboard.

On laptop keyboards, these keys are often merged with the function keys, with the media key interpretation beingthe primary function of the key and the function key interpretation requiring the Fn key to be pressed at thesame time. In this configuration the code shouldbe set to match the function key (“F1” … “F12”).When the keys are merged in this fashion, the code values are taken from the function key value because the media key value is not consistent across keyboards.

These keys are not found on modern standard keyboards. They arelisted here for reference purposes.

The following keys may be found on non-standard international keyboards.

And finally, the following code value should onlybe used when the corresponding key does not correspond to any of the code values given elsewhere in this specification.This value is appropriate for use with virtual keyboards that do nothave their keys arranged in a way that corresponds to those on aphysical keyboard.

Conforming implementations MUST only use “Unidentified” as a key codewhen there is no way for the implementation to determine the key code.Exposing only this value MUST NOT indicate a conforming implementation.

Considerable thanks are due to the following participants of the WebAppsWorking Group for providing substantial material contributions in theprocess of developing this specification.

Gary Kacmarcik (Google),Masayuki Nakano (Mozilla)

Originally posted here:

UI Events KeyboardEvent code Values – World Wide Web …

Ripple Price Forecast: XRP vs SWIFT, SEC Updates, and More

Ripple vs SWIFT: The War Begins
While most criticisms of XRP do nothing to curb my bullish Ripple price forecast, there is one obstacle that nags at my conscience. Its name is SWIFT.

The Society for Worldwide Interbank Financial Telecommunication (SWIFT) is the king of international payments.

It coordinates wire transfers across 11,000 banks in more than 200 countries and territories, meaning that in order for XRP prices to ascend to $10.00, Ripple needs to launch a successful coup. That is, and always has been, an unwritten part of Ripple’s story.

We’ve seen a lot of progress on that score. In the last three years, Ripple wooed more than 100 financial firms onto its.

The post Ripple Price Forecast: XRP vs SWIFT, SEC Updates, and More appeared first on Profit Confidential.

Continue reading here:

Ripple Price Forecast: XRP vs SWIFT, SEC Updates, and More

Cryptocurrency News: Looking Past the Bithumb Crypto Hack

Another Crypto Hack Derails Recovery
Since our last report, hackers broke into yet another cryptocurrency exchange. This time the target was Bithumb, a Korean exchange known for high-flying prices and ultra-active traders.

While the hackers made off with approximately $31.5 million in funds, the exchange is working with relevant authorities to return the stolen tokens to their respective owners. In the event that some is still missing, the exchange will cover the losses. (Source: “Bithumb Working With Other Crypto Exchanges to Recover Hacked Funds,”.

The post Cryptocurrency News: Looking Past the Bithumb Crypto Hack appeared first on Profit Confidential.

More:

Cryptocurrency News: Looking Past the Bithumb Crypto Hack

Cryptocurrency News: This Week on Bitfinex, Tether, Coinbase, & More

Cryptocurrency News
On the whole, cryptocurrency prices are down from our previous report on cryptos, with the market slipping on news of an exchange being hacked and a report about Bitcoin manipulation.

However, there have been two bright spots: 1) an official from the U.S. Securities and Exchange Commission (SEC) said that Ethereum is not a security, and 2) Coinbase is expanding its selection of tokens.

Let’s start with the good news.
SEC Says ETH Is Not a Security
Investors have some reason to cheer this week. A high-ranking SEC official told attendees of the Yahoo! All Markets Summit: Crypto that Ethereum and Bitcoin are not.

The post Cryptocurrency News: This Week on Bitfinex, Tether, Coinbase, & More appeared first on Profit Confidential.

Original post:

Cryptocurrency News: This Week on Bitfinex, Tether, Coinbase, & More

Cryptocurrency News: What You Need to Know This Week

Cryptocurrency News
Cryptocurrencies traded sideways since our last report on cryptos. However, I noticed something interesting when playing around with Yahoo! Finance’s cryptocurrency screener: There are profitable pockets in this market.

Incidentally, Yahoo’s screener is far superior to the one on CoinMarketCap, so if you’re looking to compare digital assets, I highly recommend it.

But let’s get back to my epiphany.

In the last month, at one point or another, most crypto assets on our favorites list saw double-digit increases. It’s true that each upswing was followed by a hard crash, but investors who rode the trend would have made a.

The post Cryptocurrency News: What You Need to Know This Week appeared first on Profit Confidential.

Read the original:

Cryptocurrency News: What You Need to Know This Week

Cryptocurrency News: XRP Validators, Malta, and Practical Tokens

Cryptocurrency News & Market Summary
Investors finally saw some light at the end of the tunnel last week, with cryptos soaring across the board. No one quite knows what kicked off the rally—as it could have been any of the stories we discuss below—but the net result was positive.

Of course, prices won’t stay on this rocket ride forever. I expect to see a resurgence of volatility in short order, because the market is moving as a single unit. Everything is rising in tandem.

This tells me that investors are simply “buying the dip” rather than identifying which cryptos have enough real-world value to outlive the crash.

So if you want to know when.

The post Cryptocurrency News: XRP Validators, Malta, and Practical Tokens appeared first on Profit Confidential.

See the original post:

Cryptocurrency News: XRP Validators, Malta, and Practical Tokens

Cryptocurrency News: Bitcoin ETFs, Andreessen Horowitz, and Contradictions in Crypto

Cryptocurrency News
This was a bloody week for cryptocurrencies. Everything was covered in red, from Ethereum (ETH) on down to the Basic Attention Token (BAT).

Some investors claim it was inevitable. Others say that price manipulation is to blame.

We think the answers are more complicated than either side has to offer, because our research reveals deep contradictions between the price of cryptos and the underlying development of blockchain projects.

For instance, a leading venture capital (VC) firm launched a $300.0-million crypto investment fund, yet liquidity continues to dry up in crypto markets.

Another example is the U.S. Securities and Exchange Commission’s.

The post Cryptocurrency News: Bitcoin ETFs, Andreessen Horowitz, and Contradictions in Crypto appeared first on Profit Confidential.

Link:

Cryptocurrency News: Bitcoin ETFs, Andreessen Horowitz, and Contradictions in Crypto

Cryptocurrency News: New Exchanges Could Boost Crypto Liquidity

Cryptocurrency News
Even though the cryptocurrency news was upbeat in recent days, the market tumbled after the U.S. Securities and Exchange Commission (SEC) rejected calls for a Bitcoin (BTC) exchange-traded fund (ETF).

That news came as a blow to investors, many of whom believe the ETF would open the cryptocurrency industry up to pension funds and other institutional investors. This would create a massive tailwind for cryptos, they say.

So it only follows that a rejection of the Bitcoin ETF should send cryptos tumbling, correct? Well, maybe you can follow that logic. To me, it seems like a dramatic overreaction.

I understand that legitimizing cryptos is important. But.

The post Cryptocurrency News: New Exchanges Could Boost Crypto Liquidity appeared first on Profit Confidential.

See the original post:

Cryptocurrency News: New Exchanges Could Boost Crypto Liquidity

Cryptocurrency News: Bitcoin ETF Rejection, AMD Microchip Sales, and Hedge Funds

Cryptocurrency News
Although cryptocurrency prices were heating up last week (Bitcoin, especially), regulators poured cold water on the rally by rejecting calls for a Bitcoin exchange-traded fund (ETF). This is the second time that the proposal fell on deaf ears. (More on that below.)

Crypto mining ran into similar trouble, as you can see from Advanced Micro Devices, Inc.‘s (NASDAQ:AMD) most recent quarterly earnings. However, it wasn’t all bad news. Investors should, for instance, be cheering the fact that hedge funds are ramping up their involvement in cryptocurrency markets.

Without further ado, here are those stories in greater detail.
ETF Rejection.

The post Cryptocurrency News: Bitcoin ETF Rejection, AMD Microchip Sales, and Hedge Funds appeared first on Profit Confidential.

View post:

Cryptocurrency News: Bitcoin ETF Rejection, AMD Microchip Sales, and Hedge Funds


12345...10...