jtsteffen Posted October 13, 2008 Share Posted October 13, 2008 Hello I am attempting to write a script that will open a Word file when I press on the "Edit" button in my GUI. I can get it to open the file, but it then begins to try opening the file over and over and over again utill my computer runs out of memory. Needless to say it is a pain. I have just started using AutoIt 3 this weekend and have been able to figure out how to get around on my own fairly well, but I'm a bit short of time and need to fix this as soon as I can. I am assuming that the the $msg is getting stuck to the key button I just pushed which is causing an endless loop. However I'm not sure why this button is doing it and the otherones don't get into this type of loop. Any help would be greatly appreicated. The problem happens when I check the Case for $EditDoc1, $EditDoc2, or $EditDoc3. Thanks CODE ; Main Run Loop While 1 $msg = GUIGetMsg() Select Case $msg = $CancelButton $Answer = MsgBox(36, "Cancel", "Do you wish to Close this program?") ; Canceling running the program If $Answer = 6 Then ; Yes was pressed ; _OpenFiles() ExitLoop EndIf Case $msg = $GUI_EVENT_CLOSE ;Closing the dialog box ; _OpenFiles() ExitLoop Case $msg = $ExitItem ; _OpenFiles() ExitLoop Case $msg = $Version MsgBox(0, "AutoFarm Document Management Utility", "AutoFarm Product Specialist Documentation Group" & @CR &@CR & "Date: " & $SoftwareDate & @CR & "Version: " & $SoftwareVersion) Case $msg = $MoreLocalFiles _SetLocalMarks() $LocPage = $LocPage +1 If $LocPage > $TotalLocPages Then $LocPage = 1 _ShowLocalFiles() ; Rewrite the data to the screen Case $msg = $MoreRemoteFiles _SetRemoteMarks() $RemPage = $RemPage +1 If $RemPage > $TotalRemPages Then $RemPage = 1 _ShowRemoteFiles() ; Rewrite the data to the screen Case $msg = $ProcessButton _SetLocalMarks() _SetRemoteMarks() _Transfer_Files() _Proceed_On_Off() Case $msg = $EditDoc1 $WinFile = Chr(34) & $LocalFolder & "\" & $LocalFile1 & Chr(34) Run(@ComSpec & " /C START Winword.exe "& $WinFile, $LocalFolder, @SW_HIDE) $msg ="" Case $msg = $EditDoc2 $WinFile = Chr(34) & $LocalFolder & "\" & $LocalFile2 & Chr(34) Run(@ComSpec & " /C START Winword.exe "& $WinFile, $LocalFolder, @SW_HIDE) $msg="" Case $msg = $msg = $EditDoc3 $WinFile = Chr(34) & $LocalFolder & "\" & $LocalFile3 & Chr(34) Run(@ComSpec & " /C START Winword.exe "& $WinFile, $LocalFolder, @SW_HIDE) $msg="" Case $msg = $CheckBack1 If $LocalCheck1 = 1 Then $LocalCheck1 = 0 $CheckMarks = $CheckMarks - 1 Else $LocalCheck1 = 1 $CheckMarks = $CheckMarks + 1 EndIf _Proceed_On_Off() Case $msg = $CheckBack2 If $LocalCheck2 = 1 Then $LocalCheck2 = 0 $CheckMarks = $CheckMarks - 1 Else $LocalCheck2 = 1 $CheckMarks = $CheckMarks + 1 EndIf _Proceed_On_Off() Case $msg = $CheckBack3 If $LocalCheck3 = 1 Then $LocalCheck3 = 0 $CheckMarks = $CheckMarks - 1 Else $LocalCheck3 = 1 $CheckMarks = $CheckMarks + 1 EndIf _Proceed_On_Off() Case $msg = $CheckOut1 If $RemoteCheck1 = 1 Then $RemoteCheck1 = 0 $CheckMarks = $CheckMarks - 1 Else $RemoteCheck1 = 1 $CheckMarks = $CheckMarks + 1 EndIf _Proceed_On_Off() Case $msg = $CheckOut2 If $RemoteCheck2 = 1 Then $RemoteCheck2 = 0 $CheckMarks = $CheckMarks - 1 Else $RemoteCheck2 = 1 $CheckMarks = $CheckMarks + 1 EndIf _Proceed_On_Off() Case $msg = $CheckOut3 If $RemoteCheck3 = 1 Then $RemoteCheck3 = 0 $CheckMarks = $CheckMarks - 1 Else $RemoteCheck3 = 1 $CheckMarks = $CheckMarks + 1 EndIf _Proceed_On_Off() Case $msg = $CheckOut4 If $RemoteCheck4 = 1 Then $RemoteCheck4 = 0 $CheckMarks = $CheckMarks - 1 Else $RemoteCheck4 = 1 $CheckMarks = $CheckMarks + 1 EndIf _Proceed_On_Off() Case $msg = $CheckOut5 If $RemoteCheck5 = 1 Then $RemoteCheck5 = 0 $CheckMarks = $CheckMarks - 1 Else $RemoteCheck5 = 1 $CheckMarks = $CheckMarks + 1 EndIf _Proceed_On_Off() Case $msg = $CheckOut6 If $RemoteCheck6 = 1 Then $RemoteCheck6 = 0 $CheckMarks = $CheckMarks - 1 Else $RemoteCheck6 = 1 $CheckMarks = $CheckMarks + 1 EndIf _Proceed_On_Off() Case $msg = $CheckOut7 If $RemoteCheck7 = 1 Then $RemoteCheck7 = 0 $CheckMarks = $CheckMarks - 1 Else $RemoteCheck7 = 1 $CheckMarks = $CheckMarks + 1 EndIf _Proceed_On_Off() Case $msg = $CheckOut8 If $RemoteCheck8 = 1 Then $RemoteCheck8 = 0 $CheckMarks = $CheckMarks - 1 Else $RemoteCheck8 = 1 $CheckMarks = $CheckMarks + 1 EndIf _Proceed_On_Off() Case $msg = $CheckOut9 If $RemoteCheck9 = 1 Then $RemoteCheck9 = 0 $CheckMarks = $CheckMarks - 1 Else $RemoteCheck9 = 1 $CheckMarks = $CheckMarks + 1 EndIf _Proceed_On_Off() Case $msg = $CheckOut10 If $RemoteCheck10 = 1 Then $RemoteCheck10 = 0 $CheckMarks = $CheckMarks - 1 Else $RemoteCheck10 = 1 $CheckMarks = $CheckMarks + 1 EndIf _Proceed_On_Off() EndSelect Wend EndFunc Link to comment Share on other sites More sharing options...
jtsteffen Posted October 13, 2008 Author Share Posted October 13, 2008 Never mind. I found the problem. I had accidentally told the system to compare "$msg = $msg =$EditDoc3". Since $msg and $msg are always going to be equal, it started opening the file as soon as I started the program.Sorry to waste peoples time looking at this.HelloI am attempting to write a script that will open a Word file when I press on the "Edit" button in my GUI. I can get it to open the file, but it then begins to try opening the file over and over and over again utill my computer runs out of memory. Needless to say it is a pain.I have just started using AutoIt 3 this weekend and have been able to figure out how to get around on my own fairly well, but I'm a bit short of time and need to fix this as soon as I can. I am assuming that the the $msg is getting stuck to the key button I just pushed which is causing an endless loop. However I'm not sure why this button is doing it and the otherones don't get into this type of loop. Any help would be greatly appreicated.The problem happens when I check the Case for $EditDoc1, $EditDoc2, or $EditDoc3.ThanksCODE ; Main Run Loop While 1 $msg = GUIGetMsg() Select Case $msg = $CancelButton $Answer = MsgBox(36, "Cancel", "Do you wish to Close this program?") ; Canceling running the program If $Answer = 6 Then ; Yes was pressed ; _OpenFiles() ExitLoop EndIf Case $msg = $GUI_EVENT_CLOSE ;Closing the dialog box ; _OpenFiles() ExitLoop Case $msg = $ExitItem ; _OpenFiles() ExitLoop Case $msg = $Version MsgBox(0, "AutoFarm Document Management Utility", "AutoFarm Product Specialist Documentation Group" & @CR &@CR & "Date: " & $SoftwareDate & @CR & "Version: " & $SoftwareVersion) Case $msg = $MoreLocalFiles _SetLocalMarks() $LocPage = $LocPage +1 If $LocPage > $TotalLocPages Then $LocPage = 1 _ShowLocalFiles() ; Rewrite the data to the screen Case $msg = $MoreRemoteFiles _SetRemoteMarks() $RemPage = $RemPage +1 If $RemPage > $TotalRemPages Then $RemPage = 1 _ShowRemoteFiles() ; Rewrite the data to the screen Case $msg = $ProcessButton _SetLocalMarks() _SetRemoteMarks() _Transfer_Files() _Proceed_On_Off() Case $msg = $EditDoc1 $WinFile = Chr(34) & $LocalFolder & "\" & $LocalFile1 & Chr(34) Run(@ComSpec & " /C START Winword.exe "& $WinFile, $LocalFolder, @SW_HIDE) $msg ="" Case $msg = $EditDoc2 $WinFile = Chr(34) & $LocalFolder & "\" & $LocalFile2 & Chr(34) Run(@ComSpec & " /C START Winword.exe "& $WinFile, $LocalFolder, @SW_HIDE) $msg="" Case $msg = $msg = $EditDoc3 $WinFile = Chr(34) & $LocalFolder & "\" & $LocalFile3 & Chr(34) Run(@ComSpec & " /C START Winword.exe "& $WinFile, $LocalFolder, @SW_HIDE) $msg="" Case $msg = $CheckBack1 If $LocalCheck1 = 1 Then $LocalCheck1 = 0 $CheckMarks = $CheckMarks - 1 Else $LocalCheck1 = 1 $CheckMarks = $CheckMarks + 1 EndIf _Proceed_On_Off() Case $msg = $CheckBack2 If $LocalCheck2 = 1 Then $LocalCheck2 = 0 $CheckMarks = $CheckMarks - 1 Else $LocalCheck2 = 1 $CheckMarks = $CheckMarks + 1 EndIf _Proceed_On_Off() Case $msg = $CheckBack3 If $LocalCheck3 = 1 Then $LocalCheck3 = 0 $CheckMarks = $CheckMarks - 1 Else $LocalCheck3 = 1 $CheckMarks = $CheckMarks + 1 EndIf _Proceed_On_Off() Case $msg = $CheckOut1 If $RemoteCheck1 = 1 Then $RemoteCheck1 = 0 $CheckMarks = $CheckMarks - 1 Else $RemoteCheck1 = 1 $CheckMarks = $CheckMarks + 1 EndIf _Proceed_On_Off() Case $msg = $CheckOut2 If $RemoteCheck2 = 1 Then $RemoteCheck2 = 0 $CheckMarks = $CheckMarks - 1 Else $RemoteCheck2 = 1 $CheckMarks = $CheckMarks + 1 EndIf _Proceed_On_Off() Case $msg = $CheckOut3 If $RemoteCheck3 = 1 Then $RemoteCheck3 = 0 $CheckMarks = $CheckMarks - 1 Else $RemoteCheck3 = 1 $CheckMarks = $CheckMarks + 1 EndIf _Proceed_On_Off() Case $msg = $CheckOut4 If $RemoteCheck4 = 1 Then $RemoteCheck4 = 0 $CheckMarks = $CheckMarks - 1 Else $RemoteCheck4 = 1 $CheckMarks = $CheckMarks + 1 EndIf _Proceed_On_Off() Case $msg = $CheckOut5 If $RemoteCheck5 = 1 Then $RemoteCheck5 = 0 $CheckMarks = $CheckMarks - 1 Else $RemoteCheck5 = 1 $CheckMarks = $CheckMarks + 1 EndIf _Proceed_On_Off() Case $msg = $CheckOut6 If $RemoteCheck6 = 1 Then $RemoteCheck6 = 0 $CheckMarks = $CheckMarks - 1 Else $RemoteCheck6 = 1 $CheckMarks = $CheckMarks + 1 EndIf _Proceed_On_Off() Case $msg = $CheckOut7 If $RemoteCheck7 = 1 Then $RemoteCheck7 = 0 $CheckMarks = $CheckMarks - 1 Else $RemoteCheck7 = 1 $CheckMarks = $CheckMarks + 1 EndIf _Proceed_On_Off() Case $msg = $CheckOut8 If $RemoteCheck8 = 1 Then $RemoteCheck8 = 0 $CheckMarks = $CheckMarks - 1 Else $RemoteCheck8 = 1 $CheckMarks = $CheckMarks + 1 EndIf _Proceed_On_Off() Case $msg = $CheckOut9 If $RemoteCheck9 = 1 Then $RemoteCheck9 = 0 $CheckMarks = $CheckMarks - 1 Else $RemoteCheck9 = 1 $CheckMarks = $CheckMarks + 1 EndIf _Proceed_On_Off() Case $msg = $CheckOut10 If $RemoteCheck10 = 1 Then $RemoteCheck10 = 0 $CheckMarks = $CheckMarks - 1 Else $RemoteCheck10 = 1 $CheckMarks = $CheckMarks + 1 EndIf _Proceed_On_Off() EndSelect WendEndFunc 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