 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Micahs
Joined: 01 Dec 2006 Posts: 413
|
Posted: Sat Sep 08, 2007 4:18 am Post subject: ahkosk |
|
|
The latest version is up. I've added layer support and fixed some things.
Here is the structure for adding layers: | Code: | <key shift="!" layer1="®" layer2="¶" layer3="Ý">1</key>
<key shift="@" layer1="Œ" layer2="¿" layer3="Þ">2</key>
<key shift="#" layer1="ž" layer2="À" layer3="ß">3</key>
<key shift="$" layer1="©" layer2="Ø" layer3="€">4</key>
| Click the "layr" button to toggle.
Thanks for the idea, RedX _________________
 |
|
| Back to top |
|
 |
wrybread
Joined: 05 Jul 2006 Posts: 33
|
Posted: Thu Oct 04, 2007 8:45 pm Post subject: Nice work, but.... |
|
|
Nice work, just a couple of questions.
First, I find that in its default configuration it doesn't pick up nearly all the key presses if someone presses the keys very rapidly. Adjusting clickUpdateRate in the config file fixes this... Is there an advantage to leaving this at 40? Or at anything above 0?
And is there a way to give the keyboard a transparent background? In other words, make it so it's not an even rectangle, but has edge keys "floating" on a transparent background?
And would it be possible to make the buttons be images instead of blocks? In other words, define the keyboard the same way we are now, but allow an image overlay over each key?
Or another approach might be to allow the user to create their own complete keyboard in, say, Photoshop, and capture keystrokes depending on where their clicks were registered? I'm thinking of kiosk designers and people for whom the aesthetics of the keyboard is extremely important...
Again, really nice work. As I get deeper into its configurations (the ini file and the xml layout) I really really like it. |
|
| Back to top |
|
 |
davez Guest
|
Posted: Fri Oct 05, 2007 4:00 pm Post subject: |
|
|
I also think you've got a great piece of software here.
Just an Idea I thought I would toss out.
You should be able to add totally customizable buttons for AHK.
Like a blank row of keys we can label and add function to with our hotkeys.
Thanks for a great product. |
|
| Back to top |
|
 |
Micahs
Joined: 01 Dec 2006 Posts: 413
|
Posted: Mon Oct 08, 2007 8:46 am Post subject: |
|
|
Thanks for the interest!
Here is a screenshot of what the latest version can do. This is the "english-fancy" layout.
| wrybread wrote: | | Is there an advantage to leaving this at 40? | At the time, the click detection sub was such a mess that I just left it where it was. I've recently improved that sub, making it faster and more efficient. BTW, I changed this to 15.
| wrybread wrote: | | give the keyboard a transparent background? | Sure! Check out the latest version. Or this - with no blobs:
| wrybread wrote: | | make the buttons be images instead of blocks? | I'm looking into this (there are some things floating around the forum about this.) I also am working on round and elliptical buttons.
| wrybread wrote: | | allow the user to create their own complete keyboard in, say, Photoshop, and capture keystrokes depending on where their clicks were registered? | Sorry, I don't wish to pursue this option. If you or someone else would, I'd be happy to advise.
| davez wrote: | You should be able to add totally customizable buttons for AHK.
Like a blank row of keys we can label and add function to with our hotkeys. | What functions are you thinking of? Do you mean macros or Special key combos?
Again, thanks for the feedback and ideas! _________________
 |
|
| Back to top |
|
 |
wrybread
Joined: 05 Jul 2006 Posts: 33
|
Posted: Mon Oct 08, 2007 11:31 am Post subject: |
|
|
Awesome!
Note that the link to the source is broken... |
|
| Back to top |
|
 |
Micahs
Joined: 01 Dec 2006 Posts: 413
|
Posted: Wed Oct 10, 2007 11:45 pm Post subject: |
|
|
The link is back up! Sorry - I left out a space in the name when I updated. I'll have to come up with something simpler. _________________
 |
|
| Back to top |
|
 |
joakimk Guest
|
Posted: Thu Oct 11, 2007 8:26 am Post subject: Linux support? |
|
|
That is impressive!
I am working on a touch-screen interface keyboard for a "terminal application", in Java, and my idea was simply to map JButtons over each key, which append the desired character to the JTextArea.
Did you solve the problem of capturing simultaneous key combinations, like Shift + H, or Ctrl + Alt + W? The touch screen acts like a mouse, which, normally (AFAIK), can only capture single mouse events. In other words, if you click somewhere (using your finger on the screen) and hold, while moving a second finger around, the screen will not respond to the second finger until the first one is released. I guess this is why the "OnScreen Keyboard" XP application (osk.exe) has an inferior solution, where the Shift key acts like a one-time Caps Lock, capitalizing the next keystroke. I guess this implies that something like Ctrl + Alt + W requires three separate clicks in sequence?
Please let me know how you solved this! Perhaps I can port this function into my Linux/Java project, if I'm lucky.
Otherwise, maybe you have plans for a Linux version of your excellent keyboard app?  |
|
| Back to top |
|
 |
Micahs
Joined: 01 Dec 2006 Posts: 413
|
Posted: Thu Oct 11, 2007 9:31 am Post subject: |
|
|
Thanks for the kind words!
I solved the problem by creating a queue (I misspelled this in the code. )
When you click, for instance, Ctrl, "{Ctrl Down}" gets appended to the "stickyQueOpen" variable and "{Ctrl Up}" gets prepended to the "stickyQueClose" variable.
If you then click Alt, "{Alt down}" is appended to "stickyQueOpen" and "{Alt up}" is prepended to "stickyQueClose".
When you also click a non-modifier key like F1, this is sent:
"{Ctrl down}{Alt down}{F1}{Alt up}{Ctrl up}" and the queue is cleared.
If you click Ctrl or Alt, Etc a second time without clicking a non-modifier, the keys are removed from the Queue.
| joakimk wrote: | | screen will not respond to the second finger until the first one is released | As far as I know, this is standard with touchscreens.
| joakimk wrote: | | inferior solution, where the Shift key acts like a one-time Caps Lock, capitalizing the next keystroke. I guess this implies that something like Ctrl + Alt + W requires three separate clicks in sequence? | This is how I do it. Because the mouse itself can only be in one place at a time, there is not a workaround that I am aware of. Standard touchscreens, all the ones I have worked with (only 4), emulate the mouse and behave the same way. If you have a special purpose touchscreen, it may have the capability of reading multiple presses simultaneously. I have no experience with that, though.
[EDIT]
I plan to check to see if it will work in wine. Autohotkey is listed as working in wine, but some of the stuff I need to do for ahkosk may not. I'll have to see. If anyone tries it before me, let me know!
[EDIT]
AhkOsk does not function properly in linux. I ran it under Ubuntu (Feisty) with Wine. The transparent stuff isn't transparent and the virtual key stuff doesn't work. I will revisit this later. _________________

Last edited by Micahs on Fri Feb 22, 2008 9:36 am; edited 2 times in total |
|
| Back to top |
|
 |
tic
Joined: 22 Apr 2007 Posts: 1458
|
Posted: Thu Nov 08, 2007 5:08 pm Post subject: |
|
|
I have just about finished my own onsceen keyboard, very similar to the wiis in appearance (if youve seen that) and I have made buttons in ahk that act like flash, but theres one thing i was hoping you could advise me on without me having to read your entire code..... how did you make the keyboard not steal focus? For example, if I go to rename a file, then when i am in the rename edit box, then i can still click on the keyboard and rename it. Thanks
It looks like to me that you have disabled the onscreen keyboard, and then are setting a timer to check if LButton is down and which control you are over at the time. Is this correct, or is there more to it? |
|
| Back to top |
|
 |
Micahs
Joined: 01 Dec 2006 Posts: 413
|
Posted: Thu Nov 08, 2007 11:14 pm Post subject: |
|
|
| tic wrote: | | or is there more to it? | Yeah, there is. If you only disable the gui, it still steals focus when you click. See the origin thread for other methods that were tried.
The only way to prevent focus-stealing (AFAIK) is to prevent the gui from ever seeing the click. My solution was to remap the left-click button to something else (something that would not cause the gui to grab focus) and then checking the state of that.
I settled on using virtual keys (suggested by ricke, although I have since revised this method to be event-driven and not timer-based - I haven't posted it yet, though. I'm still testing. I am trying to make this compatible with Wine on Linux, if possible.)
By checking the mouse pos to get which control it's over when the virtual key is down, you can detect the clicks. Keep in mind that you have to disable the remap when the mouse is not over the kb gui, and enable it when it is over the gui.
Hopefully this makes sense.
Upcoming Features:- More reliable click detection - never miss a click!
- Multiple keyboards at once
- Different fonts for each key or row
- Key label can be different from key function
- Something else I can't remember
- Macros
_________________
 |
|
| Back to top |
|
 |
tic
Joined: 22 Apr 2007 Posts: 1458
|
Posted: Fri Nov 09, 2007 7:05 am Post subject: |
|
|
Ay yes, I see what you mean now, with the *LButton at the bottom. The problem is that mine is a fullscreen keyboard like the wiis, and to open it, you must click on the system tray icon. Would there be a way to open the program from the system tray icon without the system tray stealing focus? so some way to do what you are already doing with *LButton but only when over the sys tray icon, or would it be necessary to make a small gui in the corner say that would open the keyboard?
My keyboard requires WM_MOUSEMOVE (0x200) to give it a flash like appearance. Is this possible with your method, as it would appear it would be if youre just remapping LButton and not disabling the window.
Thanks again Micahs. |
|
| Back to top |
|
 |
Micahs
Joined: 01 Dec 2006 Posts: 413
|
Posted: Fri Nov 09, 2007 10:16 am Post subject: |
|
|
Try this. Left-Click on the icon and the gui will appear - without stealing focus.
| Code: | ;ORIGINAL CODE BY Tasman HERE: http://www.autohotkey.com/forum/viewtopic.php?t=12334
#persistent
leftclick("off") ;by default disable the leftclick remap
Menu, Tray, Icon, pifmgr.dll, 2 ; set the icon for this script
; the icon to look for (in this case the one of this script)
iconstr = 2 pifmgr.dll ; the number of the icon [space] filename containing the icon
; get the icon sizes (system small) in order to determine the size of the area for the mouseover event
sysget, sm_cxsmicon, 49
sysget, sm_cysmicon, 50
virtualkey = VK07
; MsgBox, %sm_cxsmicon% %sm_cysmicon%
SetTimer, mouseovericon, 250 ; check if the mouse is over the icon
SetTimer, CheckForClick, 25
Gui, Add, Button,, Keyboard
Gui, Add, Button,, Keyboard
Gui, Add, Button,, Keyboard
Return
mouseovericon:
mouseovericon := iconfind(iconstr,sm_cxsmicon,sm_cysmicon)
if mouseovericon = 0
{ leftclick("on")
}
Else
{ leftclick("off")
If GetKeyState(%virtualkey%)
{ Send, {%virtualkey% Up} ;make sure it's up
debounce=0
}
}
Return
iconfind(iconstr,sm_cxsmicon,sm_cysmicon)
; checks to see if the mouse is over the given tray icon
; returns:
; 0 if mouse is over the icon,
; 1 if image not found
; 2 if imagesearch produced an error or
; 3 if icon was found but mouse was not over the image
{
coordmode, pixel, screen ; set the coords for imagesearch to absolute
coordmode, mouse, screen ; set mouse coords to absolute
; retrieve the tray position and size in order to limit (speedup) the imagesearch
WinGetPos, trayX, trayY, trayWidth, trayHeight, ahk_class Shell_TrayWnd
MouseGetPos, mouseX, mouseY ; get the mouse position
; see if the icon exists in the traywindow
ImageSearch, imageX, imageY, trayX, trayY, trayX+trayWidth, trayY+trayHeight, *Icon%iconstr%
coordmode, pixel, relative ; reset the coords for imagesearch to default
coordmode, mouse, relative ; reset mouse coords to default
if ErrorLevel > 0 ; image not found or an image search error occurred
return %errorlevel%
imageXlarge := imageX+sm_cxsmicon ; the outerlimit for X
imageYlarge := ImageY+sm_cysmicon ; the outerlimit for Y
if mouseX between %imageX% and %imageXlarge%
if mouseY between %imageY% and %imageYlarge%
return 0 ; if the mouse is over the designated icon
return 3 ; 3 means mouse not over the icon
}
CheckForClick:
GetKeyState, vKey, %virtualkey%
If (vKey="D") and (debounce=0)
{ debounce=1
Gui, Show, NA
}
Return
;the following are from ahkosk
LeftClick(which) ;enable or disable left-click hotkey
{
If(which="on")
{ Hotkey, *LButton, On
Hotkey, *LButton up, On
}
Else
{ Hotkey, *LButton, Off
Hotkey, *LButton up, Off
}
}
*LButton:: ;map left click to the Virtual Key - VK does not stand for Voigt-Kampff
SetKeyDelay -1
Send {Blind}{%virtualkey% Down}
Return
*LButton up::
SetKeyDelay -1
Send {Blind}{%virtualkey% Up}
debounce=0
Return
|
Some clever use of the imagesearch function by Tasman and my ZeroFocus technique seem to do the trick. Keep in mind that you'll have to ensure that your icon is visible for this to work. _________________
 |
|
| Back to top |
|
 |
Micahs
Joined: 01 Dec 2006 Posts: 413
|
Posted: Fri Nov 09, 2007 10:39 am Post subject: |
|
|
Or this. Same thing but with added WM_MOUSEMOVE stuff. Crude, I know, but it demonstrates the point: LeftClick remap will not interfere with MouseMove.
| Code: | ;ORIGINAL CODE BY Tasman HERE: http://www.autohotkey.com/forum/viewtopic.php?t=12334
#persistent
leftclick("off") ;by default disable the leftclick remap
Menu, Tray, Icon, pifmgr.dll, 2 ; set the icon for this script
; the icon to look for (in this case the one of this script)
iconstr = 2 pifmgr.dll ; the number of the icon [space] filename containing the icon
; get the icon sizes (system small) in order to determine the size of the area for the mouseover event
sysget, sm_cxsmicon, 49
sysget, sm_cysmicon, 50
virtualkey = VK07
debounce=0
; MsgBox, %sm_cxsmicon% %sm_cysmicon%
OnMessage(0x200, "WM_MOUSEMOVE")
OnMessage(0x2A3, "WM_MOUSELEAVE")
SetTimer, mouseovericon, 250 ; check if the mouse is over the icon
SetTimer, CheckForClick, 25
DetectHiddenWindows, On
Gui, Add, Button,, Keyboard
Gui, Add, Button,, Keyboard
Gui, Add, Button,, Keyboard
Gui, +LastFound +AlwaysOnTop
guiID := WinExist()
Return
guiClose:
ExitApp
Return
mouseovericon:
mouseovericon := iconfind(iconstr,sm_cxsmicon,sm_cysmicon)
if mouseovericon = 0
{ leftclick("on")
}
Else
{ leftclick("off")
If GetKeyState(%virtualkey%)
{ Send, {%virtualkey% Up} ;make sure it's up
debounce=0
}
}
Return
iconfind(iconstr,sm_cxsmicon,sm_cysmicon)
; checks to see if the mouse is over the given tray icon
; returns:
; 0 if mouse is over the icon,
; 1 if image not found
; 2 if imagesearch produced an error or
; 3 if icon was found but mouse was not over the image
{
coordmode, pixel, screen ; set the coords for imagesearch to absolute
coordmode, mouse, screen ; set mouse coords to absolute
; retrieve the tray position and size in order to limit (speedup) the imagesearch
WinGetPos, trayX, trayY, trayWidth, trayHeight, ahk_class Shell_TrayWnd
MouseGetPos, mouseX, mouseY ; get the mouse position
; see if the icon exists in the traywindow
ImageSearch, imageX, imageY, trayX, trayY, trayX+trayWidth, trayY+trayHeight, *Icon%iconstr%
coordmode, pixel, relative ; reset the coords for imagesearch to default
coordmode, mouse, relative ; reset mouse coords to default
if ErrorLevel > 0 ; image not found or an image search error occurred
return %errorlevel%
imageXlarge := imageX+sm_cxsmicon ; the outerlimit for X
imageYlarge := ImageY+sm_cysmicon ; the outerlimit for Y
if mouseX between %imageX% and %imageXlarge%
if mouseY between %imageY% and %imageYlarge%
return 0 ; if the mouse is over the designated icon
return 3 ; 3 means mouse not over the icon
}
WM_MOUSEMOVE()
{
global currButt, guiID
MouseGetPos,,,gID,kID
If(gID != guiID)
{ Return
}
currButt := kID
GuiControl,,%currButt%,in
tooltip,%currButt%
}
WM_MOUSELEAVE()
{
global currButt
GuiControl,,%currButt%,out
}
CheckForClick:
GetKeyState, vKey, %virtualkey%
If (vKey="D") and (debounce=0)
{ debounce=1
Gui, Show, NA
}
Return
;the following are from ahkosk
LeftClick(which) ;enable or disable left-click hotkey
{
If(which="on")
{ Hotkey, *LButton, On
Hotkey, *LButton up, On
}
Else
{ Hotkey, *LButton, Off
Hotkey, *LButton up, Off
}
}
*LButton:: ;map left click to the Virtual Key - VK does not stand for Voigt-Kampff
SetKeyDelay -1
Send {Blind}{%virtualkey% Down}
Return
*LButton up::
SetKeyDelay -1
Send {Blind}{%virtualkey% Up}
debounce=0
Return
|
_________________

Last edited by Micahs on Fri Nov 09, 2007 6:37 pm; edited 1 time in total |
|
| Back to top |
|
 |
tic
Joined: 22 Apr 2007 Posts: 1458
|
Posted: Fri Nov 09, 2007 10:50 am Post subject: |
|
|
| thanks micahs. i realise now that i may not be able to use the method to stop it stealing focus as i have an edit box at the top of my gui that needs to let the user select text etc. unless you can also think of a way to do that. |
|
| Back to top |
|
 |
engunneer
Joined: 30 Aug 2005 Posts: 7698 Location: Germany (but I only speak English)
|
Posted: Fri Nov 09, 2007 5:46 pm Post subject: |
|
|
| Micahs wrote: | - Something else I can't remember
|
I hope that makes the Changelog
The other comment thing I like to do is
| Code: |
;The next line is an awful, horrible hack!
(some code that is really bad, but works) ;This is a horrible horrible hack!
;The previous line was a really bad hack that makes (n) work.
|
Though I usually use CAPS for it...
 _________________
Unless noted, all code is UNTESTED.
Answers Here: 1.(Loops, Viruses, etc.) 2.Search 3.RTFM 4.Ask for Help.
PMs will be ignored unless you are hiring me. |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|