TokeySmurf Posted September 9, 2006 Share Posted September 9, 2006 (edited) Ok, the program is functioning but it'll contiously show/hide if I use sleep it hangs and doesn't function as should, if anyone could test it out and see what I'm talking about that would be awesome. Been playing with it for some time now. Also it doesn't seem to stop anymore.. It was stoping. 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 GUICtrlSetData($hStatus,"Status: Please Start Program to Begin!") EndIf $mainwindow = GUICreate("ProgTitle", 200, 150) $optionsm = GuictrlCreateMenu("Options") $restorem = GUICtrlCreateMenuitem("Restore", $optionsm) GUICtrlSetOnEvent($restorem, "Restore") $hidem = GUICtrlCreateMenuitem("Hide", $optionsm) GUICtrlSetOnEvent($hidem, "Hide") $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) $hideb = GUICtrlCreateCheckbox("Hide/Unhide Game on Start", 10, 80, 200, 20) GUISetState(@SW_SHOW) GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") WinSetOnTop($mainwindow, "", 1) GUICtrlSetData($hStatus,"Status: Click Start to Begin!") While 1 Sleep(20) $info = GUICtrlRead($hideb);read the checkbox if ($info = $GUI_CHECKED) And $Show = 1 Then;check if its checked WinSetState($handle, "", @SW_MINIMIZE);set the window state WinSetState ($handle, "", @SW_HIDE ) ControlSend($handle, "", "", "{Z}") sleep(30000) $Show = 1 ElseIf $Show = 1 Then ControlSend($handle, "", "", "{Z}") sleep(30000) $Show = 1 EndIf WEnd Func Start() ;WinSetState($handle, "", @SW_MINIMIZE) ;WinSetState ($handle, "", @SW_HIDE ) If @error Then MsgBox(0, "ProgTitle", "Program Not Found",) Else GUICtrlSetData($hStatus,"Status: ProgTitle Started") $Show = 1 EndIf EndFunc ;==>Start func Stop() If $Show = 1 Then; $Stop = 0 Then WinSetState($handle, "", @SW_SHOW) WinSetState($handle, "", @SW_RESTORE) WinActivate($handle, "") GUICtrlSetData($hStatus,"Status: ProgTitle Halted") $Show = 0 Else GUICtrlSetData($hStatus,"Status: 'ERROR' ProgTitle Not Running") $Show = 0 EndIf EndFunc Func Restore() WinSetState($handle, "", @SW_SHOW) WinSetState($handle, "", @SW_RESTORE) EndFunc Func Hide() WinSetState($handle, "", @SW_MINIMIZE);set the window state WinSetState ($handle, "", @SW_HIDE ) EndFunc Func CLOSEClicked() GUICtrlSetData($hStatus,"Status: Closing.. Have a nice day!") Exit EndFunc ;==>CLOSEClicked I guess what I'm really trying to ask is how do I go about getting start to call the function and loop only the keypress and not the Hide / show etc features - Edited September 9, 2006 by TokeySmurf Link to comment Share on other sites More sharing options...
PsaltyDS Posted September 9, 2006 Share Posted September 9, 2006 Ok, the program is functioning but it'll contiously show/hide if I use sleep it hangs and doesn't function as should, if anyone could test it out and see what I'm talking about that would be awesome. Been playing with it for some time now. Also it doesn't seem to stop anymore.. It was stoping. CODE#include <GUIConstants.au3> Opt("GUIOnEventMode", 1) Opt("GUICoordMode", 1) Opt("WinTitleMatchMode", 4) Global $Show = 0 Global $handle = WinGetHandle("classname=GxWindowClassD3d") If @error Then GUICtrlSetData($hStatus,"Status: Please Start Program to Begin!") EndIf $mainwindow = GUICreate("ProgTitle", 200, 150) $optionsm = GuictrlCreateMenu("Options") $restorem = GUICtrlCreateMenuitem("Restore", $optionsm) GUICtrlSetOnEvent($restorem, "Restore") $hidem = GUICtrlCreateMenuitem("Hide", $optionsm) GUICtrlSetOnEvent($hidem, "Hide") $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) $hideb = GUICtrlCreateCheckbox("Hide/Unhide Game on Start", 10, 80, 200, 20) GUISetState(@SW_SHOW) GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") WinSetOnTop($mainwindow, "", 1) GUICtrlSetData($hStatus,"Status: Click Start to Begin!") While 1 Sleep(20) $info = GUICtrlRead($hideb);read the checkbox if ($info = $GUI_CHECKED) And $Show = 1 Then;check if its checked WinSetState($handle, "", @SW_MINIMIZE);set the window state WinSetState ($handle, "", @SW_HIDE ) ControlSend($handle, "", "", "{Z}") sleep(30000) $Show = 1 ElseIf $Show = 1 Then ControlSend($handle, "", "", "{Z}") sleep(30000) $Show = 1 EndIf WEnd Func Start() ;WinSetState($handle, "", @SW_MINIMIZE) ;WinSetState ($handle, "", @SW_HIDE ) If @error Then MsgBox(0, "ProgTitle", "Program Not Found",) Else GUICtrlSetData($hStatus,"Status: ProgTitle Started") $Show = 1 EndIf EndFunc ;==>Start func Stop() If $Show = 1 Then; $Stop = 0 Then WinSetState($handle, "", @SW_SHOW) WinSetState($handle, "", @SW_RESTORE) WinActivate($handle, "") GUICtrlSetData($hStatus,"Status: ProgTitle Halted") $Show = 0 Else GUICtrlSetData($hStatus,"Status: 'ERROR' ProgTitle Not Running") $Show = 0 EndIf EndFunc Func Restore() WinSetState($handle, "", @SW_SHOW) WinSetState($handle, "", @SW_RESTORE) EndFunc Func Hide() WinSetState($handle, "", @SW_MINIMIZE);set the window state WinSetState ($handle, "", @SW_HIDE ) EndFunc Func CLOSEClicked() GUICtrlSetData($hStatus,"Status: Closing.. Have a nice day!") Exit EndFunc ;==>CLOSEClickedI guess what I'm really trying to ask is how do I go about getting start to call the function and loop only the keypress and not the Hide / show etc features - Well, your only loop has confused logic in the If/ElseIf/EndIF part. The $Show = 1 check is done either way, so break it out as a seperate If/EndIf: While 1 Sleep(20) $info = GUICtrlRead($hideb);read the checkbox if ($info = $GUI_CHECKED) Then ;check if its checked WinSetState($handle, "", @SW_MINIMIZE);set the window state WinSetState ($handle, "", @SW_HIDE ) $Show = 1 EndIf If $Show = 1 Then ControlSend($handle, "", "", "{Z}") sleep(30000) $Show = 1 EndIf WEnd Now you can adjust the logic of just the WinSetStat() part to whatever you were talking about. 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...
TokeySmurf Posted September 9, 2006 Author Share Posted September 9, 2006 Well, your only loop has confused logic in the If/ElseIf/EndIF part. The $Show = 1 check is done either way, so break it out as a seperate If/EndIf: While 1 Sleep(20) $info = GUICtrlRead($hideb);read the checkbox if ($info = $GUI_CHECKED) Then ;check if its checked WinSetState($handle, "", @SW_MINIMIZE);set the window state WinSetState ($handle, "", @SW_HIDE ) $Show = 1 EndIf If $Show = 1 Then ControlSend($handle, "", "", "{Z}") sleep(30000) $Show = 1 EndIf WEndoÝ÷ ØÚ0Êjvë-¶¥¢¡øî²Ûayh§IëRµ«ij»m£ZµëÞ¯*.ÁêÞµ©dxnþ«¨µäájy,ç!~íè^î¶Ø^¦ºé¬¶)e¡Ç.®ÀZ²'½êòßKrݲØ^²W¦Ø¦z²-Â)eçh¶ºÚ"µÍÚ[HBTÛY BIÌÍÚ[ÈHÕRPÝXY ÌÍÚYXNÜXYHÚXÚØÞZY ÌÍÚ[ÈH ÌÍÑÕRWÐÒPÒÑQ H[ØÚXÚÈY]ÈÚXÚÙYBUÚ[Ù]Ý]J ÌÍÚ[K ][ÝÉ][ÝËÕ×ÓRSSRVJNÜÙ]HÚ[ÝÈÝ]BBHÚ[Ù]Ý]H ÌÍÚ[K ][ÝÉ][ÝËÕ×ÒQH BBIÌÍÔÚÝÈHBQ[Y Part . if I take the sleep timer off it'll do it repeatedly over an over (ouch my ram!) I've tried moving that out of the while statement and puting it under the start() .. and then it wont start at all.. I've been trying so hard!! lol.. thanks for the help but I need more =( Link to comment Share on other sites More sharing options...
PsaltyDS Posted September 10, 2006 Share Posted September 10, 2006 (edited) Thanks much for the help but the problem still occurs. Basically Every 30 seconds (the sleep timer) It will redo the While 1 Sleep(20) $info = GUICtrlRead($hideb);read the checkbox if ($info = $GUI_CHECKED) Then ;check if its checked WinSetState($handle, "", @SW_MINIMIZE);set the window state WinSetState ($handle, "", @SW_HIDE ) $Show = 1 EndIf oÝ÷ Øö«¶'ȵ©¶¬ç©¶)®ßÝýWhÚÞ¥æyÙr¢÷«jz/zº.r²©·Üý½ëkçf¢ø§ØZ¶¡ûa{bë-jצz{ZÚn¶)àÛ§uêíë-j»ZÛazxÂí²Ö«µ«ZR7ö÷yéí¯(§Ê!j·wß}å¢[ajy,~íè^î´ÞyÙ¨ Edited September 10, 2006 by PsaltyDS 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