Sign in to follow this  
Followers 0
steve20020

WinActivate ($My program)

7 posts in this topic

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

Share this post


Link to post
Share on other sites



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._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

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 :( 

Share this post


Link to post
Share on other sites

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._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

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
1 person likes this

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.")

Share this post


Link to post
Share on other sites

Many thanks for the responses :) it turned out that when I switched my computer back on and tried it again it worked  :ermm:  (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 

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0