a program which repeats users action
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 3 123 LastLast
Results 1 to 15 of 36

Thread: a program which repeats users action

  1. #1
    Join Date
    Jul 2007
    Location
    somwhere nearby
    Posts
    150

    a program which repeats users action

    hello all .
    i need to make a program which when runs repeats what the user inputs .
    by saying repeating the user input , i mean getting the Keystroke the user inputs and then repeating that Keystroke . (so that any action initiated by that keystroke , re-initiate again )
    how should i go about it ?
    what steps and APIs are needed to achieve such task ?
    Thanks in advance

  2. #2
    Join Date
    Jun 2010
    Location
    Germany
    Posts
    2,583

    Re: a program which repeats users action

    This time I'll ask first... What platform is this supposed to run on?
    I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.

    This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.

  3. #3
    Join Date
    Jul 2007
    Location
    somwhere nearby
    Posts
    150

    Re: a program which repeats users action

    windows of course

  4. #4
    Join Date
    Jun 2010
    Location
    Germany
    Posts
    2,583

    Re: a program which repeats users action

    Ok, then if it is planned to be a console app it seems logical that it doesn't record and play back the keystrokes it receives itself, otherwise it would also need to define the "action initiated by that keystroke" itself, right? And you didn't say any word about what they might be so I don't think that's the case.

    If, OTOH, you're planning a GUI app, I don't think it makes a big difference whether your app is supposed to record/play back its own keystrokes or those of other apps: In both cases you would probably need some sort of hooking, at least if you want to implement it in a half-way generic manner. Unfortunately, this is an area of Windows programing on which I don't have the slightest experience...

    At any rate, it would involve some amount of Windows API and using that basically doesn't differ between assembly language and C++. Therefore I would suggest to post an inquiry in the C++ and Win API section (that is more frequented than the one here) in order to first put up a solution in C or C++ and then translate that to assembly language. (You know, C++, don't you?)

    BTW, I always wonder why people want to write something like that in assembly language. It's much more effort without the slightest effective gain in performance. Is this an assignment?
    I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.

    This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.

  5. #5
    Join Date
    Jul 2007
    Location
    somwhere nearby
    Posts
    150

    Re: a program which repeats users action

    Quote Originally Posted by Eri523 View Post
    Ok, then if it is planned to be a console app it seems logical that it doesn't record and play back the keystrokes it receives itself, otherwise it would also need to define the "action initiated by that keystroke" itself, right? And you didn't say any word about what they might be so I don't think that's the case.

    If, OTOH, you're planning a GUI app, I don't think it makes a big difference whether your app is supposed to record/play back its own keystrokes or those of other apps: In both cases you would probably need some sort of hooking, at least if you want to implement it in a half-way generic manner. Unfortunately, this is an area of Windows programing on which I don't have the slightest experience...

    At any rate, it would involve some amount of Windows API and using that basically doesn't differ between assembly language and C++. Therefore I would suggest to post an inquiry in the C++ and Win API section (that is more frequented than the one here) in order to first put up a solution in C or C++ and then translate that to assembly language. (You know, C++, don't you?)

    BTW, I always wonder why people want to write something like that in assembly language. It's much more effort without the slightest effective gain in performance. Is this an assignment?
    thanks .
    the program must be resident in memory , no GUI, nothin, sth like windows service which has no GUI but is running at background doing its jobs .
    yeah i know C++ .
    I agree with you , this is my little brothers final project in assembly course and the prof told them to bring him such a thing in assembly!
    so he asked for my help and thats im here to find all i can and help him out on his project

  6. #6
    Join Date
    Jun 2010
    Location
    Germany
    Posts
    2,583

    Re: a program which repeats users action

    Quote Originally Posted by Master. View Post
    the program must be resident in memory , no GUI, nothin, sth like windows service which has no GUI but is running at background doing its jobs .
    That entire "resident in memory" concept is a remnant from the days of DOS (you know when they were, don't you? ) and nowadays completely antiquated. Now that all sorts of processes are concurrently running under Windows it doesn't make any sense any more at all. The concept that probably comes closest to that under Windows is the hooking that I mentioned already.

    yeah i know C++ .
    That helps a lot!

    I agree with you , this is my little brothers final project in assembly course and the prof told them to bring him such a thing in assembly!
    so he asked for my help and thats im here to find all i can and help him out on his project
    Well, honestly, that prof seems to be an alien from a planet (or alternate universe) where high-level languages and modern OSes not yet have been invented...
    I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.

    This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.

  7. #7
    Join Date
    Jul 2007
    Location
    somwhere nearby
    Posts
    150

    Re: a program which repeats users action

    Quote Originally Posted by Eri523 View Post
    That entire "resident in memory" concept is a remnant from the days of DOS (you know when they were, don't you? ) and nowadays completely antiquated. Now that all sorts of processes are concurrently running under Windows it doesn't make any sense any more at all. The concept that probably comes closest to that under Windows is the hooking that I mentioned already.



    That helps a lot!



    Well, honestly, that prof seems to be an alien from a planet (or alternate universe) where high-level languages and modern OSes not yet have been invented...
    lol man , )
    your last paragraph made me lol for real )
    sure thing .
    anyway, the c++ section seems to be of no use ( so far) .
    im currently playing with Iczelions tuts on windows hooks . (git 24 hours left )lets see if i can make it

  8. #8
    Join Date
    Jul 2007
    Location
    somwhere nearby
    Posts
    150

    Re: a program which repeats users action

    Ok . i've got my hands on an assembly sample .
    but i had no luck in compiling this kind of app !! any help is greatly appreciated .
    (reading the windows assembly tuts on compiling and linking procedures i found out that for compiling : i should :
    Code:
    ml  /c  /coff  /Cp myapp.asm
    and then for linking :
    Code:
    link /SUBSYSTEM:WINDOWS  /LIBPATH:c:\masm32\lib  myapp.obj
    how ever this one wont work for the sample i downloaded .
    ( i could only build a simple windows assembly sample with this method! ( actually it was only a messagebox!)

    i attached the sample . i would greatly appreciate if some one help me build this sample , so that i can work on it

    and by the way if there is a need for masm , you can download one from here :
    http://www.masm32.com/

    Thanks in advance
    Attached Files Attached Files

  9. #9
    Join Date
    Jun 2010
    Location
    Germany
    Posts
    2,583

    Wink Re: a program which repeats users action

    Quote Originally Posted by Master. View Post
    (git 24 hours left )lets see if i can make it
    Apparently these 24 hours are over now but it looks like you're still interested in this subject.

    I downloaded your sample file and had a brief look at the source files. I didn't see anything obviously wrong. The command lines you use for compiling and linking look ok too. I couldn't do more for now because I'm a bit in a hurry, but I'll pick that up later (unless I find a message from you saying you don't need that anymore.)

    Quote Originally Posted by Master. View Post
    how ever this one wont work for the sample i downloaded .
    Could you please define "won't work"? Compilation error? Linker error? Runtime error? Runtime crash?

    BTW, it is generally helpful to describe the problem as preceisely as possible when asking others for help...
    I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.

    This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.

  10. #10
    Join Date
    Jul 2007
    Location
    somwhere nearby
    Posts
    150

    Re: a program which repeats users action

    Quote Originally Posted by Eri523 View Post
    Apparently these 24 hours are over now but it looks like you're still interested in this subject.

    I downloaded your sample file and had a brief look at the source files. I didn't see anything obviously wrong. The command lines you use for compiling and linking look ok too. I couldn't do more for now because I'm a bit in a hurry, but I'll pick that up later (unless I find a message from you saying you don't need that anymore.)



    Could you please define "won't work"? Compilation error? Linker error? Runtime error? Runtime crash?

    BTW, it is generally helpful to describe the problem as preceisely as possible when asking others for help...
    Thanks Eri523 .
    actually i get no error at all ! the executable gets built , but the catch is it is not either executable nor does it have any ICON!! it seems as if it is a console application! 5KB! and nothing happens!
    i think because this sample has a library , ICON and a resource file , the compilation procedure differs a bit!
    and about that 24 hour ( i got another 12 hours )
    Last edited by Master.; June 10th, 2011 at 08:40 AM.

  11. #11
    Join Date
    Jul 2007
    Location
    somwhere nearby
    Posts
    150

    Re: a program which repeats users action

    any help?

  12. #12
    Join Date
    Jun 2010
    Location
    Germany
    Posts
    2,583

    Unhappy Re: a program which repeats users action

    I have not forgotten you and your problem. Sorry, though, that I couldn't yet get back to you. I'm busier than expected at the moment (and actually a significant part of that is CodeGuru-related.) Unfortunately, thoroughly checking your assembly code is nothing I can simply do en passant.

    But there's specifically one thing you can do right now to help me with my analysis in advance: Did I understand your scenario right that your program is meant to be a Windows GUI app, just without any (visible) GUI? Or, in particular, no Windows console app?

    Counting from the time stamp of your post #10, your additional 12 hours seem to be over now too. I hope all our efforts still are not completely in vain...
    I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.

    This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.

  13. #13
    Join Date
    Jul 2007
    Location
    somwhere nearby
    Posts
    150

    Re: a program which repeats users action

    Quote Originally Posted by Eri523 View Post
    I have not forgotten you and your problem. Sorry, though, that I couldn't yet get back to you. I'm busier than expected at the moment (and actually a significant part of that is CodeGuru-related.) Unfortunately, thoroughly checking your assembly code is nothing I can simply do en passant.

    But there's specifically one thing you can do right now to help me with my analysis in advance: Did I understand your scenario right that your program is meant to be a Windows GUI app, just without any (visible) GUI? Or, in particular, no Windows console app?

    Counting from the time stamp of your post #10, your additional 12 hours seem to be over now too. I hope all our efforts still are not completely in vain...
    Thanks Eri523 , you are indeed a great help to me
    the application has a GUI , ( as you should have known by now by looking at the attachments content- there is an executable Makro.exe - )
    currently all i want to do is compiling and making that Makro.exe out of its source code .i dont plan on hiding the GUI nor i want to use the console for this app. just a method to have a successful compilation of this example
    (after figuring out how i can compile and build this GUI assembly sample, i can modify it as i wish and test different scenarios on it and see the change in behavior of the program , without having a successful build, i cant check whether my changes were ok or not )
    and about the time , my brother has'nt called , so i think i have alittle more time , though im not sure , in anycase i should get this sample to work or i wont let it alone

  14. #14
    Join Date
    Jul 2007
    Location
    somwhere nearby
    Posts
    150

    Re: a program which repeats users action

    i could finally get this sample to compile
    now i have two issues concerning this sample .
    first : i found out this app works only under windows 98!! and probably 2000 , but not XP! why?(windows API differs between these Versions? if it is so why do i have successful compilation under windows xp? )

    second and the most important section :
    i'm having trouble changing the sample so that it only uses 1 file name to record/play the events.
    the problem is , i have to (Open rec file ) choose the file name manually and then press Play or it says file cant be found !.
    specifying the path statically wont work!
    i checked the source code , and checked the section which deals with opening a file dialog .
    its :
    Code:
    ;-------------------------------------------------------------------------
    ; open button is pressed...
    ;_________________________________________________________________________
    .ELSEIF     ax == IDC_P_OPEN
                invoke GetOpenFileName,addr ofn
    .IF         eax != 0            
                invoke SetDlgItemText,hWnd,IDC_P_EDIT,addr Buffer
    .ENDIF
    to my opinion disabling all above must not effect the code , because i couldnt find any use for ofn! ! but then again if i disable this two lines of code , i get the message , file not found!
    and these are the codes for Play button :
    Code:
    ;-------------------------------------------------------------------------
    ; play button is pressed...
    ;_________________________________________________________________________   
    .IF         ax == IDC_P_PLAY
    .IF         hookflag == 0
                mov stopflag,0
                mov sleepflag,0
                mov lasttime,0
                invoke GetDlgItemText,hWnd,IDC_P_EDIT,addr playfilename,sizeof playfilename
                invoke CreateFile,addr playfilename,GENERIC_READ,0,+\
                NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0
                
    .IF         eax != INVALID_HANDLE_VALUE
                mov fhandle,eax
                invoke ReadFile,fhandle,addr oheader,12,addr byteswritten,0                        
    .IF         oheader == 1246259           
                invoke CloseWindow,hWnd
                invoke SetWindowsHookEx,WH_JOURNALPLAYBACK,addr PlaybckProc,NULL,0  
                mov hhandle,eax   
    .ELSE
                invoke CloseHandle,fhandle
                invoke MessageBox,hWnd,addr msg1,addr caption,MB_OK
    .ENDIF               
    .ELSE
                invoke MessageBox,hWnd,addr msg2,addr caption,MB_OK ;errormsg
    .ENDIF            
    .ENDIF
    i already set the playfilename sth as "norec.rec" or ( "C:\test.rec" )
    and as you see there is nothing to do with that ofn!!
    and this is were i get the error !
    msg2 contains the error message :
    Code:
    msg2            db "sorry can't find file or file is damaged!",0
    anyhelp ? i just drove me insane !

  15. #15
    Join Date
    Jun 2010
    Location
    Germany
    Posts
    2,583

    Re: a program which repeats users action

    First, pardon my currently low responsiveness. Sometimes seemingly easy things can turn out to be much more time-consuming than expected...

    Quote Originally Posted by Master. View Post
    first : i found out this app works only under windows 98!! and probably 2000 , but not XP! why?(windows API differs between these Versions? if it is so why do i have successful compilation under windows xp? )
    Of course there are differences in the API between those versions, but if that was the reason for your problems I would rather expect your program to work under XP but not 98, and not the other way 'round. I suspect a permission issue. Up to Win 98 (well, more exactly, ME) any program could practically do anything it wants. It stopped being that simple with XP (and that probably applies to 2000 too).

    second and the most important section :
    i'm having trouble changing the sample so that it only uses 1 file name to record/play the events.
    I'm not sure whether I really understand how makro.exe and play.exe relate. Isn't one for recording and the other one for playback?

    the problem is , i have to (Open rec file ) choose the file name manually and then press Play or it says file cant be found !.
    specifying the path statically wont work!
    i checked the source code , and checked the section which deals with opening a file dialog .

    [...]

    to my opinion disabling all above must not effect the code , because i couldnt find any use for ofn! ! but then again if i disable this two lines of code , i get the message , file not found!
    and these are the codes for Play button :

    [...]
    You're right in that the Play button handler code (second snippet) doesn't access the ofn structure, but both snippets access the IDC_P_EDIT control's window text property and that's the "variable" they communicate over.

    I think you can set up a default file name by setting up the initial text in that edit control. At the moment I have no idea how to do that in your assembly code, though. (It would be so easy in Windows Forms... )
    I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.

    This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.

Page 1 of 3 123 LastLast

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center