Clipboard troubles and variables

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Amarillien
Posts: 2
Joined: 15 Jun 2017, 15:08

Clipboard troubles and variables

21 Jun 2017, 13:10

Hi,

I've got a problem with a script that copies cell data from excel and then pastes these variables in another application.
I got two variables that each grab data from a cell in excel. The symptoms of the problem is that often it seems that the two variables get the same values though they should not. should i do something different?
The excel file im working in can contain up to 10 000 rows with two cells for each row. The script copies cell 1 and sets it in a variable and does the same for the other cell then it switch to the other application and pastes them in two fields and presses a button.
The variables are unreliable, sometimes it works and sometimes not.
I'll give you the code below..... don't judge me... it's probably not the most perfect code you have seen since im rather new to this scripting thing :) Notations are in swedish :)

SetMouseDelay, 100
Clipboard :="" ;Rensar Clipboard
Sleep 200
WinActivate, ahk_exe Excel.exe ;Byter fönster till Excel
Send, ^{Home}
Send, ^{Down} ;Send blocket ner till Loop gör
Send, {Down} ;så att det står END längs ner i exceldatat
Send, END ;på A kolumnen och ställer markören i A1 som ursprungsläge.
Send, ^{Up}
Send, ^{Up}

Loop { ;Loopen börjar för att mata in data i Regina och fullbetala E-Mål.
Clipboard :=""
Send, {Down}
Send, ^c
ClipWait,,1
if InStr(Clipboard, "END") ;Om textstrengen i Clipboarden innehåller END så bryter den loopen
Break ;och går längs ner i scriptet för att visa ett meddelande om att listan är klar.
PerVar := clipboard ;Sätter en variabel med det som finns i clipboard
Sleep, 300
Clipboard :=""
Send, {Right}
Send, ^c
ClipWait,,1
DiaVar := clipboard ;Sätter en variabel med det som finns i clipboard
sleep, 300
Send, {Left}
WinActivate, Regina [xxxxxxx] ;Byter fönster till Regina.
Sleep, 500
MouseClickDrag, Left, 201, 292, 450, 292 ;Markerar fältet
Send , {delete}
Sleep, 500
Send %PerVar% ;Gör ett musklick på specifika koordinater i aktiva fönstret(relativa till aktiva fönstret). (Gäldenär)
Sleep, 2000
MouseClickDrag, Left, 204, 232, 450, 238 ;Markerar fältet
send , {delete}
Sleep, 500
Send %DiaVar%
Sleep, 300
Click 581, 368 ;Klickar på tomt utrymme för att aktivera båda persn och måln så att åtgärda knappen blir tillgänglig.
Sleep, 2000
Send , {Enter} ;registrera åtgärd
Sleep, 800
WinActivate, ahk_exe Excel.exe ;Byter fönster till Excel
Sleep 400
}
MsgBox, ,, Listan är klar. (Tryck OK)


$Esc::ExitApp
Guest

Re: Clipboard troubles and variables

25 Jun 2017, 04:38

Perhaps replace the ClipWaits you have with the simple Sleep 300 - personally I find a sleep to work better for me compared to Clipwait.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: aitaixy, dipahk, Nerafius and 206 guests