FAQFAQ   SearchSearch   UsergroupsUsergroups   RegisterRegister   ProfileProfile    Log inLog in   RSS Feed

How to use SendVirtualKeystroke in VBS?

 
Post new topic   Reply to topic    Salling Software Forums Forum Index -> Scripting Salling Clicker for Windows
View previous topic :: View next topic  
Author Message
Mihail
Newbie


Joined: 02 Feb 2008
Posts: 4
Location: Russia, Moscow.

PostPosted: Sun Feb 03, 2008 5:48 pm    Post subject: How to use SendVirtualKeystroke in VBS? Reply with quote

I'm trying to use this function with VBS, but the script does not start - somewhere error.

[code:1]Dim nWh, sCode

sCode = "0x41"

nWh = FindWindow( "Notepad", "" )
ActivateWindow( nWh )
SendVirtualKeystroke( sCode, false, true, false, false ) ' Ctrl + A[/code:1]
it does not working... i think the problem is - as i know VB cannot declare variables as hex - for example u cannot declare sCode = 0x41; you must use string... is that right?
Back to top
View user's profile Send private message
salling
Site Admin


Joined: 27 Jul 2004
Posts: 7498
Location: Stockholm, Sweden

PostPosted: Sun Feb 03, 2008 6:40 pm    Post subject: Re: How to use SendVirtualKeystroke in VBS? Reply with quote

Hello,

You cannot pass a string into that function. Instead, convert from hex to decimal like so: 4 * 16 + 1 = 65. I.e. pass 65 as a number.

Best.
--
Jonas

[quote="Mihail"]I'm trying to use this function with VBS, but the script does not start - somewhere error.

[code:1]Dim nWh, sCode

sCode = "0x41"

nWh = FindWindow( "Notepad", "" )
ActivateWindow( nWh )
SendVirtualKeystroke( sCode, false, true, false, false ) ' Ctrl + A[/code:1]
it does not working... i think the problem is - as i know VB cannot declare variables as hex - for example u cannot declare sCode = 0x41; you must use string... is that right?[/quote]
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Mihail
Newbie


Joined: 02 Feb 2008
Posts: 4
Location: Russia, Moscow.

PostPosted: Mon Feb 04, 2008 12:33 am    Post subject: Reply with quote

Thank you, I did not know that the function SendVirtualKeystroke supports decimal key code. Also, I searching on the Internet that the VBS declaration hex-variable must be with prefix "&h" ie = 0x41 &h41 ..
Now, I encountered a new problem .. boolean variable is not working too :D ie, I can not refer to the function parameters [code:1]SendVirtualKeystroke (&h41, false, true, false, false)[/code:1] What then could be the reason?

Certainly, i could use:
[code:1]SendVirtualKeyDown( &h11 ) ' ctrl
SendVirtualKeyDown( &h41 ) ' a
ClearKeyboardState()[/code:1]
but i want to understand, what wrong


----
update

i also can not use Enumerators, because as i know in VBS to use it you must know name of section, for example i can not use
[code:1]ShowMessage ("Hello World", NoIcon, -1, 1000)[/code:1] i must use something like this [code:1]ShowMessage ("Hello World", enumVisualsIcons.NoIcon, -1, 1000)[/code:1] but it not working too :(
Back to top
View user's profile Send private message
salling
Site Admin


Joined: 27 Jul 2004
Posts: 7498
Location: Stockholm, Sweden

PostPosted: Mon Feb 04, 2008 12:05 pm    Post subject: Reply with quote

Try using 0 and 1 instead of false and true. Also, use the number values instead of the enumeration names (you can find the number values here: http://www.salling.com/Clicker/windows/APIDocs/html/index.html)

Best.
--
Jonas

[quote="Mihail"]Thank you, I did not know that the function SendVirtualKeystroke supports decimal key code. Also, I searching on the Internet that the VBS declaration hex-variable must be with prefix "&h" ie = 0x41 &h41 ..
Now, I encountered a new problem .. boolean variable is not working too :D ie, I can not refer to the function parameters [code:1]SendVirtualKeystroke (&h41, false, true, false, false)[/code:1] What then could be the reason?

Certainly, i could use:
[code:1]SendVirtualKeyDown( &h11 ) ' ctrl
SendVirtualKeyDown( &h41 ) ' a
ClearKeyboardState()[/code:1]
but i want to understand, what wrong


----
update

i also can not use Enumerators, because as i know in VBS to use it you must know name of section, for example i can not use
[code:1]ShowMessage ("Hello World", NoIcon, -1, 1000)[/code:1] i must use something like this [code:1]ShowMessage ("Hello World", enumVisualsIcons.NoIcon, -1, 1000)[/code:1] but it not working too :([/quote]
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Salling Software Forums Forum Index -> Scripting Salling Clicker for Windows All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group