Jump to content

GUIHotkey.au3


Mat
 Share

Recommended Posts

Sorry to Achilles for nicking his project but... I had a look through some old code and decided that it would be easy enough to do and there was a few things I wanted it to do for a new project. Anyway, here it is, with tonnes of improvements on my old code. His example was very helpful though, so thanks ;)

Current functions:

* _GUICtrlHotkey_Create

* _GUICtrlHotkey_Delete

* _GUICtrlHotkey_GetHotkey

* _GUICtrlHotkey_GetHotkeyCode

* _GUICtrlHotkey_GetHotkeyName

* _GUICtrlHotkey_SetFont

* _GUICtrlHotkey_SetHotkey

* _GUICtrlHotkey_SetHotkeyCode

* _GUICtrlHotkey_SetHotkeyName

* _GUICtrlHotkey_SetRules

Get and Set HotkeyCode refer to the standard format that HKM_SETHOTKEY expects it in. "The LOBYTE of the LOWORD is the virtual key code of the hot key. The HIBYTE of the LOWORD is the key modifier that indicates the keys that define a hot key combination". Unless you really want to thats probably not the best option, so I made the other 2 "types". The "Name" is the string as it would appear in the control itself, and how the end user would expect it as well. For example "CTRL+SHIFT+ALT+2".

The normal functions Get and Set Hotkey use the send syntax that can then be used directly with functions such as HotkeySet. Logical eh? This makes it a lot easier YOU to use the control.

Its all in proper UDF form etc, and... It goes through Au3Check cleanly which must be a first for me :evil:

Download link: GUIHotkey.zip

M∝τ

Edited by Mat
Link to comment
Share on other sites

It goes through Au3Check cleanly

Nope ;)

AutoIt3 Syntax Checker v1.54.8  Copyright (c) Tylo 2007

GUIHotkey.au3(28,40) : WARNING: $iM_USER: possibly used before declaration.
Global Const $HKM_SETHOTKEY = $iM_USER +
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
GUIHotkey.au3(89,47) : WARNING: $iS_OVERLAPPED: possibly used before declaration.
    If $iStyle = -1 Then $iStyle = $iS_OVERLAPPED
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
GUIHotkey.au3(90,54) : WARNING: $iS_EX_CLIENTEDGE: possibly used before declaration.
    If $iStyleEx = -1 Then $iStyleEx = $iS_EX_CLIENTEDGE
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
GUIHotkey.au3(92,38) : WARNING: $iS_VISIBLE: possibly used before declaration.
    $iStyle = BitOR($iStyle, $iS_VISIBLE,
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
GUIHotkey.au3(92,49) : WARNING: $iS_CHILD: possibly used before declaration.
    $iStyle = BitOR($iStyle, $iS_VISIBLE, $iS_CHILD)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
GUIHotkey.au3(28,40) : ERROR: $iM_USER: undeclared global variable.
Global Const $HKM_SETHOTKEY = $iM_USER +
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
GUIHotkey.au3 - 1 error(s), 5 warning(s)

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

Is that with the version I fixed? If you download it now are there still those errors?

Sorry, that was my bad. Just got back on my desktop for the first time in a month and obviously didn't have the latest beta. With that it works great. This is exactly what I had in mind to make, I just never got around to finishing it.. most of the stuff looks pretty similar to what I was thinking..

I'm pretty sure you can set different fonts for hotkeys ctrls.. Does your code allow you to do that?

My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]
Link to comment
Share on other sites

I haven't made a function for it, but I'm assuming that a generic GUIFont.au3 would work... MSDN has WM_SETFONT on the list of messages associated with the control. Its a question of creating an HFONT and then sending the message. Its a simple function:

#include<WinApi.au3>
#include<SendMessage.au3>
#include<FontConstants.au3>
#include<WindowsConstants.au3>

Func _GUICtrlSetFont($hCtrl, $nHeight, $nWidth, $nEscape = 0, $nOrientn = 0, $fnWeight = $FW_NORMAL, $bItalic = False, $bUnderline = False, $bStrikeout = False, $nCharset = $DEFAULT_CHARSET, $nOutputPrec = $OUT_DEFAULT_PRECIS, $nClipPrec = $CLIP_DEFAULT_PRECIS, $nQuality = $DEFAULT_QUALITY, $nPitch = 0, $szFace = 'Arial')
    Local $hFont = _WinAPI_CreateFont($nHeight, $nWidth, $nEscape, $nOrientn, $fnWeight, $bItalic, $bUnderline, $bStrikeout, $nCharset, $nOutputPrec, $nClipPrec, $nQuality, $nPitch, $szFace)
    If @error Then Return SetError(@error, @extended, 0)

    _SendMessage($hCtrl, $WM_SETFONT, $hFont, True)
    _WinAPI_DeleteObject($hFont)
    Return 1
EndFunc   ;==>_GUICtrlSetFont

I will see if I can implement it neatly.

Link to comment
Share on other sites

Updated the UDF.

Added 2 new functions:

* _GUICtrlHotkey_Delete

* _GUICtrlHotkey_SetFont

The code in the post above will not work I discovered after testing. The handle needs to remain open while in use. As a result, I added the delete function in order to delete the font object as well as the control.

_GUICtrlHotkey_Delete does not have its own example yet... Look at the SetFont's example.

Mat

Link to comment
Share on other sites

  • 7 years later...

Hello
There is a problem with the screen readers I hope you solved the problem

If we use
_GUICtrlHotkey_Create
And if  we create a button underneath or label
the hot key writing box
become not visible if you move using a screen  reader.
can solve this problem please.
Or if there is a solution
wer is it?
thank you

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...