Problem with Simple Excel to Webform Code

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
BRONZ
Posts: 1
Joined: 25 Nov 2019, 01:13

Problem with Simple Excel to Webform Code

25 Nov 2019, 01:27

I'm new to AHK and I'm having problem in the below code. The problems is when the second cell is being selected and copied, the content is not being pasted neither is the TAB after pasting is being sent. All the other thing's the ALT+TAB is working correctly. Before this I tested the code without loop it was working correctly, the problem occurred after trying to do the same with loop

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

^j::
Clipboard := ""
xl := ComObjCreate("Excel.Application")
xl.Visible := true
path = xxxx ; real path in real code
xl.Workbooks.Open(Path)
xl.sheets("Converted").select ; selects the sheet

;set first column
col = 6

Loop 2
{

;set columns to copy
col1 := "F" . col
col2 := "G" . col

;first cell selection and copy
xl.Range(col1).Select
xl.Range(col1).Copy

;ALT+TAB to switch to web form
Send, {Alt Down}
Send, {Tab}
Send, {Alt Up}

;TAB's to switch to first form field
if(A_Index = 1)
{
    Loop 13
    {
            Send {Tab}
        }
}

;Paste Copied Cell Data and TAB to next field ;Form is restricted only this kind on input works
SendInput {Raw}%clipboard%
Send, {Tab}

;ALT+TAB to switch back to excel file
Send, {Alt Down}
Send, {Tab}
Send, {Alt Up}

;Clear Clipboard before copying
Clipboard:= ""
ClipWait, 2

;second cell selection and copy
xl.Range(col2).Select
xl.Range(col2).copy

;ALT+TAB to switch back to web form
Send, {Alt Down}
Send, {Tab}
Send, {Alt Up}

;Paste the copied cell and TAB to next form field
SendInput {Raw}%clipboard%
Send, {Tab}

;ALT+TAB back to excel file
Send, {Alt Down}
Send, {Tab}
Send, {Alt Up}

;increment to get next column
col++

}

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: filipemb, Google [Bot], Spawnova and 338 guests