Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- AutoKanaInput.ahk
- requires: autohotkey (obviously)
- windows since windows messages are used
- to detect the input language
- the image linked below
- _____________________________________________________________________________________________________________________
- The purpose of this script is to automatically force the windows input method to kana whenever japanese is
- selected as the input language.
- General Usage
- For this script to work correctly, you will have to change your input language to japanese via the default
- hotkey combination, Shift+Alt. (this can of course be changed by minimally tweaking this script)
- You could also try to modify the script to automatically detect the change to japanese, completely
- independent of a hotkey by putting the part under ~+Alt:: into some kind of loop, but that sounds boring.
- !! You will also need this image: !!
- files.catbox.moe/a2ozv3.png | http://www.mediafire.com/view/lj6t9q586y4ip85/NEEDLE.png
- !! called NEEDLE.png to be located in the same folder as the script. !!
- in case both of these links stop working, pray to your
- diety of choosing and consult the limitiations
- section below
- ----------------------------------------
- Functionality
- Because windows message documentation is absolute dogshit, this script searches for the provided image on
- screen to check if the current input method is alphanumeric and if that is the case, sends the hotkey to
- switch between kana and alphanumeric input (by default, Shift+Caps).
- This behaviour can be suspended/reenabled by pressing the switch hotkey yourself.
- Please note that if you suspend the auto switching, change your input to another language and switch
- back to japanese, the auto switching will still be suspended.
- Limitations/Problems
- Because the script uses image search to determine the input method, it is of course far from an universal
- method. if your monitor has a resolution other than 1920x1080 or even if your toolbar is
- a different size than mine, the image recongition might not work.
- If that is the case, you will have to adjust the searched screen area and/or the NEEDLE image.
- For the image, just Screenshot the big "A" in your toolbar that indicates alphanumeric input and
- edit the background to a #000000 (R0 G0 B0) black.
- Read comments in the code below for instructions on the screen search area.
- also blame pastebin for the wonky formatting. it looked fine in my editor
- _____________________________________________________________________________________________________________________
- */
- #NoEnv
- SendMode Input
- SetWorkingDir %A_ScriptDir%
- if not FileExist("NEEDLE.png") {
- msgbox,,お知らせ,in the description of this script I made clear in `nNO UNCERTAIN TERMS `nthat this script requires an image to be downloaded to the folder the script is located. `nin case you can actually read this`, consult the giant fancy description at the top of the script
- ExitApp
- }
- jp := DllCall("LoadKeyboardLayout", "Str", "00000411", "Int", 1)
- w := DllCall("GetForegroundWindow")
- pid := DllCall("GetWindowThreadProcessId", "UInt", w, "Ptr", 0)
- l := DllCall("GetKeyboardLayout", "UInt", pid)
- ; SC03A equates to capslock but for some reason it doesn't want to recognise a normal capslock input
- ; the hotkey for kana/alphanumeric switch
- #If (l = jp)
- ~+SC03A::Pause,,1
- #If
- ; the hotkey for language change
- ~+Alt::
- sleep,10
- start:
- w := DllCall("GetForegroundWindow")
- pid := DllCall("GetWindowThreadProcessId", "UInt", w, "Ptr", 0)
- l := DllCall("GetKeyboardLayout", "UInt", pid)
- if (l = jp) {
- coordMode,Pixel
- ; search area: upper left corner x1,y1, followed by bottom right corner x2,y2.
- ; to easily get coords, run any ahk script, rclick on the taskbar icon and
- ; select window spy. you need the "screen" coordinates
- ; x1 y1 x2 y2
- ImageSearch,FX,FY,1760,1050,1800,1080,*Trans000000 *100 NEEDLE.png ; depending on your monitor resolution/taskbar size you might
- ; Searched image needs to be called NEEDLE.png ; have to change the searched coordinates in this function and/or
- if (FX != "") { ; adjust the searched image. Screenshot the alphanumeric mode "A"
- send, {ShiftDown}{CapsLock}{ShiftUp} ; and edit the background to black #000000 to correctly make the
- } ; NEEDLE image. this image needs to be located in the script's
- sleep,200 ; the delay between each image search ; folder.
- ; if you don't run this on an actual potato
- ; it should be able easily handle even
- ; smaller intervals
- goto,start
- }
- else {
- return
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement