Jump to content

ControlSetText on toolbarWindow


Go to solution Solved by javiwhite,

Recommended Posts

Hello!

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)

    Sleep(1000)
    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]")
    EndIf
    WinMove("Save as", "", 0, 0)

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

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


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

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!

Link to comment
Share on other sites

  • Solution

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!

Javi

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.

Link to comment
Share on other sites

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
Link to comment
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
 Share

×
×
  • Create New...