Jump to content

M23's interrupting topic, need help understanding


heyhey
 Share

Recommended Posts

  • Moderators

heyhey,

You have no loops to interrupt! :)

What exactly are you trying to do here? It looks to me as if a simple HotKey would be all you need - no GUIs required: :idiot:

; Set a HotKey to do what you want
HotKeySet("^q", "Interrupt")
; And another to exit
HotKeySet("{ESC}", "On_Exit")

; Keep the script alive
While 1
    Sleep(10)
WEnd

; When we press the HotKey we run this
Func Interrupt()

    stopitunes()
    teamspeak()
    openmsn()

EndFunc

Func stopitunes()
    $title = WinGetTitle("[active]")
    WinActivate("iTunes")
    Send("{SPACE}")
    Sleep(100)
    WinActivate($title)
EndFunc   ;==>stopitunes

Func teamspeak()
    Global $enable = 0
    If ProcessExists("ts3client_win64.exe") Then $enable = 1
    If $enable = 0 Then
        Run("C:\Program Files\TeamSpeak 3 Client\ts3client_win64")
        Sleep(1000)
        WinActivate("Teamspeak 3")
        Send("^s")
        Send("{ENTER}")
        Sleep(1000)
        Send("{ENTER}")
    EndIf
    If $enable = 1 Then
        MsgBox(0, "Error", "Je teamspeak staat al open.")
    EndIf
EndFunc   ;==>teamspeak

Func openmsn()
    WinActivate("Live")
EndFunc   ;==>openmsn

; And this lets us exit gracefully
Func On_Exit()
    Exit
EndFunc

You might want to check the various windows are activated before sending or you could get some nasty surprises. :idiot:

Does that work for you? ;)

M23

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

I just want it to be using a GUI , since I'm still just learning to script, this program isn't meant to be usefull to me nayways

EDIT : the meaning of this program = when I'm for example on youtube, and I want to stop my music to listen to the commentary , I press control+E to pause my itunes,

your script deleted that :)

Thanks anyways.

Edited by heyhey
Link to comment
Share on other sites

  • Moderators

heyhey,

Then look at this:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Opt("WinTitleMatchMode", 2)

$hgui = GUICreate("Boyenn's pc bot",100,200,@DesktopWidth / 2 , @DesktopHeight / 2)
$button1 = GUICtrlCreateButton("Start",0,0,100,100)
$button2 = GUICtrlCreateButton("Exit",0,100,100,100)
GUISetState()

While 1
    Switch GUIGetMsg()
    case $button1
        button1()
    Case $button2
        button2()
    EndSwitch
WEnd

Func button1()
    stopitunes()
    teamspeak()
    openmsn()
EndFunc

Func stopitunes()
    $title = WinGetTitle("[active]")
    WinActivate("iTunes")
    ;Send("{SPACE}")
    Sleep(100)
    WinActivate($title)
EndFunc   ;==>stopitunes

Func teamspeak()
    Global $enable = 0
    If ProcessExists("ts3client_win64.exe") Then $enable = 1
    If $enable = 0 Then
        Run("C:\Program Files\TeamSpeak 3 Client\ts3client_win64")
        Sleep(1000)
        WinActivate("Teamspeak 3")
        Send("^s")
        ;Send("{ENTER}")
        Sleep(1000)
        ;Send("{ENTER}")
    EndIf
    If $enable = 1 Then
        MsgBox(0, "Error", "Je teamspeak staat al open.")
    EndIf
EndFunc   ;==>teamspeak

Func openmsn()
    WinActivate("Live")
EndFunc   ;==>openmsn

; And this lets us exit gracefully
Func button2()
    Exit
EndFunc

I disabled the Send commands because if the other windows were not activated (and on my system they would not be) the SPACE and ENTER keys fire the focused button on the GUI so we end up in an eternal series of button presses! I told you that checking if the correct window was active was a good idea! :)

M23

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

After checking your post rapidly, I don't think you understand my problem.

I'm trying to activate my programs using hotkeys, I would not press the hotkey if the program was open (except for teamspeak, but I did make a check active on that one)

Let me explain it totally:

the script is a script that is meant to run in the background and do a few functions, for example "open teamspeak, connect with server" or "open itunes, pause or resume, go back to previous windows" just to make stuff easyer.

The GUI was meant as a disabler for the script : so if I press the "pause button" , my hotkeys will stop starting the functions, but if I pressed start on the GUI again, it would enable the hotkeys again.

However, my GUI created on my own does not stop my hotkeys from pausing itunes / ...

Thank you.

Link to comment
Share on other sites

  • Developers

Yes , I did understand it , and I can see you used google translator :), it's not ik hebt but ik heb, grammar mistake that google makes :idiot:

Ik gebruik geen google translator en ben gewoon ook een nederlander.

Volgens mij is het in dit geval niet "ik heb" maar "je bebt", maar het kan zijn dat mijn gramatica wat roestig is.

ah het is de 2de "heb" waar het fout is.... "Shit Happens"

Jos

oh, en ik speel over het algemeen een serieus spel wanneer het over dit soort zaken gaat. Het is maar dat je het weet. ;)

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Moderators

heyhey,

The GUI was meant as a disabler for the script : so if I press the "pause button" , my hotkeys will stop starting the functions, but if I pressed start on the GUI again, it would enable the hotkeys again.

A light dawns! :)

Here you go! ;)

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

; Set HotKeys
HotKeySet("^b", "openmsn")
HotKeySet("^t", "stopitunes")
HotKeySet("^e", "teamspeak")

Opt("WinTitleMatchMode", 2)

$hgui = GUICreate("Boyenn's pc bot", 100, 200, @DesktopWidth / 2, @DesktopHeight / 2)
$button1 = GUICtrlCreateButton("Start", 0, 0, 100, 100)
$button2 = GUICtrlCreateButton("Pause", 0, 100, 100, 100)
GUISetState()

While 1
    Switch GUIGetMsg()
        Case $button1
            button1()
        Case $button2
            button2()
    EndSwitch
WEnd

Func button1()
    ; Set HotKeys
    HotKeySet("^b", "openmsn")
    HotKeySet("^t", "stopitunes")
    HotKeySet("^e", "teamspeak")
EndFunc   ;==>button1

Func button2()
    ; Clear HotKeys
    HotKeySet("^b")
    HotKeySet("^t")
    HotKeySet("^e")
EndFunc   ;==>button2

Func stopitunes()
    $title = WinGetTitle("[active]")
    WinActivate("iTunes")
    Send("{SPACE}")
    Sleep(100)
    WinActivate($title)
EndFunc   ;==>stopitunes
Func teamspeak()
    Global $enable = 0
    If ProcessExists("ts3client_win64.exe") Then $enable = 1
    If $enable = 0 Then
        Run("C:\Program Files\TeamSpeak 3 Client\ts3client_win64")
        Sleep(1000)
        WinActivate("Teamspeak 3")
        Send("^s")
        Send("{ENTER}")
        Sleep(1000)
        Send("{ENTER}")
    EndIf
    If $enable = 1 Then
        MsgBox(0, "Error", "Je teamspeak staat al open.")
    EndIf
EndFunc   ;==>teamspeak

Func openmsn()
    WinActivate("Live")
EndFunc   ;==>openmsn

M23

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 alot, that's (almost) exactly what I want !

One more thing , I tryed binding a hotkey to the button functions, as in, I can pause it both by clicking the button or hotkeypresses , hotkey did not do anything, any ideas why not? I just added them at the set hotkeys, and moved from Opt to GuiSetState above the variables, so the hotkey would have a declared variable, this didnt work though.

And also, when I run the script , and press a hotkey without pressing start, it will do the functions, is there any way I can put default = paused when starting the GUI?

And thank alot for the script you gave me, after reading it I understand alot more now :)

EDIT : I have fixed problem 2 now, after noticing that button 1 sets the hotkeys, it wasn't needed for me to have them at start, I feel so dumb for not seeing that before ;)

Edited by heyhey
Link to comment
Share on other sites

  • Moderators

heyhey,

Please post the code you tried - it makes it much easier to debug. :)

M23

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

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