RunProgram("c:notepad.exe","","",0) ?

Just starting out? Need help? Post your questions and find answers here.
vmars316
Enthusiast
Enthusiast
Posts: 474
Joined: Fri Jun 29, 2012 12:24 am
Contact:

RunProgram("c:notepad.exe","","",0) ?

Post by vmars316 »

Hello & Thanks ,
I am having trouble getting focus into Notepad's FIND function .
It works fine until
Delay(1000) : SendKeys(0,w$,"{CONTROLDOWN}v{CONTROLUP}") ; Paste.

BUT it can't Paste into FIND box .
It always pastes into the text area .

Anyone know how to gain Focus and entry to the FIND box ?
I tried all kinds of combinations , but no go .
Thanks

Code: Select all

From:
; German forum: ; Author: Danilo ; Date: 07. April 2003 ; OS: Windows
;SendKeys(handel,Window$,Keys$) 

RunProgram("c:notepad.exe","","",0) 
w$="Untitled - Notepad" ; Specifies target window name. 
Delay(1000) : SendKeys(0,w$,"This is a test!") ; Type some dummy text. 
Delay(1000) : SendKeys(0,w$,"{CONTROLDOWN}a{CONTROLUP}") ; Select it all. 
Delay(1000) : SendKeys(0,w$,"{CONTROLDOWN}c{CONTROLUP}") ; Copy. 
Delay(1000) : SendKeys(0,w$,"{CONTROLDOWN}f{CONTROLUP}") ; Find. 
Delay(1000) : SendKeys(0,w$,"{CONTROLDOWN}v{CONTROLUP}") ; Paste. 
;Delay(1000) : SendKeys(0,w$,"{DELETE}")      ; Delete it. 

;Delay(1000) : SendKeys(0,w$,"{CONTROLDOWN}p{CONTROLUP}") 
;Delay(1000) : SendKeys(0,w$,"This is a test!") ; Type some dummy text. 
;Delay(1000) : SendKeys(0,w$,"{ALTDOWN}{F4}") ; Close the Notepad Window
vmars.us Win11 x64 , Martin Guitar 000-16 (1995)
"All things in moderation , except for love and forgiveness."
infratec
Always Here
Always Here
Posts: 7623
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: RunProgram("c:notepad.exe","","",0) ?

Post by infratec »

That's normal.
The Find dialog is a new window.
You have to find the handle of that window to send messages to it.
Julian
Enthusiast
Enthusiast
Posts: 276
Joined: Tue May 24, 2011 1:36 pm

Re: RunProgram("c:notepad.exe","","",0) ?

Post by Julian »

Change the w$ to "Find" in your paste so you send it to the correct window.

Code: Select all

Delay(1000) : SendKeys(0,"Find","{CONTROLDOWN}v{CONTROLUP}") ; Paste.
vmars316
Enthusiast
Enthusiast
Posts: 474
Joined: Fri Jun 29, 2012 12:24 am
Contact:

Re: RunProgram("c:notepad.exe","","",0) ?

Post by vmars316 »

Julian wrote:Change the w$ to "Find" in your paste so you send it to the correct window.

Code: Select all

Delay(1000) : SendKeys(0,"Find","{CONTROLDOWN}v{CONTROLUP}") ; Paste.
Ah.. yes , works perfectly now .
Thanks !

Code: Select all

RunProgram("notepad.exe","","",0) 
w$="Untitled - Notepad" ; Specifies target window name. 
Delay(1000) : SendKeys(0,w$,"This is a test!") ; Type some dummy text. 
Delay(1000) : SendKeys(0,w$,"{CONTROLDOWN}a{CONTROLUP}") ; Select it all. 
Delay(1000) : SendKeys(0,w$,"{CONTROLDOWN}c{CONTROLUP}") ; Copy. 
Delay(1000) : SendKeys(0,w$,"{CONTROLDOWN}f{CONTROLUP}") ; Find. 

Delay(1000) : SendKeys(0,"Find","{CONTROLDOWN}v{CONTROLUP}") ; Paste. 
w$="Untitled - Notepad" ; Specifies target window name. 

;Delay(1000) : SendKeys(0,w$,"{DELETE}")      ; Delete it. 
;Delay(1000) : SendKeys(0,w$,"{CONTROLDOWN}p{CONTROLUP}") 

Delay(1000) : SendKeys(0,w$,"This is a second test!") ; Type some dummy text. 

;Delay(1000) : SendKeys(0,w$,"{ALTDOWN}{F4}") ; Close the Notepad Window
vmars.us Win11 x64 , Martin Guitar 000-16 (1995)
"All things in moderation , except for love and forgiveness."
vmars316
Enthusiast
Enthusiast
Posts: 474
Joined: Fri Jun 29, 2012 12:24 am
Contact:

Re: RunProgram("c:notepad.exe","","",0) ?

Post by vmars316 »

Almost there:
In this last step
I want to Click the "Find Next" Button .
But have been unsuccessful so far .
Need help with this:

Code: Select all

RunProgram("C:\Windows\notepad.exe","C:\OpenNotepad\TextFile.txt","",0) 
w$="TextFile.txt - Notepad" ; Specifies target window name. 
Delay(1000) : SendKeys(0,w$,"{CONTROLDOWN}f{CONTROLUP}") ; Find. 
SetClipboardText(".txt") 
Delay(1000) : SendKeys(0,"Find","{CONTROLDOWN}v{CONTROLUP}") ; Paste. 
w$="TextFile.txt - Notepad" ; Specifies target window name. 
Delay(1000) : SendKeys(0,"Find","{CONTROLDOWN}ENTER{CONTROLUP}")      
Thanks
vmars.us Win11 x64 , Martin Guitar 000-16 (1995)
"All things in moderation , except for love and forgiveness."
sec
Enthusiast
Enthusiast
Posts: 792
Joined: Sat Aug 09, 2003 3:13 am
Location: 90-61-92 // EU or ASIA
Contact:

Re: RunProgram("c:notepad.exe","","",0) ?

Post by sec »

vmars316 wrote:Almost there:
In this last step
I want to Click the "Find Next" Button .
But have been unsuccessful so far .
Need help with this:

Code: Select all

RunProgram("C:\Windows\notepad.exe","C:\OpenNotepad\TextFile.txt","",0) 
w$="TextFile.txt - Notepad" ; Specifies target window name. 
Delay(1000) : SendKeys(0,w$,"{CONTROLDOWN}f{CONTROLUP}") ; Find. 
SetClipboardText(".txt") 
Delay(1000) : SendKeys(0,"Find","{CONTROLDOWN}v{CONTROLUP}") ; Paste. 
w$="TextFile.txt - Notepad" ; Specifies target window name. 
Delay(1000) : SendKeys(0,"Find","{CONTROLDOWN}ENTER{CONTROLUP}")      
Thanks
I guess that you need typing/feed some text before find them?
vmars316
Enthusiast
Enthusiast
Posts: 474
Joined: Fri Jun 29, 2012 12:24 am
Contact:

Re: RunProgram("c:notepad.exe","","",0) ?

Post by vmars316 »

I did try 2 lines of:
Delay(1000) : SendKeys(0,"Find","{CONTROLDOWN}ENTER{CONTROLUP}"
but that made no difference.
Here is the whole code
perhaps someone could give it a whirl :

Code: Select all

; German forum:
; Author: Danilo
; Date: 07. April 2003
; OS: Windows
; Demo: No


; Posted 07 April 2003 by Danilo on german forum

;SendKeys(handel,Window$,Keys$) 

;Handel ......... ist ein Handel zu einen Fenster bekommst du wenn du das Fenster erzeugst. 
;Window$ ........ Ist der Name des Fesnters, wenn du den Handel nicht kennst. In dem Fall gibt man dan Handel = 0 an. 
;Keys$ .......... Sind die Tasten die du schicken möchtest, wobei du Sondertasten in {} Einschliest (zb. {CONTROLDOWN}) 

; SendKeys procedure by PB -- do whatever you want with it. :) 
; Syntax: r=SendKeys(handle,window$,keys$) ; r = 0 for failure. 
; Specify either a handle or window$ title to type to, but not both! 
; You cannot type curly braces { } as part of the keystrokes, sorry! 
; 
Procedure SendKeys(handle,window$,keys$) 
If window$<>"" : handle=FindWindow_(0,window$) : EndIf ; Use window$ instead of handle. 
   If IsWindow_(handle)=0 ; Does the target window actually exist? 
      ProcedureReturn 0 ; Nope, so report 0 for failure to type. 
   Else 
   ; This block gives the target window the focus before typing. 
   thread1=GetWindowThreadProcessId_(GetForegroundWindow_(),0) 
   thread2=GetWindowThreadProcessId_(handle,0) 
   If thread1<>thread2 : AttachThreadInput_(thread1,thread2,#True) : EndIf 
      SetForegroundWindow_(handle) ; Target window now has the focus for typing. 
      Delay(125) ; 1/8 second pause before typing, to prevent fast CPU problems. 
      ; Now the actual typing starts. 
      For r=1 To Len(keys$) 
          vk$=Mid(keys$,r,1) 
          If vk$="{" ; Special key found. 
             s=FindString(keys$,"}",r+1)-(r+1) ; Get length of special key. 
             s$=Mid(keys$,r+1,s) ; Get special key name. 
             Select s$ ; Get virtual key code of special key. 
                Case "ALTDOWN" : keybd_event_(#VK_MENU,0,0,0) ; Hold ALT down. 
                Case "ALTUP" : keybd_event_(#VK_MENU,0,#KEYEVENTF_KEYUP,0) ; Release ALT. 
                Case "BACKSPACE" : vk=#VK_BACK 
                Case "CONTROLDOWN" : keybd_event_(#VK_CONTROL,0,0,0) ; Hold CONTROL down. 
                Case "CONTROLUP" : keybd_event_(#VK_CONTROL,0,#KEYEVENTF_KEYUP,0) ; Release CONTROL. 
                Case "DELETE" : vk=#VK_DELETE 
                Case "DOWN" : vk=#VK_DOWN 
                Case "END" : vk=#VK_END 
                Case "ENTER" : vk=#VK_RETURN 
                Case "F1" : vk=#VK_F1 
                Case "F2" : vk=#VK_F2 
                Case "F3" : vk=#VK_F3 
                Case "F4" : vk=#VK_F4 
                Case "F5" : vk=#VK_F5 
                Case "F6" : vk=#VK_F6 
                Case "F7" : vk=#VK_F7 
                Case "F8" : vk=#VK_F8 
                Case "F9" : vk=#VK_F9 
                Case "F10" : vk=#VK_F10 
                Case "F11" : vk=#VK_F11 
                Case "F12" : vk=#VK_F12 
                Case "ESCAPE" : vk=#VK_ESCAPE 
                Case "HOME" : vk=#VK_HOME 
                Case "INSERT" : vk=#VK_INSERT 
                Case "LEFT" : vk=#VK_LEFT 
                Case "PAGEDOWN" : vk=#VK_NEXT 
                Case "PAGEUP" : vk=#VK_PRIOR 
                Case "PRINTSCREEN" : vk=#VK_SNAPSHOT 
                Case "RETURN" : vk=#VK_RETURN 
                Case "RIGHT" : vk=#VK_RIGHT 
                Case "SHIFTDOWN" : shifted=1 : keybd_event_(#VK_SHIFT,0,0,0) ; Hold SHIFT down. 
                Case "SHIFTUP" : shifted=0 : keybd_event_(#VK_SHIFT,0,#KEYEVENTF_KEYUP,0) ; Release SHIFT. 
                Case "TAB" : vk=#VK_TAB 
                Case "UP" : vk=#VK_UP 
             EndSelect 
             If Left(s$,3)<>"ALT" And Left(s$,7)<>"CONTROL" And Left(s$,5)<>"SHIFT" 
                keybd_event_(vk,0,0,0) : keybd_event_(vk,0,#KEYEVENTF_KEYUP,0) ; Press the special key. 
             EndIf 
             r=r+s+1 ; Continue getting the keystrokes that follow the special key. 
          Else 
             vk=VkKeyScanEx_(Asc(vk$),GetKeyboardLayout_(0)) ; Normal key found. 
             If vk>304 And shifted=0 : keybd_event_(#VK_SHIFT,0,0,0) : EndIf ; Due to shifted character. 
             keybd_event_(vk,0,0,0) : keybd_event_(vk,0,#KEYEVENTF_KEYUP,0) ; Press the normal key. 
             If vk>304 And shifted=0 : keybd_event_(#VK_SHIFT,0,#KEYEVENTF_KEYUP,0) : EndIf ; Due to shifted character. 
          EndIf 
      Next 
      If thread1<>thread2 : AttachThreadInput_(thread1,thread2,#False) : EndIf ; Finished typing to target window! 
      keybd_event_(#VK_MENU,0,#KEYEVENTF_KEYUP,0) ; Release ALT key if user forgot. 
      keybd_event_(#VK_CONTROL,0,#KEYEVENTF_KEYUP,0) ; Release CONTROL key if user forgot. 
      keybd_event_(#VK_SHIFT,0,#KEYEVENTF_KEYUP,0) ; Release SHIFT key if user forgot. 
      ProcedureReturn 1 ; Report successful typing! :) 
   EndIf 
EndProcedure 
; 
m$= "This example types some text to Notepad, then clears and closes it."+Chr(13) 
m$=m$+"Open a new Notepad window, then click the OK button and watch! :)" 
;MessageRequester("SendKeys example",m$,#MB_ICONINFORMATION) 
; copy
RunProgram("C:\Windows\notepad.exe","C:\OpenNotepad\TextFile.txt","",0) 
w$="TextFile.txt - Notepad" ; Specifies target window name. 
Delay(1000) : SendKeys(0,w$,"{CONTROLDOWN}f{CONTROLUP}") ; Find. 
SetClipboardText(".txt") 
Delay(1000) : SendKeys(0,"Find","{CONTROLDOWN}v{CONTROLUP}") ; Paste. 
w$="TextFile.txt - Notepad" ; Specifies target window name. 
Delay(1000) : SendKeys(0,"Find","{CONTROLDOWN}ENTER{CONTROLUP}")     
Thanks

ALso: This code is basically 2003 code
I am wondering if there is a 2019 version of this program somewhere ?
Thanks
vmars.us Win11 x64 , Martin Guitar 000-16 (1995)
"All things in moderation , except for love and forgiveness."
BarryG
Addict
Addict
Posts: 4178
Joined: Thu Apr 18, 2019 8:17 am

Re: RunProgram("c:notepad.exe","","",0) ?

Post by BarryG »

vmars316 wrote:I want to Click the "Find Next" Button
Why click it? Just send F3 to the Notepad window (does the same thing).
vmars316
Enthusiast
Enthusiast
Posts: 474
Joined: Fri Jun 29, 2012 12:24 am
Contact:

Re: RunProgram("c:notepad.exe","","",0) ?

Post by vmars316 »

BarryG wrote:
vmars316 wrote:I want to Click the "Find Next" Button
Why click it? Just send F3 to the Notepad window (does the same thing).
Delay(1000) : SendKeys(0,"Find","{CONTROLDOWN}ENTER{CONTROLUP}")
Works manually , but doesn't work with SendKeys .

Delay(1000) : SendKeys(0,"Find","{CONTROLDOWN}F3{CONTROLUP}") ; Find.
Doesn't work manually , and doesn't work with SendKeys .

Thanks
vmars.us Win11 x64 , Martin Guitar 000-16 (1995)
"All things in moderation , except for love and forgiveness."
infratec
Always Here
Always Here
Posts: 7623
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: RunProgram("c:notepad.exe","","",0) ?

Post by infratec »

Hi,

this works for me.
But you have to change the german window names :wink:

Code: Select all

EnableExplicit

; German forum:
; Author: Danilo
; Date: 07. April 2003
; OS: Windows
; Demo: No



Procedure keybd_event(VK.i, D1.i, Flag.i, D2.i)
  
  Protected Dim SendInputData.INPUT(1)
  
  SendInputData(0)\type = #INPUT_KEYBOARD
  SendInputData(0)\ki\dwFlags = Flag
  SendInputData(0)\ki\wVK = VK
  
  SendInput_(1, @SendInputData(0), SizeOf(INPUT))
  
EndProcedure


; Posted 07 April 2003 by Danilo on german forum

;SendKeys(handel,Window$,Keys$) 

;Handel ......... ist ein Handel zu einen Fenster bekommst du wenn du das Fenster erzeugst. 
;Window$ ........ Ist der Name des Fesnters, wenn du den Handel nicht kennst. In dem Fall gibt man dan Handel = 0 an. 
;Keys$ .......... Sind die Tasten die du schicken möchtest, wobei du Sondertasten in {} Einschliest (zb. {CONTROLDOWN}) 

; SendKeys procedure by PB -- do whatever you want with it. :) 
; Syntax: r=SendKeys(handle,window$,keys$) ; r = 0 for failure. 
; Specify either a handle or window$ title to type to, but not both! 
; You cannot type curly braces { } as part of the keystrokes, sorry! 
; 
Procedure SendKeys(handle.i, window$, keys$)
  
  Protected.i s, thread1, thread2, r, vk, shifted, Result, KeyLen
  Protected s$, vk$
  
  ; Use window$ instead of handle. 
  If window$ <> ""
    handle = FindWindow_(0, window$)
  EndIf
  
  If IsWindow_(handle)                                 ; Does the target window actually exist?
                                                       ; This block gives the target window the focus before typing.
    thread1 = GetWindowThreadProcessId_(GetForegroundWindow_(), 0)
    thread2 = GetWindowThreadProcessId_(handle, 0)
    If thread1 <> thread2
      AttachThreadInput_(thread1, thread2, #True)
    EndIf
    
    SetForegroundWindow_(handle) ; Target window now has the focus for typing.
    Delay(125)                   ; 1/8 second pause before typing, to prevent fast CPU problems.
                                 ; Now the actual typing starts.
    KeyLen = Len(keys$)
    For r = 1 To KeyLen
      vk$ = Mid(keys$, r, 1)
      If vk$ = "{" ; Special key found.
        s = FindString(keys$, "}", r + 1) - (r + 1) ; Get length of special key.
        s$ = Mid(keys$, r + 1, s)               ; Get special key name.
        Select s$                         ; Get virtual key code of special key.
          Case "ALTDOWN" : keybd_event(#VK_MENU, 0, 0, 0) ; Hold ALT down.
          Case "ALTUP" : keybd_event(#VK_MENU, 0, #KEYEVENTF_KEYUP, 0) ; Release ALT.
          Case "BACKSPACE" : vk = #VK_BACK
          Case "CONTROLDOWN" : keybd_event(#VK_CONTROL, 0, 0, 0) ; Hold CONTROL down.
          Case "CONTROLUP" : keybd_event(#VK_CONTROL, 0, #KEYEVENTF_KEYUP, 0) ; Release CONTROL.
          Case "DELETE" : vk = #VK_DELETE
          Case "DOWN" : vk = #VK_DOWN
          Case "END" : vk = #VK_END
          Case "ENTER" : vk = #VK_RETURN
          Case "F1" : vk = #VK_F1
          Case "F2" : vk = #VK_F2
          Case "F3" : vk = #VK_F3
          Case "F4" : vk = #VK_F4
          Case "F5" : vk = #VK_F5
          Case "F6" : vk = #VK_F6
          Case "F7" : vk = #VK_F7
          Case "F8" : vk = #VK_F8
          Case "F9" : vk = #VK_F9
          Case "F10" : vk = #VK_F10
          Case "F11" : vk = #VK_F11
          Case "F12" : vk = #VK_F12
          Case "ESCAPE" : vk = #VK_ESCAPE
          Case "HOME" : vk = #VK_HOME
          Case "INSERT" : vk = #VK_INSERT
          Case "LEFT" : vk = #VK_LEFT
          Case "PAGEDOWN" : vk = #VK_NEXT
          Case "PAGEUP" : vk = #VK_PRIOR
          Case "PRINTSCREEN" : vk = #VK_SNAPSHOT
          Case "RETURN" : vk = #VK_RETURN
          Case "RIGHT" : vk = #VK_RIGHT
          Case "SHIFTDOWN" : shifted = #True : keybd_event(#VK_SHIFT, 0, 0, 0) ; Hold SHIFT down.
          Case "SHIFTUP" : shifted = #False : keybd_event(#VK_SHIFT, 0, #KEYEVENTF_KEYUP, 0) ; Release SHIFT.
          Case "TAB" : vk = #VK_TAB
          Case "UP" : vk = #VK_UP
        EndSelect
        
        If Left(s$, 3) <> "ALT" And Left(s$, 7) <> "CONTROL" And Left(s$, 5) <> "SHIFT"
          keybd_event(vk, 0, 0, 0)
          keybd_event(vk, 0, #KEYEVENTF_KEYUP, 0)
        EndIf 
        r = r + s + 1 ; Continue getting the keystrokes that follow the special key. 
        
      Else
        
        vk = VkKeyScanEx_(Asc(vk$), GetKeyboardLayout_(0)) ; Normal key found.
        If vk > 304 And Not shifted ; Due to shifted character.
          keybd_event(#VK_SHIFT, 0, 0, 0)
        EndIf
        
        keybd_event(vk, 0, 0, 0)
        keybd_event(vk, 0, #KEYEVENTF_KEYUP, 0)  ; Press the normal key.
        
        If vk > 304 And Not shifted ; Due to shifted character.
          keybd_event(#VK_SHIFT, 0, #KEYEVENTF_KEYUP, 0)
        EndIf
        
      EndIf
    Next
    
    ; Finished typing to target window! 
    If thread1 <> thread2
      AttachThreadInput_(thread1, thread2, #False)
    EndIf
    
    keybd_event(#VK_MENU, 0, #KEYEVENTF_KEYUP, 0)     ; Release ALT key if user forgot. 
    keybd_event(#VK_CONTROL, 0, #KEYEVENTF_KEYUP, 0)  ; Release CONTROL key if user forgot. 
    keybd_event(#VK_SHIFT, 0, #KEYEVENTF_KEYUP, 0)    ; Release SHIFT key if user forgot. 
    Result = #True                                     ; Report successful typing! :) 
  EndIf 
  
  ProcedureReturn Result
  
EndProcedure


Define m$, w$

m$= "This example types some text to Notepad, then clears and closes it."+Chr(13) 
m$=m$+"Open a new Notepad window, then click the OK button and watch! :)" 
MessageRequester("SendKeys example",m$,#MB_ICONINFORMATION) 
; 
RunProgram("notepad.exe", "", "", 0)
w$="Unbenannt - Editor" ; Specifies target window name. 
Delay(1000) : SendKeys(0,w$,"This is a test!") ; Type some dummy text. 
Delay(1000) : SendKeys(0,w$,"{CONTROLDOWN}f{CONTROLUP}")
Delay(1000) : SendKeys(0,"Suchen","{ENTER}") ; Select it all. 
Why you use ctlr with enter for search?
vmars316
Enthusiast
Enthusiast
Posts: 474
Joined: Fri Jun 29, 2012 12:24 am
Contact:

Re: RunProgram("c:notepad.exe","","",0) ?

Post by vmars316 »

infratec ,
With this code
it runs fine & even appears to have clicked ENTER .

Code: Select all

RunProgram("C:\Windows\notepad.exe", "", "", 0)
w$="Untitled - Notepad" ; Specifies target WINDOW NAME . 
Delay(1000) : SendKeys(0,w$,"This is a test!") ; Type some dummy text. 
Delay(1000) : SendKeys(0,w$,"{CONTROLDOWN}f{CONTROLUP}")
Delay(1000) : SendKeys(0,"Find","{ENTER}") ; Select it all. 
With this code it runs fine ,
Even pastes ".txt" into "Find" Window .
And APPEARS to hit "ENTER" , TWICE ,
But doesn't actually Find anything .
That's the problem I need help with .
Please run my code & you will see what I mean .

Code: Select all

RunProgram("C:\Windows\notepad.exe","C:\OpenNotepad\TextFile.txt","",0) 
w$="TextFile.txt - Notepad" ; Specifies target window name. 
Delay(1000) : SendKeys(0,w$,"{CONTROLDOWN}f{CONTROLUP}") ; Find. 
SetClipboardText(".txt") 
Delay(1000) : SendKeys(0,"Find","{CONTROLDOWN}v{CONTROLUP}") ; Paste. 
w$="TextFile.txt - Notepad" ; Specifies target window name. 
Delay(1000) : SendKeys(0,"Find","{CONTROLDOWN}ENTER{CONTROLUP}")     
Delay(1000) : SendKeys(0,"Find","{CONTROLDOWN}F3{CONTROLUP}") ; Find. 
Thanks
vmars.us Win11 x64 , Martin Guitar 000-16 (1995)
"All things in moderation , except for love and forgiveness."
infratec
Always Here
Always Here
Posts: 7623
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: RunProgram("c:notepad.exe","","",0) ?

Post by infratec »

You ignore what I write
Why you use ctlr with enter for search?
And you don't think about what you are doing.
Where is the cursor when your text is opened?
I which direction do you searching?

Use this:

Code: Select all

Delay(1000) : SendKeys(0,w$,"This is a test!") ; Type some dummy text.
Delay(200) : SendKeys(0,w$,"{CONTROLDOWN}{HOME}{CONTROLUP}")
Delay(1000) : SendKeys(0,w$,"{CONTROLDOWN}f{CONTROLUP}")
Delay(1000) : SendKeys(0,"Suchen","{ENTER}") ; Select it all. 
vmars316
Enthusiast
Enthusiast
Posts: 474
Joined: Fri Jun 29, 2012 12:24 am
Contact:

Re: RunProgram("c:notepad.exe","","",0) ?

Post by vmars316 »

Oh , I missed that , I see now :
My apologies , it does work with this :

Code: Select all

RunProgram("C:\Windows\notepad.exe","C:\OpenNotepad\TextFile.txt","",0) 
w$="TextFile.txt - Notepad" ; Specifies target window name. 
Delay(1000) : SendKeys(0,w$,"{CONTROLDOWN}f{CONTROLUP}") ; Find. 
SetClipboardText(".txt") 
Delay(1000) : SendKeys(0,"Find","{CONTROLDOWN}v{CONTROLUP}") ; Paste. 
w$="TextFile.txt - Notepad" ; Specifies target window name. 
Delay(1000) : SendKeys(0,"Find","{ENTER}")     
Thank you very much !!!
vmars.us Win11 x64 , Martin Guitar 000-16 (1995)
"All things in moderation , except for love and forgiveness."
Post Reply