| View previous topic :: View next topic |
| Author |
Message |
salling Site Admin
Joined: 27 Jul 2004 Posts: 7498 Location: Stockholm, Sweden
|
Posted: Fri Nov 04, 2005 9:02 pm Post subject: What's new in 3.0.1's scripting? |
|
|
One of the goals in this update, aside from fixing some issues, was to improve the ability of Salling Clicker plugins (scripts) to control applications that aren't scriptable.
Here are the new commands, available inside scripts:
[code:1]LONG FindWindow( BSTR windowClass, BSTR windowName );
[/code:1]
Finds a window based on class and name; an empty string "" parameter indicates that the parameter should be ignored in the search.
[code:1]VARIANT_BOOL ActivateWindow( LONG hwnd )
[/code:1]
Brings a window into the foreground. Find the window with FindWindow().
[code:1]SendUnicodeKeystroke( WORD code );
[/code:1]
Sends a keystroke (down followed by up) based on a character.
[code:1]SendVirtualKeystroke(
WORD code,
VARIANT_BOOL shiftState = false,
VARIANT_BOOL ctrlState = false,
VARIANT_BOOL altState = false,
VARIANT_BOOL winState = false )
[/code:1]
Sends a keystroke (down followed by up) based on a virtual key; with modifiers.
[code:1]SendStringUsingCopyData(
LONG hwnd,
ULONG_PTR dwData,
BSTR string )
[/code:1]
Uses WM_COPYDATA to send a string to an application. To use this, you must consult the documentation for the application you want to control; not all applications will be able to use this.
[code:1]BSTR ReceiveStringUsingCopyData(
LONG hwnd,
ULONG_PTR dwData,
LONG maxLength )
[/code:1]
Uses WM_COPYDATA to retreive a string from an application. To use this, you must consult the documentation for the application you want to control; not all applications will be able to use this.
[code:1]BSTR GetWindowCaption( LONG hwnd )
[/code:1]
Gets the caption/title of a window.
[code:1]SendVirtualKeyDown( WORD code )
[/code:1]
Simulates pressing a key by virtual keycode. The key is held down until (1) released with SendVirtualKeyUp(), (2) "hit" with SendVirtualKeystroke() or SendUnicodeKeystroke(), or (3) the current widget is made inactive.
[code:1]SendVirtualKeyUp( WORD code )
[/code:1]
Releases a pressed key.
[code:1]ClearKeyboardState()
[/code:1]
Releases all pressed keys.
[b]Examples[/b]
Find BSPlayer's window.
[code:1]var bspwh = 0;
try {
bspwh = FindWindow( "BSPlayer", "" );
} catch( e ) {}
[/code:1]
Get the name of the currently playing media in BSPlayer.
[code:1]var bspwh = FindWindow( "BSPlayer", "" );
var filename = ReceiveStringUsingCopyData( bspwh, 0x1010B, 256 );
[/code:1]
Get the length of the currently active media in BSPlayer:
[code:1]var bspwh = FindWindow( "BSPlayer", "" );
var mediaLength = SendMessage( bspwh, 0x402, 0x10100, 0 );
[/code:1]
That's about it! Check the included BSPlayer script for a real-life example. Please post questions and comments below.
Cheers.
--
Jonas
|
|
| Back to top |
|
 |
schiefersoft Newbie
Joined: 15 Nov 2005 Posts: 11
|
Posted: Sun Nov 20, 2005 1:52 pm Post subject: |
|
|
How can i send an Key combination like
CTRL + M
??
I will build an WinTV Script and WintTV needs that
Example:
CTRL + M -> Mute
CTRL + T -> Fullscreen
and so on ...
Thanks Ralf
|
|
| Back to top |
|
 |
salling Site Admin
Joined: 27 Jul 2004 Posts: 7498 Location: Stockholm, Sweden
|
Posted: Sun Nov 20, 2005 2:03 pm Post subject: |
|
|
In 3.0.1, try using this:
HRESULT SendVirtualKeystroke(
[in] WORD code,
[in, defaultvalue(FALSE)] VARIANT_BOOL shiftState,
[in, defaultvalue(FALSE)] VARIANT_BOOL ctrlState,
[in, defaultvalue(FALSE)] VARIANT_BOOL altState,
[in, defaultvalue(FALSE)] VARIANT_BOOL winState );
What's left is finding the virtual keycode for M; setting the modifier state is rather straightforward. :-)
Best.
--
Jonas
[quote="schiefersoft"]How can i send an Key combination like
CTRL + M
??
I will build an WinTV Script and WintTV needs that
Example:
CTRL + M -> Mute
CTRL + T -> Fullscreen
and so on ...
Thanks Ralf[/quote]
|
|
| Back to top |
|
 |
schiefersoft Newbie
Joined: 15 Nov 2005 Posts: 11
|
Posted: Sun Nov 20, 2005 3:58 pm Post subject: |
|
|
Thanks it works
here the example:
for "CTRL + T" it is:
SendVirtualKeystroke( 0x54,false,true,false,false );
here the virtual keycodes:
[url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/WinUI/WindowsUserInterface/UserInput/VirtualKeyCodes.asp[/url]
[b]Greetings to all...[/b] :D :) :( :o
|
|
| Back to top |
|
 |
Smeagol Junior Member
Joined: 15 Oct 2005 Posts: 27 Location: Vänersborg, Sweden
|
Posted: Sun May 28, 2006 10:46 pm Post subject: |
|
|
| is it restricted to chars only? I try 0x2D and 0x2B but it doesn't work :/ (+ and -)
|
|
| Back to top |
|
 |
salling Site Admin
Joined: 27 Jul 2004 Posts: 7498 Location: Stockholm, Sweden
|
Posted: Mon May 29, 2006 12:15 am Post subject: |
|
|
I fixed schiefersoft's post above. He was listing ASCII codes. You need virtual keycodes. Follow the updated link.
Best.
--
Jonas
[quote="Smeagol"]is it restricted to chars only? I try 0x2D and 0x2B but it doesn't work :/ (+ and -)[/quote]
|
|
| Back to top |
|
 |
vincentDM Newbie
Joined: 13 Nov 2007 Posts: 1 Location: Israel
|
Posted: Tue Nov 13, 2007 10:08 am Post subject: Re: What's new in 3.0.1's scripting? |
|
|
Get the name of the currently playing media in BSPlayer.
Code:
var bspwh = FindWindow( "BSPlayer", "" );
var filename = ReceiveStringUsingCopyData( bspwh, [b]0x1010B[/b], 256 );
Get the length of the currently active media in BSPlayer:
Code:
var bspwh = FindWindow( "BSPlayer", "" );
var mediaLength = SendMessage( bspwh, [b]0x402[/b], [b]0x10100[/b], 0 );
How do you know what the string length is and what is the starting address of it's pointer?
I know how to write vbscripts and jscripts, but i dont know how to get at the material.
if you ould give me a push in the right direction that would be great.
[/b]
|
|
| Back to top |
|
 |
soldstatic Newbie
Joined: 24 Jan 2008 Posts: 16
|
Posted: Thu Jan 24, 2008 5:15 am Post subject: |
|
|
could somebody be amazing and help me? i've been trying this one but can't get it for some (im sure really stupid oversight) reason...
windows+L. I have fast switching on and want to do the pseudo log off thing when my girlfriend is using my laptop for too long... ;)
|
|
| Back to top |
|
 |
soldstatic Newbie
Joined: 24 Jan 2008 Posts: 16
|
Posted: Thu Jan 24, 2008 5:31 am Post subject: |
|
|
nevermind, I got it. Code is following, and zipped folder is attached!
[code:1]var widget = CreateQuestionDialog( "confirmation_");
widget.textualContent = "Fast user logoff? (Leaves all programs running!)"
theTerminal.Push(widget);
function confirmation_OK(w)
{
SendVirtualKeystroke( 0x4C,false,false,false,true );
}
function confirmation_Cancel(w)
{
}
[/code:1]
Damn that was so easy... great stuff. Thanks for the amazing program!
| Description: |
| Simulates windows+L logoff. Fast user switching must be enabled for this to work. Otherwise it locks the computer. This leaves all programs running in the background but limits use of computer unless someone has log in account. |
|
 Download |
| Filename: |
fastUserSwitch.zip |
| Filesize: |
867 Bytes |
| Downloaded: |
838 Time(s) |
|
|
| Back to top |
|
 |
|
|
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
|