Sign in to follow this  
Followers 0
Knab

Button controlling action

13 posts in this topic

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

Share this post


Link to post
Share on other sites



When you call Send, just try Send("Q") because Q is a shifted q.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

In the AutoIt internal source for Send, if the letter is capitalized, the shift key will be pressed. I doubt that changed.

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

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

Share this post


Link to post
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?

Share this post


Link to post
Share on other sites

That's why you learn how to separate information. It's just like writing a research paper. It's all one paper, you just add headers and whatnot.

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

At this rate, I don't think he'll get it. This thread has become a mess of my half thoughts and another member's repeat postings.

Also, my side question was aimed at the maker of the software the OP is trying to automate. Shift+letter doesn't seem like a normal hotkey.

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Yeah, sorry again for the mess.

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  
Followers 0