Sign in to follow this  
Followers 0
Frit

Random Gui

5 posts in this topic

Somebody can help me please?

I'm having problems with my gui. It randomly accepts my orders (such as close, open a file).

Sometimes I have to click many times on a control to make it work and sometime later, it will open with just a click. o.O

Confusing, heh?

Here's the code:

#include <GuiConstants.au3>

GuiCreate("UAP v.1.0 by Frit", 320, 485,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))

$editbox = GuiCtrlCreateEdit("", 10, 30, 300, 390)
$open = GUICtrlCreateMenu("Open")
$calc = GUICtrlCreateMenuitem ("Calculator", $open)
$top = GuiCtrlCreateCheckbox("Always on top?", 10, 430, 90, 20)

GuiSetState()

;calculator open
While 1
    If guigetmsg () = $calc Then 
        Run ("calc.exe", "D:\Windows\System32\")
EndIf
    
;close
    If GuiGetMsg() = $GUI_EVENT_CLOSE Then
    Exit
EndIf
    
;always on top mode
    If GUICtrlRead($top) = 1 Then
        WinSetOnTop ( "UAP v.1.0 by Frit", "", 1)
    Else
        WinSetOnTop ( "UAP v.1.0 by Frit", "", 0)
EndIf   
    
WEnd
Exit

I'm just starting it and I'm going to make it bigger.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

$Msg = GUIGetMsg()
    If $Msg = $calc Then Run ("calc.exe")
    If $Msg = $GUI_EVENT_CLOSE Then Exit
No need to keep calling GUIGetMsg() more than once.

Edited by SmOke_N

[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

I don't know why it would be going slow but try this. I'm not sure if you can use GUIGetMsg to see if the checkbox gets clicked because I've never really used checkboxes. Feel free to correct me.

#include <GuiConstants.au3>

GuiCreate("UAP v.1.0 by Frit", 320, 485,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))

$editbox = GuiCtrlCreateEdit("", 10, 30, 300, 390)
$open = GUICtrlCreateMenu("Open")
$calc = GUICtrlCreateMenuitem ("Calculator", $open)
$top = GuiCtrlCreateCheckbox("Always on top?", 10, 430, 90, 20)

GuiSetState()

;calculator open
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $calc Then 
            Run ("calc.exe", "D:\Windows\System32\")
        Case $msg = $GUI_EVENT_CLOSE Then
            Exit
        Case GUICtrlRead($top) = 1 Then
            WinSetOnTop ( "UAP v.1.0 by Frit", "", 1)
        Case GUICtrlRead($top) = 0 then
            WinSetOnTop ( "UAP v.1.0 by Frit", "", 0)
    EndSelect   
WEnd

Share this post


Link to post
Share on other sites

Thank you two, the script worked well.

:whistle:

Share this post


Link to post
Share on other sites

I don't know why it would be going slow but try this. I'm not sure if you can use GUIGetMsg to see if the checkbox gets clicked because I've never really used checkboxes. Feel free to correct me.

#include <GuiConstants.au3>

GuiCreate("UAP v.1.0 by Frit", 320, 485,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))

$editbox = GuiCtrlCreateEdit("", 10, 30, 300, 390)
$open = GUICtrlCreateMenu("Open")
$calc = GUICtrlCreateMenuitem ("Calculator", $open)
$top = GuiCtrlCreateCheckbox("Always on top?", 10, 430, 90, 20)

GuiSetState()

;calculator open
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $calc Then 
            Run ("calc.exe", "D:\Windows\System32\")
        Case $msg = $GUI_EVENT_CLOSE Then
            Exit
        Case GUICtrlRead($top) = 1 Then
            WinSetOnTop ( "UAP v.1.0 by Frit", "", 1)
        Case GUICtrlRead($top) = 0 then
            WinSetOnTop ( "UAP v.1.0 by Frit", "", 0)
    EndSelect   
WEnd
@BPBNA ... There's no "Then" after a Case Condition and GUICtrlRead($top) = 0 would be GUICtrlRead($top) = 4 :whistle: ... I kept looking at that function... I think there should be another variable in there to see if it was checked or not... maybe something like this so your not constantly calling WinSetOnTop():
#include <GuiConstants.au3>

GuiCreate("UAP v.1.0 by Frit", 320, 485,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))

$editbox = GuiCtrlCreateEdit("", 10, 30, 300, 390)
$open = GUICtrlCreateMenu("Open")
$calc = GUICtrlCreateMenuitem ("Calculator", $open)
$top = GuiCtrlCreateCheckbox("Always on top?", 10, 430, 90, 20)

GuiSetState()
Local $WOnTop
;calculator open
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $calc
            Run ("calc.exe", "D:\Windows\System32\")
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case GUICtrlRead($top) = 1 And Not $WOnTop
            $WOnTop = Not $WOnTop
            WinSetOnTop ( "UAP v.1.0 by Frit", "", 1)
        Case GUICtrlRead($top) = 4 And $WOnTop
            $WOnTop = Not $WOnTop
            WinSetOnTop ( "UAP v.1.0 by Frit", "", 0)
    EndSelect   
WEnd

[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

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