Jump to content

Button controlling action


Recommended Posts

Hey everyone, I just started using AutoIT for work a few days ago and I have a quick question. I'm trying to get a script written up to step through a rendering demo and then give an option to re-render if the user wants to see it again. It works fine up to the point of clicking 'ok' but I can't figure out how to have the button push trigger the rendering... my code for this section is below if anyone sees anything I did wrong. Thanks!

CODE
;Alert user rendering is starting

MsgBox(64, "Information", "The scene will now be rendered", 3)

;Starts rendering of scene

Send("{LSHIFT}Q")

;Recognize when rendering is over and give option to render again

WinWaitClose("Rendering")

$Done = MsgBox(36, "Rendering Complete", "Would you like to render again?")

; -If 'No' is selected, do nothing. Image stays open and user can

; fiddle around in program

; -If 'Yes' is clicked, restart the render.

If $Done = 1 Then

Sleep(100)

MouseMove(840, 144) ;on screen location of render button

MouseClick("left")

EndIf

Link to comment
Share on other sites

The left shift is probably a hotkey combo. Sending a capital letter might not work.

Try this:

HotKeySet("r", "Render")

While 1
    Sleep(100)
WEnd

Func Render()

    MsgBox(64, "Information", "The scene will now be rendered", 3)

;Starts rendering of scene

    Send("{LSHIFT}Q")

;Recognize when rendering is over and give option to render again

;~ WinWaitClose("Rendering")
    $Done = MsgBox(36, "Rendering Complete", "Would you like to render again?")

; -If 'No' is selected, do nothing. Image stays open and user can
; fiddle around in program
; -If 'Yes' is clicked, restart the render.

    If $Done = 6 Then
        Sleep(100)
        MouseMove(840, 144);on screen location of render button
        MouseClick("left")
    EndIf

EndFunc  ;==>Render

You can change "r" to whatever you like, pressing it will start your code. I see in the bottom of your script you do a mousemove instead of lshift+q, if that starts the render you can just send that again.

Edited by Distrophy
Link to comment
Share on other sites

I am "thinking". That's why when I say SHIFT is a legitimate modifier for a hotkey combination, it makes sense.

If you open up adobe photoshop and press Ctrl+Shift+N it opens up a new layer.

Simply sending Ctrl and a capital N does nothing.

If he needs to hit shift+Q to trigger an action, sending a capital Q will do nothing.

Edited by Distrophy
Link to comment
Share on other sites

Use {LSHIFT} or {RSHIFT} for the Shift Key

But your trying to hit Shift+Q so you need to

Either +Q will work or {SHIFTDOWN}Q{SHIFTUP} will work

This is done on five of the keys but only three ALT, Shift, Ctrl will be used the other two WindowKeys are used for windows

{ALTDOWN} Holds the ALT key down until {ALTUP} is sent

{SHIFTDOWN} Holds the SHIFT key down until {SHIFTUP} is sent

{CTRLDOWN} Holds the CTRL key down until {CTRLUP} is sent

{LWINDOWN} Holds the left Windows key down until {LWINUP} is sent

{RWINDOWN} Holds the right Windows key down until {RWINUP} is sent

You aren't thinking. If you press shift, then specify another shift command, you get a plain letter. Send("Q") is the same as Send("{SHIFT}q") and Send("{SHIFT}Q") is the same as Send("q").

Write up a script that test your theory then. But It should work by what he has on his scripts Send("{LSHIFT}Q") press and release Left Shift then press Q so you should have a capital Q because you have already release the Shift key. But do test this theory of yours based on that

{LSHIFT}

{LSHIFT down}{LSHIFT up}

{RSHIFT}

{RSHIFT down}{RSHIFT up}

{SHIFTDOWN}{SHIFTUP}

+ if front of it also minmicks a Shiftdown till it all ends on a Send function then Shiftup

Edited by TerarinKerowyn

Contact via MSN: [email=terarink_msn@hotmail.com]terarink_msn@hotmail.com[/email], yahoo: terarink_yah

Link to comment
Share on other sites

Edit, next time instead of posting four times in a row.

Yes, I realize what I was writing was wrong. What I was trying to point out was that if you want to use the Q key, and you use a capital Q in the string, it is going to be a shift q.

And on a side question, what kind of modifier is left shift? Who writes hotkeys like that?

Link to comment
Share on other sites

Edit, next time instead of posting four times in a row.

Yes, I realize what I was writing was wrong. What I was trying to point out was that if you want to use the Q key, and you use a capital Q in the string, it is going to be a shift q.

And on a side question, what kind of modifier is left shift? Who writes hotkeys like that?

It's simply a beginner writing for AutoIT using keys that he is familiar with. Left/right who cares. Hopefully his question was answered in a way that he can understand.

Link to comment
Share on other sites

No, I follow what you are saying. I just tried using Send("Q") and it worked the same as my original code.

As for the original question of getting the render to run again, thanks for the input Distrophy. Didn't do it quite the way you did, but you gave me an idea that got the job done. Thanks guys.

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...