19dman73 Posted August 2, 2019 Share Posted August 2, 2019 Why wont WinClose work on my Win 10 PC? Once it arrives at that Command it stops. Link to comment Share on other sites More sharing options...
Developers Jos Posted August 2, 2019 Developers Share Posted August 2, 2019 @19dman73, This is for sure not enough information to understand your issue! Please try explaining it with more details. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
19dman73 Posted August 3, 2019 Author Share Posted August 3, 2019 (edited) When I run the script seen below, it does not close the window. It waits for me to close it manually then finishes the script with no problem. I don't think it is stopping at the WinClose command. It seems like it is ignoring, or skipping the command. #cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.14.5 Author: Donald Brockstedt Script Function: Template AutoIt script. #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here Run("notepad.exe") WinWaitActive("Untitled - Notepad") Send("This is some text") WinClose("Untitled - Notepad") WinWaitActive("Notepad", "Save") ;WinWaitActive("Notepad", "Do you want to save") ; When running under Windows XP Send("!n") Edited August 3, 2019 by 19dman73 Link to comment Share on other sites More sharing options...
Developers Jos Posted August 3, 2019 Developers Share Posted August 3, 2019 (edited) Didn't the Window title of notepad change after you send() the text, so shouldn't winclose() reflex that change? Jos Edited August 3, 2019 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
martin Posted August 13, 2019 Share Posted August 13, 2019 The window title doesn't change for me. The script works so I don't see a problem. Maybe there is some problem because of a different language - my PC is Windows 10 and the language is English (UK). Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
Gianni Posted August 13, 2019 Share Posted August 13, 2019 (edited) try by omitting the second parameter in the second WinWaitActive() WinWaitActive("Notepad") ; , "Save") Edited August 13, 2019 by Chimp Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... Link to comment Share on other sites More sharing options...
Bilgus Posted August 15, 2019 Share Posted August 15, 2019 I'd probably do it more like this ; Run Notepad. Local $iPID = Run("notepad.exe", "", @SW_SHOWNORMAL) ; Wait 10 seconds for the Notepad window to appear. $hWnd = _GetHwndFromPID($iPID, 10) ControlSend($hWnd, "", "", "This is some text") sleep(1000) ; Close the Notepad process using the PID returned by Run. ProcessClose($iPID) Func _GetHwndFromPID($PID, $iTimeout_secs) ;;https://www.autoitscript.com/forum/topic/86680-pid-window-handle-hwnd-conversion/ $iTimeout_secs = $iTimeout_secs * 100 local $hWnd = 0 local $stPID = DllStructCreate("int") Do $winlist2 = WinList() For $i = 1 To $winlist2[0][0] If $winlist2[$i][0] <> "" Then DllCall("user32.dll", "int", "GetWindowThreadProcessId", "hwnd", $winlist2[$i][1], "ptr", DllStructGetPtr($stPID)) If DllStructGetData($stPID, 1) = $PID Then $hWnd = $winlist2[$i][1] ExitLoop EndIf EndIf Next Sleep(100) $iTimeout_secs -= 100 Until $hWnd <> 0 Or $iTimeout_secs <= 0 Return $hWnd EndFunc Link to comment Share on other sites More sharing options...
CalebG Posted April 22, 2021 Share Posted April 22, 2021 I had the same issue, just trying to follow the 'Simple Notepad Automation' tutorial in AutoIt Help. I think Jos' answer is the solution. After typing something in notepad the title changes from "Untitled - Notepad" to "*Untitled - Notepad" (the '*' indicates you have unsaved changes). So you need to change the WinClose command to: WinClose("*Untitled - Notepad") And then it works. The AutoIt Help should probably be updated to reflect this? Vanisher143 1 Link to comment Share on other sites More sharing options...
argumentum Posted April 22, 2021 Share Posted April 22, 2021 (edited) WinClose() uses the CLASS in the help file. Hey, welcome to the forum @CalebG ok, I see it now. I've pass it along. Edited April 22, 2021 by argumentum found it CalebG 1 Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. 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