Source language: Translate to:

SendKeys back to your EXE

NeoBook tips, tricks, code samples and more...

Moderator: Neosoft Support

SendKeys back to your EXE

Postby Jim Brammer » Fri Feb 08, 2002 2:06 pm

In Nbk 3.2 I used to be able to SendKey strokes to nothing: "". Once compiled, this sent keystrokes to the program itself. So, if "My Editor.EXE" had a toolbar with Copy & Paste buttons, clicking one would send Ctrl+C and Ctrl+V keystrokes to itself. The last time I tried it in Nbk 4 it didn't work. It doesn't do anything. If you do try to specify to SendKeys to "My Editor.EXE" the program will launch another instance of itself. This kind of put a damper on a couple tricks I used in the past.

<hr>

You can still use this trick with NeoBook 4, but you need to make sure that the object you want to receive the keystrokes has the input focus. For example:

FocusObject "TextEntry1"
SendKeys "" "abcd"

<hr>

Tested and it worked! :)
Jim Brammer
 

SendKeys back to your EXE

Postby DPayer » Fri Mar 07, 2003 9:14 am

I am trying this with a webbrowser object in the application and it doesn't seem to work. (I am trying to logon to a website in the browser)

I tried putting the focus on the object before, during and after navigation and it didnt seem to make a difference and cause it to work.

After the page ran I could manually enter in the keys and that worked (the focus was in the right place) but the keys didn't get sent to the app itself (using the "" to indicate send keystrokes to itself).

The code simply loads a webpage in the object and then tries to send the keys.

Just to test, I include an alert box after the sendkeys to declare the sendkeys statement done. It shows but the keys aren't sent.

Any ideas? Or is this a webbrowser object thing?

David Payer
DPayer
 

SendKeys back to your EXE

Postby NeoSoft Support » Fri Mar 07, 2003 11:43 am

This may not work with all types of web pages. You should be able to send page up. page down, etc. to the browser itself, but if you're trying to fill out a web-based form, it may not work unless you can find a way to set the input focus the actual object on the page that you're trying to affect.
NeoSoft Support
 

SendKeys back to your EXE

Postby HPW » Fri Mar 07, 2003 12:26 pm

May be you can try AutoItDLL:

http://www.neosoftware.com/cgi-bin/ikon ... &topic=192


(Edited by HPW at 8:27 pm on Mar. 7, 2003)
HPW
 

SendKeys back to your EXE

Postby Gaev » Fri Mar 07, 2003 12:47 pm

David Payer:

I haven't tried to "SendKeys" to a logon dialog box, but my experience with a web page with an input box pointed to two issues ...

a) timing ; with the following code associated with a button ...

BrowserGoTo "WebBrowser1" "http://www.yahoo.com"
FocusObject "WebBrowser1"
SendKeys "" "abcd"

... did not work ; however, after visually verifying the display of the said page in the Browser object, and clicking on another button with just ...

FocusObject "WebBrowser1"
SendKeys "" "abcd"

... sent the keys to the input box (to the left of Yahoo's search button).

As per my post elsewhere, NeoBook has stated that the "variable to store Browser's Status" is passed (as is) from the Browser control ; and the values in this variable are not reliable at all ; e.g. I documented instances of the variable indicating that document was loaded, only to follow it up with another status indicating that it was not ; sometimes, it took three such cycles before the web page was visible ; the thinking was that the earlier status values might be related to other associated web files being loaded.

b) focus ; FocusObject gives control to the Browser control ; however, when received, this control will pass the keys to the particular element within the web page that has focus ; for instance, in my earlier example, if i (manually) tab'ed over to the Search button before clicking on my second button, nothing happens ; this is because the keys are sent to (Yahoo's) Search button, which of course is not set up to receive keystrokes (except perhaps a short-cut key) ; so, your keys end up in "the Black Hole of the Windows Universe".

This is where I can't speak for your specific case (with the logon dialog box) ; but if you can post the web address in question (no need for the logon values), I can examine it some more.
User avatar
Gaev
 
Posts: 3734
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

SendKeys back to your EXE

Postby DPayer » Fri Mar 07, 2003 7:09 pm

Thanks all for looking into this. I could not get it to work (I am trying to make an interface to a virtual ISP control panel I use at http://visp.velocitywest.com ).

I decided instead to send the information in the URL itself. I was surprised it worked because the form is stated to use the POST method but I used the general format of a GET request  (http://www.anyurl.com/XXXX?param1=this¶m2=that )

[where xxxx is the file/script you are posting to]

This worked and got me logged on to the site. Now I am grabbing html pages generated by their database and parsing them so I can put them in to MY db.

I would like to find an answer for this because I can envision using NB to automate web driven processes that generate data.

I didn't figure out how to use that AutoIT dll. Are there more references for it?

David Payer


(Edited by DPayer at 5:05 am on Mar. 8, 2003)
DPayer
 

SendKeys back to your EXE

Postby HPW » Sat Mar 08, 2003 12:37 am

>I didn't figure out how to use that AutoIT dll. Are there more references for it?

Besides my sample pub is a CHM-help file (AutoItDll.chm) from the auther of AutoItDll. In the plugin all commands are named similar to the original commands. You may also have a look to the full product on the AutoIt homepage.
HPW
 

SendKeys back to your EXE

Postby Gaev » Sat Mar 08, 2003 7:37 am

David Payer:

I checked out the referenced web page (velocitywest.com).

For reasons unclear to me (except perhaps something to do with the post method of the form), the form on this page behaves differently than forms on yahoo.com. ; in particular, the behaviour of the (sent) Tab key.

In the yahoo page, as long as some element has focus (and the search box seems to have it at load time), regular as well as control keys (like Tab & Shift-tab) can be sent / accepted without problem.

In the velocitywest page, no element has focus to begin with ; and (worse) Tab & Shift-Tab keys are ignored altogether ; even after accepting regular text inside the input box.

So, if you absolutely must have this facility, the only thing I can suggest is to use the SetMousePos & ClickMouse commands to set focus for each of the input boxes, followed by the required text via SendKeys. Not the most elegant (and prone to maintenance), but I can't see another way around it. Hope you have better luck with other sites' web pages.
User avatar
Gaev
 
Posts: 3734
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

SendKeys back to your EXE

Postby Rastaboogie » Mon Apr 21, 2003 10:13 pm

Hey Guys.... Just rippin thru the boards real quick (not alot of time to read everything). If I understand correctly you want to load a web page, then have a form field filled out? Heres what I just did with yahoo and it worked.

Make an HTML Object and a timer.

Timer 1:
If "[stat1]" "=" "Done"
FocusObject "WebBrowser1"
SendKeys "" "mazzacom media arts"
SendKeys "" "{Enter}"
TimerStop "Timer1"
EndIf

Worked for me using http://www.yahoo.com as the website for the WebBrowser Object


If this isn't even what you wanted... ignore me.

(Edited by Rastaboogie at 1:19 am on April 22, 2003)
Rastaboogie
 

SendKeys back to your EXE

Postby Gaev » Tue Apr 22, 2003 5:59 am

Rastaboogie:

As per my last post to David Payer ...

In the velocitywest page (http://visp.velocitywest.com ), no element has focus to begin with ; and (worse) Tab & Shift-Tab keys are ignored altogether ; even after accepting regular text inside the input box

... and so the said technique does not work ; but if some element has focus, like the search box in yahoo.com (at load time) , regular as well as control keys (like Tab & Shift-tab) can be sent / accepted without problem, and so the technique works fine.
User avatar
Gaev
 
Posts: 3734
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada


Return to NeoBook Knowledgebase

Who is online

Users browsing this forum: No registered users and 1 guest