autosign1k Posted May 12, 2016 Share Posted May 12, 2016 expandcollapse popupHotKeySet("{F1}", "LWTcopyAndPaste1") HotKeySet("{F2}", "LWTcopyAndPaste1") HotKeySet("{F3}", "LWTcopyAndPaste1") HotKeySet("{F4}", "LWTcopyAndPaste1") HotKeySet("{`}", "Ignore") ;HotKeySet("{ESCAPE}", "Terminate") sleep(2000) While 1 sleep(10) WEnd Func LWTcopyAndPaste1() Local $englishString = "" ;get original mouse position $startPOSX = MouseGetPos(0); $startPOSY = MouseGetPos(1); ;copy highlighted english definition Sleep(5) Send("{CTRLDOWN}c{CTRLUP}") Sleep(5) $englishString = ClipGet() Sleep(5) ;paste to define box MouseMove(1130,200,0) Sleep(5) MouseClick("left") Sleep(5) Send("{CTRLDOWN}v{CTRLUP}") Sleep(5) ;save send("{ENTER}") Sleep(5) ;reposition mouse to start MouseMove($startPOSX,$startPOSY,0); ToolTip($englishString,650,247) EndFunc The script is pretty simple. Pressing F1-F4 copies highlighted text to a box then sends enter to save it. The problem is sometimes it pastes things on the clipboard from the previous word meaning it did not copy. Since it saves so fast I do not even realize it made a mistake. That is why I had to add a ToolTip that is constantly on showing what was last saved. Trying to fix something saved incorrectly is very slow so I would like to find out how to stop this from messing up. Link to comment Share on other sites More sharing options...
jdelaney Posted May 12, 2016 Share Posted May 12, 2016 (edited) Different applications require different length of presses to register...play with the AutoITSetOptions. Also, send is sending at the active window, where sometimes, your mouse needs to be within the frame of that window...depends on the app. You might rather look into controlsend (which is more accurate, but still has the issues with the application not registering the send) 100% - use ControlGetText...ControlSetText or the DOM object if it's IE. Edited May 12, 2016 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
mikell Posted May 12, 2016 Share Posted May 12, 2016 I'd try longer Sleep's - i.e. Sleep(50) - and WinActivate before Send("^c") But as jdelaney said Control* funcs are much better 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