Jump to content

I can't figure this out


 Share

Recommended Posts

Hay, I love the GUI idea so i started to look into it. I was reading through the help file and i found like 7 different ways to accept button imputs and some things close it and somethings dont close it but dont work. SO CONFUSING! :ph34r: .... I just wanted a stright forward solution. All I wanted to do for my first project is just create a test program that would control the WMP (windows media player). I got the GUI creation down but I can't figure out for the life of me how to make it say open after the button was clicked. I just want the user to my able to click a button, say next, and it would send the next command to WMP, but not exit just stay open :(. Heres was I ended up with and it doesn't even work :">

Opt("GuiNotifyMode",1)
GUICreate ( "Controller", 150, 100)
GUICreateEx ( "", 0x4B73AA)
$ntest = GUISetControl ( "Button", "Test", 20, 70) 
GUIShow() 
GuiWaitClose ()
if GuiRead () = $ntest then

    send( "{VOLUME_MUTE}")
Endif

Sry for being so nubish at the GUI part but I just dont understand the help file

Edited by DarkNecromancer
Link to comment
Share on other sites

I am usually against the use of Wizards like the CyberSlug's one. Using them will allow only their user to understand something.

If you do not want to close you GUI after clicking... don't leave the script :ph34r:

This way use your idea and it uses few CPU cycles since it just wait that you press something.But GuiWaitClose is a 'stoping' func like msgboxes, so the script will not execute hotkeys func, adblib func until the GUIWaitClose pass...

Opt("GuiNotifyMode",1)
GUICreate ( "Controller", 150, 100)
GUICreateEx ( "", 0x4B73AA)
$ntest = GUISetControl ( "Button", "Test", 20, 70) 
GUIShow() 
While 1

   GuiWaitClose ();This command wait that a button is pressed.
   if GuiRead () = -3 then Exitloop;if the user clicked the 'Cross' the script leave.

  ;Otherwise it checks what as been pressed.
   if GuiRead () = $ntest then
      send( "{VOLUME_MUTE}")
   Endif

  ;You can add here the check for any other controls...
WEnd
 ;You can add here any 'just before leave' action
Exit

This other instead, will check always is something happen, it is a little 'heavier' but it allows the use of hotkeys, Adlib functions and such.

Opt("GuiNotifyMode",1)
GUICreate ( "Controller", 150, 100)
GUICreateEx ( "", 0x4B73AA)
$ntest = GUISetControl ( "Button", "Test", 20, 70) 
GUIShow() 
While 1
   Sleep(100)
   $msg = GUIMsg(0)
   
   If $msg = 0 Then Continueloop;If nothing happened it just restart the loop
   if $msg = -3 then Exit;if the user clicked the 'Cross' the script leave.

  ;Otherwise it checks what as been pressed.
   if $msg = $ntest then
      send( "{VOLUME_MUTE}")
   Endif

  ;You can add here the check for any other controls...
WEnd
 ;You can add here any 'just before leave' action
Exit

A last advice is using a Select/Case instead of a following of If/Then so the computer will check what has been pressed only once.

Edited by ezzetabi
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...