Pages in topic: [1 2 3] > |
Need help with AHK scripts Thread poster: Chunyi Chen
|
Chunyi Chen United States Local time: 23:23 English to Chinese
Dear AHK experts, I am creating my very first set of AHK scripts to type Traditional Chinese quotation marks in any Windows based applications, including MemoQ and Studio. From what I gathered, I could do something like !+9::Send, {????} ; Type Chinese left quotation mark (Alt+9) !+0::Send, {????} ; Type Chinese left quotation mark (Alt+0) What I am strugging with is how to fill in the info in {} and how to make this script an execution file, preferr... See more Dear AHK experts, I am creating my very first set of AHK scripts to type Traditional Chinese quotation marks in any Windows based applications, including MemoQ and Studio. From what I gathered, I could do something like !+9::Send, {????} ; Type Chinese left quotation mark (Alt+9) !+0::Send, {????} ; Type Chinese left quotation mark (Alt+0) What I am strugging with is how to fill in the info in {} and how to make this script an execution file, preferrably permanent so that I can simply use Alt+9 and Alt+0 without opening/enabling the script everytime I want to use it. I looked up these quotation marks in Word, and their codes are 300C and 300D in unicode hex. How should they be written inside {}? Thank you so much for your kind help. Chun-yi ▲ Collapse | | |
Michael Beijer United Kingdom Local time: 06:23 Member (2009) Dutch to English + ... Hello Chun-yi! Here's my AHK section on special symbols, etc. | Aug 23, 2012 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; *** ; ^ = control ; + = shift ; # = windows key ; ! = alt key ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; *** ; Special symbols ^+3::Send, {U+00A3} ; Pound symbol ( £ ) ^+2::Send, {€} ; Euro symbol ( € ) ^+-::Send, {U+2014} ; Em dash symbol ... See more ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; *** ; ^ = control ; + = shift ; # = windows key ; ! = alt key ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; *** ; Special symbols ^+3::Send, {U+00A3} ; Pound symbol ( £ ) ^+2::Send, {€} ; Euro symbol ( € ) ^+-::Send, {U+2014} ; Em dash symbol ( — ) ^+6::Send, {U+2013} ; En dash symbol ( – ) ^+o::Send, {U+2022} ; Bullet point ( • ) ^+9::Send, {U+2018} ; Single, curly, opening quotation mark ( ‘ ) ^+0::Send, {U+2019} ; Single, curly, closing quotation mark ( ’ ) ^+[::Send, {U+201C} ; Double, curly, opening quotation mark ( “ ) ^+]::Send, {U+201D} ; Double, curly, closing quotation mark ( “ ) ^+x::Send, {U+00D7} ; Multiplication symbol ( × ) ^+p::Send, {U+2032} ; Prime ( ′ ) ^+l::Send, {U+2033} ; Double prime ( ″ ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; *** • Install AHK. • Then type your script in a text file (make sure the text file is saved as UTF-8!) • Change the file ending from '.txt' to '.ahk'. • Place this file in your startup folder so it starts automatically when you start Windows. Mine is: C:\Users\Michael J.W. Beijer\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup • double-click the file to start your first AHK script! That ought to do it! Michael
[Edited at 2012-08-23 20:34 GMT] ▲ Collapse | | |
Chunyi Chen United States Local time: 23:23 English to Chinese TOPIC STARTER Thank you for the information | Aug 23, 2012 |
Hi Michael, Thank you so much for this information. I actually found something similar in the messages you posted on the Yahoo MemoQ forum:) So for a special character in hex unicode 300C, the correct way to do it would be {U+300C}? Have you got your AHK scripts working in MemoQ now? That's the program I intend to use my script in at the moment. Thanks again! Chun-yi | | |
Michael Beijer United Kingdom Local time: 06:23 Member (2009) Dutch to English + ... you're welcome! | Aug 23, 2012 |
Yes, I had a small problem running my AHK scripts inside memoQ for a while, but they all work again. Good luck! Michael | |
|
|
Script for French quotes and apostrophes | Aug 23, 2012 |
Chun-yi Chen wrote: I am creating my very first set of AHK scripts to type Traditional Chinese quotation marks in any Windows based applications, including MemoQ and Studio. Here is a script I put together (with the help of Dave Turner, obtained on the Help_ list) last year, when there was no support for smart quotes in memoQ: #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. SendMode Input ; Recommended for new scripts due to its superior speed and reliability. ; Dave Turner, Help_, 12.3.2011 ; Windows+i - Change straight quotes and curly quotes to ; French guillemets with non-breaking spaces inside ; Puts a non-breaking space before ; : ! ? SetTitleMatchMode 1 #IfWinActive, memoQ #i:: SendInput, ^a ; Select whole segment clipboard= ; Empty clipboard SendInput, ^c ; Copy segment Clipwait Row:= Clipboard newrow:=regexreplace(Row, Chr(34)"(.*?)"Chr(34), Chr(171)Chr(160)"$1"Chr(160)Chr(187)) newrow:=regexreplace(newrow, Chr(147)"(.*?)"Chr(148), Chr(171)Chr(160)"$1"Chr(160)Chr(187)) newrow:=regexreplace(newrow, "(\S)(\;|:|\?|!)", "$1"Chr(160)"$2") newrow:=regexreplace(newrow, "(\s)(\;|:|\?|!)", Chr(160)"$2") Clipboard := newrow Clipwait SendInput, ^v SendInput, ^{PgUp} ; Set cursor to start of segment Row = return
Maybe you can adapt it for use with Chinese quotes?
[Edited at 2012-08-23 21:32 GMT] | | |
#IfWinActive, GroupAdd | Aug 23, 2012 |
Chun-yi Chen wrote: Have you got your AHK scripts working in MemoQ now? That's the program I intend to use my script in at the moment. If you want a script to be active in a single application only, you can use the #IfWinActive command. For instance, in the case of memoQ, you would use: #IfWinActive,memoQ
If you want a script to be active in several applications, you can use the GroupAdd command. For instance, a script with the following lines would be active both in memoQ and in Studio: GroupAdd,MyGroup,memoQ GroupAdd,MyGroup,Trados #IfWinActive,ahk_group MyGroup
| | |
Chunyi Chen United States Local time: 23:23 English to Chinese TOPIC STARTER Thank you, Dominique, but... | Aug 23, 2012 |
Your version is way over my head. I am even having difficulty riding a bike, and your script looks like a race car to me:( I take your "maybe you can adapt it for use with Chinese quotes" suggestion as a compliment, though:) I am trying to figure out what is wrong with my AHK script. Key assignment should be more straight forward than other advanced functions. I have Alt+9 and Alt+0 assigned for Chinese quotations in Word. I am trying to reproduce them in MemoQ but haven't figured out... See more Your version is way over my head. I am even having difficulty riding a bike, and your script looks like a race car to me:( I take your "maybe you can adapt it for use with Chinese quotes" suggestion as a compliment, though:) I am trying to figure out what is wrong with my AHK script. Key assignment should be more straight forward than other advanced functions. I have Alt+9 and Alt+0 assigned for Chinese quotations in Word. I am trying to reproduce them in MemoQ but haven't figured out how. Chun-yi Dominique Pivard wrote: Chun-yi Chen wrote: I am creating my very first set of AHK scripts to type Traditional Chinese quotation marks in any Windows based applications, including MemoQ and Studio. Here is a script I put together (with the help of Dave Turner, obtained on the Help_ list) last year, when there was no support for smart quotes in memoQ: #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. SendMode Input ; Recommended for new scripts due to its superior speed and reliability. ; Dave Turner, Help_, 12.3.2011 ; Windows+i - Change straight quotes and curly quotes to ; French guillemets with non-breaking spaces inside ; Puts a non-breaking space before ; : ! ? SetTitleMatchMode 1 #IfWinActive, memoQ #i:: SendInput, ^a ; Select whole segment clipboard= ; Empty clipboard SendInput, ^c ; Copy segment Clipwait Row:= Clipboard newrow:=regexreplace(Row, Chr(34)"(.*?)"Chr(34), Chr(171)Chr(160)"$1"Chr(160)Chr(187)) newrow:=regexreplace(newrow, Chr(147)"(.*?)"Chr(148), Chr(171)Chr(160)"$1"Chr(160)Chr(187)) newrow:=regexreplace(newrow, "(\S)(\;|:|\?|!)", "$1"Chr(160)"$2") newrow:=regexreplace(newrow, "(\s)(\;|:|\?|!)", Chr(160)"$2") Clipboard := newrow Clipwait SendInput, ^v SendInput, ^{PgUp} ; Set cursor to start of segment Row = return
Maybe you can adapt it for use with Chinese quotes? [Edited at 2012-08-23 21:32 GMT] ▲ Collapse | | |
Chunyi Chen United States Local time: 23:23 English to Chinese TOPIC STARTER My problem right now is how to do the AHK script correctly. | Aug 23, 2012 |
Thank you, Dominique, for your additional information. I am sure these will come in handy later, but I am still struggling with Step 1... Chun-yi Dominique Pivard wrote: Chun-yi Chen wrote: Have you got your AHK scripts working in MemoQ now? That's the program I intend to use my script in at the moment. If you want a script to be active in a single application only, you can use the #IfWinActive command. For instance, in the case of memoQ, you would use: #IfWinActive,memoQ
If you want a script to be active in several applications, you can use the GroupAdd command. For instance, a script with the following lines would be active both in memoQ and in Studio: GroupAdd,MyGroup,memoQ GroupAdd,MyGroup,Trados #IfWinActive,ahk_group MyGroup | |
|
|
SendInput or Send | Aug 23, 2012 |
Chun-yi Chen wrote: Thank you, Dominique, for your additional information. I am sure these will come in handy later, but I am still struggling with Step 1... OK, try these, they work for me: !9:: SendInput {U+300C} Return !0:: Send {U+300D} Return
I'm using two different commands that achieve the same result: Send and SendInput. | | |
Chunyi Chen United States Local time: 23:23 English to Chinese TOPIC STARTER I will give these a try, but I have one more question. | Aug 23, 2012 |
Thank you so much, Dominique, for bringing yourself down to my level:)) Here is one very basic question: After I replace the codes below with the existing ones in the .ahk file, do I need to "compile" the file and make it an exe file? And to enable, do I click (or double click) on the ahk file or the exe file? Chun-yi Dominique Pivard wrote: Chun-yi Chen wrote: Thank you, Dominique, for your additional information. I am sure these will come in handy later, but I am still struggling with Step 1... OK, try these, they work for me: !9:: SendInput {U+300C} Return !0:: Send {U+300D} Return
I'm using two different commands that achieve the same result: Send and SendInput. | | |
Two possibilities | Aug 23, 2012 |
Chun-yi Chen wrote: Here is one very basic question: After I replace the codes below with the existing ones in the .ahk file, do I need to "compile" the file and make it an exe file? And to enable, do I click (or double click) on the ahk file or the exe file? You can either keep the .ahk as it is and run it by right-clicking it and selecting the relevant option. Or you can compile it into an .exe, after which you run the .exe. In both case you will see the small AHK icon (white "H" on green background) in your system tray. As long as you're still testing the script, it's better to keep it as .ahk. When your script is ready and works as you want, you can compile it. If/when you have several scripts, you can put all of them into a single .ahk and compile it as one .exe. The advantage of an .exe is that you can run it on a system where AHK is not installed. The inconvenient is that some anti-virus programs don't like compiled AHK scripts. | | |
Chunyi Chen United States Local time: 23:23 English to Chinese TOPIC STARTER I am making some progress, but it's still not working | Aug 23, 2012 |
Dominique, Here is what I got so far: I copied and pasted your codes and replaced the old ones in ahk file, right click to run it, and saw the H icon in my system tray. I still can't get those Chinese symbols in MemoQ when I use the keyboard combos. I even changed the combos to Shift+Ctrl+9 and 0 thinking that Alt+#s may have already been assigned. What could be the reason for these codes not working? On a side note, I have a compiled execution file in .exe sitting i... See more Dominique, Here is what I got so far: I copied and pasted your codes and replaced the old ones in ahk file, right click to run it, and saw the H icon in my system tray. I still can't get those Chinese symbols in MemoQ when I use the keyboard combos. I even changed the combos to Shift+Ctrl+9 and 0 thinking that Alt+#s may have already been assigned. What could be the reason for these codes not working? On a side note, I have a compiled execution file in .exe sitting in my desktop I would like to delete. (This was compiled from the codes I used earlier) How do I do this? Thank you very much for your patience and expertise! Chun-yi Dominique Pivard wrote: You can either keep the .ahk as it is and run it by right-clicking it and selecting the relevant option. Or you can compile it into an .exe, after which you run the .exe. In both case you will see the small AHK icon (white "H" on green background) in your system tray. As long as you're still testing the script, it's better to keep it as .ahk. When your script is ready and works as you want, you can compile it. If/when you have several scripts, you can put all of them into a single .ahk and compile it as one .exe. The advantage of an .exe is that you can run it on a system where AHK is not installed. The inconvenient is that some anti-virus programs don't like compiled AHK scripts.
[Edited at 2012-08-24 00:04 GMT] ▲ Collapse | |
|
|
Script available for download | Aug 24, 2012 |
Chun-yi Chen wrote: Here is what I got so far: I copied and pasted your codes and replaced the old ones in ahk file, right click to run it, and saw the H icon in my system tray. I still can't get those Chinese symbols in MemoQ when I use the keyboard combos. I even changed the combos to Shift+Ctrl+9 and 0 thinking that Alt+#s may have already been assigned. What could be the reason for these codes not working? I have no idea, but I uploaded the script (both .ahk and .exe) here: http://commondatastorage.googleapis.com/memoq/chinese-quotes.zip Download it, run it and see if it works. If it works, compare my .ahk with yours. Sometimes it is important the .ahk file is Unicode. Chun-yi Chen wrote: On a side note, I have a compiled execution file in .exe sitting in my desktop I would like to delete. (This was compiled from the codes I used earlier) How do I do this? It's just a normal file that you can delete at any time (eg. in Windows Explorer), provided the script isn't running. If it is running, right-click on the system tray icon and select Exit. | | |
Chunyi Chen United States Local time: 23:23 English to Chinese TOPIC STARTER I am making some more progress | Aug 24, 2012 |
Thanks so much for sending me your working codes. The bad news is, they are not working on my end. When I ran your ahk script, I received an error message saying error in line 1; Line Text: yp (both y and p in weird format), followed by Error: This line does not contain a recognized action. Then program exited due to the error. I think what happened was you saved your codes in unicode, which for some reason didn't work on my end. I suspect that the codes I got from W... See more Thanks so much for sending me your working codes. The bad news is, they are not working on my end. When I ran your ahk script, I received an error message saying error in line 1; Line Text: yp (both y and p in weird format), followed by Error: This line does not contain a recognized action. Then program exited due to the error. I think what happened was you saved your codes in unicode, which for some reason didn't work on my end. I suspect that the codes I got from Word for these Chinese quotations may not be the correct ones after all. Those are the unicode hex, but there is no option to save the ahk scripts in -16.txt/ahk format. I will see if I can find other codes in -8 that also render Chinese quotations. My codes looked exactly as yours except for the first three lines which I don't have. (Also I changed from ! to ^+ after the first failed attempt.) But I don't need the first three lines (see below, copied from your ahk file) anyway, right? #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. SendMode Input ; Recommended for new scripts due to its superior speed and reliability. SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory. I think I am on the right track...thank you for your guidance. Chun-yi Dominique Pivard wrote: Chun-yi Chen wrote: Here is what I got so far: I copied and pasted your codes and replaced the old ones in ahk file, right click to run it, and saw the H icon in my system tray. I still can't get those Chinese symbols in MemoQ when I use the keyboard combos. I even changed the combos to Shift+Ctrl+9 and 0 thinking that Alt+#s may have already been assigned. What could be the reason for these codes not working? I have no idea, but I uploaded the script (both .ahk and .exe) here: http://commondatastorage.googleapis.com/memoq/chinese-quotes.zip Download it, run it and see if it works. If it works, compare my .ahk with yours. Sometimes it is important the .ahk file is Unicode. Chun-yi Chen wrote: On a side note, I have a compiled execution file in .exe sitting in my desktop I would like to delete. (This was compiled from the codes I used earlier) How do I do this? It's just a normal file that you can delete at any time (eg. in Windows Explorer), provided the script isn't running. If it is running, right-click on the system tray icon and select Exit. ▲ Collapse | | |
Chunyi Chen United States Local time: 23:23 English to Chinese TOPIC STARTER U+300C and U+300D seem to be correct | Aug 24, 2012 |
Hi Dominique, I looked up the unicodes and they seem to be correct. http://www.fileformat.info/info/unicode/char/300c/index.htm I thought there might be different codes for left corner bracket (=opening Chinese quotation mark) and right corner bracket (= right counterpart) in another category such as Unicode (8), but these turn out the b... See more Hi Dominique, I looked up the unicodes and they seem to be correct. http://www.fileformat.info/info/unicode/char/300c/index.htm I thought there might be different codes for left corner bracket (=opening Chinese quotation mark) and right corner bracket (= right counterpart) in another category such as Unicode (8), but these turn out the be the only codes I can find to produce these brackets. My ahk codes seem to be good (since I copied from you and you said it worked on your end), but they just don't work here...Maybe Alt+9/0 are Windows OS predefined key combos for something else?? I would think AHK codes should overwrite these predefined shortcuts. Anyway, thank you so much for being so patient and being so helpful. I just don't know what keeps these ahk scripts from working. Chun-yi ▲ Collapse | | |
Pages in topic: [1 2 3] > |