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 


[VB6] SendKeys Dilemma [Resolved]

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

Joined: 26 Oct 2007
Posts: 32

PostPosted: Tue Jan 01, 2008 10:03 pm    Post subject: [VB6] SendKeys Dilemma [Resolved] Reply with quote

I've just started working on a private software project not long ago.

And now I'm stucked in the middle of the SendKeys thingy
My idea was to start up a selected application from my PC and then execute it by clicking on a button which also activates the timer and then sends programmed key inputs to the executed application without activating the executed application.
But, I somehow wasn't able to send the key inputs to the executed application.

This was my code

Code:

Private Sub aaa_Click()
    Set wShell = CreateObject("WScript.Shell")
    wShell = Shell("C:\WINDOWS\system32\notepad.exe", vbNormalFocus)
       If wShell > 32 Then
      If aaa.Value = 1 Then
         Me.WindowState = vbMinimized
    wShell.AppActivate ("Notepad")
    WScript.Sleep 20
    wShell.SendKeys ("OMG!")
        End If
    End If
   
   

End Sub

I've also tried this code.

Code:

Private Sub Button1_Click()
        Dim L As Long
       
        L = Shell("C:\WINDOWS\system32\notepad.exe", vbNormalFocus)
        If L > 32 Then
            If Command1.Value = 1 Then
                Me.WindowState = vbMinimized
         SendKeys ("OMG")
         
        End If
        End If
End Sub

Any help is very much appreciated.


Last edited by LiquidNeon on Wed Jan 02, 2008 7:22 am; edited 1 time in total
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: Wed Jan 02, 2008 1:40 am    Post subject: Reply with quote

SendKeys does not work like that. It sends keys to the currently active application. AppActivate can be used to pull a given window to the front and give it focus to then send the keys via SendKeys.

You can look at the examples of PostMessage and SendInput that are posted here to do things a bit different.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
LiquidNeon
Cheater
Reputation: 0

Joined: 26 Oct 2007
Posts: 32

PostPosted: Wed Jan 02, 2008 4:22 am    Post subject: Ex. Reply with quote

Examples please?

I've tried using Object.AppActivate ("AppName")

But however, it doesn't work.
Back to top
View user's profile Send private message
Kerelmans
Advanced Cheater
Reputation: 0

Joined: 29 Oct 2007
Posts: 57

PostPosted: Wed Jan 02, 2008 5:44 am    Post subject: Sendkeys Reply with quote

Hey, add a timer and a button to it, set timer interval to 1-1000 and the value to FALSE

add this code to your button:
command1_click ()
shell ("notepad.exe",vbnormalfocus)
timer1=1

end sub

Timer1 ()
sendkeys "put your text here"
timer1=0

end sub

this will write the text into notepad, after 1-1000 seconds!



The Extension 'rar' was deactivated by an board admin, therefore this Attachment is not displayed.

Back to top
View user's profile Send private message
LiquidNeon
Cheater
Reputation: 0

Joined: 26 Oct 2007
Posts: 32

PostPosted: Wed Jan 02, 2008 7:16 am    Post subject: Re: Sendkeys Reply with quote

Kerelmans wrote:
Hey, add a timer and a button to it, set timer interval to 1-1000 and the value to FALSE

add this code to your button:
command1_click ()
shell ("notepad.exe",vbnormalfocus)
timer1=1

end sub

Timer1 ()
sendkeys "put your text here"
timer1=0

end sub

this will write the text into notepad, after 1-1000 seconds!

I lub j00!!!
Anyway, thanks.

(o 3 o)
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: Wed Jan 02, 2008 10:35 am    Post subject: Reply with quote

Although you marked this as solved, heres a quick example:

Code:
Private Sub Form_Load()
    AppActivate "Notepad", 1000
    SendKeys "This is a test.", 500
End Sub


I suggest not using this method because the control to type in does not always get focus from AppActivate unless you gave it focus before minimizing it and such.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
dnsi0
I post too much
Reputation: 0

Joined: 04 Jan 2007
Posts: 2674

PostPosted: Wed Jan 02, 2008 12:16 pm    Post subject: Reply with quote

Use PostMessage or SendMessage. There is a parm thingy on msdn.

BTW. SOme1 with 1 post has rep o.o
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