Jump to content

Recommended Posts

Posted (edited)

#include <GUIConstants.au3>

GUICreate("My GUI Button")


GUICtrlCreateButton ("OK",  10, 30, 50,40,$bs_pushlike)


GUISetState ()


While 1
    $msg = GUIGetMsg()
    
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend

while i hover the mouse over the button, the border of the button changes to an orange color,

i click the button, and the border changes to blue. this is not what i want though...

i want a button, that i can turn music on and off with.

that looks like a REAL BUTTON. where when you click it, the button changes from appearing to be pressed, and sunken.. to appearing to be unpressed and raised.

there is a style that appears this way, i believe.

i thought that $bs_pushlike was the thing to use, maybe im using it wrong????

Edited by t0ddie

Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.

Posted

ahh yes, now that i read more closely, the help file mentions that it only works with the checkboxes.

ty

Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.

Posted

how can i make the button start out as pushed?

and i need to play a .wav while its pushed down, and stop playing when it is clicked again (unpushed)

Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.

Posted

Global $checkmusic

$GUI = GUICreate("testing", 510, 390)
$music = GUICtrlCreateCheckbox ("music ON",  449, 24, 60,20,$bs_pushlike)
guictrlsetstate($music,$GUI_CHECKED)

GUISetState()

$msg = 0
While $msg <> $GUI_EVENT_CLOSE
   $msg = GUIGetMsg()
      $checkmusic = guictrlgetstate($music)

   Select
      
  Case $msg = $music
      If $checkmusic = 80 Then
          guictrlsetstate($music,$GUI_UNCHECKED)
          guictrlsetdata($music,"music OFF")
      Else
              guictrlsetstate($music,$GUI_CHECKED)
                    guictrlsetdata($music,"music ON")
                  EndIf
endselect
wend

i checked with a message box, and the value of the button when checked, is 80. so why isnt this working?

Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.

Posted

#include <GUIConstants.au3>
Global $checkmusic
$toggle = 1

$GUI = GUICreate("testing", 510, 390)
$music = GUICtrlCreateCheckbox ("music ON",  449, 24, 60,20,$bs_pushlike)
guictrlsetstate($music,$GUI_CHECKED)

GUISetState()

$msg = 0
While $msg <> $GUI_EVENT_CLOSE
   $msg = GUIGetMsg()
   $checkmusic = guictrlgetstate($music)

   Select
      
  Case $msg = $music
      If $checkmusic = 80 and $toggle=1 Then
        guictrlsetstate($music,$GUI_UNCHECKED)
        guictrlsetdata($music,"music OFF")
        $toggle=0
    Else
        guictrlsetstate($music,$GUI_CHECKED)
        guictrlsetdata($music,"music ON")
        $toggle=1
    EndIf
endselect
wend

Ok the above code is yours but ive added a toggle switch / probably a better way to do this..but its late..

Basically , your test of the state was returning 80 correctly, but you were testing the control (which of course exists=80) but not whether its on or off (hence the toggle)

This now works

hth

HardCopy

Contributions: UDF _DateYearFirstChildren are like Farts, you can just about stand your own.Why am I not a Vegetarian?...Well...my ancestors didn't fight & evolve to the Top of the food chain for me to survive on Salad

Posted (edited)

Use GUICtrlRead('checkbox') to determine what state it is at, $GUI_CHECKED or $GUI_UNCHECKED. Check 'GUICtrlSetState' in the help file and look at the state table.

Edit:

#include <GUIConstants.au3>

$GUI = GUICreate("Testing", 510, 390)
$Music = GUICtrlCreateCheckbox ("Music ON",  449, 24, 60,20,$bs_pushlike)

GUISetState()

While 1
   $msg = GUIGetMsg()
   Select
      Case $msg = $GUI_EVENT_CLOSE 
         Exit
      Case $msg = $Music      
         If GUICtrlRead($CheckMusic) = $GUI_UNCHECKED Then
            GUICtrlSetData($Music,"Music OFF")
         ElseIf GUICtrlRead($CheckMusic) = $GUI_CHECKED Then
            GUICtrlSetData($Music,"Music ON")
         EndIf
   EndSelect
Wend
Edited by Burrup

qq

Posted (edited)

looks good.

now with the soundplay....

should i do something like this?

Case $msg = $GUI_EVENT_CLOSE
         Exit
      Case $msg = $Music      
         If GUICtrlRead($CheckMusic) = $GUI_UNCHECKED Then
processclose("music.exe")
            GUICtrlSetData($Music,"Music OFF")
         ElseIf GUICtrlRead($CheckMusic) = $GUI_CHECKED Then
run ("music.exe")
            GUICtrlSetData($Music,"Music ON")
         EndIf
   EndSelect
Wend

music.exe

soundplay("music.wav",1)

is there a more practical way to do this? is there a way to force a command to pause? (for pausing soundplay or possibly some other command, instead of stopping it and starting it over from the beginning when you turn it back on.)

edit: typos

Edited by t0ddie

Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.

Posted (edited)

alrighty then. this workaround i have will do, heh. i dont want to study! its summer man.. even though im WAY out of highschool lol

one more question without posting a new thread.

$current = _GUICtrlTabGetCursel ($tab)
   If $var1 = 0 And $current = 0 Then
      GUICtrlSetState($d1, $GUI_FOCUS)
   EndIf

$d1 is the control input

$var1 is the amount of characters in the control input

and basically what i am doing here, is keeping the cursor on that input if it is on the first tab, and until something is typed into it, because when you click on other places in the gui the cursor dissappears from the input. (loses focus)

so sometimes when you arent looking at the monitor, and your typing.. then you look up and nothing was typed because you lost focus accidentally, its pretty frustrating.

the problem i am having, is that i have buttons that i would like to be able to use while that cursor is still on the control input. and i cant use them, because the focus is on the control input and the buttons do not work.

so i would more or less, (without CLICKING) like to keep the cursor on the control input, and not neccissarily keep any focus on it.

possible?

Edited by t0ddie

Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.

Posted (edited)

the way that burrup suggested will keep running the program over and over.

but i didnt mention really that i would be running another program.

well hardcopy, your suggestion is what i need, because i need to run another program when the toggle is 1

but when i click the button the first time it does nothing.

then it works from the 2nd click on.

why is that?

Edited by t0ddie

Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.

Posted (edited)

Searched forums and done some poking at MSDN and yeilded this which should help you...

http://msdn.microsoft.com/library/default....2_status_mm.asp

$sFile = FileOpenDialog("Please select file", "", "Audio Files(*.mp3;*.mp2;*.mpa;*.wav)", 4)

MCISendString("Open " & '"' & $sFile & '"' & " alias MediaFile"); open file
MCISendString("Set MediaFile Time Format ms"); set time format is milliseconds
MCISendString("Play MediaFile"); play from start to end

;MCISendString("Play MediaFile From 0 to 5000 Notify"); continue script whileplaying
;MCISendString("Play MediaFile From 0 to 5000 Wait"); Wait till song finished before continuing
;From/To means you can start and end the file at any position.

Sleep(5000)
MCISendString("Pause MediaFile"); Pause
Sleep(1000)
MCISendString("Play MediaFile"); plays from current/last position.
Sleep(1000)
MCISendString("Stop MediaFile"); stop playing
MCISendString("Close MediaFile"); close file

Func MCISendString($string)
   Local $Ret = DllCall("winmm.dll", "int", "mciSendString", "str", _
                        $string, "str", "", "int", 65534, "hwnd", 0)
   If Not @Error Then Return $Ret[2]
EndFunc
Edited by Burrup

qq

Posted

the way that burrup suggested will keep running the program over and over.

but i didnt mention really that i would be running another program.

well hardcopy, your suggestion is what i need, because i need to run another program when the toggle is 1

but when i click the button the first time it does nothing.

then it works from the 2nd click on.

why is that?

<{POST_SNAPBACK}>

:evil: Have u declared the toggle variable as = 1 at the start of your code ? if declared as 0 or "" then whis would show the odd behaviour u experience. the code i pasted here works ok for me.

hth

HardCopy :)

Contributions: UDF _DateYearFirstChildren are like Farts, you can just about stand your own.Why am I not a Vegetarian?...Well...my ancestors didn't fight & evolve to the Top of the food chain for me to survive on Salad

Posted

:evil:  Have u declared the toggle variable as = 1 at the start of your code ? if declared as 0 or "" then whis would show the odd behaviour u experience. the code i pasted here works ok for me.

hth

HardCopy    :)

<{POST_SNAPBACK}>

yes actually. because i want it to start with the music on, heh

Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.

Posted

so, is there way to start it with the music on, and make the toggle work right?

Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.

Posted

#include <GUIConstants.au3>

GUICreate("My GUI Checkbox")

$checkCN = GUICtrlCreateCheckbox ("Music ON", 10, 10, 120, 20)
GUICtrlSetState ($checkCN, $GUI_CHECKED)
GUISetState ()

While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend

qq

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
  • Recently Browsing   0 members

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