Source language: Translate to:

email address in a variable

Questions about using NeoBook's scripting language

Moderator: Neosoft Support

email address in a variable

Postby Dorjee » Wed Sep 27, 2006 10:42 am

Hello,

I want to put an email address (smith@oal.com) in a variable for using this variable through a hpwSendKeysToHandle command with the appropriate plugin (hpwSendKeys 1.6).

The result is a e (letter e) in the form field instead of @

So I create 2 variables 1 for the login (smith) and 1 for the server (oal.com).
And I put between them the special character [#64] which is the decimal code for @ character, but it puts 0 (zero) in the form field.

How can I do it? Please.
Dorjee the Neobooker
Dorjee
 
Posts: 27
Joined: Thu Nov 17, 2005 12:15 am

Postby Neosoft Support » Wed Sep 27, 2006 10:55 am

The "@" character doesn't have any special meaning in NeoBook so it should not require any special processing. For example, the following seems to work correctly:

SetVar "[EMailAddress]" "smith@oal.com"

Are you doing something different?

Does hpwSendKeys have any limitations on using the "@" character?
NeoSoft Support
Neosoft Support
NeoSoft Team
 
Posts: 5605
Joined: Thu Mar 31, 2005 10:48 pm
Location: Oregon, USA

Postby HPW » Wed Sep 27, 2006 11:10 am

Does hpwSendKeys have any limitations on using the "@" character?


Seems so. When I created hpwSendkeys I used this delphi code from www.utilmind.com

Code: Select all
{****************************************************}
{              SendKeys Unit for Delphi 32           }
{    Copyright (c) 1999 by Borut Batagelj (Slovenia) }
{                       Aleksey Kuznetsov (Ukraine)  }
{            Home Page: www.utilmind.com             }
{            E-Mail: info@utilmind.com               }
{****************************************************}

procedure SendKeyString(Text: String);
var
   i: Integer;
   Shift: Boolean;
   vk, ScanCode: Word;
   ch: Char;
   c, s: Byte;
const
   vk_keys: Array[0..9] of Byte =
      (VK_HOME, VK_END, VK_UP, VK_DOWN, VK_LEFT,
       VK_RIGHT, VK_PRIOR, VK_NEXT, VK_INSERT, VK_DELETE);
   vk_shft: Array[0..2] of Byte = (VK_SHIFT, VK_CONTROL, VK_MENU);
   flags: Array[False..True] of Integer = (KEYEVENTF_KEYUP, 0);
begin
   Shift := False;
   for i := 1 to Length(Text) do
    begin
     ch := Text[i];
     if ch >= #250 then
      begin
       s := Ord(ch) - 250;
       Shift := not Odd(s);
       c := vk_shft[s shr 1];
       ScanCode := MapVirtualKey(c,0);
       Keybd_Event(c, Scancode, Flags[shift], 0);
      end
     else
      begin
       vk := 0;
       if ch >= #240 then
        c := vk_keys[Ord(ch) - 240]
       else
        if ch >= #228 then
         c := Ord(ch) - 116
        else
          begin
           vk := VkKeyScan(ch);
           c := LoByte(vk);
          end;
       ScanCode := MapVirtualKey(c,0);
       if not Shift and (Hi(vk) > 0) then
        Keybd_Event(VK_SHIFT, $2A, 0, 0);
       Keybd_Event(c,scancode, 0, 0);
       Keybd_Event(c,scancode, KEYEVENTF_KEYUP, 0);
       if not Shift and (Hi(vk) > 0) then
        Keybd_Event(VK_SHIFT, $2A, KEYEVENTF_KEYUP, 0);
     end;
    end;
end;


Not sure where it would process the @ special.
Hans-Peter
User avatar
HPW
 
Posts: 2520
Joined: Fri Apr 01, 2005 11:24 pm
Location: Germany

Postby HPW » Wed Sep 27, 2006 12:54 pm

After some search on the web maybe a workaround:

You have to think in keyboard-codes not in Char-codes.

hpwSendKeysToHandle "[MyWinHandle]" "[TextEntry1][#252][#254]Q[#253][#255][TextEntry2]"

So replacing the @ with [#252][#254]Q[#253][#255] could work.
[#252][#254] is CTRL_DN+ALT_DN
[#253][#255] is CTRL_UP+ALT_UP
Hans-Peter
User avatar
HPW
 
Posts: 2520
Joined: Fri Apr 01, 2005 11:24 pm
Location: Germany

Almost...

Postby Dorjee » Wed Sep 27, 2006 1:15 pm

Well, thanks for the solution.

A precision: for the QWERTY keyboard the Q letter is necessary, but for an AZERTY (French) keyboard it is naturally 0 (zero). So for my keyboard I use:

Code: Select all
hpwSendKeysToHandle "[Winhandle]" "smith[#252][#254]0[#253][#255]oal.com"


which gives: smith@oal.com

Now the problem is that I am making a little webmail client: a click on a button open the url of my webmail, I put the focus on the first form field and I click on a second button and hpwSendKeys fills up the form (email address, password and click on submit button online).

As I intend to use this appli during travels and on machines alternatly with AZERTY or QWERTY keyboard, I am obliged to make two buttons for hpwSendKeys command: one with Q for QWERTY and one with 0 (zero) for AZERTY. Not very elegant!
Dorjee the Neobooker
Dorjee
 
Posts: 27
Joined: Thu Nov 17, 2005 12:15 am

Postby Gaev » Wed Sep 27, 2006 4:12 pm

Dorjee:
Now the problem is that I am making a little webmail client: a click on a button open the url of my webmail
... do you open this url in a Browser Object or in a separate (Internet Explorer) Window ?

With NeoBook v5.5, you can fill form fields inside html documents loaded in the Browser Object very easily via script WITHOUT using any type of SendKeys commands ... so you would avoid any of the headaches associated with the use of "keyboard simulation" processes like making sure the right element has focus and coding for "special keys".
User avatar
Gaev
 
Posts: 3737
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Postby Dorjee » Wed Sep 27, 2006 10:48 pm

Thanks Gaev for the suggestion that make me aware for upgrading my v5.

And yes, I am using a web-browser object in my nbpub.

I quickly found the solution, here it is:

1) open the url of your webmail page in a browser and edit the source html code. In this code find the names of the form fields for the email address and the password (that is somethnig like:

Code: Select all
<input type="text" name="youremail" value="" />
<input type="text" name="yourpassword" value="" />
)

Here the names to note are "youremail" and "yourpassword".

2) Then, you put a webbrowser object in your pub and a button command which makes two actions based on the BrowserSetElement script:

Code: Select all
BrowserSetElement "WebBrowser1" "youremail" "smith@oal.com"
BrowserSetElement "WebBrowser1" "yourpassword" "qwerty"


And it works! When your webmail page is opened in the browser object, you click on the button of your pub and it fills in email address and password automatically for you.

The only limitation is if one day the webmaster of your webmail server decides to change the name of the input type text, but it is improbable.

Thanks to all for the help.
Last edited by Dorjee on Wed Sep 27, 2006 11:29 pm, edited 1 time in total.
Dorjee the Neobooker
Dorjee
 
Posts: 27
Joined: Thu Nov 17, 2005 12:15 am

Postby HPW » Wed Sep 27, 2006 11:24 pm

After a quick look in the WIN-API maybe I could add 'GetKeyboardLayoutName' where we could get a identifier for the used keyboardlayout. Then a script could react on this.

Usefull?
Hans-Peter
User avatar
HPW
 
Posts: 2520
Joined: Fri Apr 01, 2005 11:24 pm
Location: Germany


Return to NeoBook Action Commands

Who is online

Users browsing this forum: No registered users and 1 guest