milkmoron Posted August 1, 2018 Posted August 1, 2018 Hi I'm trying to automate some copy paste stuff. I've set the hotkey to run a function that copies and pastes all the data in one area to another. But when I press the hotkey to do it again it doesnt work. Here is my code. What am I doing wrong? expandcollapse popup#include <MsgBoxConstants.au3> #include <AutoItConstants.au3> Global $g_bPaused = False HotKeySet("{PAUSE}", "TogglePause") HotKeySet("{ESC}", "Terminate") HotKeySet("{INSERT}", "CopyPaste") While 1 Sleep(10000) WEnd Func CopyPaste() $descriptionx = 350 $descriptiony = 335 $saveddate1x = 475 $saveddate1y = 207 $saveddate2x = 545 $saveddate2y = 207 $tran1x =130 $tran1y =185 $tran2x =330 $tran2y =185 $claim1x =130 $claim1y =255 $claim2x =330 $claim2y =255 $action1x =475 $action1y =120 $action2x =675 $action2y =120 $date1x = 475 $date1y = 185 $date2x = 545 $date2y = 185 $time1x = 625 $time1y = 185 $time2x = 675 $time2y = 185 $policy1x = 130 $policy1y = 115 $policy2x = 330 $policy2y = 115 $effectivedate1x =130 $effectivedate1y =160 $effectivedate2x =330 $effectivedate2y =160 $pos = WinGetPos("View Activity") ControlFocus ( "View Activity", "", "" ) WinWaitActive("View Activity") Sleep(100) MouseClick("left", $pos[0] + $descriptionx, $pos[1] + $descriptiony) Send ("^a") Send ("^c") Sleep(100) Local $tDescription = ClipGet() ;ControlFocus ( "View Activity", "", "" ) ;WinWaitActive("View Activity") ;MouseClickDrag ( $MOUSE_CLICK_LEFT, $pos[0] + $saveddate1x, $pos[1] + $saveddate1y, $pos[0] + $saveddate2x, $pos[1] + $saveddate2y ) ;Local $tsaveddate = ClipGet() ControlFocus ( "View Activity", "", "" ) WinWaitActive("View Activity") MouseClickDrag ( $MOUSE_CLICK_LEFT, $pos[0] + $tran1x, $pos[1] + $tran1y, $pos[0] + $tran2x, $pos[1] + $tran2y ) Send ("^a") Send ("^c") Local $ttran = ClipGet() ControlFocus ( "View Activity", "", "" ) WinWaitActive("View Activity") MouseClickDrag ( $MOUSE_CLICK_LEFT, $pos[0] + $claim1x, $pos[1] + $claim1y, $pos[0] + $claim2x, $pos[1] + $claim2y ) Send ("^a") Send ("^c") Local $tclaim = ClipGet() ControlFocus ( "View Activity", "", "" ) WinWaitActive("View Activity") MouseClickDrag ( $MOUSE_CLICK_LEFT, $pos[0] + $action1x, $pos[1] + $action1y, $pos[0] + $action2x, $pos[1] + $action2y ) Send ("^a") Send ("^c") Local $taction = ClipGet() ControlFocus ( "View Activity", "", "" ) WinWaitActive("View Activity") MouseClickDrag ( $MOUSE_CLICK_LEFT, $pos[0] + $date1x, $pos[1] + $date1y, $pos[0] + $date2x, $pos[1] + $date2y ) Send ("^a") Send ("^c") Local $tdate = ClipGet() ControlFocus ( "View Activity", "", "" ) WinWaitActive("View Activity") MouseClickDrag ( $MOUSE_CLICK_LEFT, $pos[0] + $time1x, $pos[1] + $time1y, $pos[0] + $time2x, $pos[1] + $time2y ) Send ("^a") Send ("^c") Local $ttime = ClipGet() ControlFocus ( "View Activity", "", "" ) WinWaitActive("View Activity") MouseClickDrag ( $MOUSE_CLICK_LEFT, $pos[0] + $policy1x, $pos[1] + $policy1y, $pos[0] + $policy2x, $pos[1] + $policy2y ) Send ("^a") Send ("^c") Local $tpolicy = ClipGet() ControlFocus ( "View Activity", "", "" ) WinWaitActive("View Activity") MouseClickDrag ( $MOUSE_CLICK_LEFT, $pos[0] + $effectivedate1x, $pos[1] + $effectivedate1y, $pos[0] + $effectivedate2x, $pos[1] + $effectivedate2y ) Send ("^a") Send ("^c") Local $teffectivedate = ClipGet() $FIADescriptionx = 350 $FIADescriptiony = 325 $FIAactionx = 355 $FIAactiony = 220 $FIADate1x = 525 $FIADate1y = 225 $FIADate2x = 600 $FIADate2y = 225 $FIAtime1x = 685 $FIAtime1y = 225 $FIAtime2x = 750 $FIAtime2y = 225 $FIApolicyx = 600 $FIApolicyy = 115 $FIAeffectivedatex = 600 $FIAeffectivedatey = 140 $FIApos = WinGetPos("Activity / Suspense") WinActivate ( "Activity / Suspense", "" ) ControlFocus ( "Activity / Suspense", "", "" ) WinWaitActive("Activity / Suspense") Sleep(100) MouseClick("left", $FIApos[0] + $FIADescriptionx, $FIApos[1] + $FIADescriptiony) MouseClick("left", $FIApos[0] + $FIADescriptionx, $FIApos[1] + $FIADescriptiony) ClipPut($tDescription) Sleep(100) Send ("^a") Send ("^v") ControlFocus ( "Activity / Suspense", "", "" ) WinWaitActive("Activity / Suspense") MouseClick("left", $FIApos[0] + $FIAactionx, $FIApos[1] + $FIAactiony) MouseClick("left", $FIApos[0] + $FIAactionx, $FIApos[1] + $FIAactiony) If $taction = "Mail Out" then Send ("correspondence") ElseIF $taction = "Agency Bill Collection Follow up" then Send ("accounting") ElseIF $taction = "Appointment" then Send ("Appointment") ElseIF $taction = "Audit Report Form" then Send ("Audit") ElseIF $taction = "Billing" then Send ("Accounting") ElseIF $taction = "Certificate" then Send ("Certificate") ElseIF $taction = "Claim" then Send ("Claim") ElseIF $taction = "Declined by Company" then Send ("Declined by Company") ElseIF $taction = "Declined by Customer" then Send ("Declined by Customer") ElseIF $taction = "Direct Bill Copy" then Send ("correspondence") ElseIF $taction = "Fax" then Send ("correspondence") ElseIF $taction = "Follow-up" then Send ("Follow-up") ElseIF $taction = "Fraud Form" then Send ("correspondence") ElseIF $taction = "Insd provided docs/UW" then Send ("customer information") ElseIF $taction = "Lease Agreement" then Send ("customer information") ; ElseIF $taction = "Loss Runs" then ; Send ("Loss run") ElseIF $taction = "Mail Out" then Send ("correspondence") ElseIF $taction = "Non-renewal Notified Agency" then Send ("Non-renewal Notified Agency") ElseIF $taction = "Policy Change Request" then Send ("Policy Change Request") ElseIF $taction = "Policy PDF" then Send ("Policy processed") ElseIF $taction = "Premium Audit" then Send ("audit processed") ElseIF $taction = "Quote" then Send ("Quote Received") ElseIF $taction = "Renewal" then Send ("Renewal") ElseIF $taction = "Telephone In" then Send ("Telephone") ElseIF $taction = "Telephone Out" then Send ("Telephone") ElseIF $taction = "Terrorism" then Send ("correspondence") ElseIF $taction = "Auto ID Card" then Send ("Auto ID Card") ElseIF $taction = "Binder" then Send ("Binder") ElseIF $taction = "Application" then Send ("Application") ElseIF $taction = "Claim Deleted" then Send ("claim payment/claim closed") Endif ControlFocus ( "Activity / Suspense", "", "" ) WinWaitActive("Activity / Suspense") MouseClickDrag ( $MOUSE_CLICK_LEFT, $FIApos[0] + $FIADate1x, $FIApos[1] + $FIADate1y, $FIApos[0] + $FIADate2x, $FIApos[1] + $FIADate2y ) ClipPut($tdate) Send ("^v") ControlFocus ( "Activity / Suspense", "", "" ) WinWaitActive("Activity / Suspense") MouseClickDrag ( $MOUSE_CLICK_LEFT, $FIApos[0] + $FIAtime1x, $FIApos[1] + $FIAtime1y, $FIApos[0] + $FIAtime2x, $FIApos[1] + $FIAtime2y ) ClipPut($ttime) Send ("^v") ControlFocus ( "Activity / Suspense", "", "" ) WinWaitActive("Activity / Suspense") MouseClick("left", $FIApos[0] + $FIApolicyx, $FIApos[1] + $FIApolicyy) MouseClick("left", $FIApos[0] + $FIApolicyx, $FIApos[1] + $FIApolicyy) Send ($tpolicy) ControlFocus ( "Activity / Suspense", "", "" ) WinWaitActive("Activity / Suspense") MouseClick("left", $FIApos[0] + $FIAeffectivedatex, $FIApos[1] + $FIAeffectivedatey) MouseClick("left", $FIApos[0] + $FIAeffectivedatex, $FIApos[1] + $FIAeffectivedatey) Send ($teffectivedate) EndFunc
wolflake Posted August 2, 2018 Posted August 2, 2018 I'm not sure what's wrong but from a debugging standpoint I'd put in a couple of console writes in different places to see how far your hotkey gets processed. Perhaps it's hung up on WinWaitActive so put in a console write before and after that and keep working your way through to see how far it gets. Hope this helps. -Rick
careca Posted August 2, 2018 Posted August 2, 2018 I would stand clear of this: Send ("^v") Has a tendency to cause problems with stuck keys, like control. Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe
careca Posted August 2, 2018 Posted August 2, 2018 There are some options, one would be writing to ini file. That is, if you find out the cause of the problem is that the ctrl key gets stuck. Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe
Xandy Posted August 2, 2018 Posted August 2, 2018 (edited) You might be able to use ClipPut(). Also simply using _SendEx() instead of Send() helps reduce stuck keys, by enforcing modifier keys are released before being sent. _SendEx("^v") Func _SendEx($ss, $raw = 0, $modup = 0, $pWin_title = -1, $pControl = "") ;when this function is called control, shift, and alt must be released before $ss keys are sent If $modup = 0 Then ; shift, ctrl, alt While _IsPressed("10") Or _IsPressed("11") Or _IsPressed("12") Sleep(20) ;feed the cpu 20 milliseconds WEnd EndIf If $pWin_title <> -1 Then ControlSend($pWin_title, "", $pControl, $ss, $raw) Else Send($ss, $raw) EndIf EndFunc ;==>_SendEx Note, I didn't really look at your code. An .ini sounds like a really good way to go. Edited August 2, 2018 by Xandy Human Male Programmer (-_-) Xandy About (^o^) Discord - Xandy Programmer MapIt (Tile world editor, Image Tile Extractor, and Game Maker)
Xandy Posted August 2, 2018 Posted August 2, 2018 (edited) I suppose "Paste" is really ClipGet() I don't know if these will help, but they access the Clipboard directly without hotkeys. ClipPut ( "value" ), ClipGet() You already know ClipPut(). I just read it in your code. Sorry Edited August 2, 2018 by Xandy Human Male Programmer (-_-) Xandy About (^o^) Discord - Xandy Programmer MapIt (Tile world editor, Image Tile Extractor, and Game Maker)
careca Posted August 2, 2018 Posted August 2, 2018 Then there's the Send("{CONTROLDOWN}") Send("{CONTROLUP}") Im not even sure the stuck keys are the problem here, just have seen in many cases it is a problem. Is there any other way to grab the text from wherever you're doing it? Maybe read the control text? Mouse drag and ctrl+c / v is kinda messy imo. Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe
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