AnRios Posted October 23, 2019 Posted October 23, 2019 Greetings, I'm very newbie with scripting and I need a little help: I need to make the X variable to appear in a message box, so I can simply insert the number of times needed for the loop to run, that's all. Could someone help me? For $i = 1 to X Opt("WinTitleMatchMode",2) WinActivate("Relatorio") Sleep (300) BlockInput (1) ; Block User Input Send("{ENTER}") Sleep (1000) Send("{F3}") Sleep (250) MouseClickDrag ( "left" ,353 ,197 ,672 ,437 ,0 ) Sleep (400) BlockInput (0) ; Unblock User Input Opt("WinTitleMatchMode",2) WinActivate("Relatorio") Send("{DOWN}") Next
water Posted October 23, 2019 Posted October 23, 2019 $x = InputBox("Title", "Please enter a number") If @error Then Exit ; Cancelled by user or other error $x = Number($x) For $i = 1 to $x ; ... Your code Next AnRios, SkysLastChance and FrancescoDiMuro 3 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
AnRios Posted October 24, 2019 Author Posted October 24, 2019 @water mate, if it's not too much to ask, I'd like to add another variable into a field inside that InputBox, could you help? The $FileName part: #include <File.au3> #include <ScreenCapture.au3> $x = InputBox("Title", "Insert Value Here", "", "", 320, 150) If @error Then Exit ; Cancelled by user or other error $x = Number($x) HotKeySet("{PRINTSCREEN}", "printscreen") Func printscreen() $FilePath =(@DesktopDir&"/") $FileName = 'Vv' ; THIS IS THE VARIABLE I'D LIKE TO INSERT IN THE INPUTBOX $FileList = _FileListToArray($FilePath, $FileName & '*.jpg', 1) If Not IsArray($FileList) Then $FileName&= '1.jpg' Else $FileName &= $FileList[0] + 1 & '.jpg' EndIf _ScreenCapture_Capture($FilePath & "\" & $FileName, 354, 196, 673, 436) EndFunc For $i = 1 to $x Opt("WinTitleMatchMode",2) WinActivate("Relatorio") Sleep (300) Send("{ENTER}") Sleep (1000) Send("{PRINTSCREEN}") Sleep (400) Opt("WinTitleMatchMode",2) WinActivate("Relatorio") Send("{DOWN}") Next
AnRios Posted October 24, 2019 Author Posted October 24, 2019 I tried adding another box with $y , however it did not work: $y = InputBox("Title", "Insert Value Here", "", "", 320, 150) If @error Then Exit $y = Number($y) HotKeySet("{PRINTSCREEN}", "printscreen") Func printscreen() $FilePath =("D:\Users\XXX\Desktop\PICS"&"/") $FileName = $y ; HERE IT DID NOT WORK $FileList = _FileListToArray($FilePath, $FileName & '*.jpg', 1) If Not IsArray($FileList) Then $FileName&= '1.jpg' Else $FileName &= $FileList[0] + 1 & '.jpg' EndIf _ScreenCapture_Capture($FilePath & "\" & $FileName, 354, 196, 673, 436) EndFunc
Sidley Posted October 24, 2019 Posted October 24, 2019 (edited) Are you trying to put the filePath and fileName together? Edit: I see now, I think you're trying to specify the Filename that the jpg is written to? In that case, remove the '*' before the '.jpg'. As it is now, it will try and write a file called FileName*.jpg. Edited October 24, 2019 by Sidley
water Posted October 24, 2019 Posted October 24, 2019 expandcollapse popup#include <File.au3> #include <ScreenCapture.au3> Global $sFilePath = (@DesktopDir & "/") ; Ask user to provide a value Global $iMaxValue = InputBox("Title", "Plerase enter value: ", "", "", 320, 150) If @error Then Exit ; Cancelled by user or other error $iMaxValue = Number($iMaxValue) ; Ask user to provide a filename Global $sFilename = InputBox("Title", "Please enter file name: ", "", "", 320, 150) If @error Then Exit ; Cancelled by user or other error HotKeySet("{PRINTSCREEN}", "PrintScreen") Func PrintScreen() $aFileList = _FileListToArray($sFilePath, $sFileName & '*.jpg', 1) If Not IsArray($aFileList) Then $sFilename &= '1.jpg' Else $sFilename &= $aFileList[0] + 1 & '.jpg' EndIf _ScreenCapture_Capture($sFilePath & "\" & $sFilename, 354, 196, 673, 436) EndFunc ;==>printscreen Opt("WinTitleMatchMode", 2) For $i = 1 To $iMaxValue WinActivate("Relatorio") Sleep(300) Send("{ENTER}") Sleep(1000) Send("{PRINTSCREEN}") Sleep(400) Opt("WinTitleMatchMode", 2) WinActivate("Relatorio") Send("{DOWN}") Next Can you please describe what you try to achieve with your script? I'm not sure this is the best solution 🤔 SkysLastChance 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
SkysLastChance Posted October 24, 2019 Posted October 24, 2019 (edited) $y = Number($y) This is trying to convert your variable into a number which will return 0 if you put 'Vv' into it. Try it without this line You should view your variables with consolewrite or msgbox to help. MsgBox(0,"title",$y) ConsoleWrite($y & @CR) Edited October 24, 2019 by SkysLastChance You miss 100% of the shots you don't take. -Wayne Gretzky -Michael Scott
AnRios Posted October 24, 2019 Author Posted October 24, 2019 (edited) Ok, I managed to do it like this: :: 1 :: This is my first variable, @water helped me with that. $x = InputBox("Title", "Insert First Variable Here", "", "", 320, 150) If @error Then Exit ;$x = Number($x) It sets the number of times the loop is executed here: For $i = 1 to $x WinActivate("Relatorio") Sleep (250) Send("{ENTER}") Sleep (1000) Send("{HOME}") Sleep (200) WinActivate("Relatorio") Send("{DOWN}") Next :: 2 :: The second one I managed to do by applying the same logic. The catch is to change the variable to String instead of Number. $y = InputBox("Title", "Insert Second Variable Here", "", "", 320, 150) If @error Then Exit$y = String($y) It sets the $FileName which eventually writes the name of the file. As String it works. As Number it didn't. Func printscreen() $FilePath =("C:\Fiscalizacao\Fotos"&"/") $FileName = $y & " - " $FileList = _FileListToArray($FilePath, $FileName & '*.jpg', 1) If Not IsArray($FileList) Then $FileName&= '1.jpg' Else $FileName &= $FileList[0] + 1 & '.jpg' EndIf _ScreenCapture_Capture($FilePath & "\" & $FileName, 354, 196, 673, 436) EndFunc The full code follows: expandcollapse popup#include <File.au3> #include <ScreenCapture.au3> $x = InputBox("Title", "Insert First Variable Here", "", "", 320, 150) If @error Then Exit $x = Number($x) $y = InputBox("Title", "Insert Second Variable Here", "", "", 320, 150) If @error Then Exit $y = String($y) HotKeySet("{HOME}", "printscreen") Func printscreen() $FilePath =("C:\Fiscalizacao\Fotos"&"/") $FileName = $y & " - " $FileList = _FileListToArray($FilePath, $FileName & '*.jpg', 1) If Not IsArray($FileList) Then $FileName&= '1.jpg' Else $FileName &= $FileList[0] + 1 & '.jpg' EndIf _ScreenCapture_Capture($FilePath & "\" & $FileName, 354, 196, 673, 436) EndFunc HotKeySet("{BS}", "Terminate") Func Terminate() Exit 0 EndFunc ;==>Terminate For $i = 1 to $x WinActivate("Relatorio") Sleep (250) Send("{ENTER}") Sleep (1000) Send("{HOME}") Sleep (200) WinActivate("Relatorio") Send("{DOWN}") Next Thanks for the guidance friends! Edited October 24, 2019 by AnRios
water Posted October 24, 2019 Posted October 24, 2019 NB: No need to translate $y to a string. It is already a string as InputBox returns a string. You can test with something like ConsoleWrite(VarGetType($y) & @CRLF) SkysLastChance 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
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