RandomSF Posted February 17, 2006 Share Posted February 17, 2006 I have a simple title case script that works everywhere except MS Access and Word. Sleep(10) Send("^c") $x=clipget() $rez = Titlecase($x) ClipPut($rez) Send("^v") If I highlight text in any other app, press the shortcut key sequence to fire the AutoIT script, it works fine. In Access and Word nothing happens. Adding a msgbox to see what's in the clipboard brings up an error showing that nothing is there. Has anyone experienced this, and more importantly, does anyone have a fix? Link to comment Share on other sites More sharing options...
CyberSlug Posted February 17, 2006 Share Posted February 17, 2006 Perhaps the keyboard shortcut already means something in Word and Access. Try a hotkey such as PAUSE that has a very low chance of conflicting. ; Example HotKeySet("{PAUSE}", "Upper") While 1 Sleep(100) WEnd Func Upper() Sleep(10) Send("^c") $x=clipget() $rez = StringUpper($x) ClipPut($rez) Send("^v") EndFunc Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig! Link to comment Share on other sites More sharing options...
RandomSF Posted February 17, 2006 Author Share Posted February 17, 2006 I was careful to pick something that Access doesn't use (this works on my previous computer and other computers in the office). I even tried a different combination and it still doesn't work. Link to comment Share on other sites More sharing options...
RandomSF Posted February 20, 2006 Author Share Posted February 20, 2006 (edited) I think I may not have stated myself clearly. The hotkey I am talking about fires the Windows Shortcut that points at the AutoIt script (EXE actually). The hotkey is not part of the AutoIt script itself. The odd thing about this is that it works on my previous computer. Both machines run Windows XP, Office 2003, same SPs. If I copy the text to the clipboard first manually, then run the macro via the Windows Shortcut hotkey, then paste manually, it works in Office. In other programs, the Copy and Paste functions within the AutoIt macro are sufficient. Still baffled. Scott Edited February 20, 2006 by RandomSF Link to comment Share on other sites More sharing options...
herewasplato Posted February 20, 2006 Share Posted February 20, 2006 (edited) Try this:Sleep(50) Send("^c") Sleep(50) $x = ClipGet() Sleep(50) $rez = Titlecase ($x) Sleep(50) ClipPut($rez) Sleep(50) Send("^v") Edited February 21, 2006 by herewasplato [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
RandomSF Posted February 21, 2006 Author Share Posted February 21, 2006 (edited) That fixed it. Many thanks. (I can hear the wicked witch saying, "Sleeeeep, sleeeeeeep.") edit: Actually, I only needed the Sleep before the Cut and Paste functions Sleep(50) Send("^c") $x = ClipGet() $rez = Titlecase ($x) ClipPut($rez) Sleep(50) Send("^v") Could this need for extra sleep time be because the CPU is very fast relative to the previous machine? Edited February 21, 2006 by RandomSF Link to comment Share on other sites More sharing options...
herewasplato Posted February 22, 2006 Share Posted February 22, 2006 ...Could this need for extra sleep time be because the CPU is very fast relative to the previous machine?This has been discussed several times - with no hard conclusion as to why sleeps are needed around clipboard operations on some computers. Best guess was when the clipboard contains large amounts of data - like an image - it just takes a while to clear that out and make room for what control-c wants to put in there. I would think that you would need the sleep after the send of control-c --- before the clipget operation... but you decide. I've also used a little loop like this:While 1 ClipPut ("") Sleep (100) $junk = ClipGet () If $junk = "" Then ExitLoop WEndto clear the clipboard before using it... you could speed it up. [size="1"][font="Arial"].[u].[/u][/font][/size] 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