Jump to content

Mspaint


Recommended Posts

Hi im trying to make a simple script that uses teh exit button to take a screen shot and paste it into mspaint.

Heres what I have so far !

HotKeySet("{Esc}", "captureEsc")

Func captureEsc()

Send("{PrintScreen}")

Run("mspaint.exe")

Opt("WinWaitDelay", 10)

HotKeySet("{Esc}")

Send("{Esc}")

HotKeySet("{Esc}", "captureEsc")

EndFunc

WinWait("untitled - Paint")

WinMenuSeylectItem("untitled - Paint","", "&Edit", "&Paste")

Theres only one problem because the screen shot is bigger than the mspaint editing area u get a msg box saying "the image in the clip board is larger than the bitmap,would you like teh bitmap enlarged ?"

This of course pauses the script.

Ive tryed

winactive Paint and winwait Paint

and then sending enter or y !

But the Paint window well its more of a msg box wont close,its proberly something simple

Any ideas ?

Link to comment
Share on other sites

Cant believe how simple that was srry

I was putting the send("y") command before the paste command so the mspaint error msg hadnt shown up yet

Old

..........................

WinWait("untitled - Paint")

send("y")

WinMenuSeylectItem("untitled - Paint","", "&Edit", "&Paste")

New

..........................

WinWait("untitled - Paint")

WinMenuSeylectItem("untitled - Paint","", "&Edit", "&Paste")

send("y")

Link to comment
Share on other sites

I've already done this, so you can look at mine for reference... Check it out in scripts and scraps... Or on the wiki.

I did what you're trying to do with an adlib. I did it that way, because the error doesn't show on XP, but does on 2k and NT...

Edited by emmanuel

"I'm not even supposed to be here today!" -Dante (Hicks)

Link to comment
Share on other sites

Also you can try the Adlib functions

To be honest i didnt know Adlib functions existed and ive never created a udf before just now either.

Ok heres what ive got not sure why its not working !

AdlibEnable ("HasEscBeenPressed") 

Func Printscreen()
    Send("{PrintScreen}") 
    Run("mspaint.exe", "", @SW_MAXIMIZE)
    Send("{enter}") 
    Opt("WinWaitDelay", 10) 
    HotKeySet("{Esc}")
    Send("{Esc}")
    WinWait("untitled - Paint") 
    WinMenuSelectItem("untitled - Paint","", "&Edit", "&Paste")
    send("y")
EndFunc

Func HasEscBeenPressed()
   HotKeySet("{Esc}", "Printscreen")
EndFunc

Ive never used AdlibEnable before but shouldnt AdlibEnable ("HasEscBeenPressed") call the function HasEscBeenPressed every 250ms ? and keep the script constantly running ?

When I run the script it seems to last for 1/2 a second and then end ,so when I press esc the script has already ended and of course nothing happens !

Little help ?

Link to comment
Share on other sites

There's nothing in your script to keep it running. There's nothing that calls the HasEscKeyBeenPressed function... read mine, see if that helps.

HotKeySet("{Esc}", "Printscreen")
hotkeyset("!{esc}"),"_exit"
while 1;this loop keeps the script open
   sleep(10) 
wend

Func Printscreen()
   Send("{PrintScreen}")
   Run("mspaint.exe", "", @SW_MAXIMIZE)
   Send("{enter}")
   Opt("WinWaitDelay", 10)
   HotKeySet("{Esc}")
   Send("{Esc}")
   WinWait("untitled - Paint")
   WinMenuSelectItem("untitled - Paint","", "&Edit", "&Paste")
   adlibenable("adlib"); from now until adlibdisable the func called here will run every 250MS
EndFunc

Func Adlib()
;functions to run every 250ms
   if winexists(save?) then
       send(y)
   endif
endfunc

func _exit();this is so hitting alt-esc exits
   exit
EndFunc

ok, that's fairly theoretical, as you should be able to see... hope it helps though.

Edited by emmanuel

"I'm not even supposed to be here today!" -Dante (Hicks)

Link to comment
Share on other sites

Tnx for the reply emmanuel but I couldnt get ur script to work for me !

Heres my new one which still dosent work.

I have AdlibEnable ("HasEscBeenPressed") which sets a hot key to esc every 250ms but the script keeps ending !

AdlibEnable ("HasEscBeenPressed") 

Func HasEscBeenPressed()
  HotKeySet("{Esc}", "Printscreen")
EndFunc

Func Printscreen()
    Send("{PrintScreen}") 
    Run("mspaint.exe", "", @SW_MAXIMIZE)
    Send("{enter}") 
    Opt("WinWaitDelay", 10) 
    HotKeySet("{Esc}")
    Send("{Esc}")
    WinWait("untitled - Paint") 
    WinMenuSelectItem("untitled - Paint","", "&Edit", "&Paste")
    send("y")
    EndFunc

So resetting a hotkey every 250ms should keep the script running shouldnt it ?

Is there a better way to do this ? So form of loop or will that slow down my system because it continusly running ?

Edited by nova
Link to comment
Share on other sites

slow down, look at my example again, I put a while loop in there to keep it open. Adlibenable isn't a loop in that form. you don't want to loop the creation of the hotkey anyways, that's why I have it outside my loop. Oh, and the script I posted needs fixing, why don't you see where?

Edited by emmanuel

"I'm not even supposed to be here today!" -Dante (Hicks)

Link to comment
Share on other sites

O rite I dont know how that happened but im completly missed the loop in ur script when I copyed it !

Also I got confussed when u had the function checking every 250ms for a window called save? The window which kept comming up wasnt a save pic prompt it was a image editing area not large enough to paste copyed infomation !

The script will only work once if the HotKeySet("{Esc}", "Printscreen") is outside of the loop.

Heres the finished working script !

HotKeySet("!{Esc}", "Off")

while 1;this loop keeps the script open
HotKeySet("{Esc}", "Printscreen")
sleep(10) 
wend

Func Printscreen()
  Send("{PrintScreen}")
  Run("mspaint.exe", "", @SW_MAXIMIZE)
  Send("{enter}")
  Opt("WinWaitDelay", 10)
  HotKeySet("{Esc}")
  Send("{Esc}")
  WinWait("untitled - Paint")
  WinMenuSelectItem("untitled - Paint","", "&Edit", "&Paste")
  sleep(10) 
  Send("y")
EndFunc

func Off();this is so hitting alt-esc exits
  exit
EndFunc

Tnx for the loop command emmanuel never used it before,and cheers for the quick replys !

Link to comment
Share on other sites

I think I will grunt, nod and think to myself "My script already does this"

you really aught to try to wrap your brain around adlibs, they're very handy. what happpens to your script on a xp machine where that popup to resize never shows?

"I'm not even supposed to be here today!" -Dante (Hicks)

Link to comment
Share on other sites

Srry but I cant get ur above code to run with the hotkey outside the loop !, dose it run ok for u ? If so can u try explain to me why it works for u and not me ?

Im trying to get my head around adlibs but I only realised they existed 10mins ago,so I need alittle more time :ph34r: !

what happpens to your script on a xp machine where that popup to resize never shows?

TBH Yep I forgot that little detail,im gonna change it now !

Tnx

edited :Srry emmanuel im talking about the code u posted above,I just checked out ur script screenshot.au3 and yea thats perfect its an advanced version of what im trying to do,pretty cool though nice one !

Edited by nova
Link to comment
Share on other sites

edited :Srry emmanuel im talking about the code u posted above,I just checked out ur script screenshot.au3 and yea thats perfect its an advanced version of what im trying to do,pretty cool though nice one !

Excellent! Glad to help.

"I'm not even supposed to be here today!" -Dante (Hicks)

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...