Sign in to follow this  
Followers 0
Possessed

need alittle help

12 posts in this topic

How do you get both the windows close button and your own buttons to work. it just does not want to work for me i am doing somthing wrong could someone give me an idea on what the code should look like?

Share this post


Link to post
Share on other sites



How do you get both the windows close button and your own buttons to work. it just does not want to work for me i am doing somthing wrong could someone give me an idea on what the code should look like?

Care to show some code?

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Please dont laugh at me I am still learning this stuff :) i want the windows close button and my button to work.

;Windows Live Tools
;Version: 1.0
;Developed by: Travis 
;-------------------------------
#include <GUIConstants.au3>

; Run the GUI until the dialog is closed
GUICreate("Windows Live Tools",256,480)  
GUISetState (@SW_SHOW)



;---------Button's-------------
Opt("GUIOnEventMode", 1)
$Status = GUICtrlCreateButton ("Status Spammer",  73, 220, 120)
GUICtrlSetOnEvent($Status, "Status")
While 1
    $msg = GUIGetMsg()
    
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend
;---------Func's---------------
  
func Status()
WinActivate("Windows Live Messenger")
$i = 0
Do
    send("{ALT}")
send("f")
send("m")
send("f");offline now
send("{ALT}")
send("f")
send("m")
send("o");online now
    $i = $i + 1
Until $i = 6
 EndFunc
Edited by Possessed

Share this post


Link to post
Share on other sites

Look at GUISetOnEvent() in the help file, you will see a remark there that says you can't use GUIGetMsg() with GUISetOnEvent or GUICtrlSetOnEvent.


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

heres a hint..

$Button1 = GUICtrlCreateButton("Exit", 192, 168, 73, 33, 0)
        GUICtrlSetFont(-1, 8, 400, 0, "Comic Sans MS")
        GUICtrlSetCursor ($Button1, 7)
        GUICtrlSetOnEvent(-1, "Terminate")

p.s: smoke loves to help people but he wont give it to you.. trust me i no :P:)

smoke i also got the time worken right xD i just got 2 set the alarms n setup stuff now :D

Share this post


Link to post
Share on other sites

heres a hint..

$Button1 = GUICtrlCreateButton("Exit", 192, 168, 73, 33, 0)
        GUICtrlSetFont(-1, 8, 400, 0, "Comic Sans MS")
        GUICtrlSetCursor ($Button1, 7)
        GUICtrlSetOnEvent(-1, "Terminate")

p.s: smoke loves to help people but he wont give it to you.. trust me i no :P:)

smoke i also got the time worken right xD i just got 2 set the alarms n setup stuff now :D

This did help alittle bit thank you but i still have the same problem but my windows exit button works but the button you gave me wont run. Any more ideas? like to redo the windows closeing code? so i can just pop in my func's and buttons with out worrying about the windows close not working.

Share this post


Link to post
Share on other sites

This did help alittle bit thank you but i still have the same problem but my windows exit button works but the button you gave me wont run. Any more ideas? like to redo the windows closeing code? so i can just pop in my func's and buttons with out worrying about the windows close not working.

Did you read what I wrote? If you did, what's the new code you are still having problems with?

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Did you read what I wrote? If you did, what's the new code you are still having problems with?

ya i am i have buggy eye from looking at the code for so long trying to find away i dont have problems with alot of things but this just dont want to work for me i must have things in the wrong place or somthing. Heres the updated code....

;Windows Live Tools
;Version: 1.0
;Developed by: Travis
;-------------------------------
#include <GUIConstants.au3>
GUISetOnEvent($GUI_EVENT_CLOSE, "Special")
GUICreate("Windows Live Tools",256,480)  
GUISetState (@SW_SHOW)

;---------Button's-------------
 $Button1 = GUICtrlCreateButton("Status Changer", 192, 168, 73, 33, 0)
        GUICtrlSetFont(-1, 8, 400, 0, "Comic Sans MS")
        GUICtrlSetCursor ($Button1, 0)
        GUICtrlSetOnEvent(-1, "Status")   

;---------Func's---------------
func Special()
    
    EndFunc
func Status()
WinActivate("Windows Live Messenger")
$i = 0
Do
    send("{ALT}")
send("f")
send("m")
send("f");offline now
send("{ALT}")
send("f")
send("m")
send("o");online now
    $i = $i + 1
Until $i = 6
 EndFunc


;Idleing the GUI
While 1
    Sleep(10)
Wend

Share this post


Link to post
Share on other sites

Try this instead...

;Windows Live Tools
;Version: 1.0
;Developed by: Travis
;-------------------------------
#include <GUIConstants.au3>
GUISetOnEvent($GUI_EVENT_CLOSE, "Special")
GUICreate("Windows Live Tools",256,480) 
GUISetState (@SW_SHOW)

;---------Button's-------------
$Button1 = GUICtrlCreateButton("Status Changer", 192, 168, 73, 33, 0)
        GUICtrlSetFont(-1, 8, 400, 0, "Comic Sans MS")
        GUICtrlSetCursor ($Button1, 0)
        GUICtrlSetOnEvent(-1, "Status")   

;Handling the GUI
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE ;Exit form GUI 
            Exitloop
        Case $msg = $Button1
            Status()
        Case Else
        ; Something else
    EndSelect
Wend

Exit
;---------Func's---------------
func Special()
   
EndFunc

func Status()
    WinActivate("Windows Live Messenger")
    $i = 0
    Do
        send("{ALT}fmf");offline now
        send("{ALT}fmo");online now
        $i = $i + 1
    Until $i = 6
EndFunc

> there are 10 types of people in the world, those who understand binary and those who don't.

Share this post


Link to post
Share on other sites

Okay... wow no one seems to be grasping exactly what his problem is except SmOke_N and I. Hrm.

Basically when creating a GUI you have two options...

  • OnEvent Mode
  • GetMsg Mode
You need to up front decide which you would prefer. Look them both up in the help file. Most people go with the GetMsg Mode as it is the default if you don't set your script to "OnEventMode".

So far all of your code has had a mixture. Trust me as SmOke has already pointed out, and it is clearly stated in the helpfile GetMsg Mode, and OnEvent Mode DO NOT work together! Dont mean to be to harsh, but you really need to read up, and help yourself.

I do understand you have probably been mulling over this code for quite some time, and that can get irritating, and you may think we have no clue what is going on, but we do. Please just take a break from the project for a minimum of 30 mins. Come back. Dont look at the code. Go straight to the helpfile, and read up on creating GUI's. It will help you immensly.

I personally use OnEventMode for most of my scripts. Below is some sample code that I always use as a template starting out on my GUI coding endeavors.

;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
;Program Name:  Template - OnEventMode
;Description:   Template for OnEventMode GUI scripts
;Filename:      Template - OnEventMode.au3
;Used With:     
;Created by:    Jarvis J Stubblefield (support "at" vortexrevolutions "dot" com)
;Created on:    06/20/2006
;Modified on:   
;Modified by:   
;Version:       0.0.2
;Copyright:     Copyright (C) 2006 Vortex Revolutions. All Rights Reserved.
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;---*** Declare Variables ***---
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

Global $wHeight, $wWidth, $wMain            ;Window variables
Global $wTitle                              ;Window variables II

;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;---*** Preprocessor ***---
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

#include <GUIConstants.au3>

Opt("GUIOnEventMode", 1) ;Set GUI to ONEvent Mode.

;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;---*** File Installations ***---
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;---*** Registry Information ***---
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;---*** Command Line Options ***---
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

#cs UNCOMMENT FOR COMMANDLINE!
If $CmdLine[0] > 0 Then
    If StringRight($CmdLine[1], 4) = ".ext" Then
        _SomeFunc($CmdLine[1])
    Else
        _ErrorMsg("Incorret file extension. Please try again.")
        _TerminateApp()
    EndIf
EndIf
#ce

;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;---*** Define Variables ***---
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

$wHeight = 300
$wWidth  = 300
$wTitle  = "Template - OnEventMode"

;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;---*** GUI Creation ***---
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

;Main GUI Creation
$wMain  = GUICreate($wTitle, $wWidth, $wHeight)
;Main Options
$btnMOptions    = GUICtrlCreateButton("Options", 5, ($wHeight - 25), 94, 20)
;Main Help
$btnMHelp       = GUICtrlCreateButton("Help", 103, ($wHeight - 25), 94, 20)
;Main Exit
$btnMExit       = GUICtrlCreateButton("Exit", 201, ($wHeight - 25), 94, 20)

;Disable Options and Help until added
GUICtrlSetState($btnMOptions, $GUI_DISABLE)
GUICtrlSetState($btnMHelp, $GUI_DISABLE)

;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;---*** GUI Set Events ***---
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

;GUI Events Handled by _GUIEventHandler()
GUICtrlSetOnEvent($btnMOptions, "_GUIEventHandler")
GUICtrlSetOnEvent($btnMExit, "_GUIEventHandler")
GUICtrlSetOnEvent($btnMHelp, "_GUIEventHandler")

;System Events Handled by _SysEventHandler()
GUISetOnEvent($GUI_EVENT_CLOSE, "_SysEventHandler", $m_HWnd)
GUISetOnEvent($GUI_EVENT_MINIMIZE, "_SysEventHandler", $m_HWnd)
GUISetOnEvent($GUI_EVENT_RESTORE, "_SysEventHandler", $m_HWnd)
GUISetOnEvent($GUI_EVENT_MAXIMIZE, "_SysEventHandler", $m_HWnd)
GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "_SysEventHandler", $m_HWnd)
GUISetOnEvent($GUI_EVENT_PRIMARYUP, "_SysEventHandler", $m_HWnd)
GUISetOnEvent($GUI_EVENT_SECONDARYDOWN, "_SysEventHandler", $m_HWnd)
GUISetOnEvent($GUI_EVENT_SECONDARYUP, "_SysEventHandler", $m_HWnd)
GUISetOnEvent($GUI_EVENT_MOUSEMOVE, "_SysEventHandler", $m_HWnd)
GUISetOnEvent($GUI_EVENT_RESIZED, "_SysEventHandler", $m_HWnd)
GUISetOnEvent($GUI_EVENT_DROPPED, "_SysEventHandler", $m_HWnd)

GUISetState(@SW_SHOW, $m_HWnd)

;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;---*** Main Program Loop ***---
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

While 1
    Sleep(100)
WEnd

;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;---*** GUI Event Functions ***---
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

Func _GUIEventHandler()
    Switch @GUI_CtrlId
        Case $btnMExit
            _TerminateApp()
        Case $btnMOptions
        Case $btnMHelp
    EndSwitch
EndFunc

Func _SysEventHandler()
    Switch @GUI_CtrlId
        Case $GUI_EVENT_CLOSE
            If @GUI_WinHandle <> $hGUI Then
                _TerminateGUI(@GUI_WinHandle)
            Else
                _TerminateApp()
            EndIf
        Case $GUI_EVENT_MINIMIZE
        Case $GUI_EVENT_RESTORE
        Case $GUI_EVENT_MAXIMIZE
        Case $GUI_EVENT_PRIMARYDOWN
        Case $GUI_EVENT_PRIMARYUP
        Case $GUI_EVENT_SECONDARYDOWN
        Case $GUI_EVENT_SECONDARYUP
        Case $GUI_EVENT_MOUSEMOVE
        Case $GUI_EVENT_RESIZED
        Case $GUI_EVENT_DROPPED
    EndSwitch
EndFunc

;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;---*** Define Functions ***---
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

#region --- Internal Functions
    ;Displays an error message to the user, and optionally times out.
    Func _ErrorMsg($message, $time = 0)
        MsgBox(48 + 262144, "Error!", $message, $time)
    EndFunc

    ;Function to be used to terminate the application. (Clean up Application)
    Func _TerminateApp()
        Exit
    EndFunc
    
    ;This function is to be used with programs that have multiple GUI's and
    ;will optionally terminate application if called incorrectly on the main
    ;GUI.
    Func _TerminateGUI($gui_hWnd, $gui_title = "")
        If $gui_title = "" Then $gui_title = $wTitle
        GUIDelete($gui_hWnd)
        If $gui_hWnd = $wMain Then
            _TerminateApp()
        Else
            WinActivate($gui_title)
        EndIf
    EndFunc
#endregion Internal Functions

You should be able to put your code in there if you decide to go that route. If not then take another break, and read more on the helpfile.

If you dont understand how the above code works then try the GetMsg Mode, and let me know how you do by posting code. We can only help you as far as you are willing to help yourself.

I hope it is clear, and easily understood, what needs to be done.

Thanks for listening,

JS


AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Share this post


Link to post
Share on other sites

Dude your the best man if i new were you lived i would hug you lol ( in a brother type of way that is ) Thank you so much bro. ill be shur to add you do the credits :) peace.

Share this post


Link to post
Share on other sites

Dude your the best man if i new were you lived i would hug you lol ( in a brother type of way that is ) Thank you so much bro. ill be shur to add you do the credits :) peace.

I appreciate the credits, and I understand the hug. lol

Enjoy scripting. If you have trouble feel free to post again! :P

Good luck with your script,

JS


AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

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