Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

read .csv file, parse, send, pause


  • Please log in to reply
10 replies to this topic
surfbum3000
  • Members
  • 53 posts
  • Last active: Jun 06 2011 07:31 PM
  • Joined: 05 Oct 2005
The following code works as far as reading the .csv file, parsing, and sending the data to the data entry screen. What I need is for the loop to pause when the cursor reaches the Save button, send mouseclick on the Save button, reopen the screen, and then resume the loop. How can I insert a pause so I can send keystokes and then resume the loop?

WinWait, Individual Service Entry (Version Q),
IfWinNotActive, Individual Service Entry (Version Q), , WinActivate, Individual Service Entry (Version Q),
WinWaitActive, Individual Service Entry (Version Q),
MouseClick, left, 96, 55
Sleep, 100
Loop, Read, R:\AutoHotKey\Import\Test.csv
{
Loop, parse, A_LoopReadLine, CSV
{
WinActivate, Individual Service Entry (Version Q),
SetKeyDelay -1, 0
Send, {CAPSLOCK}%A_LoopField%{TAB}
Sleep, 500
}
}

toralf
  • Moderators
  • 4035 posts
  • Last active: Aug 20 2014 04:23 PM
  • Joined: 31 Jan 2005
How is the cursor getting to the save button? Do you move your mouse over that button?
Ciao
toralf
 
I use the latest AHK version (1.1.15+)
Please ask questions in forum on ahkscript.org. Why?
For online reference please use these Docs.

  • Guests
  • Last active:
  • Joined: --
Since the code is sending a Tab between fields, the cursor will eventually come to the Save button. When it gets there, I need the code to send a keystoke {ENTER} or a MouseClick.

BoBo
  • Guests
  • Last active:
  • Joined: --

the data entry screen

web or app?
I'd prefer to "kick the butt'on" using one of AHK's Control commands if possible!
Once that's done, try to trigger the refreshed/reloaded data entry screen and if caught successfully ... play it again Sam :wink:

  • Guests
  • Last active:
  • Joined: --
It's an application installed on my workstation.

surfbum3000
  • Members
  • 53 posts
  • Last active: Jun 06 2011 07:31 PM
  • Joined: 05 Oct 2005
This code is close to what I need it to do but I'm not quite there yet. The code reads the text file, parses it, sends the variable to the correct field on the screen named Individual Service Entry (Version Q). After the first line of text, I need the code to pause, then click the Save button, and then reopen the window Individual Service Entry (Version Q) for the next line of data entry. The code below does this, but after the MouseClick on the Save button, the cursor jumps down the page for about 10 lines, then reopens the data entry window. I would like for it to stop clicking in each successive line on the screen before it reopens the Individual Service Entry (Version Q). Any idea as to why the cursor moves down the screen 10 times before the MouseClick works?
*********************************************
WinWait, Scheduler Live  [Single Day View], 
IfWinNotActive, Scheduler Live  [Single Day View], , WinActivate, Scheduler Live  [Single Day View], 
WinWaitActive, Scheduler Live [Single Day View], 
MouseClick, right,  275,  481
Sleep, 100
WinActivate  ; Uses the last found window.
MouseClick, left,  363,  526
Sleep, 100
WinWait, Individual Service Entry (Version Q), 
IfWinNotActive, Individual Service Entry (Version Q), , WinActivate, Individual Service Entry (Version Q), 
WinWaitActive, Individual Service Entry (Version Q), 
MouseClick, left,  96,  55
Sleep, 100
Loop, Read, R:\AutoHotKey\Import\Test.csv
{
   Loop, parse, A_LoopReadLine, CSV
   {
       WinActivate, Individual Service Entry (Version Q),
	SetKeyDelay -1, 0
	Send, {CAPSLOCK}%A_LoopField%{TAB}
	Sleep, 500
   }
ControlFocus, DFButton1, Individual Service Entry (Version Q); Set focus to the Save button
MouseClick, left,  313,  534
Sleep, 100
MouseClick, right,  303,  482
Sleep, 100
}


not-logged-in-daonlyfreez
  • Guests
  • Last active:
  • Joined: --
Ok, fiddled around with it a bit, restructured it and removed all that I thought unnecessary... untested ofcourse :p ...

One note: you are depending on the amount of fields in the csv-file for the filling of the fields in the entry window now, if the file contains too many fields, the script will malfunction...

MainWindowTitle = Scheduler Live [Single Day View]
EntryWindowTitle = Individual Service Entry (Version Q)

WinActivate, %MainWindowTitle%
; Activate your 'main' window

WinWaitActive,,,10
   IfEqual, ERRORLEVEL, 1, MsgBox, Timeout...
; Wait until it's active, show a message box if timed out.

;MouseClick, right,  275,  481 ; ??? ??? Scriptrecorder thingy?

; now the action

Loop, Read, R:\AutoHotKey\Import\Test.csv 
{ 
   
   WinActivate, %MainWindowTitle%
   MouseClick, left,  363,  526
   ; Opens the entry window I guess, can probably be done differently.
   ; Avoid using the mouse if possible.

   WinWaitActive, %EntryWindowTitle%,,10
      IfEqual, ERRORLEVEL, 1, MsgBox, Timeout...
   ; Wait until the entry window is active, show a message box if timed out.

   MouseClick, left,  96,  55
   ; first entry field? you can probably use Send, {Tab}
   SetKeyDelay -1, 0 
   Loop, parse, A_LoopReadLine, CSV 
   {
   Send, %A_LoopField%{TAB} ; {CAPSLOCK} ? Scriptrecorder ?
   Sleep, 500 ; try tweaking this for speed 
   }
   ControlFocus, DFButton1, Individual Service Entry (Version Q); Set focus to the Save button
   Send, {Enter}
}


surfbum3000
  • Members
  • 53 posts
  • Last active: Jun 06 2011 07:31 PM
  • Joined: 05 Oct 2005
Thank you not-logged-in-daonlyfreez. Your suggestions were very good. I had to modify the code a bit to get it to work, but it now does what I need it to do. I could never get the ControlFocus to work, so I just used MouseClick. I used AutoScriptWriter to discover what code AHK is using to perform some of the tasks I needed it to do since I am new to this.

MainWindowTitle = Scheduler Live  [Single Day View]
EntryWindowTitle = Individual Service Entry (Version Q)

WinActivate, %EntryWindowTitle%
; Activate your 'main' window

Loop, Read, R:\AutoHotKey\Import\Test.csv
{ 
   WinActivate, %EntryWindowTitle%
   MouseClick, left,  363,  526
   ; Opens the entry window I guess, can probably be done differently.
   ; Avoid using the mouse if possible.

   WinWaitActive, %EntryWindowTitle%,,10
      IfEqual, ERRORLEVEL, 1, MsgBox, Timeout...
   ; Wait until the entry window is active, show a message box if timed out.

   MouseClick, left,  96,  55
   ; first entry field? you can probably use Send, {Tab}
   SetKeyDelay -1, 0
   Loop, parse, A_LoopReadLine, CSV
   {
   Send, %A_LoopField%{TAB} ; {CAPSLOCK} ? Scriptrecorder ?
   Sleep, 500 ; try tweaking this for speed
   }
MouseClick, left,  303,  535; this opens a menu window
Sleep, 1000
MouseClick, right,  239,  354; this selects the menu option Individual Service Entry (Version Q)
Sleep, 1000
WinWait, Scheduler Live  [Single Day View], 
IfWinNotActive, Scheduler Live  [Single Day View], , WinActivate, Scheduler Live  [Single Day View], 
WinWaitActive, Scheduler Live  [Single Day View], 
MouseClick, left,  362,  395; Click on the Save button
Sleep, 1000
}


toralf
  • Moderators
  • 4035 posts
  • Last active: Aug 20 2014 04:23 PM
  • Joined: 31 Jan 2005
Does your app support keyboard shortcuts (e.g. Alt+s for save)?
Ciao
toralf
 
I use the latest AHK version (1.1.15+)
Please ask questions in forum on ahkscript.org. Why?
For online reference please use these Docs.

BoBo
  • Guests
  • Last active:
  • Joined: --
ControlFocus, DFButton1, Individual Service Entry (Version Q)

ControlClick, DFButton1, Individual Service Entry (Version Q)



; or

; ControlSend, DFButton1, {ENTER}, Individual Service Entry (Version Q)

; or

; Control, Check,, DFButton1, {ENTER}, Individual Service Entry (Version Q) ; I've no idea why - but it works as a click regardless that its not a radio button or checkbox as mentioned at the help
Have a try with one of AHK's Control commands instead of using mouse clicks. Thx for listening. 8)

BoBo
  • Guests
  • Last active:
  • Joined: --
Wrong:
Control, Check,, DFButton1, {ENTER}, Individual Service Entry (Version Q)
:oops:

Corrected:
Control, Check,, DFButton1, Individual Service Entry (Version Q)
:)