2

Does AutoHotkey have anything similar to "ClipWait" for "Ctrl+A" / "Select All".

Or is there a possibility to get such a function somehow ?

Vaibhav
  • 123
  • 8
  • Usually `sleep 100` is okay. Why don't you use it? Otherwise the only thing that comes to mind is analyzing the change of pixel colors in the window with [PixelGetColor](http://ahkscript.org/docs/commands/PixelGetColor.htm). – wOxxOm Oct 22 '15 at 22:19
  • Working on a SysListView321 which contains more than 7000 rows, everyday. But during same operation there are other SysListView321 tables with less than 2000 rows. So, if i increase sleep time. The whole operation goes slow because of a few tables having 7k+ rows. If i reduce sleep time, the next step of Ctrl+C and clipwait will not get completed when a huge table is encountered and the operation will hang and wait. Hence, was looking for something similar to clipwait for ctrl+a as well. Going to check your suggestion on Pixel Color change. :) thanks – Vaibhav Oct 23 '15 at 12:40
  • Take a look at [ControlGet](http://ahkscript.org/docs/commands/ControlGet.htm): `ControlGet, txt, list, , SysListView321, YOURWINDOWTITLE` – wOxxOm Oct 23 '15 at 12:50
  • Using 2 versions of code for same purpose, already. The other version i call "Slow Version" uses ControlGet and stores all data in a variable. But Ctrl+a Ctrl+c clipboard works like 3 times faster.. – Vaibhav Oct 23 '15 at 14:59

2 Answers2

1

Would this be sufficient?

^b::
    send ^a
    selectionWait()
    msgbox, All has been selected
return

selectionWait() {
    clipboardSave := clipboardAll
    loop {
        send ^c
        if(clipboard != clipboardSave)
            if(clipboard != "")
                break
    }
    clipboard := clipboardSave
}

ctrl+c IS fired before everything is selected, but this is on purpose. the action will be repeated until the clipboard contents have changed, and the clipboard will be reset to the previous value afterwards

phil294
  • 10,038
  • 8
  • 65
  • 98
  • How will it allow time to Ctrl+a to finish its select-all operation, and only then begin copy operation ? The problem usually faced is: if data amount is huge then Ctrl+a takes more than usual time to select complete data. Must not fire Ctrl+c before that select operation has been completed. Hope i was able to explain myself. – Vaibhav Oct 25 '15 at 11:59
  • ah now I see. i edited my answer, but the principle stays the same. does it work for you? – phil294 Oct 25 '15 at 12:57
  • Not sure how clipboard works. Is clipboard filled with entire selection at one go? Or, is it filled row by row ? Eg. there are like 7000 rows of data, it might so happen that only 3000 or so (arbitrarily saying) rows enter clipboard and code checks `if(clipboard != clipboardSave)` In case entire 7000 rows are saved to clipboard (by windows) at one go, then your code will work perfectly. Else, even if 100 rows of data is found your code will fire next command and will end up with partial data only. Pardon my ignorance, if any. – Vaibhav Oct 25 '15 at 13:13
  • 1
    no, your scepticism is very helpful, keep it up. I thought clpb was filled up at once, but now that you said it, I tried it out. It seems that at first, clipboard gets emptied (`:=""`) and in the next step, filled 100% without and buffering. So you might want to include a `if(clipboard != "")` somewhere – phil294 Oct 25 '15 at 13:30
  • Thanks, Blauhirn. Pls explain what you mean by "and in the next step, filled 100% without and buffering" Going to try it out on 7k+ rows in a short while. Will get back with results. – Vaibhav Oct 25 '15 at 14:02
  • 1
    sry, no native speaker here. xD - I used a small script on a 200 MB file's text contents and I observed two states the `clipboard` variable went through: 1st, it lost all of its previous contents (whatever they were). 2nd, it contained all of the selected lines at once. There were not steps in between, no filling by row by row - it happened all at once. – phil294 Oct 25 '15 at 14:07
  • i think your solution works perfectly. Going to test it full day tomorrow. If any issues arise then will comment day after tomorrow. Thanks a lot, Blauhirn – Vaibhav Oct 25 '15 at 22:03
0

I had the same problem when selecting many rows from a network database. The “Select All” command didn't have time to complete, hence making Copy & ClipWait useless, Here's the beautiful fix:

Loop
{
    Send, ^a
    Send, ^c   
    ClipWait, 1     
    if (!ErrorLevel)  
        break
}

Or like this if you want to limit the wait to 5 seconds:

Loop, 5
{
    Send, ^a
    Send, ^c   
    ClipWait, 1     
    if (!ErrorLevel)  
        break
}
Dobbelina
  • 71
  • 1
  • 5