Sign in to follow this  
Followers 0

ControlSetText on toolbarWindow

3 posts in this topic


I have a little script and in it a function that is responsible for handling saves in PDFCreator. When such a situation arise, it should set the destination folder to one predestinated in a global variable (a folder in our innernetwork).

Originally I achieved this by moving the window to 0,0 then mouseclick on a specified coordinates on the screen (I know, I know, thats why I want to change it something more reliable, more intelligent)

My candidates were ControlSetText, ControlSend and ControlCommand. I rejected ControlCommand outright since it isn't really for this. ControlSend cause the script to exit, when it reaches the first point where it would use the function.

ControlSetText returns the next console (run_debug_mode=Y)

>"C:Program FilesAutoIt3SciTE..autoit3.exe" /ErrorStdOut "D:régi gép mentésDesktopAutomata TesztelésUD - uszi új BÉTAud_uszi 3.0.1 teszter.au3"    
"D:régi gép mentésDesktopAutomata TesztelésUD - uszi új BÉTAud_uszi 3.0.1 teszter.au3" (1170) : ==> Error in expression.:
ControlSetText("Save as", "", "[CLASSNN:ToolbarWindow323]", & $PDFmentesPath)
ControlSetText("Save as", "", "[CLASSNN:ToolbarWindow323]", ^ ERROR
>Exit code: 1    Time: 34.31


Here is my function so far: (sorry its under construction)

Func RenamePDF($TopUpName)

    WinActivate("PDFCreator 1.", "")
    WinWaitActive("PDFCreator 1.", "")
    ControlCommand("PDFCreator 1.", "", "[CLASSNN:ThunderRT6TextBox6]", "EditPaste", $TopUpName)
    ControlSetText("PDFCreator 1.", "", "[CLASSNN:ThunderRT6TextBox6]", $TopUpName)
    ControlClick("PDFCreator 1.", "", "[CLASSNN:ThunderRT6CommandButton7]")
    $WindowWaitCheck = WinWaitActive("Mentés másként", "", 5)
    If $WindowWaitCheck = 0 Then
        ControlClick("PDFCreator 1.", "", "[CLASSNN:ThunderRT6CommandButton7]")
    WinMove("Save as", "", 0, 0)

    ;MouseClick("", 565, 50) ;Not like this, to many possible errors!
    ;Send("{BS}" & $PDFmentesPath & "{Enter}")

    ;ControlSend("Save as", "", "[CLASSNN:ToolbarWindow323]", & $PDFmentesPath)
    ControlSetText("Save as", "", "[CLASSNN:ToolbarWindow323]", & $PDFmentesPath)

    ControlClick("Save as", "", "[CLASSNN:Button1]")

EndFunc   ;==>RenamePDF

I have a guess that there is a problem in how I try to write/send the variable $PDFmentesPath, but not sure I know how should I do it. Trying random things that come to mind for now.

Thank you for your time and help!

Share this post

Link to post
Share on other sites

Hey SorryButImANewbie,

It looks like you've put an ampersand before the $PDFmentesPath in ControlSetText with nothing to join it too.

Does it work without the &? 

ControlSetText("Save as", "", "[CLASSNN:ToolbarWindow323]",$PDFmentesPath)

Hope This helps!


give a man an application, and he'll be frustrated for the day, Teach him how to program applications and he'll be frustrated for a lifetime.

Share this post

Link to post
Share on other sites

#3 ·  Posted (edited)

Thank you @Javiwhite!

I even tried "" & $PDFmentesPath as well.... also I left "mentés másként" in one of the rows (which is Hungarian for Save as), with these 2 modification it seems to work as intended!

Edit: I'm very happy, that I can work with autoit much quicker and with a semi sure hand, and still find a way to ask basic questions :D Thank you again

Edited by SorryButImaNewbie

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

  • Similar Content

    • ur
      By ur
      I need to set value to a text box to a desktop application.
      I am trying to do that with 
      ControlSetText($MartConfigWindow, "", "", $dbserver)  
      where $MartConfigWindow has the window ID.
      And the text box field is having class as
      THis code is working on one machine but on some machines, the last part of ID, means 378734a6
      is changing.
      Is there anyway to handle this?
    • zerothesavior
      By zerothesavior
      I can't get this to work.
      ControlSetText("[CLASS:#32770]", "", "[CLASS:Edit; INSTANCE:3]", $sString) Am I doing something wrong? The string is not blank, I checked it with a message box.
      Here is the information from the window:
      >>>> Control <<<< Class: Edit Instance: 3 ClassnameNN: Edit3 Name: Advanced (Class): [CLASS:Edit; INSTANCE:3] ID: 1001 Text: Position: 47, 78 Size: 187, 14 ControlClick Coords: 112, 9 Style: 0x50000380 ExStyle: 0x00000000 Handle: 0x000000000021064A  
    • Carm01
      By Carm01
      I have windows 10 64 bit pro with the latest versions of scite and installed. Not that it matters for this instance.
      My monitor resolution is 1920 x 1080 progressive with a refresh rate of 64 HZ ( more in a min on that )
      I have a Nvida gtx 960 card and an HP monitor
      Since moving to Windows 10 and this configuration ( latest drivers of course ) I am unable to see the " ControlSetText " being displayed under the standard 60HZ refresh rate in WIndows 10. On Windows 7 machines this is flawless and always had been. The ControlSetText is updated at an extremely fast rate. IF I change the resolution one notch lower in windows 10 the display displays the text like in Windows 7 60HZ refresh. IF I user the max resolution 1920 x 1080 @ 60 HZ nothing is displayed in Windows 10. IF I create a custom resolution profile and just change the refresh rate to 64HZ it displays normally in Windows 10.
      If I enable " GUIGetMsg() " it displays fine but processes very slow fyi
      I will place the relevant code below. I am wondering:
      1) what is the max refresh/update rate for ControlSetText ( fasted it can be updated )
      2) Could this be adjusted either in code without hampering processing speed
      3) Does this need to be addressed in AutoIT program itself as a bug ?
      #include <Array.au3> #include <File.au3> Local $aRetArray, $aArray local $sFilePath = @ScriptDir & "\info.txt" _FileReadToArray($sFilePath, $aRetArray) Local $aArray[UBound($aRetArray)] SplashTextOn("Percent Complete", "", 130, 40, -1, -1, 16, "") Local $a = 0 Local $hTimer = TimerInit() $bb = UBound($aRetArray) - 1 For $i = 1 To UBound($aRetArray) - 1 ; ;GUIGetMsg();prevent high cpu usage $line = $aRetArray[$i] If StringRight($line, 2) = " X" Then If $i = 1 Then $line1 = StringLen($line) - StringLen($aRetArray[$i]) $line2 = StringRight($line, $line1) $line3 = $aRetArray[$i] $line4 = $aRetArray[$i + 1] Else $line1 = StringLen($line) - StringLen($aRetArray[$i - 1]) $line2 = StringRight($line, $line1) $line3 = $aRetArray[$i - 1]; $line4 = $aRetArray[$i + 1]; EndIf $aArray[$a] = $i & "| " & $line3 & "| " & $line2 & "| " & $line4 $a = $a + 1 EndIf ControlSetText("Percent Complete", "", "Static1", Round((($i / $bb) * 100), 2)) Next Thanks in advance
    • louabill
      By louabill
      It seems that ControlSetText() sends only the first character to Scintilla controls.
      To see this, try the following:
      Open a SciTE window
      Put the following line into the window
      ControlSetText("[CLASS:SciTEWindow]","","[CLASS:Scintilla;Instance:1]", 'here is some text') and save the file.
      Go to the beginning of the line.
      Hit F5 to run the line.
      What I see is that the single letter h overwrites the text in the window instead of the desired text.
      Does anyone know how to get the Scintilla control to play nice? If not, is this a bug I should be reporting to the Autoit folks?
      I would like to avoid ControlSend(), because it has trouble with Unicode.
      Thanks for any tips.
      --- original post ---
      In an AutoIt script, I use ControlSetText() to send text to the Command window in the Stata statistical package.
      In Stata 14, the Command window was changed to a Scintilla control which understands Unicode instead of a RichText control (which used Latin1 encoding). In the past, all worked well, now only the first character gets put in the control.
      Here is an example which illustrates how it worked and now fails (which requires a running Stata 13 and a running Stata 14):
      Opt("WinTitleMatchMode", 1) ## in Stata 13 and earlier, the Command window was a RichText control ControlSetText("Stata/MP 13","","[CLASS:RichEdit20A;Instance:1]", "sysuse auto") ## result: 'sysuse auto' in the Command window ## in Stata 14, the Command window is a Scintilla control ControlSetText("Stata/MP 14","","[CLASS:Scintilla;Instance:1]", "sysuse auto") ## result: the letter 's' in the Command window I can use ControlSend() to send plain text successfully, but I'm betting it won't work properly with Unicode because the function is not Unicode-ready, yet.
      Any hints about what I need to do to fix the problem?
      I realize this is somewhat specialized because of the receiving software, but perhaps someone knows something about sending text to Scintilla Unicode-friendly controls.
      Thanks for any help.
    • mLipok
      By mLipok
      A long time I was using "PDFCreator - Print2PDF" made by @ptrex
      Thanks to @ptrex   for this UDF:

      which was for me an inspiration, not only for PDFCreator, but to learn ActiveX controls.
      I many times modified @ptrex UDF, but recently more and more felt the need to write it almost from scratch.
      Here it is:

      How to use it ?
      There is a region "Example Init" so you need just to run this UDF.
      #Region PDFCreator.au3 - Example Init If Not @Compiled And @ScriptName = 'PDFCreator.au3' Or @ScriptName = 'PDFCreator_DebugIt.au3' Then $g__oPDFCreator_ErrorHandler = ObjEvent("AutoIt.Error", "__PDFCreator_ErrFunc") #cs Not working yet _PDFCreator_ConvertDocument(@ScriptDir & '\PDFCreator.rtf',@ScriptDir & '\PDFCreator_2.pdf') ShellExecute(@ScriptDir & '\PDFCreator.rtf') ShellExecute(@ScriptDir & '\PDFCreator_2.pdf') MsgBox(0, 'END', '_PDFCreator_ConvertDocument()') #ce _PDFCreator_Example_1_RTF2PDF() MsgBox(0, 'END', '_PDFCreator_Example_1_RTF2PDF()') _PDFCreator_Example_2_COMBINEALL() MsgBox(0, 'END', '_PDFCreator_Example_2_COMBINEALL()') _PDFCreator_Example_3_COMBINEALL() MsgBox(0, 'END', '_PDFCreator_Example_3_COMBINEALL()') MsgBox(0, 'EXIT', 'Close this MsgBox to exit example script.') ;~ MsgBox(0, '$g__oPDFCreator.cWindowsVersion', $g__oPDFCreator.cWindowsVersion) Exit EndIf #EndRegion PDFCreator.au3 - Example Init REMAKRS: this UDF is for PDFCreator 1.x.x not for 2.x.x
      some reference and examples for PDFCreator 2.x.x
      Best regards,