
CADMonkey
Members-
Posts
13 -
Joined
-
Last visited
Recent Profile Visitors
217 profile views
CADMonkey's Achievements

Seeker (1/7)
0
Reputation
-
Hi, I have created a bit of code to enable a script to find named controls on a userform, even though the MS CLASS description changes between machines. e.g. The CLASS "WindowsForms10.EDIT.app.0.24b689f_r14_ad1" for a text box on one PC is different on another. The below code, (a cut-down version of the code from jdelaney original post) loops through all the controls and finds the first one with the desired string in the control class name - in this case "EDIT". This name is then usable for setting the text using ControlSetText. #include <array.au3> WinActivate("Edit Part Rule") $TheClassName = GetAllWindowsControls(WinGetHandle("Edit Part Rule"), "EDIT") ;Sleep(500) ControlSetText("Edit Part Rule", "", "[CLASS:" & $TheClassName & "; INSTANCE:3]", $CmdLine[1]) ControlSetText("Edit Part Rule", "", "[CLASS:" & $TheClassName & "; INSTANCE:4]", $CmdLine[2]) Func GetAllWindowsControls($hCallersWindow, $sStringIncludes) ; Get all list of controls $sClassList = WinGetClassList($hCallersWindow) ; Create array $aClassList = StringSplit($sClassList, @CRLF, 2) ; Sort array _ArraySort($aClassList) _ArrayDelete($aClassList, 0) ; Loop For $i = 0 To UBound($aClassList) - 1 If StringInStr($aClassList[$i], $sStringIncludes) Then Return $aClassList[$i] EndIf Next EndFunc ;==>GetAllWindowsControls If anyone has any suggestions to improve it, or a better way to achieve the same thing, please let me know.
-
Send not sending full string
CADMonkey replied to CADMonkey's topic in AutoIt General Help and Support
Hi Devil, Thanks for the reply and apologies ..... user error. I put the application i am interacting with into an idle loop while the autoit script is processing. The loop included a periodic refresh of the display (required for a previous task). That refresh was interrupting the 'paste' of the characters into the control. Sorted now (though it did take me several hours to find the cause!!). Many thanks. -
Hi Guys, I am using 'Send' to pass a command-line parameter to a textbox, but the string loses characters, seemingly at random. The string is a mixture of letters, numbers and spaces. ControlFocus("TheWindow", "" , "[CLASS:Edit; INSTANCE:3]") Send($CmdLine[1], 1) I can view the string correctly in a messagebox, but the string, once 'sent' it is incomplete. If I define the string within the autoit function and pass that, the string is always complete, it just doesn't seem to like passing command line variables. I tried 'raw' option with no luck. I have also tried setting a new variable in the function to the command line variable and then using that, but the result is the same. suggestions please. ...
-
Hi, I am hoping there is something simple I am doing worng here. I have an autoit executable that works when I run it from a share folder, but 'misbehaves' when run from a folder on the computer desktop. (the program has a list of window titles it reads from an ini file and then closes the windows as they appear.) I have run around in circles trying all sorts of things, but to no avail. The local file does not appear in the task manager when run, but it does perform some of its functions. It works perfectly when run from a share folder! Windows seems to treat the files differently if they are local, as the 'tooltip' when I hover the point over the file in a file manager window is different. My question, does windows handle executables differently when run locally and if so, how can I get round it? Many thanks.
-
Difficulty using ObjGet to link to open application
CADMonkey replied to CADMonkey's topic in AutoItX Help and Support
Many thanks for your help Water. Looks like I need to learn python! -
Difficulty using ObjGet to link to open application
CADMonkey replied to CADMonkey's topic in AutoItX Help and Support
a 'swing and a miss' there i'm afraid. (I tried with Y and N!) Having spoken with a collegue, this apparently works from python to catia. -
Difficulty using ObjGet to link to open application
CADMonkey replied to CADMonkey's topic in AutoItX Help and Support
CATPART_Open_Test.au3 (11) : ==> COM Error intercepted ! err.number is: 0x80004002 err.windescription: No such interface supported err.description is: err.source is: err.helpfile is: err.helpcontext is: err.lastdllerror is: 0 err.scriptline is: 11 err.retcode is: 0x00000000 Hi Water, I get the above error (line 11 is the objget line). It is weird, because the application tries to open the file, but it fails at the last. The file even appears in the history and I can manually open it from that list! I have tried the same method using VBA (excel) and it opens the file ok. Just 'thinking out lout' so to speak, but the catia application on this machine is 32bit and the OS is 64bit win 7. Does autoit see a difference between the 32 and 64 bit, and is there a way to force autoit to use 32bit? -
Difficulty using ObjGet to link to open application
CADMonkey replied to CADMonkey's topic in AutoItX Help and Support
The error occurs before it gets to the part document. To clarify, the code (modified from the example linked above) that gives the error is; #include <MsgBoxConstants.au3> Example() Func Example() ; Error monitoring. This will trap all COM errors while alive. ; This particular object is declared as local, meaning after the function returns it will not exist. Local $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc") ; Create Internet Explorer object Local $oIE = ObjGet("", "CATIA.Application") ; Check for errors If @error Then Return $oIE.Visible = True ; set visibility ; Deliberately cause error by calling non-existing method $oIE.PlayMeARockAndRollSong() ; Check for errors If @error Then MsgBox($MB_SYSTEMMODAL, "COM Error", "@error is set to COM error number." & @CRLF & "@error = 0x" & Hex(@error)) ; Wait few seconds to see if more events will be fired Sleep(3000) ; Nothing more to do. Close IE and return from the function $oIE.Quit() ;~ #forceref $oErrorHandler, $oIEEvents EndFunc ;==>Example ; User's COM error function. Will be called if COM error occurs Func _ErrFunc($oError) ; Do anything here. ConsoleWrite(@ScriptName & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _ @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _ @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _ @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _ @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _ @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _ @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _ @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _ @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _ @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF) EndFunc ;==>_ErrFunc The error given in the output; comerrortests.au3 (11) : ==> COM Error intercepted ! err.number is: 0x80020006 err.windescription: Unknown name. err.description is: err.source is: err.helpfile is: err.helpcontext is: err.lastdllerror is: 0 err.scriptline is: 11 err.retcode is: 0x00000000 +>13:52:59 AutoIt3.exe ended.rc:0 +>13:52:59 AutoIt3Wrapper Finished. >Exit code: 0 Time: 0.3662 The 'err.scriptline is: 11' above leads me to; Local $oIE = ObjGet("", "CATIA.Application") Thanks again. -
Difficulty using ObjGet to link to open application
CADMonkey replied to CADMonkey's topic in AutoItX Help and Support
Hi Water, the VBA code is in the initial post. The other difficulty is that the program starts with via a configuration script, so I cannot objcreate. (hence why i need objget) -
Difficulty using ObjGet to link to open application
CADMonkey replied to CADMonkey's topic in AutoItX Help and Support
Thanks for the quick reply Water, but the application is already running. As in the first post, i can access it from excel using CATIA.Application, but Autoit does not find it. I have tested the autoit code, and it finds EXCEL.Application ok. Any other thoughts? -
Difficulty using ObjGet to link to open application
CADMonkey replied to CADMonkey's topic in AutoItX Help and Support
HI, I have tried the script. I get the following in the output window; comerrortests.au3 (11) : ==> COM Error intercepted ! err.number is: 0x80020006 err.windescription: Unknown name. err.description is: err.source is: err.helpfile is: err.helpcontext is: err.lastdllerror is: 0 err.scriptline is: 11 err.retcode is: 0x00000000 I have tried looking up that error, but nothing seemed to apply. Any suggestions would be greatly appreciated! -
Hi Guys, i need to access the API in an application called catia (CAD). I can do what i need from Excel in VBA; Sub test() Dim CATIA As Object Set CATIA = GetObject(, "CATIA.Application") Set documents1 = CATIA.Documents Set partDocument1 = documents1.Open("\\share\thefile.CATPart") End Sub But I cannot get it to work from Autoit; #include <MsgBoxConstants.au3> Func _test() $oCatia = ObjGet("","CATIA.Application") ; Get an existing Catia Object $documents1 = $oCatia.Documents $partDocument1 = $documents1.Open("\\share\thefile.CATPart") If @error Then MsgBox($MB_SYSTEMMODAL, "", "Catia File Test" & @CRLF & "Error Getting an active Catia Object. Error code: " & Hex(@error, 8)) Return False EndIf EndFunc I get no error, it just does nothing! I tried using the autoit scriptomatic, but it threw errors! Any pointers on how to use objGet would be gratefully received!