Jump to content

WinActivate with variables?


heyhey
 Share

Recommended Posts

HotKeySet("!k","openmsn")
HotKeySet("!t","stopitunes")
While 1 
    Sleep(100)
WEnd 
Func openmsn()
    WinActivate ("Windows Live Messenger")
EndFunc
Func stopitunes()
    $title=WinGetTitle("[active]")
    WinActivate("iTunes")
    Send("{SPACE}")
    Sleep(100)
    WinActivate("$title")
    If WinActive("$title") Then
        MsgBox(0,"","Window is active again")
    EndIf
EndFunc

I'm attempting to make a script myself that opens itunes, pauses itunes (with spacebar) and then goes back to the previous window.

Everything works but it won't go back to the previous window.

If you don't understand how I attempted to do this , this was my plan:

1. Saving the current active window using $tile=WinGetTitle("[Active]")

2. Activate itunes, pause iTunes.

3. Activate the previous active window using $title again

Does anybody know what I did wrong?

Thank you.

Edited by heyhey
Link to comment
Share on other sites

  • Moderators

heyhey,

You do not need quotes ("") around variables - just use: ;)

WinActivate($title)
If WinActive($title)

M23

P.S. How is the function interrupt code comimg along? :)

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 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

 

Link to comment
Share on other sites

Thanks,

RE:P.S : The function interrupt code is not in this script, but thank you for making that tutorial, I might even consider using it in this script also, but only when I have more functions than just itunes pause and openmsn :)

EDIT: Does anyone know how to do this when watching youtube fullscreen?

Like it goes back to fullscreen, just wondering if that is possible?

Edited by heyhey
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...