Jump to content

IsPressed_UDF ! v2.3 | Advanced keypress


FireFox
 Share

Recommended Posts

@MrCreator

What do you mean about change general main function ? __KeyPressCheck ?

Cheers, FireFox.

I mean the whole concept. Instead of using many functions, let's make only one, _IsPressedEx(), and use classes and hex/string keys. For Or operation we will use «|», and for And operation we use «+». Simple :)

 

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

@MrCreator

Func _IsPressedEx($sHexKey, $param)
If $param = '+' Then
If _IsAndKeyPressed($sHexKey) Then Return 1
ElseIf $param = '-' Then
If _IsOrKeyPressed($sHexKey) Then Return 1
EndIf
Return 0
EndFunc

Not tested.

Cheers, FireFox.

:)

No, i meant the whole functions, it's a little bit (?) complicated than this. Check the PM :lmao:.

 

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

  • 3 months later...

Version 2.1 Available (see top post with update code)

Note : Changed Whell word to Wheel

Be careful to change function to _IsWheelKeyScrool

Cheers, FireFox.

Hello,

some keys did not work because the search for the hex key was not corret. I've fixed it for $Type == 0 (and adjusted to text to be all uppercase, I didn't like the case-mismatch).

However, this is my first post so I hope I made no mistakes by posting this here.

CODE
Func __GetKeyType($iKeyIn, $Type = 0)

If $iKeyIn = '' Then Return -1

Local $s_String = '|01LEFT MOUSE|02RIGHT MOUSE|04MIDDLE MOUSE|05X1 MOUSE|06X2 MOUSE|08BACKSPACE|09TAB|0CCLEAR|' & _

'0DENTER|10SHIFT|11CTRL|12ALT|13PAUSE|14CAPS LOCK|1BESC|20SPACEBAR|21PAGE UP|22PAGE DOWN|' & _

'23END|24HOME|25LEFT|26UP|27RIGHT|28DOWN|29SELECT|2APRINT|2BEXECUTE|2CPRINT SCREEN|2DINS|2EDEL|' & _

'300|311|322|333|344|355|366|377|388|399|41A|42B|43C|44D|45E|46F|47G|48H|49I|4AJ|4BK|4CL|4DM|4EN|

' & _

'4FO|50P|51Q|52R|53S|54T|55U|56V|57W|58X|59Y|5AZ|5BLEFT WINDOWS|5CRIGHT WINDOWS|60NUM 0|61NUM 1|' & _

'62NUM 2|63NUM 3|64NUM 4|65NUM 5|66NUM 6|67NUM 7|68NUM 8|69NUM 9|6AMULTIPLY|6BADD|' & _

'6CSEPARATOR|6DSUBTRACT|6EDECIMAL|6FDIVIDE|70F1|71F2|72F3|73F4|74F5|75F6|76F7|77F8|78F9|' & _

'79F10|7AF11|7BF12|7CF13|7DF14|7EF15|7FF16|80HF17|81HF18|82HF19|83HF20|84HF21|85HF22|' & _

'86HF23|87HF24|90NUM LOCK|91SCROLL LOCK|A0LEFT SHIFT|A1RIGHT SHIFT|A2LEFT CTRL|A3RIGHT CTRL|' & _

'A4LEFT MENU|A5RIGHT MENU|BA;|BB=|BC,|BD-|BE.|BF/|C0`|DB[|DC\|DD]|'

If $Type == 0 Then

Local $s_Key = '|' & $iKeyIn

$s_Key = StringTrimLeft($s_String, (StringInStr($s_String, $s_Key) + StringLen($s_Key) - 1))

$s_String = StringLeft($s_Key, (StringInStr($s_Key, '|') - 1))

ElseIf $Type == 1 Then

$iKeyIn = StringLeft($s_String, StringInStr($s_String, $iKeyIn) - 1)

$s_String = StringTrimLeft($iKeyIn, StringInStr($iKeyIn, '|', 2, -1))

EndIf

If $s_String <> '' Then

Return $s_String

EndIf

Return -1

EndFunc ;==>__GetKeyType

Link to comment
Share on other sites

  • 1 month later...
  • 1 month later...

How can you use this to detect when some key has been released?

While _IsPressed()

WEnd

;Released :)

 

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

I already know that. Just thought there was some other way to do it.

Using _IsPressedEx():

#include <IsPressedEx_UDF.au3>

$hU32_DllOpen = DllOpen("User32.dll")

While 1
    $iRet = _IsPressedEx("[:ALLKEYS:]", $hU32_DllOpen, 1, 1)
    
    If $iRet Then
        $sRet_Data = StringFormat("_IsPressedEx Return:\t%s", $iRet)
        
        MsgBox(64, 'Return', $sRet_Data)
        
        Exit DllClose($hU32_DllOpen)
    EndIf
    
    Sleep(50)
WEnd

 

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

  • 6 months later...
  • 2 months later...

How do i use this inspressed udf, too work with mouseclick counting?

I don't want too use "hotkeyset".

I tested this first, but got like 300 directly.

It's really suck the original _ispressed(), because i don't know how to check when the key is released.

#include <IsPressed_UDF.au3>
global $h

While 1
    If _IsMouseKeyPressed() Then
        $h = $h +1
        consolewrite($h & @crlf)
    EndIf
WEnd
Edited by bobbby
Link to comment
Share on other sites

  • Moderators

bobbby,

It's really suck the original _ispressed(), because i don't know how to check when the key is released.

Just wait until the _IsPressed is no longer true: :idea:

#include <Misc.au3>

$iCount = 0

$dll = DllOpen("user32.dll")

While 1

    ; Wait for left mouse click
    If _IsPressed("01", $dll) Then

        ; Increase count
        $iCount += 1
        ConsoleWrite($iCount & @CRLF)

        ; Wait until the mouse buton is released
        While _IsPressed("01", $dll)
            ; Save the CPU!
            Sleep(10)
        WEnd

    EndIf

    ; Save the CPU!
    Sleep(10)

WEnd

I imagine the same sort of code will work with the UDF too. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

bobbby,

Just wait until the _IsPressed is no longer true: :idea:

I imagine the same sort of code will work with the UDF too. :)

M23

Ah, thanks for the help. :(

Btw, how do i make like a function, too use many keys?

Do i need to add arrays or how do i do it?

Edited by bobbby
Link to comment
Share on other sites

  • Moderators

bobbby,

Please repost your question on the General forum. The Mods will get understandably annoyed if we hijack the Examples Section! :idea:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Version 2.1 Available (see top post with update code)

Note : Changed Whell word to Wheel

Be careful to change function to _IsWheelKeyScrool

Cheers, FireFox.

I take it we all know you mean't --> _IsWheelKeyScroll

:idea:

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

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...