Beetlebailey Posted April 8, 2015 Share Posted April 8, 2015 Good day to all So I am new to programming and to this application. I have written a script for a small toolbar/app launcher for the department I work in to centralize the copious amounts of applications our phone reps have to use. I have added a screen capturing button that when they click it, it snaps a screen shot of their screens. I can get the _ScreenCapture_Capture to work but it doesn't take just one screen shot it. It keeps taking them until you exit out of the program. I then decided to change it to _ScreenCapture_Saveimage function to save the shot to the desktop but am getting "error: Incorrect number of parameters in function call. Not sure what I'm leaving out but any help would be greatly appreciated. Please see script below: expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <INet.au3> #include <IE.au3> #include <Word.au3> #include <excel.au3> #include <ScreenCapture.au3> opt("MustDeclareVar" , 1) MainGUI() ;Name the Variables Func MainGUI() Global $SeondaryGUI , $Page2 , $hBmp , $Screen , $mygui , $newmsg , $Label3 , $Submit , $Edit , $Amysis , $CareManager , $CSA , $HealthX , $Kronos , $Google , $NCR , $NICEPerform , $NICEWFM , $MP , $ReportManager , $RXCLAIM Global $RxPortal , $ie , $Calc , $Password ,$IE , $Button14 , $HFHPAPP , $Button16 , $Label1 , $Label2 ,$Notepad , $Word , $Excel , $Groupwise, $Messenger , $HFlogo , $Button21 , $Pic1 , $CSapps , $msg ;Create the main GUI $mygui = GUICreate("Customer Service Launcher", 514, 711, 258, 173) GUISetCursor (2) GUISetFont(10, 800, 0, "MS Sans Serif") GUISetBkColor(0xA6CAF0) $secondGUI = GUICreate("Customer Service Launcher", 514, 711, 258, 173) GUISetCursor (2) GUISetFont(10, 800, 0, "MS Sans Serif") GUISetBkColor(0xA6CAF0) ;Assign the Variables $Amysis = GUICtrlCreateButton("Amysis", 16, 72, 139, 25) $CareManager = GUICtrlCreateButton("Care Manager", 16, 104, 139, 25) $CSA = GUICtrlCreateButton("CSA", 16, 136, 139, 25) $HealthX = GUICtrlCreateButton("Health X", 16, 168, 139, 25) $Kronos = GUICtrlCreateButton("Kronos", 16, 200, 139, 25) $Google = GUICtrlCreateButton("Google", 16, 232, 139, 25) $NCR = GUICtrlCreateButton("NCR", 16, 264, 139, 25) $NICEPerform = GUICtrlCreateButton("NICE Perform", 16, 296, 139, 25) $NICEWFM = GUICtrlCreateButton("NICE WFM ", 16, 328, 139, 25) $MP = GUICtrlCreateButton("Market Prominence", 16, 360, 139, 25) $ReportManager = GUICtrlCreateButton("Report Manager", 16, 392, 139, 25) $RXCLAIM = GUICtrlCreateButton("Rx Claim", 16, 424, 139, 25) $IE = GUICtrlCreateButton("Internet Explorer", 16, 552, 139, 25) $Dashboard = GUICtrlCreateButton("Dashboard", 16, 488, 139, 25) $HFHPAPP = GUICtrlCreateButton("HP App page", 16, 520, 139, 25) $Screen = GUICtrlCreatePic("S:\Health Plans\Operations\RYANB\UBER\CS App Launcher\Images\Camera.jpg", 176, 288, 100, 60) $RxPortal = GUICtrlCreateButton("RxPortal", 16, 456, 139, 25) $Calc = GUICtrlCreateButton("Calculator", 192, 232, 83, 25) $Label1 = GUICtrlCreateLabel("Applications", 8, 32, 141, 29) GUICtrlSetFont(-1, 18, 800, 2, "Modern No. 20") $Label2 = GUICtrlCreateLabel("Tools", 200, 32, 62, 29) GUICtrlSetFont(-1, 18, 800, 2, "Modern No. 20") $Notepad = GUICtrlCreateButton("Notepad", 192, 72, 83, 25) $Word = GUICtrlCreateButton("Word", 192, 104, 83, 25) $Excel = GUICtrlCreateButton("Excel", 192, 136, 83, 25) $Groupwise = GUICtrlCreateButton("Groupwise", 192, 168, 83, 25) $HFlogo = GUICtrlCreatePic("S:\Health Plans\Operations\RYANB\UBER\CS App Launcher\Images\HF logo.jpg", 288, 10, 180, 60) $Messenger = GUICtrlCreateButton("Messenger", 192, 200, 83, 25) $calendar = GUICtrlCreateMonthCal ("Calendar", 192 , 520 , 292 , 172 ) $Edit1 = GUICtrlCreateEdit("", 288, 72, 217, 353) GUICtrlSetData(-1, "Notes:") $Page2 = GUICtrlCreateButton("Page 2", 288, 432, 211, 57) $Password = GUICtrlCreatePic ("S:\Health Plans\Operations\RYANB\UBER\CS App Launcher\Images\word.jpg" , 24 , 624 , 116 , 76) $Label3 = GUICtrlCreateLabel("Password Keeper", 24, 605, 136, 22) GUISetState() ;Run the gui until window is closed While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE exit Case $msg = $Notepad Run ("notepad.exe") Case $msg = $Calc Run ("calc.exe") Case $msg = $Amysis ShellExecute ("http://hfhp-wcaa.dstcorp.net:8080/amisys-web/Controller?view=jsp/Pportal.jsp") Case $msg = $CareManager ShellExecute("https://apps-hfhp.healthedge.net/Citrix/XenApp/hfhp/auth/login.aspx") Case $msg = $CSA ShellExecute("http://hfhp-wccsa.dstcorp.net:8080/hfhp-PROD-csa/portal") Case $msg = $HealthX ShellExecute("https://secure.healthx.com/publicservice/loginv1/login.aspx?bc=c1503d12-e5a7-43ba-8dc8-4ce5cfc2b5e1&serviceid=8d6ab51b-6c4c-4735-a738-87341c01f849") Case $msg = $Kronos ShellExecute("http://hfvkron.health-first.org/wfc/logon/logonWFC.html") Case $msg = $Google ShellExecute ("https://www.google.com/?gws_rd=ssl") Case $msg = $NCR ShellExecute("http://hfepsprod1.priv.health-first.org/CVMEServer/Login.aspx") Case $msg = $NICEPerform ShellExecute("http://hfniceim1/NiceApplications/Desktop/WebPage/DeskTopWebForm.aspx") Case $msg = $NICEWFM ShellExecute("http://101.202.40.3/agent/") Case $msg = $MP run ("MPC4Cunlock.exe") Case $msg = $ReportManager ShellExecute("http://hfhpsql12p01.priv.health-first.org/Reports/Pages/Folder.aspx") Case $msg = $RXCLAIM ShellExecute("https://asp.rxclaim.catamaranrx.com/RxClaim.html") Case $msg = $IE ShellExecute("http://intranet.health-first.org/") Case $msg = $HFHPAPP ShellExecute("http://intranet.health-first.org/departments/health_plans/apps/index.cfm") Case $msg = $Word $Word = _WordCreate (@ScriptDir & "\Test.doc", 1) ; Check @extended return value to see if attach was successful If @extended Then MsgBox(0, "", "Attached to Existing Window") Else MsgBox(0, "", "Created New Window") EndIf Case $msg = $Excel $Excel = _ExcelBookNew() Case $msg = $Groupwise Run("grpwise.exe") Case $msg = $Messenger run("C:\Program Files (x86)\Novell\Messenger\NMCL32.exe") Case $msg = $Dashboard ShellExecute("https://10.8.3.27:8444/cuic/permalink/PermalinkViewer.htmx?viewId=B194CB921000013A02102C0A0A08031B&linkType=dashboard&uuid=9315d5a3-c745-406a-8ad9-43b27dc55749") Case $msg = $Password ShellExecute( "S:\Health Plans\Operations\RYANB\UBER\CS App Launcher\Files\BLANK Password Keeper.doc") Case $msg = $HFlogo ShellExecute ("https://www.youtube.com/watch?v=9cQgQIMlwWw") Case $msg = $Screen $Screen = _ScreenCapture_SaveImage(@DesktopDir & "\new_screenshot.jpg") Case $msg = $RxPortal ShellExecute("https://healthfirsttrain.rxportal.sxc.com/rxclaim/portal/memberLogin") Case $msg = $Page2 EndSelect WEnd EndFunc Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted April 8, 2015 Moderators Share Posted April 8, 2015 Please look again at the help file entry for _ScreenCapture_SaveImage. The second parameter ($hBitmap) is required, and you would get this from _ScreenCapture_Capture(). That is why you're getting the error. As for the _ScreenCapture_Capture continuing until you close the GUI, can you explain your methodology? It looks as though you are calling it if the GuiGetMsg() equals $Screen, yet that variable is simply a GuiCtrlCreatePic. Your posted code is not runnable without a lot of modification, so can you please explain your intent? Are you expecting the user to click on the pic you create to do a screenshot, or did you intend them to click on a button? Beetlebailey 1 "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 More sharing options...
Beetlebailey Posted April 8, 2015 Author Share Posted April 8, 2015 Hey MVP thank you for the quick response! So the script may not run on external PC's because I have the image files saved to our internal network and it pulls from there. The $Screen variable is intended to create a pic on the gui that when the user clicks it, it takes a screen shot and saves to the desktop.I looked at the help file which I believe means I'd have to turn the Case $msg =$screen into a function instead. Just confused as to where I get the $hBitmap parameter from or how that works to be honest. Thank you much Link to comment Share on other sites More sharing options...
nitekram Posted April 8, 2015 Share Posted April 8, 2015 (edited) #include <ScreenCapture.au3> Example() Func Example() Local $hBmp ; Capture full screen $hBmp = _ScreenCapture_Capture("") ; Save bitmap to file _ScreenCapture_SaveImage(@MyDocumentsDir & "\GDIPlus_Image.jpg", $hBmp) ShellExecute(@MyDocumentsDir & "\GDIPlus_Image.jpg") EndFunc ;==>Example The $hBmp = _ScreenCapture_Capture("") is the part you are missing? EDIT So maybe try: Case $msg = $Screen $hBmp = _ScreenCapture_Capture("") $Screen = _ScreenCapture_SaveImage(@DesktopDir & "new_screenshot.jpg", $hBmp) Edited April 8, 2015 by nitekram Beetlebailey 1 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator Link to comment Share on other sites More sharing options...
Beetlebailey Posted April 8, 2015 Author Share Posted April 8, 2015 Ng1-Nf3, That is the fix to my quandary! Thank you very much you guys have been informative and helpful. Wasn't quite sure as to how I should script that. Much appreciation, Link to comment Share on other sites More sharing options...
Beetlebailey Posted April 8, 2015 Author Share Posted April 8, 2015 the only issue I'm still having is that it keeps taking screen shots until I either close the app or I open then .JPEG it makes on the desktop. Any suggestions? Link to comment Share on other sites More sharing options...
Solution nitekram Posted April 8, 2015 Solution Share Posted April 8, 2015 (edited) I think your code is wrong...take a look at this and compare it to yours. expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <INet.au3> #include <IE.au3> #include <Word.au3> #include <excel.au3> #include <ScreenCapture.au3> ;opt("MustDeclareVar" , 1) MainGUI() ;Name the Variables Func MainGUI() Global $SeondaryGUI , $Page2 , $hBmp , $Screen , $mygui , $newmsg , $Label3 , $Submit , $Edit , $Amysis , $CareManager , $CSA , $HealthX , $Kronos , $Google , $NCR , $NICEPerform , $NICEWFM , $MP , $ReportManager , $RXCLAIM Global $RxPortal , $ie , $Calc , $Password ,$IE , $Button14 , $HFHPAPP , $Button16 , $Label1 , $Label2 ,$Notepad , $Word , $Excel , $Groupwise, $Messenger , $HFlogo , $Button21 , $Pic1 , $CSapps , $msg ;Create the main GUI $mygui = GUICreate("Customer Service Launcher", 514, 711, 258, 173) GUISetCursor (2) GUISetFont(10, 800, 0, "MS Sans Serif") GUISetBkColor(0xA6CAF0) $secondGUI = GUICreate("Customer Service Launcher", 514, 711, 258, 173) GUISetCursor (2) GUISetFont(10, 800, 0, "MS Sans Serif") GUISetBkColor(0xA6CAF0) ;Assign the Variables $Amysis = GUICtrlCreateButton("Amysis", 16, 72, 139, 25) $CareManager = GUICtrlCreateButton("Care Manager", 16, 104, 139, 25) $CSA = GUICtrlCreateButton("CSA", 16, 136, 139, 25) $HealthX = GUICtrlCreateButton("Health X", 16, 168, 139, 25) $Kronos = GUICtrlCreateButton("Kronos", 16, 200, 139, 25) $Google = GUICtrlCreateButton("Google", 16, 232, 139, 25) $NCR = GUICtrlCreateButton("NCR", 16, 264, 139, 25) $NICEPerform = GUICtrlCreateButton("NICE Perform", 16, 296, 139, 25) $NICEWFM = GUICtrlCreateButton("NICE WFM ", 16, 328, 139, 25) $MP = GUICtrlCreateButton("Market Prominence", 16, 360, 139, 25) $ReportManager = GUICtrlCreateButton("Report Manager", 16, 392, 139, 25) $RXCLAIM = GUICtrlCreateButton("Rx Claim", 16, 424, 139, 25) $IE = GUICtrlCreateButton("Internet Explorer", 16, 552, 139, 25) $Dashboard = GUICtrlCreateButton("Dashboard", 16, 488, 139, 25) $HFHPAPP = GUICtrlCreateButton("HP App page", 16, 520, 139, 25) GUICtrlCreatePic("S:\Health Plans\Operations\RYANB\UBER\CS App Launcher\Images\Camera.jpg", 176, 288, 100, 60) $Screen = GUICtrlCreateButton("screen", 192, 340, 83, 25) $RxPortal = GUICtrlCreateButton("RxPortal", 16, 456, 139, 25) $Calc = GUICtrlCreateButton("Calculator", 192, 232, 83, 25) $Label1 = GUICtrlCreateLabel("Applications", 8, 32, 141, 29) GUICtrlSetFont(-1, 18, 800, 2, "Modern No. 20") $Label2 = GUICtrlCreateLabel("Tools", 200, 32, 62, 29) GUICtrlSetFont(-1, 18, 800, 2, "Modern No. 20") $Notepad = GUICtrlCreateButton("Notepad", 192, 72, 83, 25) $Word = GUICtrlCreateButton("Word", 192, 104, 83, 25) $Excel = GUICtrlCreateButton("Excel", 192, 136, 83, 25) $Groupwise = GUICtrlCreateButton("Groupwise", 192, 168, 83, 25) $HFlogo = GUICtrlCreatePic("S:\Health Plans\Operations\RYANB\UBER\CS App Launcher\Images\HF logo.jpg", 288, 10, 180, 60) $Messenger = GUICtrlCreateButton("Messenger", 192, 200, 83, 25) $calendar = GUICtrlCreateMonthCal ("Calendar", 192 , 520 , 292 , 172 ) $Edit1 = GUICtrlCreateEdit("", 288, 72, 217, 353) GUICtrlSetData(-1, "Notes:") $Page2 = GUICtrlCreateButton("Page 2", 288, 432, 211, 57) $Password = GUICtrlCreatePic ("S:\Health Plans\Operations\RYANB\UBER\CS App Launcher\Images\word.jpg" , 24 , 624 , 116 , 76) $Label3 = GUICtrlCreateLabel("Password Keeper", 24, 605, 136, 22) GUISetState() ;Run the gui until window is closed While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE exit Case $msg = $Notepad Run ("notepad.exe") Case $msg = $Calc Run ("calc.exe") Case $msg = $Amysis ShellExecute ("http://hfhp-wcaa.dstcorp.net:8080/amisys-web/Controller?view=jsp/Pportal.jsp") Case $msg = $CareManager ShellExecute("https://apps-hfhp.healthedge.net/Citrix/XenApp/hfhp/auth/login.aspx") Case $msg = $CSA ShellExecute("http://hfhp-wccsa.dstcorp.net:8080/hfhp-PROD-csa/portal") Case $msg = $HealthX ShellExecute("https://secure.healthx.com/publicservice/loginv1/login.aspx?bc=c1503d12-e5a7-43ba-8dc8-4ce5cfc2b5e1&serviceid=8d6ab51b-6c4c-4735-a738-87341c01f849") Case $msg = $Kronos ShellExecute("http://hfvkron.health-first.org/wfc/logon/logonWFC.html") Case $msg = $Google ShellExecute ("https://www.google.com/?gws_rd=ssl") Case $msg = $NCR ShellExecute("http://hfepsprod1.priv.health-first.org/CVMEServer/Login.aspx") Case $msg = $NICEPerform ShellExecute("http://hfniceim1/NiceApplications/Desktop/WebPage/DeskTopWebForm.aspx") Case $msg = $NICEWFM ShellExecute("http://101.202.40.3/agent/") Case $msg = $MP run ("MPC4Cunlock.exe") Case $msg = $ReportManager ShellExecute("http://hfhpsql12p01.priv.health-first.org/Reports/Pages/Folder.aspx") Case $msg = $RXCLAIM ShellExecute("https://asp.rxclaim.catamaranrx.com/RxClaim.html") Case $msg = $IE ShellExecute("http://intranet.health-first.org/") Case $msg = $HFHPAPP ShellExecute("http://intranet.health-first.org/departments/health_plans/apps/index.cfm") Case $msg = $Word ;$Word = _WordCreate (@ScriptDir & "\Test.doc", 1) ; Check @extended return value to see if attach was successful If @extended Then MsgBox(0, "", "Attached to Existing Window") Else MsgBox(0, "", "Created New Window") EndIf Case $msg = $Excel ;$Excel = _ExcelBookNew() Case $msg = $Groupwise Run("grpwise.exe") Case $msg = $Messenger run("C:\Program Files (x86)\Novell\Messenger\NMCL32.exe") Case $msg = $Dashboard ShellExecute("https://10.8.3.27:8444/cuic/permalink/PermalinkViewer.htmx?viewId=B194CB921000013A02102C0A0A08031B&linkType=dashboard&uuid=9315d5a3-c745-406a-8ad9-43b27dc55749") Case $msg = $Password ;ShellExecute( "S:\Health Plans\Operations\RYANB\UBER\CS App Launcher\Files\BLANK Password Keeper.doc") Case $msg = $HFlogo ShellExecute ("https://www.youtube.com/watch?v=9cQgQIMlwWw") Case $msg = $Screen $hBmp = _ScreenCapture_Capture("") $Screen = _ScreenCapture_SaveImage(@DesktopDir & "\new_screenshot.jpg", $hBmp) Case $msg = $RxPortal ShellExecute("https://healthfirsttrain.rxportal.sxc.com/rxclaim/portal/memberLogin") Case $msg = $Page2 EndSelect WEnd EndFunc . Your code, does not have a button for taking a screen shot, rather an image that has a variable $Screen, I changed that, as it does not need a variable, and added a new button called Screen - you can change it to what you want. Edited April 8, 2015 by nitekram Beetlebailey 1 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator 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