WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Control Manager
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Problem automating Notepad

Keywords: 	 Problem Notepad cClickButton multiple windows same name

Question:

I am running through control manager tutorial. I attempted to add code that clicks the 'Save As' button. All was fine on the first run. When you attempt to run the code again, Notepad prompts you with a dialog, asking if your sure your want to overwrite, with a Yes and No button. This dialog has the same name ('Save As') as the other window....... How can I differentiate between the two windows???????

Answer:

Here is some sample code that may help.....
AddExtender("wwctl34I.dll")
;get process id of launched instance......
procid=Runshell("notepad.exe","","",@normal,@GETPROCID)
SendMenusTo("~Notepad","FileSaveAs")
WinWaitExist("Save As",5)
parentHwnd=DllHwnd("Save As")
editHwnd=cWndByID(parentHwnd,1152)
cSetEditText(editHwnd, "C:\Windows\Desktop\Test.txt")
saveasbutton=cWndByID(parentHwnd,1)
;Use 'other' method of pressing a button
cpostbutton(saveasbutton)

timedelay(1)
;Get a list of window ids associated with the process
list=WinitemProcid(procid,4,0)
count=ItemCount(list,@tab)
if count==3; found the 'save as overwrite' dialog
  confirmwin=ItemExtract(1,list,@tab)
  phwnd=DllHwnd(confirmwin)
  yesbutton=cWndByID(phwnd,6)
  cclickbutton(yesbutton)
endif

Exit


Article ID:   W14524
Filename:   Problem automating Notepad.txt
File Created: 2017:07:28:13:58:27
Last Updated: 2001:03:02:14:38:12