Jump to content

need help with a code i worte


Guest
 Share

Recommended Posts

Hello.

i worte a start of code that When I briefly pressing one of two buttons set, then an first the code check to see if this is long press or short press.

If if is long press, then a message appears:

MsgBox(0,"","long press",1)

If it short press, then a message appears:

MsgBox(0,"","short press",1)

The problem is that I want to Block the Input of these keys and i don't know how..

when i press of one of them so they send Input..

this is my code:

#include <Misc.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

HotKeySet("{ESC}", "Terminate")

;Settings
$VolumeUpKey = 68
$VolumeDownKey = 62

;-->EndSettings


Local $Sleep = 80 , $ChangeVolume = False , $Case , $timer , $dif , $SendOne = True , $StartTumer = False , $hDLL = DllOpen("user32.dll")

While 1
    Sleep($Sleep)
    If _IsPressed($VolumeDownKey, $hDLL) Or _IsPressed($VolumeUpKey, $hDLL) Then
        If $StartTumer = True Then
            ;MsgBox(0,"","",1)
            $timer = TimerInit()
            $SendOne = True
            $StartTumer = False
        EndIf
        If $ChangeVolume = False Then $ChangeVolume = True
        If _IsPressed($VolumeUpKey, $hDLL) Then $Case = 1
        If _IsPressed($VolumeDownKey, $hDLL) Then $Case = 2
    Else
        If $ChangeVolume = True Then $ChangeVolume = False
        If $StartTumer = False Then $StartTumer = True
    EndIf
    
    If $ChangeVolume = True Then
        $dif = TimerDiff($timer)
    Else
        ;ToolTip($dif)
        If  $dif > 0 Then
            If $dif < 800 Then
                If $SendOne = True Then
                    MsgBox(0,"","short press",1)
                    $SendOne = False
                EndIf
            Else
                MsgBox(0,"","long press",1)
            EndIf
        EndIf
        If $dif > 0 Then $dif = 0
    EndIf
    
    ;ToolTip($dif)
    
WEnd
Link to comment
Share on other sites

This is too vague, because I exactly did what you asked.

Edit: Why HotKeySet does not feet you need?

yes i got it and it working..

i don't like the way it looks but it is do the job.

thanks..

if there is better way so i will heppey to know that.

i am looking for function to convert for example the 68 to {NUMPAD8} or {NUMPAD8} to 68..

Link to comment
Share on other sites

i am looking for function to convert for example the 68 to {NUMPAD8} or {NUMPAD8} to 68..

IIRC, some of us discussed about that in my IsPressed UDF topic, you should find what you need.
Link to comment
Share on other sites

UDF

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

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