Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Request: Keyboard mapping program help

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
alienczf
Advanced Cheater
Reputation: 0

Joined: 19 Apr 2007
Posts: 59

PostPosted: Mon Oct 22, 2007 7:18 am    Post subject: Request: Keyboard mapping program help Reply with quote

My friend suggested to me to script a program that logs some keystroke that when pressed, will trigger a sound as a sort of mental training to develop perfect pitch.

I'm a complete noob in this area and thus will require help and recommendations in everything. I have about 2 months+ to develop this project which i think is enough for me to familiarize myself with the different languages and script it hopefully.

So, any suggestions as to which area of any particular language to research upon regarding this programs will be appreciated greatly.

Thanks in advance.
Back to top
View user's profile Send private message
HolyBlah
Master Cheater
Reputation: 2

Joined: 24 Aug 2007
Posts: 446

PostPosted: Mon Oct 22, 2007 8:22 am    Post subject: Reply with quote

I dont know about what language... but you can use getasynckeystate().

here is the virtual-key codes all keys:
http://msdn2.microsoft.com/en-us/library/ms645540.aspx
Back to top
View user's profile Send private message
oib111
I post too much
Reputation: 0

Joined: 02 Apr 2007
Posts: 2947
Location: you wanna know why?

PostPosted: Mon Oct 22, 2007 8:31 am    Post subject: Reply with quote

I don't get this you mean your program will pick up all keystrokes and like it will play a sound for like A, B, C, D, E, F, G keys? And then maybe like if you hit + or minus and then play it it goes an octave higher? I don't get this Confused
_________________


8D wrote:

cigs dont make people high, which weed does, which causes them to do bad stuff. like killing
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
alienczf
Advanced Cheater
Reputation: 0

Joined: 19 Apr 2007
Posts: 59

PostPosted: Mon Oct 22, 2007 9:12 am    Post subject: Reply with quote

My bad for not making it clear. Yeah it's the first case you mentioned in that when u hit A-G on your keyboard it plays the note... Don't worry about the sounds itself cuz i have a library for it already
Back to top
View user's profile Send private message
assaf84
Expert Cheater
Reputation: 0

Joined: 03 Oct 2006
Posts: 238

PostPosted: Mon Oct 22, 2007 9:38 am    Post subject: Reply with quote

You can make a window and handle the WM_KEYDOWN message, or you can use GetAsyncKeyState in an infinite loop, or you can use RegisterHotkey.
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Mon Oct 22, 2007 12:35 pm    Post subject: Reply with quote

Use GetAsyncKeyState() and Beep()

A quick example in VB6: (Add a timer and set the interval to 100)

Code:
Option Explicit

Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Private Declare Function Beep Lib "kernel32" (ByVal dwFreq As Long, ByVal dwDuration As Long) As Long

Private Sub Timer1_Timer()

    If GetAsyncKeyState(vbKeyA) Then
        Beep 1000, 50
    End If
   
    If GetAsyncKeyState(vbKeyB) Then
        Beep 1100, 50
    End If
   
    If GetAsyncKeyState(vbKeyC) Then
        Beep 1200, 50
    End If
   
    If GetAsyncKeyState(vbKeyD) Then
        Beep 1300, 50
    End If
   
    If GetAsyncKeyState(vbKeyE) Then
        Beep 1400, 50
    End If
   
    If GetAsyncKeyState(vbKeyF) Then
        Beep 1500, 50
    End If

End Sub
Back to top
View user's profile Send private message Visit poster's website
alienczf
Advanced Cheater
Reputation: 0

Joined: 19 Apr 2007
Posts: 59

PostPosted: Tue Oct 23, 2007 8:38 am    Post subject: Reply with quote

thx Wiccaan for your input. Gonna look further into the actual application and scripting of GetAsyncKeyState, ok here's the thing.. how much more complicated will it be to play music media files raw or compressed instead of using motherboard beeps?
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Tue Oct 23, 2007 8:44 am    Post subject: Reply with quote

Depends on how you wish to play the sound files. If you wanted to you could use chiptune style formats which are a lot more smaller then most standard formats and use an extension such as miniFMod with most languages. That way you could compile your sounds into a resource and compress it to keep the file size small.
_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
sired22
Cheater
Reputation: 1

Joined: 22 Aug 2006
Posts: 36

PostPosted: Thu Oct 25, 2007 9:43 am    Post subject: Reply with quote

you could try this. I use visual studio 9.0 but it should be easy to understand. On the forms key down event tell it to play the file at
{application path}\sounds\{Letter Pressed}.wav

Code:
Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
Dim appPath As String = IO.Path.GetDirectoryName(Application.ExecutablePath)
        My.Computer.Audio.Play(appPath & "\sounds\" & e.KeyData.ToString & ".wav", AudioPlayMode.WaitToComplete)
    End Sub
Back to top
View user's profile Send private message Yahoo Messenger
nog_lorp
Grandmaster Cheater
Reputation: 0

Joined: 26 Feb 2006
Posts: 743

PostPosted: Thu Oct 25, 2007 2:14 pm    Post subject: Reply with quote

Code:
#include <windows.h>

int main()
{
    while(1)
    {
        if(GetAsyncKeyState('a'))
            PlaySound("C:\path\to\sound\a.wav",0,SND_FILENAME);
        if(GetAsyncKeyState('b'))
            PlaySound("C:\path\to\sound\b.wav",0,SND_FILENAME);
        if(GetAsyncKeyState('c'))
            PlaySound("C:\path\to\sound\c.wav",0,SND_FILENAME);
        if(GetAsyncKeyState('d'))
            PlaySound("C:\path\to\sound\d.wav",0,SND_FILENAME);
        if(GetAsyncKeyState('e'))
            PlaySound("C:\path\to\sound\e.wav",0,SND_FILENAME);
        if(GetAsyncKeyState('f'))
            PlaySound("C:\path\to\sound\f.wav",0,SND_FILENAME);
        if(GetAsyncKeyState('g'))
            PlaySound("C:\path\to\sound\g.wav",0,SND_FILENAME);
    }
return(0);
}

_________________
Mutilated lips give a kiss on the wrist of the worm-like tips of tentacles expanding in my mind
I'm fine accepting only fresh brine you can get another drop of this yeah you wish
Back to top
View user's profile Send private message
AdamWest
Master Cheater
Reputation: 0

Joined: 05 Jul 2007
Posts: 354
Location: Quahog, Rhode Island

PostPosted: Fri Oct 26, 2007 3:09 pm    Post subject: Re: Request: Keyboard mapping program help Reply with quote

2 months isent enough to completely understand a language to the point where you can program something great with it.



V6 or C++ will work for your job.

DESU!

_________________

"I myself am made entirely of flaws, stitched together with good intentions." - Augusten Burroughs
Back to top
View user's profile Send private message AIM Address
alienczf
Advanced Cheater
Reputation: 0

Joined: 19 Apr 2007
Posts: 59

PostPosted: Fri Nov 02, 2007 3:51 am    Post subject: Reply with quote

tried to compile the prog with dev c++ with its default template for a windows app by adding the code given by nog_lorp and a few error's came out.

Firstly the \c \d and \g in the file names will trigger a warning that relates to unknown escape sequence which will eventually cause a error regarding undefined reference to playsound command

Even after i commented the lines involving c,d and g
the undefined reference error still shows

Lastly, can some 1 explain to me as to wat exactly does the below mean and do.

SND_FILENAME The pszSound parameter is a filename.

p.s.
I attatched the pic about the errors in case no 1 understand wat i'm saying
Back to top
View user's profile Send private message
DeltaFlyer
Grandmaster Cheater
Reputation: 0

Joined: 22 Jul 2006
Posts: 666

PostPosted: Fri Nov 02, 2007 8:47 am    Post subject: Reply with quote

In C based languages, the back slash "\" indicates the start of an escape sequence which is sort of like a command within the string. For example, "\t" will be translated into a tab, "\r" into a carriage return, "\n" into a new line. If one only wants the back slash character, double back slashes "\\" will be needed. That would be the fix to your first problem. Refer to here for a list of escape sequences in C++: http://www.cppreference.com/escape_sequences.html

The linker errors indicate you did not link the required libraries. Referring to MSDN's documentation: http://msdn2.microsoft.com/en-us/library/ms712879.aspx , PlaySound is in Winmm.lib, so configure your linker accordingly.

_________________

Wow.... still working at 827... what's INCA thinking?
zomg l33t hax at this place (IE only). Over 150 people have used it, what are YOU waiting for?
Back to top
View user's profile Send private message
alienczf
Advanced Cheater
Reputation: 0

Joined: 19 Apr 2007
Posts: 59

PostPosted: Fri Nov 02, 2007 9:34 am    Post subject: Reply with quote

thx delta for the quick reply and solution regarding the blackslash issue..

Edit: i've added the library. but the error still shows... any hint as to how to configure the library/linker?
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites