emmanuel Posted July 13, 2004 Share Posted July 13, 2004 If I hit the !^Printscreen within the first five seconds while the splash screen is up, it doesn't seem to continue on to the splashtextoff... why is that? expandcollapse popup;screenshot util ;HotKeySet("{printscreen}", "_printscreen") ;HotKeySet("!{printscreen}", "_altprintscreen") $filepath1 = "c:\screenshots" HotKeySet("!^{printscreen}", "_printscreen") HotKeySet("!^q","_exit") SplashTextOn("","ScreenShot by Emmanuel" & @LF & "Alt-Ctrl-PrintScreen to take a screenshot" & @LF & " Alt-Ctrl-Q to quit" & @LF & "Screenshots stored in C:\Screenshots", 400, 90, -1, 0, 1) Sleep(5*1000) SplashOff() If FileExists($filepath1) = 0 Then DirCreate($filepath1) While 1 Sleep(50) Wend Func _printscreen() Send("{printscreen}") _save() EndFunc ;==>_printscreen ;Func _altprintscreen() ; Send("!{printscreen}") ; _save() ;EndFunc ;==>_altprintscreen Func _save() Run("mspaint.exe", "", @SW_HIDE) WinWait("untitled - Paint") AdlibEnable("adlib") ControlSend("untitled - Paint", "", "Afx:1000000:81", "^v") WinWait("untitled - Paint") ControlSend("untitled - Paint", "", "Afx:1000000:81", "^s") WinWait("Save As", "") $filename = @UserName & " on " & @ComputerName & " at " & @HOUR & "." & @MIN & "." & @SEC & " on " & @MON & "-" & @MDAY & "-" & @YEAR & ".jpg" ControlSetText("Save As", "", "Edit1", '"' & $filepath1 & "\" & $filename & '"') ControlClick("Save As", "", "Button2") WinWait($filename & " - Paint") WinClose($filename & " - Paint") AdlibDisable() EndFunc ;==>_save Func adlib();for the 2k ver of paint's "would you like to increase the image size" message If WinExists("Paint", "The image in the clipboard is larger than the bitmap") = 1 Then ControlClick("Paint", "The image in the clipboard is larger than the bitmap", "Button1") Sleep(250) EndIf EndFunc ;==>adlib func _exit() Exit EndFunc "I'm not even supposed to be here today!" -Dante (Hicks) Link to comment Share on other sites More sharing options...
Developers Jos Posted July 13, 2004 Developers Share Posted July 13, 2004 (edited) Add this to the top of your script: opt("TrayIconDebug",1) you will see it hangs on: WinWait($filename & " - Paint") edit: maybe because this is not executed yet ? If FileExists($filepath1) = 0 Then DirCreate($filepath1) Edited July 13, 2004 by JdeB 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...
emmanuel Posted July 13, 2004 Author Share Posted July 13, 2004 Add this to the top of your script:opt("TrayIconDebug",1)you will see it hangs on: WinWait($filename & " - Paint")edit: maybe because this is not executed yet ?If FileExists($filepath1) = 0 Then DirCreate($filepath1)good point, I already have c:\screenshots created on my machine, noticed the error in the logic there and fixed that... that's not it... I just came to the same conclusion, without doing the tray debug... I'm thinking it's... damn... what? maybe I'll do a wait exists on the filename, then close after that. "I'm not even supposed to be here today!" -Dante (Hicks) Link to comment Share on other sites More sharing options...
emmanuel Posted July 13, 2004 Author Share Posted July 13, 2004 cool, once more, you save the day. Thank you Jdeb. here's the 'final' code... expandcollapse popup;screenshot util ;HotKeySet("{printscreen}", "_printscreen") ;HotKeySet("!{printscreen}", "_altprintscreen") break(0) opt("TrayIconDebug",1) $filepath1 = "c:\screenshots" If FileExists($filepath1) = 0 Then DirCreate($filepath1) HotKeySet("!^{printscreen}", "_printscreen") HotKeySet("!^q","_exit") SplashTextOn("","ScreenShot by Emmanuel" & @LF & "Alt-Ctrl-PrintScreen to take a screenshot" & @LF & " Alt-Ctrl-Q to quit" & @LF & "Screenshots stored in C:\Screenshots", 400, 90, -1, 0, 1) Sleep(5*1000) SplashOff() While 1 Sleep(50) Wend Func _printscreen() Send("{printscreen}") _save() EndFunc ;==>_printscreen ;Func _altprintscreen() ; Send("!{printscreen}") ; _save() ;EndFunc ;==>_altprintscreen Func _save() SplashOff() SplashTextOn("","ScreenShot by Emmanuel" & @LF & "Alt-Ctrl-PrintScreen to take a screenshot" & @LF & " Alt-Ctrl-Q to quit" & @LF & "Screenshots stored in C:\Screenshots" & @LF & "Saving screenshot", 400, 100, -1, 0, 1) Run("mspaint.exe", "", @SW_HIDE) WinWait("untitled - Paint") AdlibEnable("adlib") ControlSend("untitled - Paint", "", "Afx:1000000:81", "^v") WinWait("untitled - Paint") ControlSend("untitled - Paint", "", "Afx:1000000:81", "^s") WinWait("Save As", "") $filename = @UserName & " on " & @ComputerName & " at " & @HOUR & "." & @MIN & "." & @SEC & " on " & @MON & "-" & @MDAY & "-" & @YEAR & ".jpg" ControlSetText("Save As", "", "Edit1", '"' & $filepath1 & "\" & $filename & '"') ControlClick("Save As", "", "Button2") while FileExists($filepath1 & "\" & $filename) = 0 Sleep(10) Wend WinClose($filename & " - Paint") AdlibDisable() SplashOff() SplashTextOn("","ScreenShot by Emmanuel" & @LF & "Alt-Ctrl-PrintScreen to take a screenshot" & @LF & " Alt-Ctrl-Q to quit" & @LF & "Screenshots stored in C:\Screenshots" & @LF & "Screenshot Saved", 400, 100, -1, 0, 1) sleep(1000) SplashOff() EndFunc ;==>_save Func adlib();for the 2k ver of paint's "would you like to increase the image size" message If WinExists("Paint", "The image in the clipboard is larger than the bitmap") = 1 Then ControlClick("Paint", "The image in the clipboard is larger than the bitmap", "Button1") Sleep(250) EndIf EndFunc ;==>adlib func _exit() Exit EndFunc "I'm not even supposed to be here today!" -Dante (Hicks) Link to comment Share on other sites More sharing options...
emmanuel Posted July 13, 2004 Author Share Posted July 13, 2004 (edited) doh! I spoke a little too soon... the mspaint proccess is hanging around... my guess is that winclose is making it's attempt while the file is still saving, so mspaint is just ignoring it.... WinWait($filename & " - Paint") WinKill($filename & " - Paint") This works when I don't run it with the @SW_HIDE, but when I do run it hidden, it hangs at the winwait... any ideas for a workaround? Edited July 13, 2004 by emmanuel "I'm not even supposed to be here today!" -Dante (Hicks) Link to comment Share on other sites More sharing options...
emmanuel Posted July 13, 2004 Author Share Posted July 13, 2004 ok, I'm getting more complex, with nothing getting fixed... While WinExists($filename & " - Paint") = 1 Sleep(100) Do WinKill($filename & " - Paint") Until WinExists($filename & " - Paint") = 0 Wend still leaves the mspaint.exe proc there. "I'm not even supposed to be here today!" -Dante (Hicks) Link to comment Share on other sites More sharing options...
Developers Jos Posted July 13, 2004 Developers Share Posted July 13, 2004 Added a sleep after the run.. and changed WinTitleMatch before close which seems to work... so it must be something with the title.... Func _save() SplashOff() SplashTextOn("","ScreenShot by Emmanuel" & @LF & "Alt-Ctrl-PrintScreen to take a screenshot" & @LF & " Alt-Ctrl-Q to quit" & @LF & "Screenshots stored in C:\Screenshots" & @LF & "Saving screenshot", 400, 100, -1, 0, 1) Run("mspaint.exe") WinWait("untitled - Paint","",@SW_HIDE) AdlibEnable("adlib") sleep(500) ControlSend("untitled - Paint", "", "Afx:1000000:81", "^v") WinWait("untitled - Paint") ControlSend("untitled - Paint", "", "Afx:1000000:81", "^s") WinWait("Save As", "") $filename = @UserName & " on " & @ComputerName & " at " & @HOUR & "." & @MIN & "." & @SEC & " on " & @MON & "-" & @MDAY & "-" & @YEAR & ".jpg" ControlSetText("Save As", "", "Edit1", '"' & $filepath1 & "\" & $filename & '"') ControlClick("Save As", "", "Button2") while FileExists($filepath1 & "\" & $filename) = 0 Sleep(10) Wend opt("WinTitleMatchMode", 2) WinClose(" - Paint") AdlibDisable() SplashOff() SplashTextOn("","ScreenShot by Emmanuel" & @LF & "Alt-Ctrl-PrintScreen to take a screenshot" & @LF & " Alt-Ctrl-Q to quit" & @LF & "Screenshots stored in C:\Screenshots" & @LF & "Screenshot Saved", 400, 100, -1, 0, 1) sleep(1000) SplashOff() EndFunc ;==>_save 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...
emmanuel Posted July 13, 2004 Author Share Posted July 13, 2004 (edited) interesting... well, I'd been hoping to avoid closing any old notepad window, but I suppose that the "last active" clause should fix that. Edit that works, tested with another paint window open, it leaves that one alone. Edited July 13, 2004 by emmanuel "I'm not even supposed to be here today!" -Dante (Hicks) Link to comment Share on other sites More sharing options...
Guest Doflow Posted July 14, 2004 Share Posted July 14, 2004 (edited) Hi, I like to make two more points: 1. On my system, although the file is saved with a .jpg extension it is actually .bmp (the default). (Look at the file size...) To save in true .jpg format, you'll need to add: ControlSetText("Save As", "", "Edit1", '"' & $filepath1 & "\" & $filename & '"') Controlsend("Save As", "", "ComboBox3", "j");<----------------------------This line ControlClick("Save As", "", "Button2") This selects the jpg filetype in the 'save as type' combobox 2. The Paint process doesn't alter the Window title when it's hidden, only when it's shown , so as long as you open Paint in hidden mode, you can close it by: winwait("untitled - Paint") WinClose("untitled - Paint") even after the save! or you could use JdeB's method.. Regards, Doflow Edited July 14, 2004 by Doflow Link to comment Share on other sites More sharing options...
emmanuel Posted July 14, 2004 Author Share Posted July 14, 2004 Hi, I like to make two more points: Regards, Doflowcool, thanks for the input, I added Controlsend("Save As", "", "ComboBox3", "j") and am usingWinWait(" - Paint") WinClose(" - Paint") "I'm not even supposed to be here today!" -Dante (Hicks) 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