Sign in to follow this  
Followers 0
Sprachprofi

Learning a New Keyboard Layout

7 posts in this topic

I want to adapt to Colemak in order to avoid carpal tunnel syndrome. However, I type way too much in a day and going cold turkey is going to be impossible: even after familiarizing myself with the layout and doing tons of exercises, my typing speed is just not adequate for work yet. A friend had the brilliant idea to just switch one particular leisure activity to Colemak, and use my regular keyboard layout for the rest. I want to start with a language forum I frequent a lot. The problem is that I don't want my default keyboard layout to be Colemak yet because it would interfere too much with work, and I can hardly trust myself to remember to always sabotage my writing and set my layout to Colemak whenever I call up that forum (which happens a lot). So, AutoIt to the rescue.

Local $i = 0

; infinite loop always changing Language Forum to Colemak

Do

Opt("WinTitleMatchMode", 2)

WinWaitActive ( "Language Learning Forum" )

Send("^+9")

;MsgBox(0, "Yay", "Use Colemak!")

Sleep(500)

Until $i = 1

This is my very first AutoIt script, let me know if there is a better way to do it.

Share this post


Link to post
Share on other sites



I want to adapt to Colemak in order to avoid carpal tunnel syndrome. However, I type way too much in a day and going cold turkey is going to be impossible: even after familiarizing myself with the layout and doing tons of exercises, my typing speed is just not adequate for work yet. A friend had the brilliant idea to just switch one particular leisure activity to Colemak, and use my regular keyboard layout for the rest. I want to start with a language forum I frequent a lot. The problem is that I don't want my default keyboard layout to be Colemak yet because it would interfere too much with work, and I can hardly trust myself to remember to always sabotage my writing and set my layout to Colemak whenever I call up that forum (which happens a lot). So, AutoIt to the rescue.

Local $i = 0

; infinite loop always changing Language Forum to Colemak

Do

Opt("WinTitleMatchMode", 2)

WinWaitActive ( "Language Learning Forum" )

Send("^+9")

;MsgBox(0, "Yay", "Use Colemak!")

Sleep(500)

Until $i = 1

This is my very first AutoIt script, let me know if there is a better way to do it.

In order for it to be an example it should work.

All this does is activate a window, send some keys and sleep in an infinite loop.


AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Not exactly... it waits for that window to become active, and then does something. Important difference; afaik AutoHotkey (competitor) doesn't even support that feature. There are lots of examples where we activate a window and then type something, but I don't want that; I want my keyboard layout to be changed whenever I open that particular website, in my own time.

Edited by Sprachprofi

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

No, because the window activation event happens only once, it's called _onfocus in some programming languages. This event is called when the relevant tab of my web browser is first brought up, then the script stays dormant while I am on the page (I can type CTRL+SHIFT+1 to shift to another keyboard layout then and it won't change me back, this is important because I may need to type Chinese as well), it still stays dormant while I look at other tabs or other applications, and it only wakes up again when I switch back to the forum.

Edited by Sprachprofi

Share this post


Link to post
Share on other sites

Sprachprofi,

You might like to use something like this - it only sends the keys when the window becomes active: :)

Opt("WinTitleMatchMode", 2)
; Start the loop
While 1
    ; Wait until the window is active
    WinWaitActive("Language Learning Forum")
    ; Send the keys
    Send("^+9")
    ; Now wait until the window is not active
    While WinActive("Language Learning Forum")
        Sleep(100)
    WEnd
    ; And when it is not go back to wait until it is
WEnd

Do you need another key sequence sent when you leave the forum? If so then you would put that in after the inner WEnd. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0