Re: file-open-find-exe application
hello petr.
perhaps you can check this version, if it's more elegant ? ;)
Code:
' Empty GUI script created on 12-19-2009 18:25:02 by frank (ThinAIR)
'-- test it!
Uses "ui", "os", "console"
Dim startingApp,f As Long
OS_ShellExecute ( "open", "excel.exe", "", "", %OS_WNDSTYLE_NORMAL )
startingApp = WIN_GetActive
WIN_SetForeground(startingApp)
Do While startingApp = %TRUE
WIN_FindByTitle("Excel", %WIN_FINDTITLESTART) 'f=
Loop
PrintL,"excel found! " + Str$(startingApp)
SendKeys ("{ENTER}1234567 898238 4422.58 8934 Angelina Jolie{ENTER},12")
WaitKey
'-- you can try to use alternative --------------------------------------
'OS_ShellExecute ( "open", "winword.exe", "", "", %OS_WNDSTYLE_NORMAL )
'SendKeys ("1242678 898238 4422.58 8934 {ENTER},22")
'------------------------------------------------------------------------
nice day, thanks, frank lion"ice"head :)
Re: file-open-find-exe application
Hi Frank,
no :unguee:
Seriously - just simply read the documentation please. WIN_GETACTIVE returns windows handle, 32 bit number. So the probability it will ever equal %TRUE is 1:4294967295.
Then I said you should wait for the window, while you tried to get the handle immediately after sending execute command.
The while loop gets ignored by script, because handle will mostly not equal to %TRUE.
Code:
WIN_FindByTitle("Excel", %WIN_FINDTITLESTART)
Even on your screenshot the window starts "Microsoft Excel", so code above would never find excel window.
Huuu, I am evil Petr, am I not :diablo:
Here is something closer to what you probably want to achieve :):
Code:
Uses "ui", "os", "console"
Dim excelHandle As DWord
OS_ShellExecute ( "open", "excel.exe", "", "", %OS_WNDSTYLE_NORMAL )
Do
excelHandle = WIN_FindByTitle("Excel", %WIN_FINDTITLECONTAIN)
Loop Until excelHandle <> 0
WIN_SetForeground(excelHandle)
' -- Give excel time to setup spread sheet
SLEEP 2000
PrintL,"excel found! " + Str$(excelHandle)
SendKeys ("{ENTER}1234567 898238 4422.58 8934 Angelina Jolie{ENTER},12")
WaitKey
Do you plan to write any particular program for the library maybe? Then COM should be safer way comparing to simulating clicks.