Frit Posted July 28, 2006 Share Posted July 28, 2006 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. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted July 28, 2006 Moderators Share Posted July 28, 2006 (edited) $Msg = GUIGetMsg() If $Msg = $calc Then Run ("calc.exe") If $Msg = $GUI_EVENT_CLOSE Then ExitNo need to keep calling GUIGetMsg() more than once. Edited July 28, 2006 by SmOke_N 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. Link to comment Share on other sites More sharing options...
BPBNA Posted July 28, 2006 Share Posted July 28, 2006 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 Link to comment Share on other sites More sharing options...
Frit Posted July 28, 2006 Author Share Posted July 28, 2006 Thank you two, the script worked well. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted July 28, 2006 Moderators Share Posted July 28, 2006 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 ... 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 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. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now