steve20020 Posted July 11, 2013 Share Posted July 11, 2013 Hi All I am trying to pass a variable to WinActivate and it is not working could someone please explain why this would be.. $myProgram = "notepad" WinActivate ($myProgram) Send ("It worked") Thanks in advance Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 11, 2013 Moderators Share Posted July 11, 2013 steve20020,Is the title of the GUI literally "notepad"? I rather doubt it. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
steve20020 Posted July 11, 2013 Author Share Posted July 11, 2013 Hi Melba23 no sorry its "Untitled - Notepad" I used AU3 to get the title and copied and pasted it.. but it still does not work Link to comment Share on other sites More sharing options...
0xdefea7 Posted July 11, 2013 Share Posted July 11, 2013 Check this out: http://www.autoitscript.com/autoit3/docs/intro/windowsadvanced.htm steve20020 1 Link to comment Share on other sites More sharing options...
Moderators Solution Melba23 Posted July 11, 2013 Moderators Solution Share Posted July 11, 2013 steve20020, Personally I would try to get the handle of the Notepad GUI like this: $hNotepad_Handle = WinGetHandle("[CLASS:Notepad]") WinActivate($hNotepad_Handle) Get the handle once and then you can use it whenever you need. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Queener Posted July 11, 2013 Share Posted July 11, 2013 I no longer use notepad as notepad++ is the best. You can do some changes in these. #RequireAdmin is not needed, but I always like to use that. #RequireAdmin GOHERE() Func GOHERE() if WinExists("new 1 - Notepad++") Then sleep(500) WinActive("new 1 - Notepad++") send( "Test") Exit Else GOTHERE() EndIf EndFunc Func GOTHERE() Run("notepad.exe") sleep(500) WinActive("new 1 - Notepad++") send("test") Exit EndFunc steve20020 1 Msgbox(0, "Hate", "Just hate it when I post a question and find my own answer after a couple tries. But if I don't post the question, I can't seem to resolve it at all.") Link to comment Share on other sites More sharing options...
steve20020 Posted July 12, 2013 Author Share Posted July 12, 2013 Many thanks for the responses it turned out that when I switched my computer back on and tried it again it worked (classic case of switch it off and back on again). M23, thank you for that I will use WinGetHandle from now on asianqueen, I like the errorhandling I'm liking notepadd++ too much better, thank you Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now