Steven P Posted yesterday at 09:52 AM Posted yesterday at 09:52 AM Good Morning, I have been using this to search for text in a text file, now I have been upgraded to windows 11 it doesn't work, and I can't work out what change to make. Looking for some guidance again, thanks! fnm: File name (including filepath) str: Text String delay: a delay, say 1000 mS Will open notepad and should perform a 'find' to jump to the text. It gets as far as 'find' to open the dialogue box but won't populate it or hit 'enter' to do the find, using sendkeys - which has always worked before. thanks for any help ;;To find text within a text file. ;;http://www.cadtutor.net/forum/showthread.php?102326-Open-text-file-and-jumping-to-a-line&p=694572#post694572 ; example command to call it (NotepadFind "C:\\Downloads\\test 123.txt" "findtext" 300) (defun NotepadFind (fnm str delay / obj) (vl-catch-all-apply (function (lambda () (setq obj (vlax-get-or-create-object "WScript.Shell")) (vlax-invoke obj 'Run (strcat "Notepad.exe \"" fnm "\"")) ;; or notepad++ if that is used. (setvar 'cmdecho 0) (command "_.delay" delay) ; Milliseconds. For BricsCAD users: (sleep delay) does not work. (setvar 'cmdecho 1) (vlax-invoke obj 'AppActivate "Notepad++") ; Title bar name of application. ++ for notepad++ but still works? (vlax-invoke obj 'SendKeys (strcat "^f" str "{ENTER}{ESC}")) ) ) ) (if obj (vlax-release-object obj)) ) Quote
JerryFiedler Posted 14 hours ago Posted 14 hours ago @Steven P Your function seems to work for me although I am not sure what you expect. I am using Windows 11 and BricsCAD Pro V25. When I run my test program which calls your routine: NotePad++ is opened with the test data file, the specified text is highlighted and the text is in the "find" dialog box. ( I had to click the binocular icon as the find dialog did not open on its own.) Are you expecting the "find" dialog box to open automatically? testdata.txt testNF.lsp Quote
mhupp Posted 12 hours ago Posted 12 hours ago in windows 11 they have two notepads now. think you will have to remove the app one to go back to the classic one. https://www.dedoimedo.com/computers/windows-11-notepad-classic.html 1 Quote
BIGAL Posted 12 hours ago Posted 12 hours ago (edited) Maybe have a look at the windows command findstr it will search a directory for a key word, I guess could open one at a time. findstr d2 d:/mylisps/*.lsp may be useful how I find old posts Edited 12 hours ago by BIGAL Quote
Steven P Posted 4 hours ago Author Posted 4 hours ago (edited) Thanks Jerry and BigAl, The main use I have for this one is when I want to edit a LISP file - pop up dialogue to select the routine, open the file in notepad, 'Find' which usually takes me to the LISP name in the file. The find dialogue all happens without me needing to press any buttons. BIgAl - handy but in this case I know the file name and location to go straight to it - handy later in life if I don't know what file I want though, thanks MHUPP - going to look into that this morning, saving the answer into my "make windows work right" file Undoing the alias as in the link was the trick (Start Menu - settings - Apps - Advanced App Settings - Alias), pinned the proper notepad to the task bar (not the new one, located in c:\windows\notepad.exe or c:\windows\system32\notepad32.exe), now to set the proper notepad as the default as it should be. Edited 3 hours ago by Steven P 1 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.