Jump to content

Recommended Posts

Posted Image

Because I was inspired by the "virtual keyboard" shown in Far Cry Instincts Evolution (xbx) and other places - I decided to write something like it in GDI+

Now, mine doesn't look exactly [nearly] like the one in the game, but you can see it's iris-like resemblence and conceptual equivalence.

I have also modified this example so you can click the empty parts of the drawing to change keyboards (lowercase,uppercase,numeric,symbol)

There is also sound for hovering-over or selecting items. All of the sound was created through use of tapping office supplies on the desk. ^_^

I have not seen any scripts of this sort on the forum yet, but if you find one I will be happy to take a look at it.

For your viewing pleasure, I have included FUNCTION comment headers (as seen on UDF's) for the functions.

(function are currently up-to-date with version 9)

Please, PLEASE do not call the Draw/Create functions from different invents at the same time, such as a main While loop vs. a GUI event (if possible, set a bool in the event to make something happen in the prior) or vs. an Adlib; from my experience, stacked GUI events or using an event and the main execution at near the same time can have erroneous results.

(if you do that while using these keyboard functions you MAY get dimension errors or partial-drawings/mismatched keys)

I have attempted to avoid most of these problems in this example.

Why might this be useful?

If you implement this example into your scripts, it's a unique interface that can be used as decor or perhaps an On-Screen Keyboard (OSK) alternative or possibly just input interface for a GUI.

Personally, I will have to implement it into one of my personal scripts so that I can type with my controller.

Two examples are included, the main one is for a mouse, the other is for a joystick or a game controller. The joystick example has not had as much time put in to develop it.

Version 10: _IrisKB_OSK.zip

Old Screenshot:

Posted Image

5-5-13 Edit: Posted images needed fixing

Edited by crashdemons

My Projects - WindowDarken (Darken except the active window) Yahsmosis Chat Client (Discontinued) StarShooter Game (Red alert! All hands to battlestations!) YMSG Protocol Support (Discontinued) Circular Keyboard and OSK example. (aka Iris KB) Target Screensaver Drive Toolbar Thingy Rollup Pro (Minimize-to-Titlebar & More!) 2D Launcher physics example Ascii Screenshot AutoIt3 Quine Example ("Is a Quine" is a Quine.) USB Lock (Another system keydrive - with a toast.)

Link to comment
Share on other sites

Thanks for the reply, lordicast, I may add image support but first I want to nail down the CPU issue

- which means pre-drawing the text to a buffer somewhere in _Create, so that it can be quickly be drawn onto the graphic in _Draw.

However, I'm not quite sure about how I want to do this since this buffer can have no relationship to the graphics object being drawn to or it's buffer.

However, adding image support, I think, will require either:

a ) using a generic image for hot and/or cold and rotating it, or

b ) using a complete image of the circle with either a "hot" image or doing some less-than-opaque drawing on portions of it to make them appear lighter.

One of the problems with either of these, though, is that the keyboards and number of keys are variable - they aren't constant; so the images would be more like background images....

Edit: removed smiley for "b )".

Edited by crashdemons

My Projects - WindowDarken (Darken except the active window) Yahsmosis Chat Client (Discontinued) StarShooter Game (Red alert! All hands to battlestations!) YMSG Protocol Support (Discontinued) Circular Keyboard and OSK example. (aka Iris KB) Target Screensaver Drive Toolbar Thingy Rollup Pro (Minimize-to-Titlebar & More!) 2D Launcher physics example Ascii Screenshot AutoIt3 Quine Example ("Is a Quine" is a Quine.) USB Lock (Another system keydrive - with a toast.)

Link to comment
Share on other sites

Nice piece of code ^_^

But why is the window fixed to be on left upper corner? Antialiasing may look better imo...

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Nice piece of code ;)

But why is the window fixed to be on left upper corner? Antialiasing may look better imo...

UEZ

It's not fixed to the corner of the screen, drag the titlebar (or the graphic) - works here.

The GUI drag could be affected by the WS_EX_NOACTIVATE ExStyle, on my WinXP, this disallows the GUI from becoming active while it still takes input (MS' OSK exhibits the same ExStyle), without intervention however, the GUI doesn't appear to move when dragged

- I got around this (at least I thought, as I said - works here) by handling the Moving messages that are passed to the GUI with actual WinMove() movements.

Antialiasing would lower overall performance, besides - I want your input on the text issue, I need some way to draw the text to a pre-buffer (preferably in _Create with no association to the actual drawing) once so I can simply copy it on top of the image later, cutting CPU usage. Reasonably sure you could find a way to do this if anyone could.

Despite whether this is a problem for everyone or not, it's too high for my liking and I've narrowed it down to the actual text rendering, graphical data seems fine - so the idea is to somehow render the text once as graphics data and copy on top of the actual drawings.

Will handle antialiasing - and some other requests - after that. (rotatable keys? ugh..... ^_^ )

Edited by crashdemons

My Projects - WindowDarken (Darken except the active window) Yahsmosis Chat Client (Discontinued) StarShooter Game (Red alert! All hands to battlestations!) YMSG Protocol Support (Discontinued) Circular Keyboard and OSK example. (aka Iris KB) Target Screensaver Drive Toolbar Thingy Rollup Pro (Minimize-to-Titlebar & More!) 2D Launcher physics example Ascii Screenshot AutoIt3 Quine Example ("Is a Quine" is a Quine.) USB Lock (Another system keydrive - with a toast.)

Link to comment
Share on other sites

hello crashdemons,

good script and nice idea.

I'm here to ask you help 'cause in these days i'm trying to write my own on screen keyboard.

I want to copy OSK find in 2 sony games : 'ridge racer 4' in particular.

After some research i find an abstract on internet speaking about 'twostck', original idea from Vienna university.

Reading abstract i easily find their reference site http://www.twostick.org/

So i start to write my script. I've not your GDI skill and is not so easy find help its use.

I choose to use images to simulate 'twostick' idea and result is not so bad ^_^

but with GDI i 'm sure to give speed and improve usabilty.

I'm here to ask you permission to use part of your code, and to realize a 3x3 GDI grid

where is possible to make in evidence only one square as 'twostick' does...

I know to ask big effort, but i can't solve this task in other way.

thank you all for your time,

m.

Edited by myspacee
Link to comment
Share on other sites

hello crashdemons,

good script and nice idea.

I'm here to ask you help 'cause in these days i'm trying to write my own on screen keyboard.

I want to copy OSK find in 2 sony games : 'ridge racer 4' in particular.

After some research i find an abstract on internet speaking about 'twostck', original idea from Vienna university.

Reading abstract i easily find their reference site http://www.twostick.org/

So i start to write my script. I've not your GDI skill and is not so easy find help its use.

I choose to use images to simulate 'twostick' idea and result is not so bad ^_^

but with GDI i 'm sure to give speed and improve usabilty.

I'm here to ask you permission to use part of your code, and to realize a 3x3 GDI grid

where is possible to make in evidence only one square as 'twostick' does...

I know to ask big effort, but i can't solve this task in other way.

thank you all for your time,

m.

I'm not sure exactly what you want help with specifically in your project, but feel free to use any part of my code.

My Projects - WindowDarken (Darken except the active window) Yahsmosis Chat Client (Discontinued) StarShooter Game (Red alert! All hands to battlestations!) YMSG Protocol Support (Discontinued) Circular Keyboard and OSK example. (aka Iris KB) Target Screensaver Drive Toolbar Thingy Rollup Pro (Minimize-to-Titlebar & More!) 2D Launcher physics example Ascii Screenshot AutoIt3 Quine Example ("Is a Quine" is a Quine.) USB Lock (Another system keydrive - with a toast.)

Link to comment
Share on other sites

I try to make Autoit version of twostick a novel text entry method for game controllers.

Post my script and hope someone can help me to go some step forward

http://www.megaupload.com/?d=J743869S

This version is modified for mouse use, but real one works with normal joypad

As you can see from script left analogic PAD is done, but now i seacrh a solution to

make in evidence in 3x3 grid only one square when right analogic PAD choose letter.

I'm stuck 'cause GDI is too hard to use for me,

maybe skilled Autoit user can suggest me new idea,

Thank you all,

m.

Link to comment
Share on other sites

i love your focus effect, can you explain us how to send text in last focus ?

in my on screen keyboard script i set on top my gui to have always my gui visible,

but lost focus where i want to write, how avoid this issue ?

thank you for any info,

m.

Link to comment
Share on other sites

i love your focus effect, can you explain us how to send text in last focus ?

in my on screen keyboard script i set on top my gui to have always my gui visible,

but lost focus where i want to write, how avoid this issue ?

thank you for any info,

m.

It doesn't check which window was active (except when it first starts)

It uses the WS_EX_NOACTIVATE (0x08000000) Windows ExStyle to keep from being activated when it receives clicks/etc.

On occasion though it does become activated - in these occurrences I'm just activating "Progman".

Edited by crashdemons

My Projects - WindowDarken (Darken except the active window) Yahsmosis Chat Client (Discontinued) StarShooter Game (Red alert! All hands to battlestations!) YMSG Protocol Support (Discontinued) Circular Keyboard and OSK example. (aka Iris KB) Target Screensaver Drive Toolbar Thingy Rollup Pro (Minimize-to-Titlebar & More!) 2D Launcher physics example Ascii Screenshot AutoIt3 Quine Example ("Is a Quine" is a Quine.) USB Lock (Another system keydrive - with a toast.)

Link to comment
Share on other sites

Version 2 uploaded (see first post)

NOTE: I have not updated the Joystick edition, that was more a conceptual example.

(function notes need to be updated from v1)

ScreenShot: see first post or view this image.

@lordicast - background image support added, no "hot" key image overlays or PNG support yet though.

@UEZ -

A. Since you were having trouble dragging the window with the title bar, I went in favor of a fake titlebar that should be draggable via Event.

B. I added "Smoothing" but didn't notice any affect, so I commented it out.

@anonymous - The keyboard is can now be rotated CW or CCW.

@me - CPU Usage seems to have been relieved by using DrawStringEx and creating the font resources before-hand.

Because CPU usage was dropped, I also reduced the Sleep() to allow a little quicker feedback visually.

CPU Usage is still negligible while not changing.

Notes:

When using the left/right rotation buttons, click the same one again to stop rotating.

When dragging the window by the fake titlebar, click it again to release it.

Edited by crashdemons

My Projects - WindowDarken (Darken except the active window) Yahsmosis Chat Client (Discontinued) StarShooter Game (Red alert! All hands to battlestations!) YMSG Protocol Support (Discontinued) Circular Keyboard and OSK example. (aka Iris KB) Target Screensaver Drive Toolbar Thingy Rollup Pro (Minimize-to-Titlebar & More!) 2D Launcher physics example Ascii Screenshot AutoIt3 Quine Example ("Is a Quine" is a Quine.) USB Lock (Another system keydrive - with a toast.)

Link to comment
Share on other sites

It doesn't check which window was active (except when it first starts)

It uses the WS_EX_NOACTIVATE (0x08000000) Windows ExStyle to keep from being activated when it receives clicks/etc.

On occasion though it does become activated - in these occurrences I'm just activating "Progman".

from your script

; why WS_EX_NOACTIVATE isn't in the Control Styles reference, I don't know.
Opt("GUIOnEventMode", 1)
$hForm1 = GUICreate("IrisKB OSK", 202, 202,5,5,-1,0x08000088); added 0x00000088 for topmost toolwindow
GUISetOnEvent(-3,'Program_Close')
$cLabel1 = GUICtrlCreateLabel('GDI+ Object',0,0,202,202,-1,$GUI_WS_EX_PARENTDRAG)
GUICtrlSetOnEvent(-1,'GUI_ClickDrawing')

GUIRegisterMsg(0x0216,'GUI_Events'); for some reason WM_MOVING isn't processed while WS_EX_NOACTIVATE is applied, so I'll do this.
GUIRegisterMsg(0x0006,'GUI_Events')

...

Func GUI_Events($hWnd, $Msg, $wParam, $lParam)
    Switch $Msg
        Case 0x0006
            ConsoleWrite('activated'&@CRLF)
            If Not (BitAND(GUIGetStyle($hForm1),0x08000000)=0x08000000) Then
                GUISetStyle(-1,0x08000088,$hForm1)
                WinActivate('classname=Progman'); as good as anything to activate
            EndIf
        Case 0x0216; for some reason I have to handle this myself since WS_EX_NOACTIVATE is applied
            Local $stc=DllStructCreate($tagRECT,$lParam)
            WinMove($hForm1,'',DllStructGetData($stc,1),DllStructGetData($stc,2))
            $stc=0
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc

Is this the core fo your solution ?

reading now about WS_EX_NOACTIVATE that 'isn't in the Control Styles reference'

Want to apply to small example to understand your solution,

Have you time to make little exaple for a GUI with this control ?

m.

Link to comment
Share on other sites

Have you time to make little exaple for a GUI with this control ?

This will show the point of not being able to activate the window (notice the titlebar stays the "inactive" color even when clicked)

#include <WindowsConstants.au3>
$_NOACTIVATE=0x08000000
Opt('GUIOnEventMode',1)
Opt('wintitlematchmode', 4)
GUIRegisterMsg($WM_ACTIVATE,'WM_EVENTS')
$hForm1=GUICreate('GUI',200,200,-1,-1,-1,$_NOACTIVATE)
GUICtrlCreateLabel("Can't Touch This",0,0,200,20)
GUISetOnEvent(-3,'Close')
GUISetState()
Sleep(250)
WinActivate('classname=Progman')
While True
    Sleep(300)
WEnd
Func Close()
    Exit
EndFunc
Func WM_EVENTS($hWndGUI, $MsgID, $WParam, $LParam)
    Switch $MsgID
        Case $WM_ACTIVATE
            GUISetStyle(-1,0x08000000,$hForm1); this may just be paranoia
            WinActivate('classname=Progman')
    EndSwitch
EndFunc

This example will not, however, fix problems associated with this method (window not moving until dragging ends, etc.)

Edited by crashdemons

My Projects - WindowDarken (Darken except the active window) Yahsmosis Chat Client (Discontinued) StarShooter Game (Red alert! All hands to battlestations!) YMSG Protocol Support (Discontinued) Circular Keyboard and OSK example. (aka Iris KB) Target Screensaver Drive Toolbar Thingy Rollup Pro (Minimize-to-Titlebar & More!) 2D Launcher physics example Ascii Screenshot AutoIt3 Quine Example ("Is a Quine" is a Quine.) USB Lock (Another system keydrive - with a toast.)

Link to comment
Share on other sites

So if i understand well, to have a GUI always on top, but without focus i can :

#include <WindowsConstants.au3>
$_NOACTIVATE=0x08000000
Opt('GUIOnEventMode',1)
Opt('wintitlematchmode', 4)
GUIRegisterMsg($WM_ACTIVATE,'WM_EVENTS')
$hForm1=GUICreate('GUI',200,200,-1,-1,-1,$_NOACTIVATE)
GUICtrlCreateLabel("Can't Touch This",0,0,200,20)
GUISetOnEvent(-3,'Close')
GUISetState()
WinSetOnTop('GUI', "", 1);<----------------------
Sleep(250)
WinActivate('classname=Progman')

HotKeySet("{PGUP}", "send_a_key");<----------------------

While True
    Sleep(300)
WEnd

Func Close()
    Exit
EndFunc

Func WM_EVENTS($hWndGUI, $MsgID, $WParam, $LParam)
    Switch $MsgID
        Case $WM_ACTIVATE
            GUISetStyle(-1,0x08000000,$hForm1); this may just be paranoia
            WinActivate('classname=Progman')
    EndSwitch
EndFunc


Func send_a_key();<----------------------
    Send("a",1)
EndFunc

where <---------------------- are my modification to send a letter when an event occours ?

is right or need some optimization ?

m.

Edited by myspacee
Link to comment
Share on other sites

Awesome, thanks for the share. ;]

I think that removing the buttons' CS_DBLCLKS is better, in my opinion. *)

Do you mind explaining When, Where, Why, and What you mean by that statement?

If I have more detail I may be able to reach some improvements for the current script.

[doubt]

The only vague guesses I have for your statement without doing hard research is something considering allowing the rotation buttons to be double-clicked; eg: only one movement. (they are the only "buttons" on the GUI)

However, I could be terribly wrong ...

Another possible use for double-clicking would be the control under the Graphics object - which would allow some quicker character entry.

[/doubt]

Disregard the above guesses, its too early/late to be accurate.

Edited by crashdemons

My Projects - WindowDarken (Darken except the active window) Yahsmosis Chat Client (Discontinued) StarShooter Game (Red alert! All hands to battlestations!) YMSG Protocol Support (Discontinued) Circular Keyboard and OSK example. (aka Iris KB) Target Screensaver Drive Toolbar Thingy Rollup Pro (Minimize-to-Titlebar & More!) 2D Launcher physics example Ascii Screenshot AutoIt3 Quine Example ("Is a Quine" is a Quine.) USB Lock (Another system keydrive - with a toast.)

Link to comment
Share on other sites

Sorry for being not clear or worse. Please refer to this topic. I think that there is no need for double click event here and using this class style give delay to determine whether this is a double click event or a single click and I don't see any reason to use it, but it's your decision.

Edited by Authenticity
Link to comment
Share on other sites

I think that there is no need for double click event here ...

I'm not using a double-click event anywhere in my code - and currently (v3), double-clicks are simply only trigger the same events as single-clicks ...

However, with what you've given me I'm able to allow double-clicks to work as two separate clicks, which is nice for the buttons and the drawing's interface.

I currently do not have any special use for double-clicks in this project, so I needn't determine whether the events are triggered by single or double-clicks at all, but using double-clicks as two subsequent clicks is certainly nice.

I'll post Version 4, which should allow the user to click the interface rapidly.

My Projects - WindowDarken (Darken except the active window) Yahsmosis Chat Client (Discontinued) StarShooter Game (Red alert! All hands to battlestations!) YMSG Protocol Support (Discontinued) Circular Keyboard and OSK example. (aka Iris KB) Target Screensaver Drive Toolbar Thingy Rollup Pro (Minimize-to-Titlebar & More!) 2D Launcher physics example Ascii Screenshot AutoIt3 Quine Example ("Is a Quine" is a Quine.) USB Lock (Another system keydrive - with a toast.)

Link to comment
Share on other sites

Update: Version 5

The Mouse and Joystick examples are now one and the same.

If your controller supports POV input, you can control how the keyboard spins.

If you press a POV button once you will only get one movement - if you press and hold (longer than 500ms) the keyboard will continue you spin until you let up.

POV Up = Counter-clockwise

POV Down = Clockwise

POV Left = CCW

POV Right = CW

(this is also the order of checking; eg: Up+Right=Right [CW])

Edit: v6 - quick bugfix.

Edited by crashdemons

My Projects - WindowDarken (Darken except the active window) Yahsmosis Chat Client (Discontinued) StarShooter Game (Red alert! All hands to battlestations!) YMSG Protocol Support (Discontinued) Circular Keyboard and OSK example. (aka Iris KB) Target Screensaver Drive Toolbar Thingy Rollup Pro (Minimize-to-Titlebar & More!) 2D Launcher physics example Ascii Screenshot AutoIt3 Quine Example ("Is a Quine" is a Quine.) USB Lock (Another system keydrive - with a toast.)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...