Delta01 Posted September 7, 2007 Share Posted September 7, 2007 (edited) Hi, Well, i made a code but i found out that i couldn't use both parts of the code in the same script. Either the GUI buttons didn't work for the second part didn't. The GUI code is first, followed by the other. $main = GUICreate("----", 146, 150) $Kill = GUICtrlCreateButton("Kill Program", 35, 12, 80, 25) $Hide = GUICtrlCreateButton("Minimize Program", 35, 37, 80, 25) $Show = GUICtrlCreateButton("Maximize Program", 35, 63, 80, 25) $Close = GUICtrlCreateButton("Close script", 35, 88, 80, 25) GuiCtrlCreateLabel("Made by ----©", 58, 135) GuiSetstate() While 1 $GuiControl = GUIGetMsg() If $GuiControl = $Close then Exit If $GuiControl = $Kill then If ProcessExists("xxxxxx") then sleep(20) ProcessClose("xxxxx") EndIf EndIf If $GuiControl = $Hide then WinSetState("xxxxx", "", @SW_MINIMIZE) WinSetState("xxxxx", "", @SW_HIDE) EndIf If $GuiControl = $Show Then WinSetState("xxxxx", "", @SW_SHOW) WinSetState("xxxxx", "", @SW_RESTORE) EndIf WENDoÝ÷ Ù«¢+Ø%%AɽÍÍá¥ÍÑÌ ÅÕ½ÐíáááàÅÕ½Ðì¤Q¡¸(ÀÌØíÍѵÀôQ¥µÉ%¹¥Ð ¤)AɽÍÍ]¥Ñ±½Í ÅÕ½ÐíáááàÅÕ½Ðì¤(ÀÌØí¥ôQ¥µÉ¥ ÀÌØíÍѵÀ¤)%5Í ½à À°ÅÕ½ÐíáááàÅÕ½Ðì°ÅÕ½Ðíáááà±½ÍÑÈÅÕ½ÐìµÀìMÑÉ¥¹½ÉµÐ ÅÕ½Ðì¸ÅÅÕ½Ðì°ÀÌØí¥¼ØÀÀÀÀ¤µÀìÅÕ½Ðìµ¥¹ÕÑÌ ÅÕ½ÐìµÀìMÑÉ¥¹½ÉµÐ ÅÕ½Ðì¸ÅÅÕ½Ðì°ÀÌØí¥¼ÌØÀÀÀÀÀ¤µÀìÅÕ½Ðì!½ÕÉ̤ÅÕ½Ðì¤Ñ¡¸á¥Ð(%¹¥(%]9 When i try to combine them, either the GUI won't work or the 2nd part. Any ideas? Thanks Edited September 7, 2007 by Delta01 Link to comment Share on other sites More sharing options...
mrbond007 Posted September 7, 2007 Share Posted September 7, 2007 (edited) the problem lies here If MsgBox(0,"xxxx","xxxx closed after " & StringFormat("%.1f", $diff / 60000) & " minutes "& StringFormat("%.1f", $diff / 3600000) & " Hours") then Exit please explain what are you trying to do so that we can help you. Edited September 7, 2007 by mrbond007 Projects : Space Regain - Memory Fusion - PWGT - Chip-ITGames : BrainPain - BrainPain Director's Cut - ProSpeed Games Pack (New)Vista vs XP : the forbidden fight Link to comment Share on other sites More sharing options...
ssubirias3 Posted September 7, 2007 Share Posted September 7, 2007 (edited) First, the second code snippet is missing the While from the While...Wend set. Second, download and use SciTE4AutoIt3 since it comes with many cool tools to help noobs plus checks for syntax errors. Third, your If MsgBox(...) & StringFormat(...) .... looks to be missing some important stuff. And forth, read the Help file and compare each command's example code to your code. It should then become clear why this isn't working.Edit: In addition to mrbond007's point, you still need to compare your script to the examples provided in Help. Even after the If MsgBox(...) & StringFormat(...) line your buttons don't work correctly . Edited September 7, 2007 by ssubirias3 Link to comment Share on other sites More sharing options...
PsaltyDS Posted September 7, 2007 Share Posted September 7, 2007 ProcessCloseWait() doesn't actually do the ProcessClose part for you, it just waits for it to happen. This is tweaked into a runnable demo: $PID = Run("notepad.exe") WinWaitActive("Untitled - Notepad") $main = GUICreate("----", 146, 150) $Kill = GUICtrlCreateButton("Kill Program", 35, 12, 80, 25) $Hide = GUICtrlCreateButton("Minimize Program", 35, 37, 80, 25) $Show = GUICtrlCreateButton("Maximize Program", 35, 63, 80, 25) $Close = GUICtrlCreateButton("Close script", 35, 88, 80, 25) GUICtrlCreateLabel("Made by ----©", 58, 135) GUISetState() While 1 Switch GUIGetMsg() Case $Close Exit Case $Kill If ProcessExists($PID) Then $stamp = TimerInit() ProcessClose($PID) ProcessWaitClose($PID) $diff = TimerDiff($stamp) $sSec = StringFormat("%.3f", $diff / 1000) $sMin = StringFormat("%.0f", $diff / 60000) $sHr = StringFormat("%.0f", $diff / 3600000) MsgBox(0, "Notepad", "Notepad closed after " & $sHr & ":" & $sMin & ":" & $sSec) Exit EndIf Case $Hide WinSetState("Untitled - Notepad", "", @SW_MINIMIZE) WinSetState("Untitled - Notepad", "", @SW_HIDE) Case $Show WinSetState("Untitled - Notepad", "", @SW_SHOW) WinSetState("Untitled - Notepad", "", @SW_RESTORE) EndSwitch WEnd Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Delta01 Posted September 7, 2007 Author Share Posted September 7, 2007 Ok. Sorry, I didn't explain myself clear enough. I'm trying to get the script to have a GUI (done) and also detect (but not start) when Notepad runs and then start the timer and also when notepad closes and stop the timer and display a message box. But, I know what the problem is. I use "ProcessWaitClose" which pauses the entire script (GUI included) so the GUI becomes in-responsive. Is there another command i can use instead of that? I've tried. If ProcessExists("notepad.exe") then sleep(50) ElseIf ProcessExists("notepad.exe") <> ProcessExists("notepad.exe) then MsgBox(blah blah blah) I also tried WinGetProcess. Does anybody know what I can use? Link to comment Share on other sites More sharing options...
Valuater Posted September 7, 2007 Share Posted September 7, 2007 I would be vulnerable on that one... lets let Venerable help you here lol 8) Link to comment Share on other sites More sharing options...
Delta01 Posted September 8, 2007 Author Share Posted September 8, 2007 Hehe. I hope Venerable knows what's wrong Link to comment Share on other sites More sharing options...
PsaltyDS Posted September 8, 2007 Share Posted September 8, 2007 Hehe. I hope Venerable knows what's wrong Veritably... expandcollapse popupGlobal $WinFlag = False, $hWin, $WinTimer Opt("WinTitleMatchMode", 4) $main = GUICreate("----", 146, 150) $Kill = GUICtrlCreateButton("Kill Notepad", 35, 12, 80, 25) $Hide = GUICtrlCreateButton("Minimize Notepad", 35, 37, 80, 25) $Show = GUICtrlCreateButton("Restor Notepad", 35, 63, 80, 25) $Close = GUICtrlCreateButton("Close script", 35, 88, 80, 25) GUICtrlCreateLabel("Made by ----©", 58, 135) GUISetState() ConsoleWrite("Debug: $WinFlag = " & $WinFlag & @LF) While 1 $hWin = WinGetHandle("[CLASS:Notepad; INSTANCE:1]") If IsHWnd($hWin) Then ; Window exists If Not $WinFlag Then ; Window newly discovered $WinTimer = TimerInit() $WinFlag = True ConsoleWrite("Debug: $WinFlag = " & $WinFlag & @LF) EndIf Else ; Window doesn't exist If $WinFlag Then ; Window closed $WinFlag = False ConsoleWrite("Debug: $WinFlag = " & $WinFlag & @LF) MsgBox(64, "Window Closed", "Window closed after " & Int(TimerDiff($WinTimer) / 1000) & " seconds.") EndIf EndIf Switch GUIGetMsg() Case $Close Exit Case $Kill If ProcessExists("notepad.exe") Then ProcessClose("notepad.exe") EndIf Case $Hide If $WinFlag Then WinSetState($hWin, "", @SW_MINIMIZE) WinSetState($hWin, "", @SW_HIDE) EndIf Case $Show If $WinFlag Then WinSetState($hWin, "", @SW_SHOW) WinSetState($hWin, "", @SW_RESTORE) EndIf EndSwitch WEnd Victory. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law 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