Vom Thema belegte Seiten: [1 2] > | AutoHotKey Highlighter Pen Tool Initiator des Themas: James Plastow
| James Plastow Vereinigtes Königreich Local time: 04:26 Japanisch > Englisch
I made a simple highlighter pen tool in AutoHotKey. Hope some people might find it useful.
INSTRUCTIONS:
1. Open the ahk script, the Colour Menu will appear
2. Click the colour in the menu you would like to use (or press up/down)
3. Click (once) while holding down the Windows key to set the start of the highlight, move your mouse, then click again (once) to set the end of the highlight.
You can also double click to make a fixed length highlight.
4. Press F6 to clear all highlights
Thanks to Jesús Prieto for helping me with this code.
CODE: (Paste this code into Notepad and save it as an ahk file, e.g. Highlighter.ahk You will need to have AutoHotKey installed)
#NoEnv
SetWorkingDir %A_ScriptDir%
CoordMode, Mouse, Screen
global color
global trans ;transparency value from 0 (fully transparent) to 255 (fully opaque)
setting := true
Gui, font, s12, Comic Sans MS
Gui, Add, ListBox, gSelect vColorChoice w200 r6, Pink|Yellow|Green|Blue|Orange|Black ; Add / change colours in the list here, separated by | "r6" means six rows, so change this if required.
Gui, +LastFound +AlwaysOnTop +Owner
Gui, Show, X800 Y100
return
Select: ;This converts the chosen colour to the required variables. Hopefully it is self-explanatory how to modify this if required.
Gui, Submit, NoHide
if (ColorChoice = "Pink"){
color := "ff00ff"
trans := 75
}
if (ColorChoice = "Yellow"){
color := "ffff00"
trans := 75
}
if (ColorChoice = "Green"){
color := "02f216"
trans := 75
}
if (ColorChoice = "Blue"){
color := "02aef2"
trans := 75
}
if (ColorChoice = "Orange"){
color := "f2ca02"
trans := 75
}
if (ColorChoice = "Black"){
color := "000000"
trans := 255
}
Return
#LButton:: ;This draws the highlight
{
if setting{ ;This part is for the first click
global startxpos
global startypos
MouseGetPos, startxpos, startypos ;Store the position of the mouse on click
boxy:=startypos-10 ;y position of highlight
Gui, New
Gui, +LastFound +AlwaysOnTop +Owner
WinSet, Transparent, %trans% ;Set the transparency
Gui, +LastFound -Caption -Border ToolWindow
Gui, Color, %color% ;Set the colour
Gui, Show, W10 H20 X%startxpos% Y%boxy% ;Draw the highlight start marker
setting := !setting
}
else{ ;This part is for the second click
MouseGetPos, endxpos, endypos ;Store the position of the mouse on click
boxy:=startypos-10 ;y position (top of highlight bar is 10 pixels higher than the mouse y position)
if (endxpos > startxpos){
boxx:=startxpos+10 ;Set the x position and width of the highlight, depending on whether the user clicked the left end or right end
boxw:=endxpos-startxpos-10
}
if (endxpos < startxpos){
boxx:=endxpos
boxw:=startxpos-endxpos
}
if (endxpos = startxpos){ ;If you click twice in the same position you will get a 150 pixel highlight bar
boxx:=startxpos+10
boxw:=150 ;Change this value if you would like a shorter or longer fixed highlight bar
}
Gui, New
Gui, +LastFound +AlwaysOnTop +Owner
WinSet, Transparent, %trans%
Gui, +LastFound -Caption -Border ToolWindow
Gui, Color, %color%
Gui, Show, W%boxw% H20 X%boxx% Y%boxy% ;draw the full highlight
setting := !setting
}
}
return
F6::reload ;Clear the highlights
[Edited at 2021-02-21 18:03 GMT] | | | Stepan Konev Russische Föderation Local time: 07:26 Englisch > Russisch The script needs improvment | Feb 21, 2021 |
Thank you for your endeavor James, but something is wrong with this script.
First, the highlighted section appears longer than I select. I mean it slightly protrudes to the right.
Second, the highlights are always on the screen at the same place. When I scroll a document up or down, the highlights remain at the same point. Even when I switch to another program or just minimize all windows, the highlights are still there above that program or on my desktop wallpaper.
Third, I c... See more Thank you for your endeavor James, but something is wrong with this script.
First, the highlighted section appears longer than I select. I mean it slightly protrudes to the right.
Second, the highlights are always on the screen at the same place. When I scroll a document up or down, the highlights remain at the same point. Even when I switch to another program or just minimize all windows, the highlights are still there above that program or on my desktop wallpaper.
Third, I can't clear it with F6. The only way to stop it is closing the script.
▲ Collapse | | | James Plastow Vereinigtes Königreich Local time: 04:26 Japanisch > Englisch THEMENSTARTER
Stepan Konev wrote:
Thank you for your endeavor James, but something is wrong with this script.
First, the highlighted section appears longer than I select. I mean it slightly protrudes to the right.
Second, the highlights are always on the screen at the same place. When I scroll a document up or down, the highlights remain at the same point. Even when I switch to another program or just minimize all windows, the highlights are still there above that program or on my desktop wallpaper.
Third, I can't clear it with F6. The only way to stop it is closing the script.
Hi Stepan,
Thank you for your feedback
Highlighted section appears longer than I select >> Doesn't happen for me, are you double clicking to end the highlight? I designed it so you will get a fixed 150pixel highlight if you double click (but this is easy to change in the code)
Highlights are always on the screen at the same place >> Yes, perhaps I should have explained, all this script is doing is drawing boxes on the screen. They are not connected to what is underneath at all so there is no way for them to scroll with the window underneath. I still find it extremely useful without this functionality. Basically I use it for the current segment I am working on, not previous segments.
Cant clear with F6 >> This is strange. Have you assigned any other hotkey to F6? The total code for F6 is literally "F6::reload" Are you running multiple AHK scripts at once? | | | Stepan Konev Russische Föderation Local time: 07:26 Englisch > Russisch Wordbird for Trados | Feb 21, 2021 |
James Plastow wrote:
Yes, perhaps I should have explained, all this script is doing is drawing boxes on the screen. They are not connected to what is underneath at all so there is no way for them to scroll with the window underneath. I still find it extremely useful without this functionality. Basically I use it for the current segment I am working on, not previous segments. However, without this functionality, I can use colored paper stickers on my monitor to the same effect... They are easier to attach and remove.
UPDATE: There is a Wordbird plugin for SDL Trados available for this purpose.
[Edited at 2021-02-21 21:45 GMT] | |
|
|
Stepan Konev Russische Föderation Local time: 07:26 Englisch > Russisch Yes, I run other AHK scripts | Feb 21, 2021 |
James Plastow wrote:
Are you running multiple AHK scripts at once? But none of them use F6.
However this is no big deal because I have no idea how to utilize this script for my purposes. Hope others will find a use for it.
Thank you anyway. I found a plugin that I was not aware of before your post.
[Edited at 2021-02-21 20:40 GMT] | | | Rolf Keller Deutschland Local time: 05:26 Englisch > Deutsch The script does what such a script can do. | Feb 22, 2021 |
Stepan Konev wrote:
the highlights are always on the screen at the same place. When I scroll a document up or down, the highlights remain at the same point.
This behaviour is to be expected. Scrolling is performed on application level. That's why Wordbird is an Add-in: It's just a modification of the Trados application.
In order to make it workable with arbitrary applications, the programmer would have to break through important security barriers. Not a task for a script. | | | Stepan Konev Russische Föderation Local time: 07:26 Englisch > Russisch @Rolf Keller: Did you try the script? | Feb 22, 2021 |
Rolf Keller wrote:
This behaviour is to be expected. Scrolling is performed on application level. That's why Wordbird is an Add-in: It's just a modification of the Trados application.
In order to make it workable with arbitrary applications, the programmer would have to break through important security barriers. Not a task for a script.
If you talk about Wordbird, I don't question its functionality. It works fine for me. And I don't want to make it [I assume you mean 'it' = Wordbird here?] workable with arbitrary applications or break through security barriers.
On the other hand, the script [the one written by James Plastow] 'works' with any application. Why not a task? Well, even if not, James Plastow could resolve it: his script works with any application (because it just draws color strips on the screen). I don't, and never did, say it works in an unexpected manner. I say I have no idea how can I use it the way it works...
[Edited at 2021-02-22 15:45 GMT] | | | Samuel Murray Niederlande Local time: 05:26 Mitglied (2006) Englisch > Afrikaans + ...
James Plastow wrote:
I made a simple highlighter pen tool in AutoHotKey.
I confirm that it works as expected on my computer. | |
|
|
James Plastow Vereinigtes Königreich Local time: 04:26 Japanisch > Englisch THEMENSTARTER Comment and updated version | Feb 22, 2021 |
Stepan Konev wrote:
Rolf Keller wrote:
This behaviour is to be expected. Scrolling is performed on application level. That's why Wordbird is an Add-in: It's just a modification of the Trados application.
In order to make it workable with arbitrary applications, the programmer would have to break through important security barriers. Not a task for a script.
If you talk about Wordbird, I don't question its functionality. It works fine for me. And I don't want to make it [I assume you mean 'it' = Wordbird here?] workable with arbitrary applications or break through security barriers.
On the other hand, the script [the one written by James Plastow] 'works' with any application. Why not a task? Well, even if not, James Plastow could resolve it: his script works with any application (because it just draws color strips on the screen). The question is how can I use it the way it works... [Edited at 2021-02-22 15:00 GMT]
The way I use it is to "cross off" the sentence clauses as I translate them, so I can see what parts have been done. It also works very well for keeping your place in the source sentence as you look back and forth between the source and target. It is also excellent for proofreading - you can check off every part of the source and target sentences and make sure everything is right. (Japanese tends to have very long and complex sentences and the clauses are all jumbled up compared to English). Also its very useful just for things like long emails or general reading of texts that require concentration.
In my experience Wordbird is extremely buggy. I have no comment on sticking pieces of paper to your screen
Anyway, here is a slightly amended version, this time just hold down Windows for Pink, Alt for Green or Windows+Alt for Blue. That way, there are no menus to go through. Also, I changed the clear button to Escape, I think its more natural. (dont worry , Escape will still function normally due to the "~" used in the hotkey)
* Updated with monitor scaling - set your monitor scale in the line "global monitorscale := 100" change to eg global monitorscale := 150 for 150% monitor scaling
#NoEnv
SetWorkingDir %A_ScriptDir%
CoordMode, Mouse, Screen
;Menu, Tray, Icon, filename.ico ; (include this if you would like a custom icon - any ico file can be used (just find an image online then use an online converter to convert the .png/jpeg to .ico)
setting := true
global monitorscale := 100 ;set this to 100 for 100% monitor scaling, 150 for 150% monitor scaling etc.
global initialboxw := 10*100/monitorscale
global startxpos
global startypos
#LButton:: ;This draws the highlight
{
if setting{ ;This part is for the first click
MouseGetPos, startxpos, startypos ;Store the position of the mouse when clicked the first time
boxy:=startypos-10 ;y position of highlight
Gui, New
Gui, +LastFound +AlwaysOnTop +Owner
WinSet, Transparent, 75 ;Set the transparency
Gui, +LastFound -Caption -Border ToolWindow
Gui, Color, ff00ff ;Set the colour (just google "color picker" to get the hex code for other colours)
Gui, Show, W%initialboxw% H20 X%startxpos% Y%boxy% ;Draw the highlight start marker
setting := !setting
}
else{ ;This part is for the second click
MouseGetPos, endxpos, endypos ;Store the position of the mouse when clicked the second time
boxy:=startypos-10 ;y position (top of highlight bar is 10 pixels higher than the mouse y position)
if (endxpos > startxpos){
boxx:=startxpos+10 ;Set the x position and width of the highlight, depending on whether the user clicked the left end or right end
boxw:=(boxw:=endxpos-startxpos-10)*100/monitorscale
}
if (endxpos < startxpos){
boxx:=endxpos
boxw:=(startxpos-endxpos)*100/monitorscale
}
if (endxpos = startxpos){ ;If you just click twice in the same position you will get a 150 pixel highlight bar
boxx:=startxpos+10
boxw:=150 ;Change this value if you would like a shorter or longer fixed highlight bar
}
Gui, New
Gui, +LastFound +AlwaysOnTop +Owner
WinSet, Transparent, 75
Gui, +LastFound -Caption -Border ToolWindow
Gui, Color, FF00FF
Gui, Show, W%boxw% H20 X%boxx% Y%boxy% ;draw the full highlight
setting := !setting
}
}
return
!LButton:: ;This draws the highlight
{
if setting{ ;This part is for the first click
MouseGetPos, startxpos, startypos ;Store the position of the mouse when clicked the first time
boxy:=startypos-10 ;y position of highlight
Gui, New
Gui, +LastFound +AlwaysOnTop +Owner
WinSet, Transparent, 75 ;Set the transparency
Gui, +LastFound -Caption -Border ToolWindow
Gui, Color, 02F216 ;Set the colour
Gui, Show, W%initialboxw% H20 X%startxpos% Y%boxy% ;Draw the highlight start marker
setting := !setting
}
else{ ;This part is for the second click
MouseGetPos, endxpos, endypos ;Store the position of the mouse when clicked the second time
boxy:=startypos-10 ;y position (top of highlight bar is 10 pixels higher than the mouse y position)
if (endxpos > startxpos){
boxx:=startxpos+10 ;Set the x position and width of the highlight, depending on whether the user clicked the left end or right end
boxw:=((boxw:=endxpos-startxpos-10)*100/monitorscale)
}
if (endxpos < startxpos){
boxx:=endxpos
boxw:=(startxpos-endxpos)*100/monitorscale
}
if (endxpos = startxpos){ ;If you just click twice in the same position you will get a 150 pixel highlight bar
boxx:=startxpos+10
boxw:=150 ;Change this value if you would like a shorter or longer fixed highlight bar
}
Gui, New
Gui, +LastFound +AlwaysOnTop +Owner
WinSet, Transparent, 75
Gui, +LastFound -Caption -Border ToolWindow
Gui, Color, 02F216
Gui, Show, W%boxw% H20 X%boxx% Y%boxy% ;draw the full highlight
setting := !setting
}
}
return
!#LButton:: ;This draws the highlight
{
if setting{ ;This part is for the first click
MouseGetPos, startxpos, startypos ;Store the position of the mouse when clicked the first time
boxy:=startypos-10 ;y position of highlight
Gui, New
Gui, +LastFound +AlwaysOnTop +Owner
WinSet, Transparent, 75 ;Set the transparency
Gui, +LastFound -Caption -Border ToolWindow
Gui, Color, 02aef2 ;Set the colour
Gui, Show, W%initialboxw% H20 X%startxpos% Y%boxy% ;Draw the highlight start marker
setting := !setting
}
else{ ;This part is for the second click
MouseGetPos, endxpos, endypos ;Store the position of the mouse when clicked the second time
boxy:=startypos-10 ;y position (top of highlight bar is 10 pixels higher than the mouse y position)
if (endxpos > startxpos){
boxx:=startxpos+10 ;Set the x position and width of the highlight, depending on whether the user clicked the left end or right end
boxw:=(boxw:=endxpos-startxpos-10)*100/monitorscale
}
if (endxpos < startxpos){
boxx:=endxpos
boxw:=(startxpos-endxpos)*100/monitorscale
}
if (endxpos = startxpos){ ;If you just click twice in the same position you will get a 150 pixel highlight bar
boxx:=startxpos+10
boxw:=150 ;Change this value if you would like a shorter or longer fixed highlight bar
}
Gui, New
Gui, +LastFound +AlwaysOnTop +Owner
WinSet, Transparent, 75
Gui, +LastFound -Caption -Border ToolWindow
Gui, Color, 02aef2
Gui, Show, W%boxw% H20 X%boxx% Y%boxy% ;draw the full highlight
setting := !setting
}
}
return
~Esc::reload ;Clear the highlights and menu
[Edited at 2021-02-22 18:39 GMT] | | | Stepan Konev Russische Föderation Local time: 07:26 Englisch > Russisch F6 works fine now — I just didn't capture it when copied the code | Feb 22, 2021 |
This is what I get:
[Edited at 2021-02-22 15:53 GMT] | | | James Plastow Vereinigtes Königreich Local time: 04:26 Japanisch > Englisch THEMENSTARTER
Stepan Konev wrote:
This is what I get:
[Edited at 2021-02-22 15:53 GMT]
Hi Stepan,
Thank you for taking the time to check out the script! Sorry but I don't understand why you are getting that behavior. Perhaps it is to do with the yellow circle thing you have on the mouse?
No idea, but the script is extremely basic, just a few lines, so you can easily see what is going on "under the hood"
maybe try changing
if (endxpos = startxpos){ ;If you just click twice in the same position you will get a 150 pixel highlight bar
boxx:=startxpos+10
boxw:=150 ;Change this value if you would like a shorter or longer fixed highlight bar
}
to
if (endxpos = startxpos){ ;If you just click twice in the same position you will get a 150 pixel highlight bar
boxx:=startxpos+10
boxw:=1 ;Change this value if you would like a shorter or longer fixed highlight bar
}
[Edited at 2021-02-22 16:03 GMT] | | | Stepan Konev Russische Föderation Local time: 07:26 Englisch > Russisch The updated version | Feb 22, 2021 |
James Plastow wrote:
Perhaps it is to do with the yellow circle thing you have on the mouse No. The yellow circle only appears in screen capturing mode.
UPD: After changing 150 to 1, the 'trail' persists. However, if Samuel confirms the script works fine for him, then this is my local issue.
Thank you for the script. I will keep it in my 'AHK Scripts' folder.
[Edited at 2021-02-22 16:25 GMT] | |
|
|
James Plastow Vereinigtes Königreich Local time: 04:26 Japanisch > Englisch THEMENSTARTER Monitor scale | Feb 22, 2021 |
Stepan Konev wrote:
James Plastow wrote:
Perhaps it is to do with the yellow circle thing you have on the mouse No. The yellow circle only appears in screen capturing mode.
UPD: After changing 150 to 1, the 'trail' persists. However, if Samuel confirms the script works fine for him, then this is my local issue.
Thank you for the script. I will keep it in my 'AHK Scripts' folder. [Edited at 2021-02-22 16:15 GMT]
Aha! Do you have your display scale set to other than 100%? For the script to work your monitor needs to be set to 100% scale. I get the same effect if I set my monitor scale to 150%
If you want to keep your monitor scale, it can be fixed by doing boxw:=(endxpos-startxpos-10)/1.5
[Edited at 2021-02-22 16:50 GMT] | | | Stepan Konev Russische Föderation Local time: 07:26 Englisch > Russisch RE: 150% scaling | Feb 22, 2021 |
James Plastow wrote:
Aha! Do you have your display scale set to other than 100%? For the script to work your monitor needs to be set to 100% scale. I get the same effect if I set my monitor scale to 150% You are right. Usually I use 150% scaling and I am well aware of the related misfunctioning issues that may arise from time to time with different applications because of scaling. That is why I switched one of my three monitors to 100% scaling just for testing. It did not help that time.
However now, when I switched my main monitor (other than that I used first time) to 100% either, the script works fine for both monitors.
James Plastow wrote:
If you want to keep your monitor scale, I think this could be fixed by doing boxw:=(endxpos-startxpos-10)/1.5 Thank you for this tip. Will try it.
UPD: Have tried that. Works fine. Great!
UPD2: While testing it all, I recognized how can I use it. It may be real useful. Thank you
[Edited at 2021-02-22 17:04 GMT] | | | Rolf Keller Deutschland Local time: 05:26 Englisch > Deutsch Scripts are just scripts | Feb 22, 2021 |
Stepan Konev wrote:
I assume you mean 'it' = Wordbird here?
Of course not. Wordbird is no script. So far there has been mentioned only one script: James' script. That's why I said "THE script" in the subject line and referred to it as "it".
Why not a task?
Because a script can't do that, on principle.
his script works with any application
You said "The script needs improvment" and "something is wrong with this script", didn't you? As an explanation you mentioned a missing scrolling feature. So I tried to explain to you the technically founded fact that your wish is unrealizable: No AutoHotKey script will ever be able to manage scrolling with arbitrary applications. | | | Vom Thema belegte Seiten: [1 2] > | To report site rules violations or get help, contact a site moderator: You can also contact site staff by submitting a support request » AutoHotKey Highlighter Pen Tool Wordfast Pro | Translation Memory Software for Any Platform
Exclusive discount for ProZ.com users!
Save over 13% when purchasing Wordfast Pro through ProZ.com. Wordfast is the world's #1 provider of platform-independent Translation Memory software. Consistently ranked the most user-friendly and highest value
Buy now! » |
| Anycount & Translation Office 3000 | Translation Office 3000
Translation Office 3000 is an advanced accounting tool for freelance translators and small agencies. TO3000 easily and seamlessly integrates with the business life of professional freelance translators.
More info » |
|
| | | | X Sign in to your ProZ.com account... | | | | | |