SorryButImaNewbie

UDF Add fail in SciTe

13 posts in this topic

#1 ·  Posted

Hello,

I try to add a new UDF to my AutoIT library, and it seems I fail. I started to work following the insturctions found on the wiki . 

I made an extra folder just next to my AutoIT folder, called ExtraUDF, and copied the file CUIAutomation2.au3 in it (I try to use this UDF for automating a program) then I run sciteconfig, set this folder up as User Include Folder, applied the changes, then run the calltip manager and got a msg when I tried to parse it. I attach a few pictures for better present the problem.

I think I miss something here, should i put anything else on the ExtraUDF folder? I dont think that the CallTip manager added the udf to scite, If I try to run it i get a msg saying that I Scite cant open the include file and naturally after that, It can't use the functions called from it.

Thank you for your help and insight as always! Please ask, if anything is fuzzy about the problem

 

AutoIT3 folders.PNG

ExtraUDF.PNG

SciteConfig1.PNG

SciteConfig2.PNG

Trial.PNG

Share this post


Link to post
Share on other sites



#2 ·  Posted

Is UIAWrappers.au3 in the D:\AutoIT\ExtraUDF folder?

1 person likes this

Share this post


Link to post
Share on other sites

#3 ·  Posted

ohhh.....Ohh... ohhh....

No I only added CUIAutomation2 so far

Share this post


Link to post
Share on other sites

#4 ·  Posted

Also the CUIAutomation2 doesn't have any functions, so call tips aren't going to work, you need to use call tips manager on UIAWrappers.au3 to get these functions.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Thank you, I added the UIAWrappers.au3 already with no problems.

I'm reading junkew post about how to use it. Its a bit hard but not impossible to follow. I try to get somehandels on the controls the program is using with SimpleSpy or Inspectx64 version, but so far not so good.

once _UIA_setVar has set itslef to oP1,2 etc, shouldn't the above code _UIA_Action part do some given action? (I tried with click, but nothing so far)

Thank you for your help!

(code is from SimpleSpy)

#include <UIAWrappers.au3>
#include <EditConstants.au3>
#include <AutoItConstants.au3>
#include <GUIConstantsEx.au3>
#include <CUIAutomation2.au3>
#include <WindowsConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPI.au3>
#include <Misc.au3>

#AutoIt3Wrapper_UseX64

Opt("TrayIconDebug", 1)
Opt("MustDeclareVars", 1)

consolewrite("*** Some important settings you can find in " & @scriptdir & "\UIA.CFG ***" & @CRLF)
consolewrite("*** " & _UIA_getVersionInfoString() )
consolewrite("*** If logging is turned on you can find it here :" & _UIA_getVar("logFileName") & @CRLF)

_UIA_setVar("oP1","Title:=Program;controltype:=UIA_WindowControlTypeId;class:=Window")  ;Program
_UIA_setVar("oP2","Title:=;controltype:=UIA_CustomControlTypeId;class:=MainView")   ;
_UIA_setVar("oP3","Title:=;controltype:=UIA_CustomControlTypeId;class:=TileNavigationView") ;

;~ $oUIElement=_UIA_getObjectByFindAll(".mainwindow", "title:=;ControlType:=UIA_ImageControlTypeId", $treescope_subtree)
_UIA_setVar("oUIElement","Title:=;controltype:=UIA_ImageControlTypeId;class:=Image") ;ControlType:=UIA_ImageControlTypeId;classname:=Image")

;~ Actions split away from logical/technical definition above can come from configfiles

;~_UIA_Action("oP1","highlight")
_UIA_Action("oP1","click") ;setfocus
;~_UIA_Action("oP2","highlight")
_UIA_Action("oP2","click") ;setfocus
;~_UIA_Action("oP3","highlight")
_UIA_Action("oP3","click") ;setfocus

;~_UIA_action($oUIElement","highlight")
;~_UIA_action($oUIElement,"click")
;~_UIA_action("oUIElement","highlight")
;~_UIA_action("oUIElement","click")

 

Edited by SorryButImaNewbie

Share this post


Link to post
Share on other sites

#6 ·  Posted

Try changing click to highlight it should then show you what op1, op2, op3 is attempting to click on.  Whats the software you're trying to automate?

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Its a software my new company is developing, I try to make an automatic tester program, I'm now able to write code that click on the given coordinates where the controls should be (maxsizeing the window before), so I can technicly make it happen, but I would like to write one that finds the controls in the given window, for A) code don't needs to know coordinates of controls beforhand and B ) I would like to better myself in automatization with AutoIT :)

brb trying your proposed code changes with highlights

Edit: it highlights the softwarewindow and an additional control (language change options) and I think the windows startmenu? trying to look at them with SimpleSpy soon

Edit2: Ohh it should highlight an icon on a button btw :) at least the code I copied from simplespy was highlighted an icon

Edited by SorryButImaNewbie

Share this post


Link to post
Share on other sites

#8 ·  Posted

I would like to get the controls handels or IDs or something, but so far the controlClick seems not to work, or maybe the coordinates of them, so I can move the mouse there to click on them. Not with predefined coordinates, but the script would find it on its own,

Share this post


Link to post
Share on other sites

#9 ·  Posted

Have you tried Autoit Info Tool?

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Yes, it was my first try, It only saw the main window, nothing else, no control, text, or pictures

Edit:

Then I tried SimpleSpy and Inspector, they seems to find all the relevant controls but I can't act upon their information yet (I don't know the handle or ID or something that I can use, maybe text alone, but that could be problematic). Thats my goal right now, make a click command on a control without mouseclick by found coordinates or handle or title or something. 

It seems a few button can't be found by Inspector/SimpleSpy (fleshy design I guess), but lucky for me these buttons have text or text and pic on them, which can be found, so I think i will be able to click on them in the future.

Edited by SorryButImaNewbie

Share this post


Link to post
Share on other sites

#11 ·  Posted

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

Thank you Master LarsJ, I have that very thread open in my browser and to be honest its the source of like 75-85% of my work :)

Inspect (and SimpleSpy) was able to detect every control I will need for the automatization. The only bump is that two pretty important control can't be detected, but the text on them can, so I plan to click on the text, which should translate to a click on the button, right? (since the textbox is on the button or the pic is on the button)

Unfourtunetly, Inspect treeview isnt giving back as a straight forward "clean" view as with the Intel Example and I'm not that experienced (let say this is my second day of using it) with them.

Edit: I post a few pic with the Inspect results momentarly

Edit2: Attaching the returned values of Inspect x64 on an icon of the target software (sorry for the redout, but I have to follow regulations, I think its still usefull)

This is what I get back

InspectResultsOnIcon.PNG

Edited by SorryButImaNewbie

Share this post


Link to post
Share on other sites

#13 ·  Posted

If nothing else works then you may want to click with the usual MouseClick command. Calculate the bounding rectangle of the text control and make a MouseClick in the center of the rectangle. See here how to do it. Especially posts 17 - 22.

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

  • Similar Content

    • imitto
      By imitto
      Hello all!
      I use Autoit for a while, already made some automation for a TV station's master control room with it. I made a UDF to easily work with PAL timecode and time with milliseconds, convert, add or subtract them. Feel free to use it if you want something like this
      #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Res_Description=PAL Timecode Calculator UDF #AutoIt3Wrapper_Res_LegalCopyright=horvath.imre@gmail.com #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** ; ; #FUNCTION# ; Name...........: _tcAdd ; Description....: Returns addition of two timecodes ; Syntax.........: _tcAdd($fTc1, fTc2 [, $fFormat = "P"]) ; ; Parameters.....: $fTc1 - First timecode in hh:mm:ss.ff format ; $fTc2 - Second timecode in hh:mm:ss.ff format ; $fFormat - Time base - "P" (default): PAL (25 fps) ; "M" : millisecond ; ; Return value...: Sum of the two timecode in the selected format Func _tcAdd($fTc1, $fTc2, $fFormat = "P", $fHourFormat = 1) Local $fMs1 = _tcToMs($fTc1) Local $fMs2 = _tcToMs($fTc2) Local $fSumMs = $fMs1 + $fMs2 Return _msToTc($fSumMs, $fFormat, $fHourFormat) EndFunc ; #FUNCTION# ; Name...........: _tcsSub ; Description....: Returns addition of two timecodes ; Syntax.........: _tcSub($fTc1, fTc2 [, $fFormat = "P"]) ; ; Parameters.....: $fTc1 - First timecode in hh:mm:ss.ff format ; $fTc2 - Second timecode in hh:mm:ss.ff format ; $fFormat - Time base - "P" (default): PAL (25 fps) ; "M" : millisecond ; ; Return value...: Subtract $fTc2 from $fTc1 in the source format Func _tcSub($fTc1, $fTc2, $fFormat = "P") Local $fMs1 = _tcToMs($fTc1) Local $fMs2 = _tcToMs($fTc2) Local $fSumMs = $fMs1 - $fMs2 If $fSumMs < 0 Then $fSumMs = _tcToMs("24:00:00.00") - ($fSumMs * -1) EndIf Return _msToTc($fSumMs, $fFormat) EndFunc ; #FUNCTION# ; Name...........: _tcToMs ; Description....: Returns timecode converted to total milliseconds ; Syntax.........: _tcToMs($fTc) ; ; Parameters.....: $fTc - Timecode in hh:mm:ss.ff or hh:mm:ss:xxx format, where xxx are milliseconds ; ; Return value...: Milliseconds as an integer value Func _tcToMs($fTc) Local $fTemp = StringSplit($fTc, ":.") Local $fChr = StringLen($fTemp[4]) Switch $fChr Case 2 Return ($fTemp[4] * 40) + ($fTemp[3] * 1000) + ($fTemp[2] * 60000) + ($fTemp[1] * 3600000) Case 3 Return ($fTemp[4]) + ($fTemp[3] * 1000) + ($fTemp[2] * 60000) + ($fTemp[1] * 3600000) EndSwitch EndFunc ; #FUNCTION# ; Name...........: _msToTc ; Description....: Converts total milliseconds to timecode ; Syntax.........: _msToTc($fIn, $fFormat = "P", $fHourFormat = 1) ; ; Parameters.....: $fIn - Time in milliseconds ; $fFormat - Output format "P": PAL TC (default) ; "M": hh:mm:ss.xxx where xxx are milliseconds ; $fHourFormat - Hour format "1": max. value is 23, then starts from 0 (default) ; "0": hours can be more then 23 ; ; Return value...: Timecode as string in the selected format Func _msToTc($fIn, $fFormat = "P", $fHourFormat = 1) Switch $fFormat Case "P" Local $fFr = StringFormat("%02i", (StringRight($fIn, 3) - Mod(StringRight($fIn, 3), 40)) / 40) Case "M" Local $fFr = StringFormat("%03i", StringRight($fIn, 3)) EndSwitch $fIn = StringTrimRight($fIn, 3) Local $fSec = StringFormat("%02i", Mod($fIn, 60)) $fIn -= $fSec Local $fMinTot = $fIn / 60 Local $fMin = StringFormat("%02i", Mod($fMinTot, 60)) $fIn -= $fMin*60 Local $fHourTot = $fIn / 60 / 60 Switch $fHourFormat Case 1 $fHour = StringFormat("%02i", Mod($fHourTot, 24)) Case 0 $fHour = StringFormat("%02i", $fHourTot) EndSwitch Return($fHour & ":" & $fMin & ":" & $fSec & "." & $fFr) EndFunc ; #FUNCTION# ; Name...........: _tcFormatChange ; Description....: Toggle TC format ; Syntax.........: _tcFormatChange($fTc) ; ; Parameters.....: $fTc - Timecode in hh:mm:ss.ff or hh:mm:ss:xxx format, where xxx are milliseconds ; ; Return value...: PAL timecode or time with milliseconds as string, depends on input Func _tcFormatChange($fTc) Local $fTemp = StringSplit($fTc, ":.") Local $fChr = StringLen($fTemp[4]) Switch $fChr Case 2 Return $fTemp[1]&":"&$fTemp[2]&":"&$fTemp[3]&"."&StringFormat("%03i", $fTemp[4]*40) Case 3 Return $fTemp[1]&":"&$fTemp[2]&":"&$fTemp[3]&"."&StringFormat("%02i", ($fTemp[4]-Mod($fTemp[4], 40))/40) EndSwitch EndFunc And the example script:
      #include<_PAL_TC_Calc.au3> $palTC1 = "00:01:12.20" $palTC2 = "23:59:50.02" $msTC1 = "00:01:12.800" $msTC2 = "23:59:50.120" MsgBox(0, "1", _tcAdd($palTC1, $palTC2)); Adds $palTC1 to $palTC2, turns hour back to 0 after 23, returns PAL TC format MsgBox(0, "2", _tcAdd($palTC1, $palTC2, "M")); Adds $palTC1 to $palTC2, turns hour back to 0 after 23, returns time with milliseconds format MsgBox(0, "3", _tcAdd($palTC1, $palTC2, "M", 0)); Adds $palTC1 to $palTC2, hours can be infinite, returns time with milliseconds format MsgBox(0, "4", _tcAdd($msTC1, $msTC2)); Adds $palTC1 to $palTC2, turns hour back to 0 after 23, returns PAL TC format MsgBox(0, "5", _tcAdd($msTC1, $msTC2, "M")); Adds $palTC1 to $palTC2, turns hour back to 0 after 23, returns time with milliseconds format MsgBox(0, "6", _tcAdd($msTC1, $msTC2, "M", 0)); Adds $palTC1 to $palTC2, hours can be infinite, returns time with milliseconds format MsgBox(0, "7", _tcSub($palTC2, $palTC1)); Subtract $palTC1 from $palTC2, returns PAL TC format MsgBox(0, "8", _tcSub($palTC2, $palTC1, "M")); Subtract $palTC1 from $palTC2, time with milliseconds format MsgBox(0, "9", _tcSub($msTC1, $msTC2)); Subtract $palTC1 from $palTC2, returns PAL TC format - when hits zero, counts back from 24:00:00.00 MsgBox(0, "10", _tcSub($msTC1, $msTC2, "M")); Subtract $palTC1 from $palTC2, time with milliseconds format - when hits zero, counts back from 24:00:00.000 MsgBox(0, "11", _tcFormatChange($palTC2)); Convert PAL TC to time with milliseconds and back MsgBox(0, "12", _tcFormatChange($msTC2)); Convert PAL TC to time with milliseconds and back  
      TC_CALC_example.au3
      _PAL_TC_Calc.au3
    • TRAGENALPHA
      By TRAGENALPHA
      A small UDF to Modify the Console Interface.
      #include-once ;#AutoIt3Wrapper_Au3Check_Parameters=-q -d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7 ; =============================================================================================================================== ; Name...........: Console Modify ; Description ...: A small UDF to manipulate the Console Interface for scripts that are compiled as a console application. ; Syntax.........: _ConsoleClear() -- Clears the Console ; _ConsoleTitle("VALUE") - Sets the console title. ; _ConsoleWindow([WIDTH BUFFER SIZE], [HEIGHT BUFFER SIZE]) - Sets the Width and Height Buffer size of the console. ; Parameters ....: $bh6e5v_ctval = Title of the Console Window. ; $bh6e5v_cwwidth = Window width buffer size. ; $bh6e5v_cwheight = Window height buffer size. ; Return values .: True = Console window buffer size has been changed ; False = Failed to change console window buffer size. ; Author ........: TRAGENALPHA <3 ; Example .......: _ConsoleTitle("This is the new title") // _ConsoleWindow(200, 60) ; =============================================================================================================================== ; -- This is here because writing RunDos and including a whole UDF is too much. But this is basically just _RunDos() ;Func cmd($bh6e5v_ldvar) ; RunWait(@ComSpec & " /c " & $bh6e5v_ldval) ;EndFunc Func _ConsoleClear() RunWait(@ComSpec & " /c cls") EndFunc Func _ConsoleTitle($bh6e5v_ctval) RunWait(@ComSpec & " /c title " & $bh6e5v_ctval) EndFunc Func _ConsoleWindow($bh6e5v_cwwidth, $bh6e5v_cwheight) If IsNumber($bh6e5v_cwwidth) And IsNumber($bh6e5v_cwheight) And ($bh6e5v_cwwidth > 0) And ($bh6e5v_cwheight > 0) Then RunWait(@ComSpec & " /c mode con: cols=" & $bh6e5v_cwwidth & " lines=" & $bh6e5v_cwheight) Return True Else Return False EndIf EndFunc  
      ConsoleModify.au3
    • rudi
      By rudi
      Hello,
      very propably this has been asked before, well, I miss the thread(s) ...
      Is there a command line switch to tell the SciTE setup EXE to install silently ("/S") *AND* to end up with "edit" (instead of "run") as system wide default action for *.au3 files?
       

       
      As it can be done with the config tool:
      https://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/SciTEConfigb1.PNG
       
      Regards, Rudi.
    • tremolux66
      By tremolux66
      I use a monospace font for editing AutoIt scripts in SciTE (currently, CourierNew 9pt). Regardless of what font size I set in the configuration, when I start SciTE to resume editing the script text is one size smaller than I specified. When I type Ctrl+<numpad-slash> the text changes to the desired size. The same is true of the output pane, and I have to reset the size for both areas every time I start SciTE.
      IIRC, I've made few other changes to the configuration (e.g., changed the search highlight color and disabled Tidy), so this behavior seems odd. About SciTE says it's version 3.6.0 (Aug. 4, 2015).
      Any idea how to fix this?
    • user4157124
      By user4157124
      As they're opinion-based to some degree; how are AutoIt's best practices decided and do suggestions get considered?
      Some suggestions :
      For...To...Step...Next -loop variable-naming like $iN ($i1, $i2, etc.) : conforms to recommended naming convention, identifies level (albeit inverted to ExitLoop and ContinueLoop's convention) and enables SciTE selection-highlighting (requires minimum of 3 characters). Minimize logic in global scope, separate data & settings from logic, use of vertical space, project organization (folder structure, resource- and include file management). Example (loop variable-naming, minimizing logic in global scope and separation of settings from logic) :
      #include <Array.au3> Global Enum $RANDOM_RETURNFLOAT, _ $RANDOM_RETURNINTEGER Global Enum $EXITCODE_NONE Global Const $g_sChar0 = '-' Global Const $g_sChar1 = '+' Global Const $g_iAmountX = 10 Global Const $g_iAmountY = $g_iAmountX Main() Func Main() Local $aArray[$g_iAmountY][$g_iAmountX] For $i1 = 0 To $g_iAmountY - 1 For $i2 = 0 To $g_iAmountX - 1 $aArray[$i1][$i2] = Random(0, 1, $RANDOM_RETURNINTEGER) ? $g_sChar1 : $g_sChar0 Next Next _ArrayDisplay($aArray) Exit $EXITCODE_NONE EndFunc Example (project organization) :
      + project_folder + bak [backup files] + bin [distributed binaries and dependencies] + inc [non-standard include files] + res [resource files (icons, file+install files, etc.)] + usr [configuration files, databases, etc.] - script.au3 - script.exe Example (use of vertical space) :
      Func _DigitalRoot($iNum) Local $sNum = '' Local $aNum While $iNum > 9 $sNum = String($iNum) $aNum = StringSplit($sNum, '') $iNum = 0 For $i1 = 1 To $aNum[0] $iNum += Int($aNum[$i1]) Next WEnd Return $iNum EndFunc