At my school, the Windows control panel is locked and I am only allow to use the standard German QWERTZ layout there, which I cannot touch-type on. With the agreement of my teacher, I am allowed to use a program or script to simulate the QWERTY layout, which I am used to. This is what I got so far:
y::z
z::y
-::Sendraw /
+-::Sendraw ?
+::Sendraw ]
*::SendRaw }
+2::SendRaw #
+3::SendRaw #
+6::Send {^}{Space}
+7::SendRaw &
+8::SendRaw *
+9::SendRaw (
+0::SendRaw )
ß::SendRaw -
+ß::SendRaw _
´::Send {U+003D}
+´::SendRaw +
ö::Send {U+003B}
+ö::SendRaw :
ä::SendRaw '
+ä::SendRaw "
ü::SendRaw [
+ü::SendRaw {
Most things work nicely except Shift + 7, 8, 9, 0 and ´
Shift + 8, 9 or 0 all produce }
Shift + 7 produces an ^
Shift + ´ produces an ]
Minus produces an ^
Shift + - produces an overflow error.
Fetch pressed keys by unicode is not possible from what I understand.
What am I doing wrong?
Do you maybe know a program which does exactly this, so I can just leave all this?
y::z
z::y
-::Send {U+002F} ; /
+-::Send {U+003F} ; ?
+::Send {U+005D} ; ]
*::Send {U+007D} ; }
+2::Send {U+0040} ; (
+3::Send {U+0023} ; #
+6::Send {U+005E}{Space}; ^
+7::Send {U+0026} ; &
+8::Send {U+002A} ; *
+9::Send {U+0028} ; (
+0::Send {U+0029} ; )
ß::Send {U+002D} ; -
+ß::Send {U+005F} ; _
´::Send {U+003D} ; =
+´::Send {U+002B} ; +
ö::Send {U+003B} ; ;
+ö::Send {U+003A} ; :
ä::Send {U+0027} ; '
+ä::Send {U+0022} ; "
ü::Send {U+005B} ; [
+ü::Send {U+007B} ; {
^::Send {U+0060} ; ~
+°::Send {U+007E} ; `
#::Send {U+005C} ; \
+'::Send {U+007C} ; |
You just have to use unicode characters as output.
Related
My current script copies text like this with a shortcut:
:WiltedFlower: aetheryxflower ─ 4
:Alcohol: alcohol ─ 3,709
:Ant: ant ─ 11,924
:Apple: apple ─ 15
:ArmpitHair: armpithair ─ 2
and pastes it modified into a single line
Pls trade 4 aetheryxflower 3 alcohol 11 ant 15 apple 2 armpithair <#id>
As you can see there are already two little problems, the first one is that it copies only the number/s before a comma if one existed instead of ignoring it. The second is that I always need to also copy before hitting the hotkey and start re/start the script, I've thought of modifying the script so that it uses the already selected text instead of the copied one so that I can bind it with a single hotkey.
That is my current script, it would be cool if anyone can also tell me what they used and why exactly, so that I also get better with ahk
!q::
list =
While pos := RegExMatch(Clipboard, "(\w*) ─ (\d*)", m, pos ? pos + StrLen(m) : 1)
list .= m2 " " m1 " "
Clipboard := "", Clipboard := "Pls trade " list " <#951737931159187457>"
ClipWait, 0
If ErrorLevel
MsgBox, 48, Error, An error occurred while waiting for the clipboard.
return
If the pattern of your copied text dont change, you can use something like this:
#Persistent
OnClipboardChange:
list =
a := StrSplit(StrReplace(Clipboard, "`r"), "`n")
Loop,% a.Count() {
b := StrSplit( a[A_Index], ": " )
c := StrSplit( b[2], " - " )
list .= Trim( c[2] ) " " Trim( c[1] ) " "
}
Clipboard := "Pls trade " list " <#951737931159187457>"]
ToolTip % Clipboard ; just for debug
return
With your example text, the output will be:
Pls trade aetheryxflower ─ 4 alcohol ─ 3,709 ant ─ 11,924 apple ─ 15 armpithair ─ 2 <#951737931159187457>
And this will run EVERY TIME your clipboard changes, to avoid this, you can add at the top of the script #IfWinActive, WinTitle or #IfWinExist, WinTitle depending of your need.
The answer given would solve the problem, assuming that it never changes pattern as Diesson mentions.
I did the explanation of the code you provided with comments in the code below:
!q::
list = ; initalize a blank variable
; regexMatch(Haystack, regexNeedle, OutputVar, startPos)
; just for frame of reference in explanation of regexMatch
While ; loop while 'pos' <> 0
pos := RegExMatch(Clipboard ; Haystack is the string to be searched,
in this case the Clipboard
, "(\w*) ─ (\d*)" ; regex needle in this case "capture word characters
(a-z OR A-Z OR 0-9 OR _) any number of times, space dash space
then capture any number of digits (0-9)"
, m ; output var array base name, ie first capture will be in m1
second m2 and so on.
, pos ? pos + StrLen(m) : 1) ; starting position for search
"? :"used in this way is called a ternary operator, what is saying
is "if pos<>0 then length of string+pos is start position, otherwise
start at 1". Based on the docs, this shouldn't actually work well
since 'm' in this case should be left blank
list .= m2 " " m1 " " ; append the results to the 'list' variable
followed with a space
Clipboard := "" ; clear the clipboard.
Clipboard := "Pls trade " list " <#951737931159187457>"
ClipWait, 0 ; wait zero seconds for the clipboard to change
If ErrorLevel ; if waiting zero seconds for the clipboard to change
doesn't work, give error msg to user.
MsgBox, 48, Error, An error occurred while waiting for the clipboard.
return
Frankly this code is what I would call quick and dirty, and seems unlikely to work well all the time.
In Python, we break a long line of code into multiple code lines with backslash like this.
a = 5
b = 11
print(str(a) + " plus " + \
str(b) + " is " + \
str(a + b))
# prints "5 plus 11 is 16"
How do we do that in NetLogo?
NetLogo doesn't care about multiple lines except for comments (the comment marker ; only lasts to the end of the line). All of these are the same:
to testme
; single line
let a 25 print a
; command per line
let b 20
print b
; unreadable
let
c
15
print
c
end
I had a snippet that used to work well (neovim 0.2.0)
snippet #= "comment ===" b
# `!p snip.rv = '=' * (78 - vim.current.window.cursor[1])`
# ${1:comments}
# `!p snip.rv = '=' * (78 - vim.current.window.cursor[1])`
endsnippet
This snippet is basically writing python comments block when triggered,
where the length of "=" depends on the position of the cursor.
For a few days now (I don't know which update makes it failing), the length of "=" is decreasing as long as I type my comment.
It looks like vim.current.window.cursor[1] is constantly re-evaluated.
Any idea how to "freeze" the value?
I finally found:
snippet #= "comment ===" b
`!p
if not snip.c:
width = int(vim.eval("78 - virtcol('.')"))
snip.rv = '# ' + '=' * width`
# ${1:comments}
`!p snip.rv = '# ' + '=' * width`
endsnippet
I have the following script:
For $alpha = 1 to 10
For $beta = 1 to 10
Run('"C:\Users\MyProg.exe ' & alpha/10 & ' ' & beta/10 & ' 200 2 0.5'
;some other actions follow
Next
Next
I have checked many times that the string is well-formed, thus I have no idea why the script wouldn't run the program. Could you help me please?
Just replace the ending ' with "') and use proper variable names including the $... like $alpha instead of just alpha. Your syntax check in SciTE should have told you.
For $alpha = 1 to 10
For $beta = 1 to 10
Run('"C:\Users\MyProg.exe ' & $alpha/10 & ' ' & $beta/10 & ' 200 2 0.5"')
;some other actions follow
Next
Next
A media keyboard I'm using doesn't have a full set of keys, so I'm trying to map alternatives using AutoHotkey. Basically, I want to use the Alt Gr key together with some other keys to simulate the missing keys. This is what I've done:
<^>!,::send {Home}
<^>!.::send {End}
<^>![::send {PrintScreen}
<^>!]::send {Insert}
However, if I want to do the equivalent of Shift + Home (to select all text to the beginning of a line), this doesn't work as I'd hoped. I know I can put a * at the beginning of the line so that Home is still sent even when I'm holding Shift, but the problem is that I'd like the Shift key to still be active so that I get the equivalent of Shift + Home.
Likewise, if I want to do Alt + Print Screen then holding Alt while pressing Alt Gr + [ doesn't have the desired effect.
I assume I could set up extra rules to catch those combinations, but surely there must be a way to just have AutoHotkey not discard whatever modifier I'm holding at the time I hit the hotkey so that whatever combination I use it'll work?
EDIT (2014-07-16):
Here is the latest version of my script, which includes comments that make it clear what I'm wanting to achieve. Everything in this script works except for the last line. For some reason, even though I'm trying to send Alt + PrtScn it gets treated as just PrtScn.
; Home ( by pressing AltGr + , )
<^>!,::send {Home}
; Shift + Home ( by pressing Shift + AltGr + , )
+<^>!,::send +{Home}
; End ( by pressing AltGr + . )
<^>!.::send {End}
; Shift + End ( by pressing Shift + AltGr + . )
+<^>!.::send +{End}
; Insert ( by pressing AltGr + [ )
<^>![::send {Insert}
; Shift + Insert ( by pressing Shift + AltGr + [ )
+<^>![::send +{Insert}
; PrtScn ( by pressing AltGr + ] )
<^>!]::send {PrintScreen}
; Alt + PrtScn ( by pressing LeftAlt + AltGr + ] )
<!<^>!]::send !{PrintScreen}
Using the {Blind} attribute will pass on the modifier keys.
e.g.
<^>!,::send {Blind}{Home}
See: Send existing modifiers with a key in autohotkey?
It turns out that some of the combinations I wanted to do with Autohotkey, involving the AltGr key, are not possible due to AltGr itself actually being a combination of Control and Right Alt. Therefore, not all modifiers are available for use together with that key, and some of the AutoHotkey commands give unwanted/unexpected results when trying to use them together with AltGr.
The final version of the script I'm using with my new keyboard (the UK version of the Microsoft All-in-One Media Keyboard) is as follows:
; Set an initial state for the lock keys
SetCapsLockState, off
SetNumLockState, on
SetScrollLockState, off
; Home ( by pressing AltGr + , )
<^>!,::send {Home}
; Shift + Home ( by pressing Shift + AltGr + , )
+<^>!,::send +{Home}
; End ( by pressing AltGr + . )
<^>!.::send {End}
; Shift + End ( by pressing Shift + AltGr + . )
+<^>!.::send +{End}
; Insert ( by pressing AltGr + [ )
<^>![::send {Insert}
; Shift + Insert ( by pressing Shift + AltGr + [ )
+<^>![::send +{Insert}
; PrtScn ( by pressing AltGr + ] )
<^>!]::send {PrintScreen}
; Alt + PrtScn ( by pressing Alt + ] )
!]::send !{PrintScreen}
; Scroll Lock ( by pressing AltGr + \ )
<^>!\::send {ScrollLock}
; Pause/Break ( by pressing AltGr + p )
<^>!p::send {Pause}
; Win + Pause/Break ( by pressing Shift + Alt + p )
+!p::send #{Pause}
; Control + Pause/Break ( by pressing Shift + Ctrl + p )
+^p::send ^{CtrlBreak}
; Run Calculator ( by pressing AltGr + c )
<^>!c::Run Calc