Jump to content

Help writing a script


Recommended Posts

I was wondering if someone could tell me if it's possible to do this with autoit, and show me what commands I might need to look into in order to write it.

First off, here's what I'm trying to achieve:

I'm using the software Sony Vegas to edit video. It has a feature where you can hold down the ctrl key then then drag the playhead in order to "scrub" over the timeline. The thing is, I don't want to have to hold down control whenever I do that, because I would like to keep my hand situated over other useful keys. I also cant just keep the ctrl key toggled on, because it would interfere with other things in the program. So I want to have the ctrl key automatically held down ONLY when I am dragging the playhead.

Here is how I thought it might work:

1. Check to see that the vegas window is in focus. (I have trouble figuring this part out, because the window title can change)

2. Check for the mouse to enter a certain area on the screen.

3. If the left mouse button is held down when you enter this area of the screen, do nothing.

4. If the mouse button is NOT held when you enter this area, it should hold down ctrl until you move the mouse out of the area.

5. If the mouse button is clicked and held while it is in this area, it should continue to hold ctrl, even if the mouse moves out of the range, until the mouse button is released.

I think that would achieve what I need, I'm just not really sure how to go about it.

Link to comment
Share on other sites

Thanks, I think I'm on the right track, but I'm having a little trouble with the _IsPressed() thing. Specifically, I can't seem to find it anywhere in the documentation. How is this function used?

Link to comment
Share on other sites

Thanks, I think I'm on the right track, but I'm having a little trouble with the _IsPressed() thing. Specifically, I can't seem to find it anywhere in the documentation. How is this function used?

Usually in a conditional statement:

i.e.

While 1
If _IsPressed(01) Then ;01 is the value assigned to left mouseclick
Msgbox(0,"Notice!", "You Clicked!!")
EndIf
WEnd
Link to comment
Share on other sites

Alright, thanks for the help guys. I got this working like a charm, and it turns out I didnt even need to check if the mouse button is pressed.

Edit: HOWEVER, it looks like my autoit script is eating all of my cpu cycles! Is there any way to tone this down? Here is my full script:

$left = 258
$right = 1260
$top = 644
$bottom = 660
Opt("WinTitleMatchMode", 2)
Opt("MouseCoordMode", 1)
While 1
    If WinActive(" - Sony Vegas") Then
        $pos = MouseGetPos()
        If ($pos[0] >= $left And $pos[0] <= $right And $pos[1] >= $top And $pos[1] <= $bottom) Then
            Send("{CTRLDOWN}")
        Else
            Send("{CTRLUP}")
        EndIf
    EndIf
WEnd
Edited by Zarxrax
Link to comment
Share on other sites

Use sleep command in While loop. I added it to your script. Check for yourself which number makes it usable for you.

$left = 258
$right = 1260
$top = 644
$bottom = 660
Opt("WinTitleMatchMode", 2)
Opt("MouseCoordMode", 1)
While 1
    sleep(1)  
    If WinActive(" - Sony Vegas") Then
        $pos = MouseGetPos()
        If ($pos[0] >= $left And $pos[0] <= $right And $pos[1] >= $top And $pos[1] <= $bottom) Then
            Send("{CTRLDOWN}")
        Else
            Send("{CTRLUP}")
        EndIf
    EndIf
WEnd

My little company: Evotec (PL version: Evotec)

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...