Jump to content

_ScreenCapture_Capture not working


Recommended Posts

So this is a part of my script : 

func _xxxxxx
   WinActivate(xxxxx)
   MouseClick(xx)
   sleep(5000)
   send("xx")
   #include<ScreenCapture.au3>
   _ScreenCapture_Capture(@ScriptDir'\test.jpg',1238, 432, 1328, 447)
   EndFunc

Whenever I write this code, I get an error from autoit saying : 

_ScreenCapture_Capture(@ScriptDir'\test.jpg',1238, 432, 1328, 447)
_ScreenCapture_Capture(^ ERROR

Anyone knows how to fix that? 

 

Edited by jameelo25
Link to comment
Share on other sites

  • Moderators

That would be because you need a & between the @Scriptdir macro and the rest of the path. The help file is your friend

Edited by JLogan3o13

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

2 minutes ago, JLogan3o13 said:

That would be because you need a & between the @Scriptdir macro and the rest of the path. The help file is your friend

Yeah, I discovered that right now, but the problem is im still getting a different error now, it says that the variable is mentioned without it being declared :(

Edited by jameelo25
Link to comment
Share on other sites

You can't put an #include inside of another function. Move that #include line to the top of your script.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Sorry! Here it is 

"C:\Program Files (x86)\AutoIt3\Include\ScreenCapture.au3" (60) : ==> Variable used without being declared.:
_WinAPI_BitBlt($hCDC, 0, 0, $iW, $iH, $hDDC, $iLeft, $iTop, $__SCREENCAPTURECONSTANT_SRCCOPY)
_WinAPI_BitBlt($hCDC, 0, 0, $iW, $iH, $hDDC, $iLeft, $iTop, ^ ERROR

 

It's the same script above but I added the &

Link to comment
Share on other sites

2 minutes ago, jameelo25 said:

I put it on top of the script

And what happened? Where's you ACTUAL script then? We can't work with old scripts you know don't work.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

7 minutes ago, BrewManNH said:

And what happened? Where's you ACTUAL script then? We can't work with old scripts you know don't work.

func _xxxxxx
   WinActivate(xxxxx)
   MouseClick(xx)
   sleep(5000)
   send("xx")
   _ScreenCapture_Capture(@ScriptDir&'\test.jpg',1238, 432, 1328, 447)
   EndFunc

The #include got moved to the top of the script, I still get the same error :

"C:\Program Files (x86)\AutoIt3\Include\ScreenCapture.au3" (60) : ==> Variable used without being declared.:
_WinAPI_BitBlt($hCDC, 0, 0, $iW, $iH, $hDDC, $iLeft, $iTop, $__SCREENCAPTURECONSTANT_SRCCOPY)
_WinAPI_BitBlt($hCDC, 0, 0, $iW, $iH, $hDDC, $iLeft, $iTop, ^ ERROR

Edited by jameelo25
Link to comment
Share on other sites

What version of AutoIt are you using?

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

That's not the version of AutoIt, that's the version of SciTE. Run this script, and paste your clipboard in here.

#include <Misc.au3>
; Version: 1.00. AutoIt: V3.3.8.1
; Retrieve the recommended information of the current system when posting a support question.
Local $sSystemInfo = 'I have a valid AutoIt support question and kindly provided the details of my system:' & @CRLF & @CRLF & _
          'AutoIt Version: V' & @AutoItVersion & ' [' & (@AutoItX64 ?'X64':'X32') & ']' & @CRLF & _
          'Windows Version: ' & @OSVersion & ' [' & @OSArch & ']' & @CRLF & _
          'Language: ' & _GetOSLanguage() & ' (' & @OSLang & ')' & @CRLF & @CRLF
ClipPut($sSystemInfo)
MsgBox(4096, 'This info has been copied to the clipboard. Use Ctrl + V to retrieve it.', $sSystemInfo)

Func _GetOSLanguage()
     Local $aString[20] = [19, "0409 0809 0C09 1009 1409 1809 1C09 2009 2409 2809 2C09 3009 3409", "0404 0804 0C04 1004 0406", "0406", "0413 0813", "0425", _
               "040B", "040C 080C 0C0C 100C 140C 180C", "0407 0807 0C07 1007 1407", "040E", "0410 0810", _
               "0411", "0414 0814", "0415", "0416 0816", "0418", _
               "0419", "081A 0C1A", "040A 080A 0C0A 100A 140A 180A 1C0A 200A 240A 280A 2C0A 300A 340A 380A 3C0A 400A 440A 480A 4C0A 500A", "041D 081D"]
     Local $aLanguage[20] = [19, "English", "Chinese", "Danish", "Dutch", "Estonian", "Finnish", "French", "German", "Hungarian", "Italian", _
               "Japanese", "Norwegian", "Polish", "Portuguese", "Romanian", "Russian", "Serbian", "Spanish", "Swedish"]
     For $i = 1 To $aString[0]
          If StringInStr($aString[$i], @OSLang) Then
               Return $aLanguage[$i]
          EndIf
     Next
     Return $aLanguage[1]
EndFunc   ;==>_GetOSLanguage

 

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

22 minutes ago, BrewManNH said:

That's not the version of AutoIt, that's the version of SciTE. Run this script, and paste your clipboard in here.

#include <Misc.au3>
; Version: 1.00. AutoIt: V3.3.8.1
; Retrieve the recommended information of the current system when posting a support question.
Local $sSystemInfo = 'I have a valid AutoIt support question and kindly provided the details of my system:' & @CRLF & @CRLF & _
          'AutoIt Version: V' & @AutoItVersion & ' [' & (@AutoItX64 ?'X64':'X32') & ']' & @CRLF & _
          'Windows Version: ' & @OSVersion & ' [' & @OSArch & ']' & @CRLF & _
          'Language: ' & _GetOSLanguage() & ' (' & @OSLang & ')' & @CRLF & @CRLF
ClipPut($sSystemInfo)
MsgBox(4096, 'This info has been copied to the clipboard. Use Ctrl + V to retrieve it.', $sSystemInfo)

Func _GetOSLanguage()
     Local $aString[20] = [19, "0409 0809 0C09 1009 1409 1809 1C09 2009 2409 2809 2C09 3009 3409", "0404 0804 0C04 1004 0406", "0406", "0413 0813", "0425", _
               "040B", "040C 080C 0C0C 100C 140C 180C", "0407 0807 0C07 1007 1407", "040E", "0410 0810", _
               "0411", "0414 0814", "0415", "0416 0816", "0418", _
               "0419", "081A 0C1A", "040A 080A 0C0A 100A 140A 180A 1C0A 200A 240A 280A 2C0A 300A 340A 380A 3C0A 400A 440A 480A 4C0A 500A", "041D 081D"]
     Local $aLanguage[20] = [19, "English", "Chinese", "Danish", "Dutch", "Estonian", "Finnish", "French", "German", "Hungarian", "Italian", _
               "Japanese", "Norwegian", "Polish", "Portuguese", "Romanian", "Russian", "Serbian", "Spanish", "Swedish"]
     For $i = 1 To $aString[0]
          If StringInStr($aString[$i], @OSLang) Then
               Return $aLanguage[$i]
          EndIf
     Next
     Return $aLanguage[1]
EndFunc   ;==>_GetOSLanguage

 

It's 3.3.14.5, didn't know that, really sorry.

Link to comment
Share on other sites

15 hours ago, jameelo25 said:

It's 3.3.14.5, didn't know that, really sorry.

No worries.

BTW, I ran the example script in the help file for _ScreenCapture_Capture and did not see that error. Is it possible for you to post the entire script you're using, or at least a reproducer that demonstrates the problem?

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

On 5/16/2018 at 3:59 PM, BrewManNH said:

No worries.

BTW, I ran the example script in the help file for _ScreenCapture_Capture and did not see that error. Is it possible for you to post the entire script you're using, or at least a reproducer that demonstrates the problem?

HotKeySet("{^}", "_switchnumb")
   sleep(100)
WEnd
#include<ScreenCapture.au3>
func _switchnumb()
   WinActivate("MEmu1")
   MouseClick("left", 1434, 317) ;free button
   MouseClick("left", 1187, 162) ;state Select
   MouseClick("left", 1456, 366) ;delaware
   MouseClick("left", 1450, 791) ;ok
   MouseClick("left", 1174, 202) ;select area code
   MouseClick("left", 1457, 433) ;area code
   MouseClick("left", 1453, 472) ;ok
   MouseClick("left", 1240, 246) ;get a custom number
   MouseClick("left", 1448, 484) ;ok
   sleep(5000)
  send("^4")
   sleep(2000)
   WinActivate("Chrome")
   _ScreenCapture_Capture(@ScriptDir&'\test.jpg', 1234, 432, 1327, 446 )
   EndFunc

Here :D

Link to comment
Share on other sites

I see the problem. Your #include statement is after the While loop, the code in it doesn't get run. The functions are added to the script so the functions are there to be activated but the constants added to the UDF are never added to the variable table.

Do this instead.

#include <ScreenCapture.au3> ; <<<<<<<<<<<<<<<<<<<<< Moved to the TOP of the script, as I explained previously.
HotKeySet("{^}", "_switchnumb")
While 1
    Sleep(100)
WEnd

 

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

4 hours ago, BrewManNH said:

I see the problem. Your #include statement is after the While loop, the code in it doesn't get run. The functions are added to the script so the functions are there to be activated but the constants added to the UDF are never added to the variable table.

Do this instead.

#include <ScreenCapture.au3> ; <<<<<<<<<<<<<<<<<<<<< Moved to the TOP of the script, as I explained previously.
HotKeySet("{^}", "_switchnumb")
While 1
    Sleep(100)
WEnd

 

Thank you so much!! It's working now, moving it to the top actually fixed it! Thanks again!

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...