|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
sendkeys doesnt sometimes send keysim using vb6 app to control Microstation command line with sendkeys. The first commands worked well, but somewhere along the line everything became unstable. While debugging, I created two lines of code left, and isolated the problem: SendKeys "{ESC}" SendKeys "123456789abcdefghijklmnopqrstuvxyz123456789abcdefghijklmnopqrstuvxyz" Usually(about 9/10 times), this works okay, and 123456789abcdefghijklmnopqrstuvxyz123456789abcdefghijklmnopqrstuvxyz appears in the Microstation command line. around 1/10 times only 123456789abcdefghijklmnopqrstu appears in the command line. (always stops in the same position) Tried using sleep to counter this, didnt work. What to do? Thanks for help, Amos "A. Ahola" <AAh***@discussions.microsoft.com> wrote in message I've got no idea what a Microstation is, but I do know that Sendkeys is not news:C3B37930-8E24-4CE9-B8E7-2CA34F620794@microsoft.com... > im using vb6 app to control Microstation command line with sendkeys. > The first commands worked well, but somewhere along the line everything > became unstable . . . Usually(about 9/10 times), this works okay, and > 123456789abcdefghijklmnopqrstuvxyz123456789abcdefghijklmnopqrstuvxyz > appears in the Microstation command line. around 1/10 times only > 123456789abcdefghijklmnopqrstu appears in the command line. > (always stops in the same position) always reliable, and in some cases (for certain specific keys) doesn't work at all. Have you tried sending the string in "more than one go", for example: Sendkeys "123456789abcdefghijklmnop" Sendkeys "qrstuvxyz123456789abcd" Sendkeys "efghijklmnopqrstuvxyz" Alternatively, have you tried the alternative keyboard event API method. The keyboard event deals with this stuff at a lower level than SendKeys and is often more reliable and also it is capable of sending keys that SendKeys is unable to send (the PrintScreen key, for example, although that of course is not relevant to you). The following rather simplified example shows the basics of how it's done. Paste it into a VB Form containing a Timer Control and a Text Box and click into the Text Box. As I've said, the code is just the "bare bones" at the moment (don't want Dave shouting at me!). You should easily be able to modify the code to produce a small function that accepts a String as its input and "presses" the appropriate keys. Your problem might be related to something else of course, but the keyboard event is definitely worth a try. Mike Option Explicit Private Declare Sub keybd_event Lib "User32" _ (ByVal bVk As Byte, ByVal bScan As Byte, _ ByVal dwFlags As Long, ByVal dwExtraInfo As Long) Private Sub Form_Load() Timer1.Interval = 1000 Timer1.Enabled = True End Sub Private Sub Timer1_Timer() Call keybd_event(16, 0, 0, 0) ' press the shift key Call keybd_event(77, 0, 0, 0) ' press the "M" key Call keybd_event(77, 0, 2, 0) ' release the "M" key Call keybd_event(16, 0, 2, 0) ' release the shift key Call keybd_event(73, 0, 0, 0) ' press the "I" key Call keybd_event(73, 0, 2, 0) ' release the "I" key Call keybd_event(75, 0, 0, 0) ' press the "K" key Call keybd_event(75, 0, 2, 0) ' release the "K" key Call keybd_event(69, 0, 0, 0) ' press the "E" key Call keybd_event(69, 0, 2, 0) ' release the "E" key End Sub
Show quote
Hide quote
"Mike Williams" wrote: Actually my code was like this in the first place, i just put it together to > "A. Ahola" <AAh***@discussions.microsoft.com> wrote in message > news:C3B37930-8E24-4CE9-B8E7-2CA34F620794@microsoft.com... > > > im using vb6 app to control Microstation command line with sendkeys. > > The first commands worked well, but somewhere along the line everything > > became unstable . . . Usually(about 9/10 times), this works okay, and > > 123456789abcdefghijklmnopqrstuvxyz123456789abcdefghijklmnopqrstuvxyz > > appears in the Microstation command line. around 1/10 times only > > 123456789abcdefghijklmnopqrstu appears in the command line. > > (always stops in the same position) > > I've got no idea what a Microstation is, but I do know that Sendkeys is not > always reliable, and in some cases (for certain specific keys) doesn't work > at all. Have you tried sending the string in "more than one go", for > example: > > Sendkeys "123456789abcdefghijklmnop" > Sendkeys "qrstuvxyz123456789abcd" > Sendkeys "efghijklmnopqrstuvxyz" see where it stops. Doesnt seem to make a difference (even if I put sleep(100) in between, which is very strange) Show quoteHide quote > I tried using a class with this implementation:> Alternatively, have you tried the alternative keyboard event API method. The > keyboard event deals with this stuff at a lower level than SendKeys and is > often more reliable and also it is capable of sending keys that SendKeys is > unable to send (the PrintScreen key, for example, although that of course is > not relevant to you). The following rather simplified example shows the > basics of how it's done. Paste it into a VB Form containing a Timer Control > and a Text Box and click into the Text Box. As I've said, the code is just > the "bare bones" at the moment (don't want Dave shouting at me!). You should > easily be able to modify the code to produce a small function that accepts a > String as its input and "presses" the appropriate keys. Your problem might > be related to something else of course, but the keyboard event is definitely > worth a try. > > Mike > > Option Explicit > Private Declare Sub keybd_event Lib "User32" _ > (ByVal bVk As Byte, ByVal bScan As Byte, _ > ByVal dwFlags As Long, ByVal dwExtraInfo As Long) > > Private Sub Form_Load() > Timer1.Interval = 1000 > Timer1.Enabled = True > End Sub > > Private Sub Timer1_Timer() > Call keybd_event(16, 0, 0, 0) ' press the shift key > Call keybd_event(77, 0, 0, 0) ' press the "M" key > Call keybd_event(77, 0, 2, 0) ' release the "M" key > Call keybd_event(16, 0, 2, 0) ' release the shift key > Call keybd_event(73, 0, 0, 0) ' press the "I" key > Call keybd_event(73, 0, 2, 0) ' release the "I" key > Call keybd_event(75, 0, 0, 0) ' press the "K" key > Call keybd_event(75, 0, 2, 0) ' release the "K" key > Call keybd_event(69, 0, 0, 0) ' press the "E" key > Call keybd_event(69, 0, 2, 0) ' release the "E" key > End Sub http://www.vbaccelerator.com/home/VB/Tips/SendKeys_using_the_API/article.asp ,but it didnt do me any good : ( -Amos Show quoteHide quote > > > > Have you tried Sendkeys "xyz", True?
> around 1/10 times only That's 30 bytes. It seems to be a keyboard buffer limit. Try not sending > 123456789abcdefghijklmnopqrstu > appears in the command line. (always stops in the same position) more than 15 key combinations. Using Ctrl, Alt, Shift would send 2 bytes AFAIK. Show quoteHide quote "A. Ahola" <AAh***@discussions.microsoft.com> wrote in message news:8E365D72-E8D1-4DAE-8F4E-F6BF927FB185@microsoft.com... > > > "Mike Williams" wrote: > >> "A. Ahola" <AAh***@discussions.microsoft.com> wrote in message >> news:C3B37930-8E24-4CE9-B8E7-2CA34F620794@microsoft.com... >> >> > im using vb6 app to control Microstation command line with sendkeys. >> > The first commands worked well, but somewhere along the line everything >> > became unstable . . . Usually(about 9/10 times), this works okay, and >> > 123456789abcdefghijklmnopqrstuvxyz123456789abcdefghijklmnopqrstuvxyz >> > appears in the Microstation command line. around 1/10 times only >> > 123456789abcdefghijklmnopqrstu appears in the command line. >> > (always stops in the same position) >> >> I've got no idea what a Microstation is, but I do know that Sendkeys is >> not >> always reliable, and in some cases (for certain specific keys) doesn't >> work >> at all. Have you tried sending the string in "more than one go", for >> example: >> >> Sendkeys "123456789abcdefghijklmnop" >> Sendkeys "qrstuvxyz123456789abcd" >> Sendkeys "efghijklmnopqrstuvxyz" > > Actually my code was like this in the first place, i just put it together > to > see where it stops. Doesnt seem to make a difference (even if I put > sleep(100) in between, which is very strange) > >> >> Alternatively, have you tried the alternative keyboard event API method. >> The >> keyboard event deals with this stuff at a lower level than SendKeys and >> is >> often more reliable and also it is capable of sending keys that SendKeys >> is >> unable to send (the PrintScreen key, for example, although that of course >> is >> not relevant to you). The following rather simplified example shows the >> basics of how it's done. Paste it into a VB Form containing a Timer >> Control >> and a Text Box and click into the Text Box. As I've said, the code is >> just >> the "bare bones" at the moment (don't want Dave shouting at me!). You >> should >> easily be able to modify the code to produce a small function that >> accepts a >> String as its input and "presses" the appropriate keys. Your problem >> might >> be related to something else of course, but the keyboard event is >> definitely >> worth a try. >> >> Mike >> >> Option Explicit >> Private Declare Sub keybd_event Lib "User32" _ >> (ByVal bVk As Byte, ByVal bScan As Byte, _ >> ByVal dwFlags As Long, ByVal dwExtraInfo As Long) >> >> Private Sub Form_Load() >> Timer1.Interval = 1000 >> Timer1.Enabled = True >> End Sub >> >> Private Sub Timer1_Timer() >> Call keybd_event(16, 0, 0, 0) ' press the shift key >> Call keybd_event(77, 0, 0, 0) ' press the "M" key >> Call keybd_event(77, 0, 2, 0) ' release the "M" key >> Call keybd_event(16, 0, 2, 0) ' release the shift key >> Call keybd_event(73, 0, 0, 0) ' press the "I" key >> Call keybd_event(73, 0, 2, 0) ' release the "I" key >> Call keybd_event(75, 0, 0, 0) ' press the "K" key >> Call keybd_event(75, 0, 2, 0) ' release the "K" key >> Call keybd_event(69, 0, 0, 0) ' press the "E" key >> Call keybd_event(69, 0, 2, 0) ' release the "E" key >> End Sub > > I tried using a class with this implementation: > http://www.vbaccelerator.com/home/VB/Tips/SendKeys_using_the_API/article.asp > ,but it didnt do me any good : ( > > -Amos > > > >> >> >> >> Amos,
SendKeys is notoriously unreliable as you cannot be sure where the keystrokes are going. Haven't really used MicroStation but according to http://www.eomap.ee/info/MicroStationGeoGraphics_tech_profile.pdf : "MicroStation also supports OLE Automation. MicroStation GeoGraphics can expose its functionality to other OLEdriven applications through the use of a development environment such as Microsoft Visual Basic. This means that MicroStation GeoGraphics functions can be driven from OLE-Automation controllers such as Microsoft Excel spreadsheets or Microsoft Access databases." Have you tried this route ? NickHK Show quoteHide quote "A. Ahola" <AAh***@discussions.microsoft.com> wrote in message news:C3B37930-8E24-4CE9-B8E7-2CA34F620794@microsoft.com... > Hello, > > im using vb6 app to control Microstation command line with sendkeys. The > first commands worked well, but somewhere along the line everything became > unstable. > > While debugging, I created two lines of code left, and isolated the problem: > > SendKeys "{ESC}" > > SendKeys > "123456789abcdefghijklmnopqrstuvxyz123456789abcdefghijklmnopqrstuvxyz" > > > Usually(about 9/10 times), this works okay, and > 123456789abcdefghijklmnopqrstuvxyz123456789abcdefghijklmnopqrstuvxyz appears > in the Microstation command line. > > around 1/10 times only > 123456789abcdefghijklmnopqrstu > appears in the command line. (always stops in the same position) > > Tried using sleep to counter this, didnt work. What to do? > > Thanks for help, > Amos
Show quote
Hide quote
"NickHK" wrote: Yes, the latest version of Microstation does use OLE, but even though we > Amos, > SendKeys is notoriously unreliable as you cannot be sure where the > keystrokes are going. > > Haven't really used MicroStation but according to > http://www.eomap.ee/info/MicroStationGeoGraphics_tech_profile.pdf : > "MicroStation also supports OLE Automation. MicroStation GeoGraphics can > expose its functionality to other OLEdriven applications through the use of > a development environment such as Microsoft Visual Basic. This means that > MicroStation GeoGraphics functions can be driven from OLE-Automation > controllers > such as Microsoft Excel spreadsheets or Microsoft Access databases." > > Have you tried this route ? have it, we havent migrated to it yet : ) -Amos Show quoteHide quote > NickHK > > "A. Ahola" <AAh***@discussions.microsoft.com> wrote in message > news:C3B37930-8E24-4CE9-B8E7-2CA34F620794@microsoft.com... > > Hello, > > > > im using vb6 app to control Microstation command line with sendkeys. The > > first commands worked well, but somewhere along the line everything became > > unstable. > > > > While debugging, I created two lines of code left, and isolated the > problem: > > > > SendKeys "{ESC}" > > > > SendKeys > > "123456789abcdefghijklmnopqrstuvxyz123456789abcdefghijklmnopqrstuvxyz" > > > > > > Usually(about 9/10 times), this works okay, and > > 123456789abcdefghijklmnopqrstuvxyz123456789abcdefghijklmnopqrstuvxyz > appears > > in the Microstation command line. > > > > around 1/10 times only > > 123456789abcdefghijklmnopqrstu > > appears in the command line. (always stops in the same position) > > > > Tried using sleep to counter this, didnt work. What to do? > > > > Thanks for help, > > Amos > > > Amos,
You would save yourself a lot of trouble and uncertainty by using the OLE interface instead of hoping SendKeys works. As you have found, it seems a hit/miss affair. NickHK Show quoteHide quote "A. Ahola" <AAh***@discussions.microsoft.com> wrote in message news:68158B55-E519-4466-9353-18426BCCF575@microsoft.com... > > > "NickHK" wrote: > > > Amos, > > SendKeys is notoriously unreliable as you cannot be sure where the > > keystrokes are going. > > > > Haven't really used MicroStation but according to > > http://www.eomap.ee/info/MicroStationGeoGraphics_tech_profile.pdf : > > "MicroStation also supports OLE Automation. MicroStation GeoGraphics can > > expose its functionality to other OLEdriven applications through the use of > > a development environment such as Microsoft Visual Basic. This means that > > MicroStation GeoGraphics functions can be driven from OLE-Automation > > controllers > > such as Microsoft Excel spreadsheets or Microsoft Access databases." > > > > Have you tried this route ? > > Yes, the latest version of Microstation does use OLE, but even though we > have it, we havent migrated to it yet : ) > > -Amos > > > NickHK > > > > "A. Ahola" <AAh***@discussions.microsoft.com> wrote in message > > news:C3B37930-8E24-4CE9-B8E7-2CA34F620794@microsoft.com... > > > Hello, > > > > > > im using vb6 app to control Microstation command line with sendkeys. The > > > first commands worked well, but somewhere along the line everything became > > > unstable. > > > > > > While debugging, I created two lines of code left, and isolated the > > problem: > > > > > > SendKeys "{ESC}" > > > > > > SendKeys > > > "123456789abcdefghijklmnopqrstuvxyz123456789abcdefghijklmnopqrstuvxyz" > > > > > > > > > Usually(about 9/10 times), this works okay, and > > > 123456789abcdefghijklmnopqrstuvxyz123456789abcdefghijklmnopqrstuvxyz > > appears > > > in the Microstation command line. > > > > > > around 1/10 times only > > > 123456789abcdefghijklmnopqrstu > > > appears in the command line. (always stops in the same position) > > > > > > Tried using sleep to counter this, didnt work. What to do? > > > > > > Thanks for help, > > > Amos > > > > > >
Show quote
Hide quote
> im using vb6 app to control Microstation command line with This is more a question of how to properly handle a specializedsendkeys. The > first commands worked well, but somewhere along the line everything became > unstable. > > While debugging, I created two lines of code left, and isolated the problem: > > SendKeys "{ESC}" > > SendKeys > "123456789abcdefghijklmnopqrstuvxyz123456789abcdefghijklmnopqrstuv xyz" > > > Usually(about 9/10 times), this works okay, and > 123456789abcdefghijklmnopqrstuvxyz123456789abcdefghijklmnopqrstuvx yz appears > in the Microstation command line. > > around 1/10 times only > 123456789abcdefghijklmnopqrstu > appears in the command line. (always stops in the same position) > > Tried using sleep to counter this, didnt work. What to do? third-party product than it is a question about VB6. You might try asking your question at the communities provided by the vendor of Microstation. This link should give you a start at locating their resources... http://www.bentley.com/en-US/Community/Discussion+Groups/Overview.htm This next link might get you to some useful resources... http://www.be.org/en-US/BE+Community/Find+a+Community/ Rick
Show quote
Hide quote
"Rick Rothstein [MVP - Visual Basic]" wrote: I actually thought this problem was only related to VB6 Sendkeys, but I > > im using vb6 app to control Microstation command line with > sendkeys. The > > first commands worked well, but somewhere along the line > everything became > > unstable. > > > > While debugging, I created two lines of code left, and isolated > the problem: > > > > SendKeys "{ESC}" > > > > SendKeys > > > "123456789abcdefghijklmnopqrstuvxyz123456789abcdefghijklmnopqrstuv > xyz" > > > > > > Usually(about 9/10 times), this works okay, and > > > 123456789abcdefghijklmnopqrstuvxyz123456789abcdefghijklmnopqrstuvx > yz appears > > in the Microstation command line. > > > > around 1/10 times only > > 123456789abcdefghijklmnopqrstu > > appears in the command line. (always stops in the same position) > > > > Tried using sleep to counter this, didnt work. What to do? > > This is more a question of how to properly handle a specialized > third-party product than it is a question about VB6. You might try > asking your question at the communities provided by the vendor of > Microstation. This link should give you a start at locating their > resources... > > http://www.bentley.com/en-US/Community/Discussion+Groups/Overview.htm > > This next link might get you to some useful resources... > > http://www.be.org/en-US/BE+Community/Find+a+Community/ > > Rick couldnt recreate the problem in a single VB form, so theres something definetily wrong the MS side as well. Ill try asking in Bentley forums, thanks for the help to all of you here. -Amso Show quoteHide quote > > > > > > If you have a Bentley Select subscription, just log
a service request. From my experience, they're most happy to help. Also, you might try taking the question to the bentley.microstation.v8.vba newsgroup in the news.viecon.com group. Occasionally, VB questions get asked there, and there are a few frequest posters who'll try to answer them. Good luck. A. Ahola wrote: Show quoteHide quote > Hello, > > im using vb6 app to control Microstation command line with sendkeys. > The first commands worked well, but somewhere along the line > everything became unstable. > > While debugging, I created two lines of code left, and isolated the > problem: > > SendKeys "{ESC}" > > SendKeys > "123456789abcdefghijklmnopqrstuvxyz123456789abcdefghijklmnopqrstuvxyz" > > > Usually(about 9/10 times), this works okay, and > 123456789abcdefghijklmnopqrstuvxyz123456789abcdefghijklmnopqrstuvxyz > appears in the Microstation command line. > > around 1/10 times only > 123456789abcdefghijklmnopqrstu > appears in the command line. (always stops in the same position) > > Tried using sleep to counter this, didnt work. What to do? > > Thanks for help, > Amos -- -------------------------------------------------------- The impossible just takes a little longer
Normalizing data for quick extraction - ideas?
Question about thread safety... Responding to horizontal scroll messages from MS mice HELP! Menu commands - Cut, Copy, Paste, & Find Winsock API callback events Visual Studio 6.0 Product ID Number locking of DB Autosizing ListView columns Properties Dialog box GONE MISSING Minimised Application Not Restoring or Maximising |
|||||||||||||||||||||||