TokeySmurf Posted September 9, 2006 Share Posted September 9, 2006 (edited) It only exectues once, the buttons still seem functional but the actual loop doesn't work expandcollapse popup#include <GUIConstants.au3> Opt("GUIOnEventMode", 1) Opt("GUICoordMode", 1) Opt("WinTitleMatchMode", 4) Global $Show = 0 Global $handle = WinGetHandle("classname=GxWindowClassD3d") If @error Then MsgBox(0, "Blank Not Found", "Please Start Blank") Exit EndIf $mainwindow = GUICreate("Blank", 200, 100) $startb = GUICtrlCreateButton("Start",25,50,70,25) GUICtrlSetOnEvent($startb, "Start") $Stopb = GUICtrlCreateButton("Stop",100 ,50,70,25 ) GUICtrlSetOnEvent($Stopb, "Stop") $hStatus = GUICtrlCreateLabel("", 10, 25, 200, 20) GUISetState(@SW_SHOW) WinSetState($handle, "", @SW_RESTORE) GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") WinSetOnTop($mainwindow, "", 1) GUICtrlSetData($hStatus,"Status: Click Start to Begin!") While 1 Sleep(20) If $Show = 1 Then ControlSend($handle, "", "", "{UP DOWN}") Sleep(100) ControlSend($handle, "", "", "{UP UP}") ControlSend($handle, "", "", "{DOWN DOWN}") Sleep(100) ControlSend($handle, "", "", "{DOWN UP}") Sleep(200000) $Show = 0 EndIf WEnd Func Start() ;WinSetState($handle, "", @SW_MINIMIZE) ;WinSetState ($handle, "", @SW_HIDE ) If @error Then MsgBox(0, "Blank2 Not Found", "Please Start Blank2", 3) Else GUICtrlSetData($hStatus,"Status: Blank Started") $Show = 1 EndIf EndFunc ;==>Start func Stop() If $Show = 1 Then WinSetState($handle, "", @SW_SHOW) WinSetState($handle, "", @SW_RESTORE) WinActivate($handle, "") GUICtrlSetData($hStatus,"Status: Blank Halted") $Show = 0 Else GUICtrlSetData($hStatus,"Status: 'ERROR' Blank Not Running") $Show = 0 EndIf EndFunc Func CLOSEClicked() GUICtrlSetData($hStatus,"Status: Closing.. Have a nice day!") Exit EndFunc ;==>CLOSEClicked Edited September 9, 2006 by TokeySmurf Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted September 9, 2006 Moderators Share Posted September 9, 2006 Well, you never make $show = 1 again 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...
TokeySmurf Posted September 9, 2006 Author Share Posted September 9, 2006 Well, you never make $show = 1 again Would I do it here? While 1 Sleep(20) If $Show = 1 Then ControlSend($handle, "", "", "{UP DOWN}") Sleep(100) ControlSend($handle, "", "", "{UP UP}") ControlSend($handle, "", "", "{DOWN DOWN}") Sleep(100) ControlSend($handle, "", "", "{DOWN UP}") Sleep(200000) $Show = 1 <--- here? EndIf WEnd Link to comment Share on other sites More sharing options...
TokeySmurf Posted September 9, 2006 Author Share Posted September 9, 2006 Would I do it here? While 1 Sleep(20) If $Show = 1 Then ControlSend($handle, "", "", "{UP DOWN}") Sleep(100) ControlSend($handle, "", "", "{UP UP}") ControlSend($handle, "", "", "{DOWN DOWN}") Sleep(100) ControlSend($handle, "", "", "{DOWN UP}") Sleep(200000) $Show = 1 <--- here? EndIf WEnd I'm really confused now.. As the msgs change (halt start stop etc) but the loop just wont start back up no matter if you hit stop then start or what.. I don't get it Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted September 9, 2006 Moderators Share Posted September 9, 2006 (edited) Try this: CODE#include <GUIConstants.au3> Opt("GUIOnEventMode", 1) Opt("GUICoordMode", 1) Opt("WinTitleMatchMode", 4) Global $Show Global $handle = WinGetHandle("classname=GxWindowClassD3d") If @error Then MsgBox(0, "Blank Not Found", "Please Start Blank") Exit EndIf $mainwindow = GUICreate("Blank", 200, 100) $startb = GUICtrlCreateButton("Start",25,50,70,25) GUICtrlSetOnEvent($startb, "Start") $Stopb = GUICtrlCreateButton("Stop",100 ,50,70,25 ) GUICtrlSetOnEvent($Stopb, "Stop") $hStatus = GUICtrlCreateLabel("", 10, 25, 200, 20) GUISetState(@SW_SHOW) WinSetState($handle, "", @SW_RESTORE) GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") WinSetOnTop($mainwindow, "", 1) GUICtrlSetData($hStatus,"Status: Click Start to Begin!") While 1 Sleep(20) If $Show Then ControlSend($handle, "", "", "{UP DOWN}") Sleep(100) ControlSend($handle, "", "", "{UP UP}") ControlSend($handle, "", "", "{DOWN DOWN}") Sleep(100) ControlSend($handle, "", "", "{DOWN UP}") Sleep(200000) ;$Show = Not $Show ; Only use this one if you want the loop to run 1 time, if you want it to run until you press stop then keep it commented or remove it. EndIf WEnd Func Start() ;WinSetState($handle, "", @SW_MINIMIZE) ;WinSetState ($handle, "", @SW_HIDE ) If @error Then MsgBox(0, "Blank2 Not Found", "Please Start Blank2", 3) Else GUICtrlSetData($hStatus,"Status: Blank Started") $Show = Not $Show EndIf EndFunc ;==>Start func Stop() $Show = Not $Show If $Show Then WinSetState($handle, "", @SW_SHOW) WinSetState($handle, "", @SW_RESTORE) WinActivate($handle, "") GUICtrlSetData($hStatus,"Status: Blank Halted") $Show = Not $Show Else GUICtrlSetData($hStatus,"Status: 'ERROR' Blank Not Running") $Show = Not $Show EndIf EndFunc Func CLOSEClicked() GUICtrlSetData($hStatus,"Status: Closing.. Have a nice day!") Exit EndFunc ;==>CLOSEClicked Edited September 9, 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...
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