AutoHotkey Community

It is currently May 27th, 2012, 5:48 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 171 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6, 7 ... 12  Next
Author Message
 Post subject:
PostPosted: June 1st, 2010, 5:51 pm 
Offline

Joined: March 27th, 2008, 2:14 pm
Posts: 700
This is really nice, poly. (yes I noticed you haven't posted for almost a year and a half) I'm going to attempt to make a frontend gui for it. It'll be posted on the forums when it's done. (It's not my idea btw. noobs are motivating lol)

I noticed one very tiny issue. Line 54 needs a slight modification:
Code:
; from:
Else If (GetKeyState("Shift") OR GetKeyState("CapsLock", "T"))

; to:
Else If (GetKeyState("Shift") ^ GetKeyState("CapsLock", "T"))

Because if both capslock is on AND shift is held down then it should remain lowercase.

<3 xor logic

_________________
Scripts - License


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 1st, 2010, 8:06 pm 
Offline
User avatar

Joined: August 11th, 2004, 1:47 am
Posts: 5347
Location: UK
Thanks for the tip, I've updated the script :)

_________________
GitHubScriptsIronAHK Contact by email not private message.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 1st, 2010, 11:08 pm 
Offline
User avatar

Joined: October 31st, 2008, 9:39 am
Posts: 641
Location: France
Samethings that InfoG :o

1/ On my computer your "hook" don't take numpad number, perhaps only for me...
In other word, hotkey, *~$1... don't work with 1NumPad (with or without VerrNum).
2/ I think that SubStr() is better than StringTrimLeft (not include in IronAHK, no ?)

or maybe a function with all virtual key ? :lol:
Code:
#SingleInstance Force

SetFormat, IntegerFast, Hex
loop 255
{
  StringReplace, index, a_index, % a_index < 0x10 ? "x" : "0x"
  Hotkey, ~VK%index%, Hook
  Hotkey, ~VK%index% Up, Hook
}
SetFormat, IntegerFast, Dec

virtualkey =
(
01 Left mouse button
02 Right mouse button
03 Control-break processing
04 Middle mouse button (three-button mouse)
05-07 Undefined
08 BACKSPACE key
09 TAB key
0A-0B Undefined
0C CLEAR key
0D ENTER key
0E-0F Undefined
10 SHIFT key
11 CTRL key
12 ALT key
13 PAUSE key
14 CAPS LOCK key
15-19 Reserved for Kanji systems
1A Undefined
1B ESC key
1C-1F Reserved for Kanji systems
20 SPACEBAR
21 PAGE UP key
22 PAGE DOWN key
23 END key
24 HOME key
25 LEFT ARROW key
26 UP ARROW key
27 RIGHT ARROW key
28 DOWN ARROW key
29 SELECT key
2A Original equipment manufacturer (OEM) specific
2B EXECUTE key
2C PRINT SCREEN key for Windows 3.0 and later
2D INS key
2E DEL key
2F HELP key
30 0 key
31 1 key
32 2 key
33 3 key
34 4 key
35 5 key
36 6 key
37 7 key
38 8 key
39 9 key
3A-40 Undefined
41 A key
42 B key
43 C key
44 D key
45 E key
46 F key
47 G key
48 H key
49 I key
4A J key
4B K key
4C L key
4D M key
4E N key
4F O key
50 P key
51 Q key
52 R key
53 S key
54 T key
55 U key
56 V key
57 W key
58 X key
59 Y key
5A Z key
5B Left Windows key (Microsoft Natural Keyboard)
5C Right Windows key (Microsoft Natural Keyboard)
5D Applications key (Microsoft Natural Keyboard)
5E-5F Undefined
60 Numeric keypad 0 key
61 Numeric keypad 1 key
62 Numeric keypad 2 key
63 Numeric keypad 3 key
64 Numeric keypad 4 key
65 Numeric keypad 5 key
66 Numeric keypad 6 key
67 Numeric keypad 7 key
68 Numeric keypad 8 key
69 Numeric keypad 9 key
6A Multiply key
6B Add key
6C Separator key
6D Subtract key
6E Decimal key
6F Divide key
70 F1 key
71 F2 key
72 F3 key
73 F4 key
74 F5 key
75 F6 key
76 F7 key
77 F8 key
78 F9 key
79 F10 key
7A F11 key
7B F12 key
7C F13 key
7D F14 key
7E F15 key
7F F16 key
80H F17 key
81H F18 key
82H F19 key
83H F20 key
84H F21 key
85H F22 key
86H F23 key
87H F24 key
88-8F Unassigned
90 NUM LOCK key
91 SCROLL LOCK key
92-B9 Unassigned
BA-C0 OEM specific
C1-DA Unassigned
DB-E4 OEM specific
E5 Unassigned
E6 OEM specificr
E7-E8 Unassigned
E9-F5 OEM specific
F6 Attn key
F7 CrSel keyr
F8 ExSel key
F9 Erase EOF key
FA Play key
FB Zoom key
FC Reserved for future use.
FD PA1 key
FE Clear key
)

return

Hook:
info:=
if pos:=InStr(virtualkey, SubStr(a_thishotkey, 4, 2))
  info:=SubStr(virtualkey, pos, InStr(virtualkey, "`n", "", pos)-pos)
if ( SubStr(a_thishotkey, 4, 2) <= 2 )
{
  mousegetpos, x, y
  info.=" " x "/" y
}
tooltip % a_thishotkey " " info
return


Edit: virtualkey list can be edit with only one character after VKcode for to add it to a matchlist, or we work always with VK code... however VK can be good for multilanguage, but I don't know I haven't russian or a kanji keyboard for example...

Perhaps we can do a major autocompletion apps with your IronAHk for crossplatform and with unicode, that's the "noobs" (cf InfoG reply) ask...


Report this post
Top
 Profile  
Reply with quote  
PostPosted: July 1st, 2010, 6:36 pm 
Offline

Joined: October 11th, 2007, 3:03 pm
Posts: 51
Can you mix hotkeys in as in:

Code:

hotstrings("{Escape}([A-z])", "%$1%{Up}{Enter}")


using Hotstrings.ahk or something else?

thanks.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 1st, 2010, 7:16 pm 
Offline
User avatar

Joined: October 31st, 2008, 9:39 am
Posts: 641
Location: France
Maybe this can help you (use google translator french to english if needed)
http://www.autohotkey.com/forum/viewtop ... 396#365396

In other you must enhance this function with your "new" key

_________________
"You annoy me, therefore I exist."


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 2nd, 2010, 1:26 am 
Offline

Joined: October 11th, 2007, 3:03 pm
Posts: 51
Zaelia wrote:
Maybe this can help you (use google translator french to english if needed)
http://www.autohotkey.com/forum/viewtop ... 396#365396

In other you must enhance this function with your "new" key


sadly, google translate is not helping much with this. Can you translate just a little?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 2nd, 2010, 3:29 am 
Offline
User avatar

Joined: October 31st, 2008, 9:39 am
Posts: 641
Location: France
It's not the only way, it's just a merge with the original script and your example.

Code:

hotstrings("Ø([A-z])", "line1{enter}line2")


; We use an extented ascii character, this key doesn't exist (example: alt+157)
; in other word, "Ø" is the key "escape"
; So, esc+letter give the text line1`nline2


hotstrings(k, a = "")
{
   static z, m = "*~$", s, t, w = 2000
   global $
   If z = ; init
   {
      Loop, 94
      {
         c := Chr(A_Index + 32)
         If A_Index not between 33 and 58
            Hotkey, %m%%c%, __hs
      }
      e = BS|Space|Enter|Return|Tab|Escape ; we add key "escape" to the hook
      Loop, Parse, e, |
         Hotkey, %m%%A_LoopField%, __hs
      z = 1
   }
   If (a == "" and k == "") ; poll
   {
      StringTrimLeft, q, A_ThisHotkey, StrLen(m)
      If q = BS
      {
         If (SubStr(s, 0) != "}")
            StringTrimRight, s, s, 1
      }
      Else
      {
         If q = Space
            q := " "
         Else If q = Escape ; we transform key escape in a character for the matchlist
            q := "Ø"
         Else If q = Tab
            q := "`t"
         Else If q in Enter,Return
            q := "`n"
         Else If (StrLen(q) != 1)
            q = {%q%}
         Else If (GetKeyState("Shift") ^ GetKeyState("CapsLock", "T"))
            StringUpper, q, q
         s .= q
      }
      Loop, Parse, t, `n ; check
      {
         StringSplit, x, A_LoopField, `r
         If (RegExMatch(s, x1 . "$", $)) ; match
         {
            StringLen, l, $
            StringTrimRight, s, s, l
            l := InStr($, "Ø")>0 ? l-1 : l ; we need to change the count of del char, because esc is not printable
            SendInput, {BS %l%}
            If (IsLabel(x2))
               Gosub, %x2%
            Else
            {
               Transform, x0, Deref, %x2%
               SendInput, %x0%
            }
         }
      }
      If (StrLen(s) > w)
         StringTrimLeft, s, s, w // 2
   }
   Else ; assert
   {
      StringReplace, k, k, `n, \n, All ; normalize
      StringReplace, k, k, `r, \r, All
      Loop, Parse, t, `n
      {
         l = %A_LoopField%
         If (SubStr(l, 1, InStr(l, "`r") - 1) == k)
            StringReplace, t, t, `n%l%
      }
      If a !=
         t = %t%`n%k%`r%a%
   }
   Return
   __hs: ; event
   hotstrings("", "")
   Return
}

_________________
"You annoy me, therefore I exist."


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 2nd, 2010, 2:54 pm 
Offline

Joined: October 11th, 2007, 3:03 pm
Posts: 51
Zaelia wrote:
It's not the only way, it's just a merge with the original script and your example.



Thank you. This is very useful. Basically, the technique is to use the Alt+157 character as a proxy for the ESC key and then somehow loop through and replace it with the ESC-key in the regular expression.

Furthermore, doing

Code:
hotstrings("`t([A-z])", "line1{enter}line2")


makes it possible to do "TAB a" and then activate the action.

Why is BS listed in the "hook", but not used elsewhere? in other words, how would I do

Code:
hotstrings("BS([A-z])", "line1{enter}line2")


Would I have to resort to using another character from the extended set for this?

Thanks for all the help.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 2nd, 2010, 3:23 pm 
Offline
User avatar

Joined: October 31st, 2008, 9:39 am
Posts: 641
Location: France
For simple thing and use the power of Regex, the original function only match (check) the classic printable character.

BS is not a printable character, it is used for delete the last printable character in the matchlist.

Try with a real tab, I don't know
hotstrings(" ([A-z])", "line1{enter}line2")

_________________
"You annoy me, therefore I exist."


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 23rd, 2010, 7:05 pm 
Offline

Joined: May 18th, 2005, 11:03 am
Posts: 30
Does anybody have a neat way to force the dynamic hostrings recogniser to be reset when a mouse click occurs (like with the built in hotstrings functionality)?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 24th, 2010, 1:39 am 
Offline
User avatar

Joined: October 31st, 2008, 9:39 am
Posts: 641
Location: France
simple example...

brute force:
Code:
~Lbutton::
reload
return


or more usefull in not simple script: (his part of code must be in function or declare "s" variable as global) for example
Code:
~Lbutton::
~Rbutton::
~Mbutton::
s=
return

; hotstring function...
; global $, s


or you can manage "q" variable when %a_thishotkey% is your mouse click (like the orginial function with key "enter" , but result is not s.=q but s:="" )


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 24th, 2010, 9:57 am 
Offline

Joined: May 18th, 2005, 11:03 am
Posts: 30
Setting s as global and clearing its value (your second solution) is working very nicely, thank you.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 28th, 2011, 1:26 pm 
Offline

Joined: March 31st, 2011, 6:28 pm
Posts: 13
I'm having some trouble with hotstrings I'm trying to create

hotstrings("cc#", "closing incident") never fires
hotstrings("cc", "closing incident#") fires but does not output the #
hotstrings("cc", "closing incident@") works fine
hotstrings("cc@", "closing incident") never fires

I want to use some character after my hotstrings to prevent conflicts with normal words, but then the strings don't work. Also during testing I found that it will not output '#', which is a problem.

I don't understand the code well enough to debug the issue myself. I greatly appreciate any help!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 28th, 2011, 1:56 pm 
Offline

Joined: June 6th, 2006, 3:19 pm
Posts: 1654
Location: Denmark
Some chars must be escaped with {}, see Send:
Code:
hotstrings("cc", "closing incident{#}")

The hotstrings are fired on first match; having cc, ccx are never reached.

Edit:
Code:
hotstrings("cc#","whatever") ; not working
hotstrings("cc+3","whatever") ; working (danish keyboard)

_________________
RegEx Powered Dynamic Hotstrings
COM
AutoHotkey 2


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 28th, 2011, 3:10 pm 
Offline

Joined: March 31st, 2011, 6:28 pm
Posts: 13
tonne wrote:
Some chars must be escaped with {}, see Send:

Aha! That certainly explains the output issue!

Quote:
The hotstrings are fired on first match; having cc, ccx are never reached.

These are just examples of things I've tried. My intention is to have only one of those statements in my script. As seem to have realized in your edit the "cc#" trigger just does not seem to work.

I also realized that characters used to define regular expressions will cause failure or other undesirable behavior. It is obvious in retrospect that as we wish to have regular expressions used as triggers this behavior is to be expected.

According to my testing these characters used to define RegEx cannot be used as literals in triggers: $, +, *, [, ], ), \
It seems possible to escape them if desired, I tried doing that with $ and it worked fine ("cc\$" allows cc$ to trigger). Escaping # the same way does not work.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 171 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6, 7 ... 12  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: HotkeyStick, JamixZol and 22 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