I'm using Visual Basic 2005 Express Edition. I'm attempting to make a program that, after a button on the form (button1 or whatever I name it), the program will start programmaticall y pressing the F1 key continuously. The thing is, I don't know the code to make it press a key for you. Any help?
Programmatically Press Key - How to do it?
Collapse
X
-
Tags: None
-
Originally posted by ShizzMasteRI'm using Visual Basic 2005 Express Edition. I'm attempting to make a program that, after a button on the form (button1 or whatever I name it), the program will start programmaticall y pressing the F1 key continuously. The thing is, I don't know the code to make it press a key for you. Any help? -
Originally posted by ShizzMasteRI'm using Visual Basic 2005 Express Edition. I'm attempting to make a program that, after a button on the form (button1 or whatever I name it), the program will start programmaticall y pressing the F1 key continuously. The thing is, I don't know the code to make it press a key for you. Any help?
Code:System.Windows.Forms.SendKeys.Send("{F1}")
Don't mind the ravings of an old man. ;o)>>> For more info, see the help file, http://msdn2.microsoft.com/en-us/lib...keys.send.aspxComment
-
Originally posted by SammyBIt survived. :( (I think that using it indicates poor design)Originally posted by SammyBCode:System.Windows.Forms.SendKeys.Send("{F1}")
Don't mind the ravings of an old man. ;o)>>> For more info, see the help file, http://msdn2.microsoft.com/en-us/lib...keys.send.aspxComment
-
Originally posted by Killer42I disagree. You might just as well say the same about any statement. It depends how you use it.You have a problem with the braces? Why? What would you suggest instead? VB has to have some way to know you didn't want to send an "F" key followed by a "1" key.
Re braces: An enum seems to me to be better: in VB6, we have vbKeyF1, and in DotNet we have System.Windows. Forms.Keys.F1, so why add another language feature.Comment
-
Originally posted by SammyBRe braces: An enum seems to me to be better: in VB6, we have vbKeyF1, and in DotNet we have System.Windows. Forms.Keys.F1, so why add another language feature.
StrThingy = "ABC" & vbKeyF1
is simpler than
StrThingy = "ABC{F1}"
I still don't agree.
It would be nice if they could be used interchangeably , I suppose. Presumably there was some reason why they wanted to use only normal printable characters in SendKeys. Also, I'm not sure VB had anything to do with it - it may be due to other constraints.Comment
-
Originally posted by Killer42So what you're saying is that setting up a string as
StrThingy = "ABC" & vbKeyF1
is simpler than
StrThingy = "ABC{F1}"
Originally posted by Killer42I still don't agree.
Also, I'm not sure VB had anything to do with it - it may be due to other constraints.Comment
-
Originally posted by SammyBI wouldn't say simpler. I just don't see a reason for making the language syntax more complicated when "ABC" & vbKeyF1 was already in place. Plus my eyes are so bad that I cannot tell { from (, so I do not like braces anywhere.
Or perhaps you should use a bigger font or something.
Originally posted by SammyB
Originally posted by SammyBYea, it's a Net Framework thing. Works in C# also.Comment
-
Originally posted by Killer42Well, obviously the use of any similar-looking characters should be banned in all cases. So, no more "O" or "0", and so on. Wow, this is going to be hard to get used to... :p
Originally posted by Killer42"shopping" site.
Originally posted by Killer42It's been around since years before the .Net framework was even thought of.Comment
-
Originally posted by SammyBMaybe we should just use ones and zeros!
Originally posted by SammyBYou've got to find a computer to get there. You'll love it!
Originally posted by SammyBAh, this proves my point! I've taught begining & advanced VB6 programming and never heard of it until I read the help file that started this derailing.
In the last couple of months I've come across lots of features of VB6 that I had been unaware of for years - does that prove anything about them? (Example: the Replace and Split functions.)Comment
-
Originally posted by Killer42Um... sorry, what point does that prove? :confused:
Originally posted by Killer42Split functions.Comment
-
Originally posted by SammyBObvious: if I didn't teach it, you don't need it!
Originally posted by SammyBThe split function is one of the best things that Microsoft gave us.Originally posted by SammyBBTW, if s = "This is cool", did you know you can use Split(s)(1) to get the "is"?
Wish I had known years ago. I have written tons of code to do the work that Split and Replace do. Not that it hasn't been fun, of course. :) After all, what other reason is there for programming?
(By the way, zero-based arrays do have one or two useful purposes. For something like a sort, where you need to swap elements around, the "zeroth" element is handy as a temporary bucket to hold them. Also it's sometimes handy as a place to store metadata related to the array.)Comment
-
Originally posted by Killer42I hate zero-based arrays.Comment
-
Originally posted by SammyBAllowing anything but one-based arrays was one of the worst things that Microsoft did. But, the biggest irritation is their inconsistancy: you never know/can remember if an array is zero or one based. DotNet is infinitely more consistent: I only remember one time when I said that something (forgotten what) was inconsistant.
Hm... I wonder whether Option Base still works...Comment
-
1. The form's KeyPreview set to be true.
2. In form Keydown event for F1 write what u want to Perform.
3. Then in Button Click event write BelowCode
Dim evt as new System.windows. forms.keydownev entargs(keys.F1 )
call formname_keydow n(sender,evt)Comment
Comment