Sign in to follow this  
Followers 0
DelioPontes

Struggling with Inputbox and Winwait....

11 posts in this topic

Hi all!

Im new and the forum and also with autoit......

I hope learn a lot with the Forum!

My problem... Im trying to maximize, activate etc a window from a software minimized and click Contol-S  to save, all automatic.

And Im trying to call the software using the Title information from the software.

But because the title can be different every time I open the software, I created a code to insert a Inputbox to write the title first.

But after that I dont know how to use that information on the next commands.

Please look to the code until now:

#include <MsgBoxConstants.au3>
Example()
 
Func Example()
    Local $sAnswer = InputBox("SCENE Project", "Project name?", "" , "") & " - SCENE"
MsgBox($MB_SYSTEMMODAL, "", $sAnswer)
EndFunc
 
 
While 1
Local $hWnd = WinWait($Answer)
WinSetState($hWnd, "", @SW_SHOWNORMAL)
WinActivate, ($Answer)
IF WinExists($Answer) Then Send("^s")
exitloop
WEnd

 

 

Can someone help me?

 

Regards

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

There are much better ways to grab the title of your app...but just to specifically answer your question, you are declaring a local variable in your function, and not returning it.  Effectively, you are collecting the data, and then discarding it as soon as you exit the function...example of returning the variable

#include <MsgBoxConstants.au3>

$sAnswer = Example()
Func Example()
    Local $sAnswer = InputBox("SCENE Project", "Project name?", "" , "") & " - SCENE"
    MsgBox($MB_SYSTEMMODAL, "", $sAnswer)
    Return $sAnswer
EndFunc

While 1
    Local $hWnd = WinWait($Answer)
    WinSetState($hWnd, "", @SW_SHOWNORMAL)
    WinActivate($hWnd)
    IF WinExists($hWnd) Then Send("^s")
    exitloop
WEnd
Edited by jdelaney

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites

Hi jdelaney!

Thanks for the help and you are correct.

other problem I had I wrote "sAnswer" instead "Answer"..........................

Cheers

Share this post


Link to post
Share on other sites

Yes, there are other ways, you can even skip all that and go for WinGetTitle ( "title" [, "text"] ) or opt WinTitleMatchMode 2

Does the title change a lot? or are there certain bits that always appear?

Example: the word "Project" is always there, only numbers change on front of it?


Spoiler

Paster - Main function is to paste text, but has more functions.

OpenW - Open With... alternative, Open any file with any application, set it's icon, set application as default.

Renamer - Rename files and folders, remove portions of text from the filename etc.

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Firefox Profile Backup - Backup/restore previously saved profile.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

 

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Yes, there are other ways, you can even skip all that and go for WinGetTitle ( "title" [, "text"] ) or opt WinTitleMatchMode 2

Does the title change a lot? or are there certain bits that always appear?

Example: the word "Project" is always there, only numbers change on front of it?

 

Hi Careca,

Yes the word "project" changes a lot

Every time time I start a new project I change that name.

The only think that stays in the title is " - SCENE" (SCENE is the name of the software)

Ex. "Leeds project - SCENE", "Manchester project - SCENE", "London Project - SCENE" etc etc

And I can have the software open twice in my laptop, (many times Im working in 2 projects at the same time) 

That was the reasons I choose use the Title to work on the script

But for I now solve the problem....!

#include <MsgBoxConstants.au3>
Example()
Func Example()
Local $sAnswer = InputBox("SCENE Project", "Project name?", "" , "") & " - SCENE"
While 1
Local $hWnd = WinWait($sAnswer)
WinSetState($hWnd, "", @SW_SHOWNORMAL)
IF WinExists($sAnswer) Then Send("^s")
exitloop
WEnd

 

Cheers

Edited by DelioPontes

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

You can do this also:

WinWait("[REXEGPTITLE:.*\s\-\sSCENE]")

no input would be needed

Edited by jdelaney

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites

Yup, or if you set WinTitleMatchMode 2 at the top

and then have

WinWait('SCENE')

Should work without input also.


Spoiler

Paster - Main function is to paste text, but has more functions.

OpenW - Open With... alternative, Open any file with any application, set it's icon, set application as default.

Renamer - Rename files and folders, remove portions of text from the filename etc.

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Firefox Profile Backup - Backup/restore previously saved profile.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

 

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Thanks for the help.

And this last 2 examples will not mess my work  if I have the software open twice in my laptop (twice because many times  I´m working with 2 screens, one screen for the project Im still working and other screen for the project I want to save )

When the software is saving a project, can take   2, 3 hours or more to finish the save  and I don´t want the script start saving the project that I´m still working.

I need  this script because this software have a lot of bugs and open a lot of error dialog boxes that stop the saving and I need to close this dialog boxes and click again save manual...

My next step on the script  will be to close automatic this errors dialog boxes and also press automatic "save" until the software send a final dialog box with project saved correct.

Cheers

Edited by DelioPontes

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

They will grab the longest running window matching...or is the window in the highest z-order...I don't recall.

So there is no guarantee it will perform the action on the window you expect.

You should keep the input.

Edit: just tested, it will attach to the window with the highest z-order...so your active, or most recently active, window that matches.

Edited by jdelaney

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites

So...I guess the script will attach on the window Im still working....

I will try also...thanks for the help

They will grab the longest running window matching...or is the window in the highest z-order...I don't recall.

So there is no guarantee it will perform the action on the window you expect.

You should keep the input.

Edit: just tested, it will attach to the window with the highest z-order...so your active, or most recently active, window that matches.

Share this post


Link to post
Share on other sites

If the window will ALWAYS be the one your are not currently working on (ie Active), then there are ways to grab it...Using

WinList

logically loop through, until you find a handle you are currently not working on.


IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

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