Blaxxun Posted July 26, 2016 Share Posted July 26, 2016 (edited) Hello community! I wrote an importer for my 3D DCC application (Autodesk Softimage XSI 2015) to import multiple EPS / AI files (And not only one like in standard supported). It works very well but it is resolution dependant since i had to use a MouseClick command. I ran into a problem since i was not able to move the focus with a windows like - TAB keystroke. The UI of XSI is not Windows conform so it seems to be a bit limited with the standard windows TAB commands. To be able to make it work i had to use a MouseClick command which is of course not resolution independant. So now my question is: How do i set the focus to a "windows file list" or to a "specific part of an opened window". I attached an "Autoit window info" screenshot and also tryd some things. But i ended up on using a Mouseclick (blue cross) on a column header (green) to activate the File windows region (red). If i click too fast on a filename it gets opend/loaded of course. (its a Windows double click then if clicked too fast, so i used the column header instead) Here is my code : expandcollapse popup; ______________________________________________________________________________________________________________________________________ ; *** XSI Multiple EPS / AI Files Importer v0.1 *** ; ______________________________________________________________________________________________________________________________________ ; This Script works with a resolution of 1920x1080. ; If you have a different screen resolution then you have to adjust the "MouseClick" coordinates in the "Set Focus()" Funktion to match ; the very right, empty column header in the "Import EPS" window ( like centering the mouse in x and y on it). ; I was not able to set the window focus per software, so i had to use a stinky mouseclick instead. ; ______________________________________________________________________________________________________________________________________ ; USAGE: ; Load one (1) EPS / AI File in Softimage to set the Filepath (and delete it afterwards). ; Fire up the Importer with "F9" on your keyboard and it should import all the files in this folder that you used previously. ; Break the operation at any time by hitting the Escape button on your keyboard. ; ______________________________________________________________________________________________________________________________________ ; C3D Visualizations, July 2016, www.c3d.at ; ______________________________________________________________________________________________________________________________________ HotKeySet("{F9}", "Automatic") HotKeySet("{ESC}", "EndProgram") Global $WinSizeX, $WinSizeY, $WinPosX, $WinPosY, $Filename, $FilenameOld = "", $AnzahlFiles $hWnd = WinWait("[TITLE:Autodesk Softimage]") WinActivate($hWnd) While 1 Sleep(200) WEnd Func Automatic() ; Activate Softimage Window $hWnd = WinWait("[TITLE:Autodesk Softimage]") WinActivate($hWnd) ; Open "Import EPS" window Send("!f") ; ALT + f -> Select File Send("i") ; Select Import Send("{RIGHT}") ; Import Dropdown Send("e") ; Import EPS File $hWnd = WinWait("[TITLE:Import EPS]") ; Wait for "Import" Window Local $WinPos = WinGetPos("Import EPS") ; Get window dimensions and position ; Adjust EPS import window If $WinPos[0] > 0 Then WinMove("Import EPS", "", 0, 0, 1100, 1050) If $WinPos[1] > 0 Then WinMove("Import EPS", "", 0, 0, 1100, 1050) If $WinPos[2] < 1100 Then WinMove("Import EPS", "", 0, 0, 1100, 1050) If $WinPos[3] < 1050 Then WinMove("Import EPS", "", 0, 0, 1100, 1050) GetFileCount() LoadFiles() Exit EndFunc ;==>Automatic Func GetFileCount() Local $n = 0 While 1 SetFocus() Send("{DOWN}") Send("{TAB 3}") Send("^c") ; STRG + c $Filename = ClipGet() ; Clipboard in Variable legen If $Filename = $FilenameOld Then SetFocus() Send("{HOME}"); Cursor to first file $AnzahlFiles = $n ConsoleWrite("Anzahl " & $n & @LF) Send("{ENTER}") ; Load first file MsgBox(0, "Filecount", $n & " Files found", 1) $hWnd = WinWait("[TITLE:Autodesk Softimage]") WinActivate($hWnd) ExitLoop EndIf $FilenameOld = $Filename $n += 1 ConsoleWrite("File " & $n & " " & $Filename & @LF) WEnd EndFunc ;==>GetFileCount Func LoadFiles() For $x = 2 To $AnzahlFiles ; Import EPS Fenster öffnen Send("!f") ; ALT + f -> Select File Send("i") ; Select Import Send("{RIGHT}") ; Import Dropdown Send("e") ; Import EPS File $hWnd = WinWait("[TITLE:Import EPS]") ; Wait for "Import" Window SetFocus() CursorDown($x) Send("{ENTER}"); Import Sleep(1000) Next MsgBox(0, "Import EPS / AI", $AnzahlFiles & " Files imported", 2) EndFunc ;==>LoadFiles Func SetFocus() MouseClick("", 975, 95, 1, 0) ; Set Focus to Filelist (You may change this according to your screen resolution) EndFunc ;==>SetFocus Func CursorDown($n) Send("{DOWN " & $n & "}") EndFunc ;==>CursorDown Func EndProgram() Exit 0 EndFunc ;==>EndProgram Thanks, ChriS Edited July 26, 2016 by Blaxxun Link to comment Share on other sites More sharing options...
R0G Posted February 12, 2017 Share Posted February 12, 2017 (edited) Have you tried ControlFocus? As for making resolution independent scripts use the @DesktopWidth and @DesktopHeight macros Try using ControlClick: ControlClick("Import EPS","","[CLASS:SysListView32; INSTANCE:1]","left",1,791,30) Edited February 12, 2017 by R0G Link to comment Share on other sites More sharing options...
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