Jump to content
Sign in to follow this  
Miranda

Problem with ControlSend

Recommended Posts

Miranda

A few hours ago I had trouble with my PC... I restarted a few times, disabled a few services, and it works again...

However, now my script (which I've had for... 2-3 years more or less, working) suddenly stops working properly... the ControlSend acts just like a Send...

this little line:

ControlSend ("VLC media player", "", "", "{SPACE}")

used to work fine, now it just sends space to whatever has focus...

I've tried adding

Opt("WinTitleMatchMode", 3), it didn't change a thing. I've tried changing the tile, didn't work..

I've decided to try with the handle, and it works...

the controlsend line is now:

ControlSend ("", "", $a, "{SPACE}")

and the function to find it is:

Func _Rewindow()

$var = WinList()

For $i = 1 To $var[0][0]

If $var[$i][0] = "VLC media player" Then

$a = $var[$i][1]

EndIf

Next

EndFunc

Can anyone explain why this might be?

Share this post


Link to post
Share on other sites
Monamo

A few hours ago I had trouble with my PC... I restarted a few times, disabled a few services, and it works again...

However, now my script (which I've had for... 2-3 years more or less, working) suddenly stops working properly... the ControlSend acts just like a Send...

this little line:

ControlSend ("VLC media player", "", "", "{SPACE}")

used to work fine, now it just sends space to whatever has focus...

I've tried adding

Opt("WinTitleMatchMode", 3), it didn't change a thing. I've tried changing the tile, didn't work..

I've decided to try with the handle, and it works...

the controlsend line is now:

ControlSend ("", "", $a, "{SPACE}")

and the function to find it is:

Func _Rewindow()

$var = WinList()

For $i = 1 To $var[0][0]

If $var[$i][0] = "VLC media player" Then

$a = $var[$i][1]

EndIf

Next

EndFunc

Can anyone explain why this might be?

Not sure offhand, but for the sake of validation -> I'm using VLC and tried your ControlSend() line:

ControlSend ("VLC media player", "", "", "{SPACE}")

and it triggered the "pause/play" shortcut without issue.


- MoChr(77)& Chr(97)& Chr(100)& Chr(101)& Chr(32)& Chr(121)& Chr(97)& Chr(32)& Chr(108)& Chr(111)& Chr(111)& Chr(107)-------I've told you 100,000 times not to exaggerate!-------Don't make me hit you with my cigarette hand...-------My scripts:Random Episode Selector, Keyboard MouseMover, CopyPath v2.1, SmartRename for XP,Window Tracer[sup]New![/sup]

Share this post


Link to post
Share on other sites
enaiman

A well known issue with ControlSend and empty controls.

I had the problem myself some time ago and discussed it and it is decided that this is the way to behave.

When using ControlSend with an empty control (empty=no handle for that control) the command acts exactly like Send = it will send to whatever window is ACTIVE.

A fix to your script: be sure that the desired window is active before attempting to ControlSend to an "empty" control (use right before this comand something like WinActivate or something similar)

Edited by enaiman

SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Share this post


Link to post
Share on other sites
Miranda

A well known issue with ControlSend and empty controls.

I had the problem myself some time ago and discussed it and it is decided that this is the way to behave.

When using ControlSend with an empty control (empty=no handle for that control) the command acts exactly like Send = it will send to whatever window is ACTIVE.

A fix to your script: be sure that the desired window is active before attempting to ControlSend to an "empty" control (use right before this comand something like WinActivate or something similar)

Hmm, are you sure about this? Because it worked fine for me for... ever... until last night, as Monamo also states...

And well, my script is "fixed", with a workaround, so I'm happy, but I find this rather odd and am wondering what is going on :P

Share this post


Link to post
Share on other sites
Monamo

Hmm, are you sure about this? Because it worked fine for me for... ever... until last night, as Monamo also states...

And well, my script is "fixed", with a workaround, so I'm happy, but I find this rather odd and am wondering what is going on :P

Just for additional clarification, the test I performed had VLC *not* in focus when running the test, yet sent successfully.

Side note: for a script of my own which I've got setup with a similar toggle, I'm actually using ControlSend() with a target one of the internal controls on VLC (since I wasn't sure how an empty value ("") would perform).


- MoChr(77)& Chr(97)& Chr(100)& Chr(101)& Chr(32)& Chr(121)& Chr(97)& Chr(32)& Chr(108)& Chr(111)& Chr(111)& Chr(107)-------I've told you 100,000 times not to exaggerate!-------Don't make me hit you with my cigarette hand...-------My scripts:Random Episode Selector, Keyboard MouseMover, CopyPath v2.1, SmartRename for XP,Window Tracer[sup]New![/sup]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×