Page 2 of 2 FirstFirst 12
Results 11 to 14 of 14

Thread: file-open-find-exe application

  1. #11
    Senior Member Lionheart008's Avatar
    Join Date
    Sep 2008
    Location
    Germany, Bad Sooden-Allendorf
    Age
    51
    Posts
    934
    Rep Power
    109

    Re: file-open-find-exe application

    hello petr.

    perhaps you can check this version, if it's more elegant ?

    ' 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
    Last edited by ErosOlmi; 05-02-2019 at 21:30.
    you can't always get what you want, but if you try sometimes you might find, you get what you need

  2. #12
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,128
    Rep Power
    732

    Re: file-open-find-exe application

    Hi Frank,

    no

    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.

    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

    Here is something closer to what you probably want to achieve :
    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.
    Last edited by ErosOlmi; 05-02-2019 at 21:30.
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

  3. #13
    Quote Originally Posted by Lionheart008 View Post
    good evening.

    I would like to ask what results do you get with this little "starting application" example and if this one does work ? I only wanted to check if it's possible to start with these four lines microsofts "excel" application ? what happens with this ugly code ? I tried to make this example without path and folder specifications for wished application.

    [code=thinbasic]' Empty GUI script created on 12-19-2009 18:25:02 by frank (ThinAIR)
    '-- test it!

    Uses "ui", "os"

    Dim startingApp As Long
    OS_ShellExecute ( "open", "excel.exe", "", "", %OS_WNDSTYLE_NORMAL )
    SendKeys ("{ENTER}1234567 898238 4422.58 8934 Diana Rigg{ENTER},12")
    startingApp = WIN_GetActive

    '-- alternative
    'OS_ShellExecute ( "open", "winword.exe", "", "", %OS_WNDSTYLE_NORMAL )
    'SendKeys ("{ENTER}1242678 898238 4422.58 8934 {ENTER},22")
    [/code]

    for me on my notebook "excel" starts without any problems and send numbers to cell A 1. If I run this example by thinair I get this result (picture) and without using thinair for running script at another folder I get more values and numbers in cell A 1 and A 2.

    take attention: look at your tb code after closing applications !

    would be nice to get some feedback. I was looking for a maximal short way for this task and another way as you can see in my first post Lucky Patcher 9Apps VidMate

    best regards, frank
    i cant download the file zip
    Last edited by rossi; 06-02-2019 at 11:31.

  4. #14
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10
    Quote Originally Posted by rossi View Post
    i cant download the file zip
    There is no ZIP file attached in this thread.
    Just source code.
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

Page 2 of 2 FirstFirst 12

Members who have read this thread: 0

There are no members to list at the moment.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •