Sprachprofi Posted January 24, 2012 Share Posted January 24, 2012 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. Link to comment Share on other sites More sharing options...
JohnOne Posted January 24, 2012 Share Posted January 24, 2012 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 ColemakDo Opt("WinTitleMatchMode", 2) WinWaitActive ( "Language Learning Forum" ) Send("^+9") ;MsgBox(0, "Yay", "Use Colemak!") Sleep(500)Until $i = 1This 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. Link to comment Share on other sites More sharing options...
Sprachprofi Posted January 24, 2012 Author Share Posted January 24, 2012 (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 January 24, 2012 by Sprachprofi Link to comment Share on other sites More sharing options...
JohnOne Posted January 24, 2012 Share Posted January 24, 2012 But will it not just keep sending those keys in an infinite loop? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Sprachprofi Posted January 24, 2012 Author Share Posted January 24, 2012 (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 January 24, 2012 by Sprachprofi Link to comment Share on other sites More sharing options...
JohnOne Posted January 24, 2012 Share Posted January 24, 2012 Well I just tested it, and all it does is loop the keys while the window is active. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 24, 2012 Moderators Share Posted January 24, 2012 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 WEndDo 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 Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now