impaler Posted August 4, 2007 Posted August 4, 2007 (edited) Hello I am trying to make a 3d viewport in an application rotate automatically for viewing.The apps command is ALT+left click and move your mouse to rotate.So far in the script I have it moving the mouse when I make the window active. Maybe there is a specific way to combine keyboard and mouse clicks together?I cant find anything in the help that specify this BTW I just found this Autoit scripting language whilst looking for some kind of Macro recorder and was amazed. I am keen on playing with this lots it looks like fun but I am really an XML noob compared to some of you people!WinWaitActive("[CLASS:QWidget]", "") Send("{ALTDOWN}") MouseClickDrag("left", 0, 735, 1000, 735) Edited August 4, 2007 by impaler
impaler Posted August 4, 2007 Author Posted August 4, 2007 By doing a loop of this, it could rotate indefinitely and by having the 'hotkeys' editable it could work with any 3d application. I am seeing more uses for this kind of scripting as I think about it wow.
martin Posted August 4, 2007 Posted August 4, 2007 (edited) Hello I am trying to make a 3d viewport in an application rotate automatically for viewing. The apps command is ALT+left click and move your mouse to rotate. So far in the script I have it moving the mouse when I make the window active. Maybe there is a specific way to combine keyboard and mouse clicks together? I cant find anything in the help that specify this BTW I just found this Autoit scripting language whilst looking for some kind of Macro recorder and was amazed. I am keen on playing with this lots it looks like fun but I am really an XML noob compared to some of you people! WinWaitActive("[CLASS:QWidget]", "") Send("{ALTDOWN}") MouseClickDrag("left", 0, 735, 1000, 735) Welcome to the forums impaler. I would have thought your code would work. Maybe you need to move the mouse more slowly so try 50 instead of 0, and maybe you need to release the alt key afterwards. You have a starting coord of 0,735. If you haven't changed the MouseCoordMode then this might not be on the application client area because it will be screen coords. Have a look at Opt. Edited August 4, 2007 by martin Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
impaler Posted August 4, 2007 Author Posted August 4, 2007 Welcome to the forums impaler.I would have thought your code would work. Maybe you need to move the mouse more slowly so try 50 instead of 0, and maybe you need to release the alt key afterwards.You have a starting coord of 0,735. If you haven't changed the MouseCoordMode then this might not be on the application client area because it will be screen coords. Have a look at Opt.Yep cheers Martin, you right I had to AltUP!Now I just gotta play with it lots more and figure out how to move it in loops. I wouldnt mind controlling it all from a GUI with the keyboard, say up arrow rotates up, down arrow rotates down etc. I have to also find out how send the commands to this script whilst the 3d window is active, if that can be done, like some kind of global hotkey thing without making the 3d app window not active.
impaler Posted August 4, 2007 Author Posted August 4, 2007 (edited) When I do this script its like there is some kind of easing going on, like when the dragging starts to happen the acceleration is very fast then it eases off to the end of the movement. I really dont want this I hope there is a work around for just constant stable linear movement. Anyone know? WinWaitActive("[CLASS:QWidget]", "") send("{ALTDOWN}") ; MouseClickDrag ( "button", startx1, starty1, endx2, endy2 [, speed] ) MouseClickDrag("left", 40, 735, 1000, 735, 100) send("{ALTUP}") Edited August 4, 2007 by impaler
martin Posted August 4, 2007 Posted August 4, 2007 When I do this script its like there is some kind of easing going on, like when the dragging starts to happen the acceleration is very fast then it eases off to the end of the movement. I really dont want this I hope there is a work around for just constant stable linear movement. Anyone know? WinWaitActive("[CLASS:QWidget]", "") send("{ALTDOWN}") ; MouseClickDrag ( "button", startx1, starty1, endx2, endy2 [, speed] ) MouseClickDrag("left", 40, 735, 1000, 735, 100) send("{ALTUP}") Searching might get an answer, but I think I''ve had this problem before and I think what I did was to break the move into short sections with a for loop eg $xinc = ($xstart - $xend) /10 $yinc = ($ystart - $yend)/10 for $mx = 1 to 10 mousemove($xstart + $mx*$xinc, etc Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
impaler Posted August 4, 2007 Author Posted August 4, 2007 (edited) Sorry Martin I cant work out your method there I am just a noob, but I got this working 10 time yay. I need to do as you suggested in short sections or something. Thanks for your help so far, I have come a little further Its still so jittery it needs a better solution for the mouse movement, no easing off on long moves. WinWaitActive("[CLASS:QWidget]", "") HotKeySet("{PGUP}", "Terminate") MouseMove(100, 500, 0) $i = 0 Do send("{ALTDOWN}") MouseDown("left") MouseMove(180, 500, 60) send("{ALTUP}") MouseUp("left") $i = $i + 1 MouseMove(100, 500, 0) Until $i = 10 Func Terminate() Exit 0 EndFunc Edited August 4, 2007 by impaler
impaler Posted August 4, 2007 Author Posted August 4, 2007 Here is a pic of what I am tring to rotate, maybe it will inspire someone to help me work out how to rotate this smoother Basically whilst I am spending the many hours modelling it is nice to sit back and go ...ahhhhhh then pick out some inconsistencies as it rotates. As you model you are constantly rotating, but taking your hand off the mouse or tablet every now and again would be nice, then hit a hotkey and dive right back in
martin Posted August 4, 2007 Posted August 4, 2007 Here is a pic of what I am tring to rotate, maybe it will inspire someone to help me work out how to rotate this smoother Basically whilst I am spending the many hours modelling it is nice to sit back and go ...ahhhhhh then pick out some inconsistencies as it rotates. As you model you are constantly rotating, but taking your hand off the mouse or tablet every now and again would be nice, then hit a hotkey and dive right back in That's impressive. What I was trying to say was something like the code below, but it moves in steps with delays and I don't know how to make it smooth. I expect that it's no improvement on a single move WinWaitActive("[sQWidget]", "",5) mousemove(40,735) sleep(200) $mp = MouseGetPos(); $x = $mp[0] $y = $mp[1] $i = 0 $endx = 1000 $endy = 735 $steps = 4 $incx = Int(($endx - $x) / $steps) $incy = Int(($endy - $y) / $steps) Do Send("{ALTDOWN}") MouseClickDrag("left", $x, $y, $x + $incx, $y + $incy, 80) Send("{ALTUP}") $x += $incx $y += $incy Until abs($incx) >= abs($endx - $x) and abs($incy) >= abs($endy - $y) ;make sure we get to the end point Send("{ALTDOWN}") MouseClickDrag("left", $x, $y, $endx, $endy, 100) Send("{ALTUP}") Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
impaler Posted August 4, 2007 Author Posted August 4, 2007 (edited) That's impressive. What I was trying to say was something like the code below, but it moves in steps with delays and I don't know how to make it smooth. I expect that it's no improvement on a single move WinWaitActive("[sQWidget]", "",5) mousemove(40,735) sleep(200) $mp = MouseGetPos(); $x = $mp[0] $y = $mp[1] $i = 0 $endx = 1000 $endy = 735 $steps = 4 $incx = Int(($endx - $x) / $steps) $incy = Int(($endy - $y) / $steps) Do Send("{ALTDOWN}") MouseClickDrag("left", $x, $y, $x + $incx, $y + $incy, 80) Send("{ALTUP}") $x += $incx $y += $incy Until abs($incx) >= abs($endx - $x) and abs($incy) >= abs($endy - $y) ;make sure we get to the end point Send("{ALTDOWN}") MouseClickDrag("left", $x, $y, $endx, $endy, 100) Send("{ALTUP}") Cheers Martin your code is great. Although you are right its no improvement I tried a few other things and now I am trying to get hotkeys working. This isnt so far, it doesnt seem to respond unless you button bash. Its a shame about not being able to control more with mouse movement as its all probably deep in the lower source code some where. I was hoping to use a slider GUI controlling speed 'accurately' WinWaitActive("[CLASS:QWidget]", "") HotKeySet("{SPACE}", "rotate_r") HotKeySet("{ENTER}", "terminate") Opt("MouseCoordMode",3) Global $rotate_times = 10 Global $i = 0 Func rotate_r() MouseMove(100, 500, 0) Do send("{ALTDOWN}") MouseDown("left") MouseMove(300, 500, 100) send("{ALTUP}") MouseUp("left") $i = $i + 1 MouseMove(100, 500, 0) Until $i = $rotate_times Exit 0 EndFunc Func terminate() Exit 0 EndFunc These Autoit scripts are addictive me thinks I will be looking for more tasks to automate with them Edited August 4, 2007 by impaler
martin Posted August 4, 2007 Posted August 4, 2007 (edited) I'd be interested to know if this idea helps Go to Control Panel, select Mouse and in Mouse Properties on the Buttons page check turn on click lock. Apply the cahnges or exit the properties then try this code. WinWaitActive("[sQWidget]", "",5) mousemove(40,735) sleep(200) $mp = MouseGetPos(); $x = $mp[0] $y = $mp[1] $i = 0 $endx = 1000 $endy = 735 $steps = 20 $incx = Int((-$x + $endx) / $steps) $incy = Int((- $y + $endy) / $steps) $ii = true Send("{ALTDOWN}") Do if $ii then MouseClickDrag("left", $x, $y, $x+1, $y + 1, 80) $ii = false Else MouseMove($x + $incx, $y + $incy, 80) $x += $incx $y += $incy EndIf Until abs($incx) >= abs($endx - $x) and abs($incy) >= abs($endy - $y) ;make sure we get to the end point ;Send("{ALTDOWN}") ;MouseClickDrag("left", $x, $y, $endx, $endy, 100) Send("{ALTUP}") (Don't forget to uncheck the Click Lock afterwards.) Edited August 4, 2007 by martin Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
impaler Posted August 4, 2007 Author Posted August 4, 2007 (edited) I'd be interested to know if this idea helps Go to Control Panel, select Mouse and in Mouse Properties on the Buttons page check turn on click lock. Apply the cahnges or exit the properties then try this code. WinWaitActive("[sQWidget]", "",5) mousemove(40,735) sleep(200) $mp = MouseGetPos(); $x = $mp[0] $y = $mp[1] $i = 0 $endx = 1000 $endy = 735 $steps = 20 $incx = Int((-$x + $endx) / $steps) $incy = Int((- $y + $endy) / $steps) $ii = true Send("{ALTDOWN}") Do if $ii then MouseClickDrag("left", $x, $y, $x+1, $y + 1, 80) $ii = false Else MouseMove($x + $incx, $y + $incy, 80) $x += $incx $y += $incy EndIf Until abs($incx) >= abs($endx - $x) and abs($incy) >= abs($endy - $y) ;make sure we get to the end point ;Send("{ALTDOWN}") ;MouseClickDrag("left", $x, $y, $endx, $endy, 100) Send("{ALTUP}") (Don't forget to uncheck the Click Lock afterwards.) WOW! that does work, it much smoother now but the click lock didnt do anything different. You must have some good experience with Autoit! The left mouse doesn't stay down though so I just added another MouseDown("left"). I cant get hotkeys to work while this is all going on I need some kind of combination key setup to stop the movement. This language needs some kind of trace to a debug window like you do in actionscript I'll keep looking expandcollapse popupWinWaitActive("[sQWidget]", "",5) HotKeySet("{ENTER}", "terminate") mousemove(40,735) sleep(200) $mp = MouseGetPos(); $x = $mp[0] $y = $mp[1] $i = 0 $endx = 1000 $endy = 735 $steps = 60 $incx = Int((-$x + $endx) / $steps) $incy = Int((- $y + $endy) / $steps) $ii = true Send("{ALTDOWN}") Do MouseDown("left") if $ii then MouseClickDrag("left", $x, $y, $x+1, $y + 1, 80) $ii = false Else MouseMove($x + $incx, $y + $incy, 80) $x += $incx $y += $incy EndIf Until abs($incx) >= abs($endx - $x) and abs($incy) >= abs($endy - $y) ;make sure we get to the end point ;Send("{ALTDOWN}") ;MouseClickDrag("left", $x, $y, $endx, $endy, 100) Send("{ALTUP}") Func terminate() Exit 0 EndFunc Edited August 4, 2007 by impaler
martin Posted August 4, 2007 Posted August 4, 2007 (edited) Ooooh! I forgot about MouseDown! This is much simpler then WinWaitActive("[sQWidget]", "",5) mousemove(40,735) sleep(200) $mp = MouseGetPos(); $x = $mp[0] $y = $mp[1] $i = 0 $endx = 1000 $endy = 735 $steps = 20 $incx = Int((-$x + $endx) / $steps) $incy = Int((- $y + $endy) / $steps) $ii = true Send("{ALTDOWN}") Mousedown("left") Do MouseMove($x + $incx, $y + $incy, 80) $x += $incx $y += $incy Until abs($incx) >= abs($endx - $x) and abs($incy) >= abs($endy - $y) MouseMove($endx, $endy, 80) MouseUp("left");<-----------you must have the mouse up Send("{ALTUP}") Edited August 4, 2007 by martin Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
impaler Posted August 5, 2007 Author Posted August 5, 2007 (edited) Cheers again, what you done works insanely good, I want to try making a GUI for different rotations up/down etc when I get this all working, I'll credit ya where ever I post it! I have to work out how to terminate properly by having a hotkey that is Left mouse down, alt and "ENTER" or something. Also I cant work out how to have a speed variable, I think it has something to do with the $mp[] array which I dont quite understand yet. Still this script is soooo cool and I am going to try to get it to work in a few 3d programs expandcollapse popupWinWaitActive("[sQWidget]", "",5) HotKeySet("{PGDN}", "terminate");this requires button bash holding ALT and PGDN to work ;HotKeySet("{!PGDN}", "terminate");hotkey not registering trying to make ALT+PGDN maybe I need left click too? $rotated = 0 $rotate_times = 1 Do ;MsgBox(0, "Rotated:", $rotated);(trace) rotate() $rotated = $rotated + 1 Until $rotated = $rotate_times Exit 0 Func rotate() mousemove(40,900,0) sleep(200);this doesnt change when it starts moving $mp = MouseGetPos(); $x = $mp[0] $y = $mp[1] $i = 0 $endx = 1000 $endy = 900 $steps = 20 $incx = Int((-$x + $endx) / $steps) $incy = Int((- $y + $endy) / $steps) $ii = true Send("{ALTDOWN}") Mousedown("left") Do MouseMove($x + $incx, $y + $incy, 80) $x += $incx $y += $incy Until abs($incx) >= abs($endx - $x) and abs($incy) >= abs($endy - $y) MouseMove($endx, $endy, 80) MouseUp("left");<-----------works Send("{ALTUP}") EndFunc Func terminate() Send("{ALTUP}") MouseUp("left") Exit 0 EndFunc Edited August 5, 2007 by impaler
martin Posted August 5, 2007 Posted August 5, 2007 You can set the speed etc as below. This also shows how you can make key presses cause an exit. In this example, if you hold down the Alt and the PgUp when the mouse is moving it will stop expandcollapse popup#include <misc.au3> HotKeySet("{PGDN}", "terminate");this requires button bash holding ALT and PGDN to work ;HotKeySet("{!PGDN}", "terminate");hotkey not registering trying to make ALT+PGDN maybe I need left click too? $rotated = 0 $rotate_times = 1 $speed = 30;bigger is faster from 0 to 100 Do ;MsgBox(0, "Rotated:", $rotated);(trace) rotate(40,900,1000,900,40) $rotated = $rotated + 1 Until $rotated = $rotate_times Exit 0 Func rotate($startx,$starty,$endx,$endy,$speed) ;$speed is from 1 = slow to 100 = instant mousemove($startx,$starty,0) ;sleep(200);this doesnt change when it starts moving ;the sleep was not needed, just something I left in by mistake $mp = MouseGetPos(); $x = $mp[0] $y = $mp[1] $i = 0 ;$endx = 1000 ;$endy = 900 $steps = 40 $incx = Int((-$x + $endx) / $steps) $incy = Int((- $y + $endy) / $steps) If $incx = 0 And $incy = 0 Then MsgBox(0,'error','step size too small?') Return endif $ii = true Send("{ALTDOWN}") Mousedown("left") Do MouseMove($x + $incx, $y + $incy, 100 - $speed) $x += $incx $y += $incy If checkexit() Then exitloop Until abs($incx) >= abs($endx - $x) and abs($incy) >= abs($endy - $y) MouseMove($endx, $endy, 80) MouseUp("left");<-----------works Send("{ALTUP}") EndFunc Func terminate() Send("{ALTUP}") MouseUp("left") Exit 0 EndFunc Func CheckExit() ;if Alt pressed and PgUp pressed If _IsPressed(12) And _IsPressed(21) Then Return True;or could say exit Else Return False EndIf EndFunc Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
impaler Posted August 5, 2007 Author Posted August 5, 2007 (edited) Sweeet Martin although 0 and 100 work but not the numbers inbetween. 1 looks very similar speed to 90 but 100 is insanely fast. I tried to neaten the code and have a first go at a simple GUI so many cool choices, I have to make it disable and enable itself somehow though expandcollapse popup#include <GUIConstants.au3> WinActivate("[sQWidget]", "") WinWaitActive("[sQWidget]", "",1) ;$size = WinGetClientSize("") ;$screen_width = $size[0] ;$screen_height = $size[1] ;for cinema 4d WinWaitActive("[C4DR_WIN1_101_0]", "",2) HotKeySet("+!s", "terminate");ALT+SHIFT+s this registers perfectly HotKeySet("+!a", "choose_rotation");ALT+SHIFT+s this registers perfectly $rotated = 0 $move_times = 2 $speed = 1;bigger is faster from 0 to 100;1 is the same speed as 90 choose_rotation() ;<--------------------------------------------------------------------------- Func choose_rotation() ;GUISetState(@SW_ENABLE); the gui doesnt respond after it works initially Send("{ALTUP}") MouseUp("left") Opt("GUIOnEventMode",1) GUICreate("Rotate Menu", 300, 150) $Label = GUICtrlCreateLabel("Choose a Direction Menu", 10, 10) $Label = GUICtrlCreateLabel("ALT+SHIFT+s - QUIT", 10, 90) $Label = GUICtrlCreateLabel("ALT+SHIFT+a - MENU", 10, 120) $L_ID = GUICtrlCreateButton("Left", 10, 50, 50, 20) GUICtrlSetOnEvent($L_ID,"rotate_view_l") $R_ID = GUICtrlCreateButton("Right", 80, 50, 50, 20) GUICtrlSetOnEvent($R_ID ,"rotate_view_r") GUISetOnEvent($GUI_EVENT_CLOSE,"terminate") GUISetState() While 1 Sleep (1000) WEnd EndFunc ;<--------------------------------------------------------------------------- Func rotate_view_r() ;GUISetState(@SW_DISABLE) $startx = 55 $endx = 1000;end the cursor movements at 1000 right $starty = 900 $endy = $starty Do ;MsgBox(0, "Rotated:", $rotated);(trace) rotate($startx,$starty,$endx,$endy,$speed) $rotated = $rotated + 1 Until $rotated = $move_times EndFunc ;<--------------------------------------------------------------------------- Func rotate_view_l() ;GUISetState(@SW_DISABLE) $startx = 1000 $endx = 55;end the cursor movements at 1000 right $starty = 900 $endy = $starty Do ;MsgBox(0, "Rotated:", $rotated);(trace) rotate($startx,$starty,$endx,$endy,$speed) $rotated = $rotated + 1 Until $rotated = $move_times EndFunc ;<--------------------------------------------------------------------------- Func rotate($startx,$starty,$endx,$endy,$speed) ;$speed is from 1 = slow to 100 = instant mousemove($startx,$starty,0) ;sleep(200);this doesnt change when it starts moving ;the sleep was not needed, just something I left in by mistake $mp = MouseGetPos(); $x = $mp[0] $y = $mp[1] $i = 0 ;$endx = 1000 ;$endy = 900 $steps = 40 $incx = Int((-$x + $endx) / $steps) $incy = Int((- $y + $endy) / $steps) If $incx = 0 And $incy = 0 Then MsgBox(0,'error','step size too small?') Return endif $ii = true Send("{ALTDOWN}") Mousedown("left") Do MouseMove($x + $incx, $y + $incy, 100 - $speed) $x += $incx $y += $incy Until abs($incx) >= abs($endx - $x) and abs($incy) >= abs($endy - $y) MouseMove($endx, $endy, 80) MouseUp("left") Send("{ALTUP}") EndFunc ;<--------------------------------------------------------------------------- Func terminate() Send("{ALTUP}") MouseUp("left") Exit 0 EndFunc ;<--------------------------------------------------------------------------- Edited August 5, 2007 by impaler
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now