AutoHotkey Community

It is currently May 26th, 2012, 10:02 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 164 posts ]  Go to page Previous  1 ... 5, 6, 7, 8, 9, 10, 11  Next
Author Message
 Post subject:
PostPosted: August 4th, 2009, 12:32 pm 
Offline

Joined: May 27th, 2007, 9:41 am
Posts: 4999
@CovenStine: Just to be sure you know, have you tried "edit 3":
http://www.autohotkey.com/forum/viewtop ... 783#228783
if you hold down a key for one second it will be converted to a CAPITAL
letter, saves you the trouble of holding down shift. Of course you might
not like it...

_________________
AHK FAQ
TF : Text files & strings lib, TF Forum


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 5th, 2009, 3:43 am 
Offline

Joined: July 29th, 2009, 10:47 pm
Posts: 48
Thanks for the script! I broke my finger so this will help a lot! I'm actually using it right now so double thanks! :D

_________________
Click here to get free games and computer supplies! It's easy and fun! CLICK ME!

EasyAHK


Report this post
Top
 Profile  
Reply with quote  
PostPosted: August 5th, 2009, 12:28 pm 
Offline

Joined: July 24th, 2009, 5:39 pm
Posts: 6
Location: New England, USA
That's an interesting idea, holding down the button to skip the shift...
I guess I was trying to emulate -as close as possible- the behavior of my M-corp half-qwerty keyboard... I have just the one hand, and use the M- kbd on my desktop, and use this script on my laptop.
Down the road, I'd love to use an ergo keyboard on my desktop and switch to scripted work there, too.
In the meantime, I'm simply trying to make this script behave like my keyboard at home behaves, the only exception being the hardware-based stickyKeys, which suck.
Thanks though!
~C


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 14th, 2009, 11:04 pm 
Did not have a use for ' mapping to ` when using the modifier, so I just set the script so that space together with ' make an actual space. Works great and increases my typing speed.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: September 15th, 2009, 3:29 am 
Offline

Joined: April 29th, 2009, 12:08 pm
Posts: 45
thank you, this is EXACTLY what im after for online games and such, excellent work

_________________
frosty the snowman

Ex-AutoIt user

class: intermediate


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Shift-space modifier
PostPosted: September 29th, 2009, 5:58 pm 
CovenStine,

Using Edit 3A, find the following lines:

Code:
; If spacebar didn't modify anything, send a real space keystroke upon release.
+Space::Send {Space}
Space::Send {Space}


Comment out the first of those two lines as follows:

Code:
; If spacebar didn't modify anything, send a real space keystroke upon release.
;+Space::Send {Space}
Space::Send {Space}


That passes SHIFT-SPACE through properly.


Report this post
Top
  
Reply with quote  
PostPosted: November 4th, 2009, 10:13 pm 
I want to start by saying I like what you guys have been doing so far. Like one of the posters on one of the first few pages, I also am a user of AutoCAD, and so I also frequently have to use the Capslock button for lots of capital letters. Since the script as presented doesn't actually work very well for users who make use of Capslock, I decided to rewrite the script.

Since this is my first real foray into AutoHotkey scripting, I decided to rewrite most of it so that I understand what's going on. I have removed parts of the script that I felt unnecessary (such as the part that disabled the normal right-click menu on the script and the german and french keyboard options). If you want or need them, feel free to copy those parts over from the current version (Edit 3, I believe) of the script.

So without further ado, I present my code:
Code:
#SingleInstance

ShiftDelay = 200
ShiftDelay *= -1
StringCaseSense, on

leftside := "``" . "12345qwertasdfgzxcvb"
rightside := "'" . "09876poiuy;lkjh/.,mn"
other := "-=[]\"
shiftleftside :=   "~" . "!@#$%QWERTASDFGZXCVB"
shiftrightside := """" . ")(*&^POIUY:LKJH?><MN"
shiftother := "_+{}|"

Loop % StrLen(leftside)
{
   l := SubStr(leftside, A_Index, 1)
   r := SubStr(rightside, A_Index, 1)
   Hotkey Space & %l%, DoHotKey
   Hotkey Space & %r%, DoHotKey
   Hotkey Space & %l% UP, KeyUp
   Hotkey Space & %r% UP, KeyUp
   Hotkey %l%, NormalKeyDown
   Hotkey %r%, NormalKeyDown
   Hotkey %l% UP, KeyUp
   Hotkey %r% UP, KeyUp
}

Loop % Strlen(other)
{
   o := SubStr(other, A_Index, 1)
   Hotkey %o%, normalKeyDown
   Hotkey %o% UP, KeyUp
}
return

Control & Space::Suspend
Space & CapsLock::Send {Enter}
Space & Tab:: Send {Backspace}
+Space::Send {Space}
Space::Send {Space}

DoHotKey:
   StringRight ThisKey, A_ThisHotkey, 1
   MirrorKey := mirror(ThisKey)
   
   Modifiers := ""
   If (GetKeyState("LWin") || GetKeyState("RWin"))
      Modifiers .= "#"
   If (GetKeyState("Control"))
      Modifiers .= "^"
   If (GetKeyState("Alt"))
      Modifiers .= "!"
   If (GetKeyState("Shift"))
      MirrorKey := shift(MirrorKey)
   
   If (Modifiers <> "")
      send %Modifiers%{%MirrorKey%}
   Else
   {
      gosub, MaybePrintKey
      akey := Mirrorkey
       ;akey is a global variable used to pass around the key that we care about
      gosub, KeyDown
   }
   return

NormalKeyDown:
   gosub, MaybePrintKey
   akey := SubStr(A_ThisHotKey, 0, 1)
   gosub, KeyDown
   return

MaybePrintKey:
   if(keysuccess <> True)
   {
      gosub, PrintKey
      SetTimer, PrintShiftKey, off
   }
   return

KeyDown:
   keysuccess := False
   SetTimer, PrintShiftKey, %ShiftDelay%
   return

KeyUp:
   SetTimer, PrintShiftKey, off
   gosub, PrintKey
   return

PrintKey:
   if(keysuccess <> True)
   {
      If (GetKeyState("CapsLock", "T"))
         akey := togglecase(akey)
      keysuccess := True
      send {%akey%}
   }
   return

PrintShiftKey:
   if(keysuccess <> True)
   {
      If (GetKeyState("CapsLock", "T"))
         akey := togglecase(akey)
      shiftkey := shift(akey)
      send {%shiftkey%}
      send {%akey% up}
      keysuccess := True
   }
   return

togglecase(char)
{
   StringUpper, u, char
   StringLower, l, char
   If (u == char)
      char := l
   Else
      char := u
   return char
}

mirror(char)
{
   global leftside
   global rightside
   l := InStr(leftside, char)
   r := InStr(rightside, char)
   If (l > 0)
      m := SubStr(rightside, l, 1)
   Else If (r > 0)
      m := SubStr(leftside, r, 1)
   Else
      m := char
   return m
}

shift(char)
{
   global leftside
   global rightside
   global other
   global shiftleftside
   global shiftrightside
   global shiftother
   normal := leftside . rightside . other
   shifted := shiftleftside . shiftrightside . shiftother
   n := InStr(normal, char, True)
   s := InStr(shifted, char, True)
   If(n > 0)
      newchar := SubStr(shifted, n, 1)
   Else If(s > 0)
      newchar := SubStr(normal, s, 1)
   Else
      newchar := char
   return %newchar%
}


A few ways in which it differs from edit 3:
- Caps Lock works as normal. It toggles the capitalization of letters that are typed, but does not interfere with other symbols.
- Like edit 3, it does shift characters when they are held down for a while (200ms is the default in this script; it is easily changed on line 3). However, it does not send the regular character, then a backspace, and then the shifted character as edit 3 does. It instead sends only the desired character. I find this advantageous, because backspace characters can screw some things up (like going to a previous page in old Internet Explorers and causing breaks in undo history).
- When you press and hold a character to capitalize it, you need to let go after it capitalizes, but before the key starts repeating. I am unable to find a reasonable solution to this problem. If anyone has knowledge of key auto-repeating, this script could use your expertise.
- It does not support keyboards other than standard US keyboards. This should be extensible by doing something similar to what is done in edit 3.[/code]


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 5th, 2009, 8:49 am 
Offline

Joined: May 24th, 2009, 1:23 pm
Posts: 89
Location: Bærum, Norway
You could implement half-keyboard typing in PKL, as an 'extend' mapping.

That way, it'd be by virtual scan code (i.e., keyboard and layout invariant), and would easily allow toggling of Caps state (personally I use CapsLock plus Esc to toggle but anything goes) while being practical in use as a keyboard mirroring implementation without annoying and error-prone delay tricks. And it'd be editable without recompiling since it'd reside in the pkl.ini file.

I'm going to do it myself, once I get the time (and get multiple 'extend' states in PKL like I've wished for). Not soon though, so if anyone's interested they should do it themselves.

_________________
Better burden you cannot carry than man-wisdom much -- Hávamál


Report this post
Top
 Profile  
Reply with quote  
PostPosted: December 17th, 2009, 12:28 pm 
Offline

Joined: December 17th, 2009, 11:34 am
Posts: 1
Hi. Let me present my current version of the script:

Code:
; LKey    1  2  3  4  5  6  q  w  e  r  t  y  a  s  d  f  g  h  z  x  c  v  b
LScan := "02 03 04 05 06 07 10 11 12 13 14 15 1E 1F 20 21 22 23 2C 2D 2E 2F 30"
; RKey    =  -  0  9  8  7  ]  [  p  o  i  u  \  '  ;  l  k  j  /  .  ,  m  n
RScan := "0D 0C 0B 0A 09 08 1B 1A 19 18 17 16 2B 28 27 26 25 24 35 34 33 32 31"

; Define HotKeys
Scans = %LScan% %RScan%
Loop, Parse, Scans, " "
    Hotkey Space & sc0%A_LoopField%, DoHotKey

return


Space::Send {Space}     ; If spacebar didn't modify anything,
+Space::Send {Space}    ; send a space keystroke upon release

; Not exactly mirror but as close as we can get
Space & Tab::Send {Backspace}     ; Tab BackSpace
Space & CapsLock::Send {Enter}    ; Capslock Еnter


; General purpose
DoHotKey:
    StringRight ThisKey, A_ThisHotkey, 2
    i1 := InStr(LScan, ThisKey)
    i2 := InStr(RScan, ThisKey)
    If (i1 > 0)
        MirrorKey := SubStr(RScan, i1, 2)
    Else
        MirrorKey := SubStr(LScan, i2, 2)

    Modifiers := ""
    If (GetKeyState("LWin") || GetKeyState("RWin"))
        Modifiers .= "#"
    If (GetKeyState("Control"))
        Modifiers .= "^"
    If (GetKeyState("Alt"))
        Modifiers .= "!"
    If (GetKeyState("Shift") + GetKeyState("CapsLock", "T") = 1)
        Modifiers .= "+"
        ; only add if Shift is held OR CapsLock is on (XOR)
        ; (both held down would result in value of 2)

    Send %Modifiers%{sc0%MirrorKey%}

return


It differs from edit 3:
1. It supports keyboards other than US standart. I need this because I often type in Russian.
2. The line of symmetry is between H and J. I do not understand how do you type []{} with line of symmetry between G and H.
3. It does not shift characters when they are held down for a while.

Sorry for my English


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 28th, 2009, 11:32 am 
Offline

Joined: May 24th, 2009, 1:23 pm
Posts: 89
Location: Bærum, Norway
Now that's what I was talking about!

I tried the PKL 'extend' remapping method but wasn't quite satisfied as in the current state of the program it'll remap your mirrored key to the system's installed layout unless you remap by character (so it's layout dependent again). Will work around that eventually.

Seederoff: I think I prefer the symmetry line between (QWERTY) G and H still. It's very important that you can keep your fingers in their normal two-handed positions so that the one hand does exactly what the other would've done most of the time.

However, I made myself two versions: The right-handed version is simple mirroring since it already reaches the [] '\ -= keys (I used the Enter key to mirror although I'd prefer a foot pedal; Enter+Space became the new Enter press). The left-handed version has the [] '\ -= keys moved towards the middle of the board to the (QWERTY) YU HJ NM keys. I think that worked well, although the apostrophe in particular may be so common that it deserves even better and might go on a remapped Tab press.

_________________
Better burden you cannot carry than man-wisdom much -- Hávamál


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 29th, 2009, 5:05 pm 
Offline

Joined: October 27th, 2006, 10:12 am
Posts: 649
Chris wrote:
Looks great. Might be especially useful for players of flight sims who want to type messages without crashing the plane :)
Or any other case where you want and have to keep one hand busy elsewhere, but still want to be able to type in any commands with the other hand.

Imagine following example: While using a normal pc mouse, we use it to move the cursor on the 2D screen and use one of the available buttons on it to trigger some kind of action. But why limiting to only those 3 or a few more buttons on the pc mouse if we have in front of us also the whole pc keyboard?

Thus right hand onto a mouse pen, like a wacom graphics tablet pen, for moving the cursor, and the left hand on the qwerty, for entering commands might be a nice idea. Actually even single press key entries on the qwerty keys would give us already many more possibilities than using a pc mouse alone. You would only need to fill them with interesting functionality using AHK.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 12th, 2010, 9:23 pm 
Hey I was wondering if it's possible to modify this script so that when you hold down the key instead of capitalizing the letter it gives you the mirrored letter. I've been trying to modify it but I can't seem to do it. Thanks for the help. It is a great script btw though.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 12th, 2010, 9:55 pm 
Offline

Joined: May 27th, 2007, 9:41 am
Posts: 4999
Anonymous wrote:
Hey I was wondering if it's possible to modify this script so that when you hold down the key instead of capitalizing the letter it gives you the mirrored letter. I've been trying to modify it but I can't seem to do it. Thanks for the help. It is a great script btw though.


Replace these in "edit3" from here
http://www.autohotkey.com/forum/post-228783.html#228783
Code:
ReplaceWithUpper:
SetKeyDelay, -1
_key:=Substr(mirrored, InStr(original, LastKey), 1)
Send {Backspace}%_key%
_key=
Return

ReplaceWithUpperMirror:
SetKeyDelay, -1
_key:=Substr(original, InStr(mirrored, MirrorKey), 1)
Send {Backspace}%_key%
_key=
Return
Untested but I think it should work

Edit: update removed the + so it doesn't send UPPERCASE anymore

_________________
AHK FAQ
TF : Text files & strings lib, TF Forum


Last edited by SoLong&Thx4AllTheFish on January 13th, 2010, 9:00 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 12th, 2010, 11:48 pm 
Thanks for the quick response! It works but it produces the capitalized mirrored letter. I want the lowercase. I'm trying this method b/c I find using a space as a modifier is a bit cumbersome and slow, but maybe I just haven't gotten enough practice w/ it.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 13th, 2010, 9:01 am 
Offline

Joined: May 27th, 2007, 9:41 am
Posts: 4999
I removed the + (shift) in the send above so either copy or remove the + in your code

_________________
AHK FAQ
TF : Text files & strings lib, TF Forum


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 164 posts ]  Go to page Previous  1 ... 5, 6, 7, 8, 9, 10, 11  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Apollo, JamixZol and 7 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group