Jump to content

Struggling with Inputbox and Winwait....


Recommended Posts

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

Link to comment
Share on other sites

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

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

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

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

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

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.

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

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

IUIAutomation - Topic with framework and examples

Au3Record.exe

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

 

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

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

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

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

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

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.

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

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

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

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

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

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...