AutoHotkey Community

It is currently May 26th, 2012, 8:22 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 21 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: August 12th, 2009, 8:12 pm 
I know that this is a rather long post but as I really require a solution to this problem, I earnestly request all the AHK gurus to please spare me their valuable time and effort and assist me in solving this. Sincere Thanks in advance…

I use a trading software (called SACTP) to buy and sell stuff. The program I use allows me to load file(s) from my hard drive (only one file at a time), which have been prepared by me in the Microsoft Excel (.xls) format, containing details on the articles that I would like to trade in. I load these files in the front end trading software (SACTP) and then execute them as and when required. Collectively, I have forty such files with my trade details – twenty each for the buy side and for the sell side. The files are named as 01.xls, 02.xls --- 20.xls for both the Buy and Sell side. Each of these files has different data in them.

For loading the Buy side and Sell side files in the front end trading software (SACTP), I always follow an ascending and descending order pattern contrary to each other, which could also be required to be reversed at any point during my trading hours. Depending on the market dynamics, I decide on which order pattern (ascending or descending), I would like to employ for loading the Buy side and Sell side files.

The files need to be loaded in an opposite order pattern from one another and follow a sequential order pattern from within – that is – let me explain –

Opposite order pattern - if the buy side files are being loaded in an ascending order pattern then the sell side files will always need to be loaded in a descending order pattern. Like I mentioned earlier these files are not loaded together (at the same time) but as and when an opportunity arises for either buy or sell. This in other words means that if I am following the ascending order pattern for the buy side files and have loaded and executed file number five for the buy side then the next one for the buy side would always be file number six. Not only that I could continue to load and execute the Buy side files one after another in an ascending order pattern (file number six followed by seven, eight etc.) till I see the need to load and execute a Sell side file. This is totally market dependant. Only thing is - Whilst the buy side is adopting the ascending order pattern at the same time the sell side files would be following the descending order pattern. Therefore, for the sell side, if I have loaded and executed file number fifteen then the next one for the sell side would be file number fourteen.

The reverse would be in effect if it is the descending order pattern for the buy side files and the ascending order pattern for the sell side files.

Sequential order pattern from within – The file number for the buy side and sell side do not have to match regardless of which order pattern (ascending or descending pattern) is being followed – that is – if I have loaded and executed file number five for the buy side it does not mean that file number five would need to be loaded and executed for the sell side. As mentioned above, the file to be loaded is determined by the user and it follows a sequential order pattern from within and not interdependent on the other.

The reversals of the ascending and descending order patterns – that is – shifting the buy or sell side files from either their ascending to descending order pattern or vice-versa needs to be changed at any point during the course of the trading hours dependant totally on the market dynamics prevalent at the time.

Please Note - I would like to mention that these files are always used in a loop – that is – as mentioned earlier – there are twenty files each for the buy and sell side, which are used in a sequential order. Depending on the pattern for which they are loaded (ascending or descending), the files would move in a loop upwards or downwards. Like if the ascending order pattern were being followed then once file number twenty (the last file in the list) is executed, I would like to go back to file number one (the first file in the list) to be loaded and then be ready to be executed. Similarly if the descending order pattern were being followed then once file number one (the first file in the list) is executed, I would like to go back to file number twenty (the last file in the list) to be loaded and then be ready to be executed.

Using AHK I have written a script, which makes loading these files a lot easier and quicker as opposed to doing it manually and I have managed to get the script to make the files load sequentially but these are things that I cannot make it do –

- Loop it back to file number one if the ascending pattern is in operation
- Loop it back to file number twenty if the descending pattern is in operation
- Be able to change the ascending / descending pattern on-the-fly perhaps by a supported GUI, Hotkey etc. or any other method that I cannot think of to reverse the order pattern for the buy side and sell side.
- A few quirks in the code that I have written, which I will highlight in the code tags below

This is the code that I have so far –
Code:
DetectHiddenWindows, On
#NoEnv
#SingleInstance Force
#WinActivateForce
SetBatchLines, -1
SetControlDelay, 0

SetTitleMatchMode, RegEx
#IfWinActive, SACTP

$F9:: ; Please see No.1 below

InputBox, XX, Enter File Number, Please enter the File number that you want to BUY, , 200, 150

If ErrorLevel
{
WinActivate, SACTP
Return
}

Else

If (XX<10) ; Please see No.2 below
{
XX=0%XX%
}

If (XX>20) ; Please see No.3a below
{
MsgBox, You have entered an Incorrect File Number
Return
}

If (XX<1) ; Please see No.3b below
{
MsgBox, You have entered an Incorrect File Number
Return
}

{
SendInput, !b
WinWaitActive, Open
SendInput, C:\TradeFiles\Buy\%XX%.xls
}

Return

$F10:: ; Please see No.1 below

InputBox, XX, Enter File Number, Please enter the File number that you want to SELL, , 200, 150

If ErrorLevel

{
WinActivate, SACTP
Return
}

Else

If (XX<10) ; Please see No.2 below
{
XX=0%XX%
}

If (XX>20) ; Please see No.3a below
{
MsgBox, You have entered an Incorrect File Number
Return
}

If (XX<1) ; Please see No.3b below
{
MsgBox, You have entered an Incorrect File Number
Return
}

{
SendInput, !b
WinWaitActive, Open
SendInput, C:\TradeFiles\Sell\%XX%.xls
}

Return

#IfWinActive

SetTitleMatchMode, 3
#IfWinActive, Paper Order - SACTP

NumpadEnter:: ;Please see No.1 below

WinWaitActive, Paper Order - SACTP
MsgBox, 4129,File Entry,CONFIRM?,
IfMsgBox, Cancel
Return

SendInput, !i ; Please see No.4 below

ControlGetText, YY, Edit7, Paper Order – SACTP ; Please see No.5 below

If YY contains Buy
{
SendInput, !b
WinWaitActive, Open
XX++ ; Please see No.6 below
If (XX<10) ; Please see No.2 below
{
XX=0%XX%
}
SendInput, C:\TradeFiles\Buy\%XX%.xls
Return
}

If YY contains Sell
{
SendInput, !b
WinWaitActive, Open
XX-- ; Please see No.6 below
If (XX<10) ; Please see No.2 below
{
XX=0%XX%
}
SendInput, C:\TradeFiles\Sell\%XX%.xls
Return
}
Return


No.1 – I have assigned the F9, F10 and NumpadEnter keys as Hotkeys to do the following –

F9 – This Hotkey would invoke the Input box to enter the value for the Buy side files to be loaded. For Example – Once I have entered the value of say 15 in the Input box it will load the file C:\TradeFiles\Buy\15.xls and in the Window with the WinTitle Paper Order – SACTP in the Edit7 control this file name and path is displayed.
Basically it will load only the Buy side files as the path in the code is C:\TradeFiles\Buy\

F10 – This Hotkey would invoke the Input box to enter the value for the Sell side files to be loaded. For Example – Once I have entered the value of say 15 in the Input box it will load the file C:\TradeFiles\Sell\15.xls and in the Window with the WinTitle Paper Order – SACTP in the Edit7 control this file name and path is displayed.
Basically it will load only the Sell side files as the path in the code is C:\TradeFiles\Sell\

NumpadEnter – Please notice the two lines of code preceding this Hotkey –
SetTitleMatchMode, 3
#IfWinActive, Paper Order – SACTP

This means that I need this Hotkey to function only if this window is active and not otherwise.

This is the perhaps the main Hotkey as it first executes the file that is already loaded by selecting the option in the Input box generated by either the F9 or F10 Hotkey and then attempts to load the next file in the ascending or descending order pattern. First by sending the Alt+I key sequence to the SACTP Program (which is what the SACTP Program accepts to execute the file) it will execute the file. Thereafter, depending on the value obtained from the Edit7 control (using the ControlGetText command) it will load the next file in sequence. Currently this code is limited to only the ascending order pattern in the Buy side and the descending order pattern in the Sell side.

This code needs to be altered on two counts –

First – If the ascending order pattern is in force then it should be able to loop back to file number one once file number twenty is executed and if the descending order pattern is in force then it should loop back to file number twenty once file number one is executed. Currently what the code does is (if it is the ascending order) – for example - loads file number eighteen after file number seventeen has been executed and similarly will attempt to load file number twenty-one after file number twenty has been executed but will fail as file number twenty-one does not exist. At this point it must loop back to file number one. Likewise for the descending order pattern – from file number one back to file number twenty.

Second – I do not know how this can be done – perhaps by first constructing a GUI that would allow me to change the ascending and descending order by the F9 and F10 keys and then correspondingly it should also change it under the NumpadEnter key.

I have attempted to design a GUI to highlight what it should do. I have given the GUI code below.
Code:
DetectHiddenWindows, On

#SingleInstance Force
#WinActivateForce
#NoEnv
SetBatchLines -1

SetTitleMatchMode, RegEx
#IfWinActive, SACTP

$F9::
Gui, Destroy
Gui, Font, cBlue S8 bold, Verdana
Gui, Add, Text,, Please enter the File number that you want to BUY
Gui, Add, GroupBox, % "section x1 w75 h53 y", File Number
Gui, Font, cRed S8 bold, Verdana
Gui, Add, Edit, xs+10 ys+20 h25 w40 section UpDown vXX gloadfile Number Limit2, No.

Gui, Font, cBlue S8 bold, Verdana
Gui, Add, GroupBox, % "section x1 w270 h52 y", Order Pattern
Gui, Font, cRed S8 bold, Verdana

Gui, Add, CheckBox, xs+20 ys+20 h25 w155 vAscend_Buy, &Ascending
Gui, Add, CheckBox, xs+150 ys+20 h25 w155 vDescend_Buy, &Descending

Gui, Font, cBlack S8 bold, Verdana
Gui, Add, GroupBox, % "section x100 w200 h52 y", Tasks
Gui, Add, Button, xs+10 ys+20 h25 w80 section gDone Default, &OK
Gui, Add, Button, xs+100 ys+0 h25 w80 section gCancel, &Cancel
Gui, Show, AutoSize Center, Files
Return

Done:
Gui, Submit
Return

Loadfile:
SendInput, !b
WinWaitActive, Open
If (XX<10)
{
XX=0%XX%
}
SendInput, C:\TradeFiles\Buy\%XX%.xls
Return

$F10::
Gui, Destroy
Gui, Font, cBlue S8 bold, Verdana
Gui, Add, Text,, Please enter the File number that you want to SELL
Gui, Add, GroupBox, % "section x1 w125 h53 y", File Number
Gui, Font, cRed S8 bold, Verdana
Gui, Add, Edit, xs+10 ys+20 h25 w40 section UpDown vYY gloadfile1 Number Limit2, No.

Gui, Font, cBlue S8 bold, Verdana
Gui, Add, GroupBox, % "section x1 w270 h52 y", Order Pattern
Gui, Font, cRed S8 bold, Verdana

Gui, Add, CheckBox, xs+20 ys+20 h25 w155 vAscend_Sell, &Ascending
Gui, Add, CheckBox, xs+150 ys+20 h25 w155 vDescend_Sell, &Descending
;Gui, Add, CheckBox, xs+150 ys+20 h25 w155 gButtonOK, &Descending

Gui, Font, cBlack S8 bold, Verdana
Gui, Add, GroupBox, % "section x100 w200 h52 y", Tasks
Gui, Add, Button, xs+10 ys+20 h25 w80 section gDone1 Default, &OK
Gui, Add, Button, xs+100 ys+0 h25 w80 section gCancel, &Cancel
Gui, Show, AutoSize Center, Files
Return

Done1:
Gui, Submit
Return

loadfile1:
SendInput, !b
WinWaitActive, Open
If (YY<10)
{
YY=0%YY%
}
SendInput, C:\TradeFiles\Sell\%YY%.xls
Return

;perhaps under the NumpadEnter Hotkey after it asks whether I would like to execute the file like it does in my code above (Alt+I key sequence) it could be like -

ControlGetText, YY, Edit7, Paper Order – SACTP ; Please see No.5 below

;Ascend_Buy
If YY contains Buy
{
SendInput, !b
WinWaitActive, Open
XX++ ; Please see No.6 below
If (XX<10) ; Please see No.2 below
{
XX=0%XX%
}
SendInput, C:\TradeFiles\Buy\%XX%.xls
Return
}

;Descend_Buy
If YY contains Buy
{
SendInput, !b
WinWaitActive, Open
XX-- ; Please see No.6 below
If (XX<10) ; Please see No.2 below
{
XX=0%XX%
}
SendInput, C:\TradeFiles\Buy\%XX%.xls
Return
}

;Ascend_Sell
If YY contains Buy
{
SendInput, !b
WinWaitActive, Open
XX-- ; Please see No.6 below
If (XX<10) ; Please see No.2 below
{
XX=0%XX%
}
SendInput, C:\TradeFiles\Sell\%XX%.xls
Return
}

;Descend_Sell
If YY contains Buy
{
SendInput, !b
WinWaitActive, Open
XX++ ; Please see No.6 below
If (XX<10) ; Please see No.2 below
{
XX=0%XX%
}
SendInput, C:\TradeFiles\Sell\%XX%.xls
Return
}

Cancel:
GuiClose:
GuiEscape:
Gui, Destroy
Return

#IfWinActive


Obviously the above is a non-functional GUI code as my prowess with AHK isn’t that good. I have no clue which variable goes where and how to even load the file and what to do to execute it etc. What I am trying to highlight is that a GUI be created that can load the file just like my code with the Input box does. Here in the GUI, I should be able to select either the ascending or descending order pattern for both the Buy (F9 Hotkey) and Sell (F10 Hotkey) side files. The GUI should be designed in such a way that if one is selected then the other automatically gets unselected as both cannot work at the same time. Also, it should also be able to retain the selection until I unselect it for another option. Once it has been selected there should be some label or something in the code that is under the NumpadEnter key GUI, which tells it what needs to be done.

Then there should be the NumpadEnter key GUI (which I do not know how to create), which will pick up the order pattern that has been selected on the Buy (F9 Hotkey) or Sell (F10 Hotkey) side and execute the file and then load the next file in sequence and in a loop.

As the NumpadEnter key is the Hotkey that executes the file to the program whatever code needs to scripted must be linked to this Hotkey only after it has been executed. F9 and F10 simply load the file and keep it ready. When the opportunity arises, the NumpadEnter key executes the file, which is when the need for loading the next file in sequence comes into effect.

The GUI should also have other error messages in check as given in No.3a & No.3b below.

No.2 – As the files are named 01.xls, 02.xls, 03.xls etc. this section of the code tells the script that even if the user were to input 1, 2, 3 etc. instead of 01, 02, 03 etc. in the Input box as the value for the variable XX, the code would understand the same in both inputs.

No.3a & No.3b – Basically this message box would pop-up if the value entered in the Input Box were higher than 20 or lower than 1. Unfortunately, I did not know how to merge the two together so I have given the code separately for the same.

No.4 – This is the key sequence that executes the file from the Program

No.5 – This is the Edit control where the details of which filename has been loaded is available. If it is a Buy file then it would be C:\TradeFiles\Buy\%XX%.xls or if it is a Sell file then it would be C:\TradeFiles\Sell\%XX%.xls. Depending on whether it is a Buy or a Sell value the code would then load the next file in sequence.

No.6 – As mentioned above after No.4 and No.5 have been completed above, if value in the YY variable is Buy then this part of the code will increment the variable value by one and load the next file. Similarly, it would decrement the value by one if it is a Sell value.

I hope I have been able to aptly describe what I need to get done. I have tried my level best and I truly hope that someone can help me with this. Fingers crossed… :)


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: August 14th, 2009, 3:15 pm 
I understand that my above post is rather long, which is probably why only about 38 people have seen it thus far. The main reason I had to make it so long is so that I could explain my query in detail for a possible solution.

Can I earnestly request someone to please spare me their valuable time and try and think of a solution?

Any help will be greatly appreciated…

Otherwise, I reckon I will try and break-up my queries and post multiple posts and then try and put it all together.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: August 14th, 2009, 3:17 pm 
Offline
User avatar

Joined: August 30th, 2005, 8:43 pm
Posts: 8666
Location: Salem, MA
It's very strange to have so much information all in one post - usually people give too little.

Let me read the sections again, and maybe look a the issues one at a time.

Edit:

Let's look at your problem a different way - you are trying to do the following, I think:
- you have a range of sequential files (Buy1 to BuyN and Sell1 to SellN)

- you want to hit a hotkey (or something) causing your script to do something with the file Buy1. At the same time, Sell1 gets queued up, in case you decide to Sell. Also, Buy2 is queued up in case you decide to buy.

- I'm not sure what the 'something' you are going to do with the file is yet (haven't gotten that far), but I'm just trying to understand the basic concepts.

- I know your files are laid out slightly differently, I'm just going for concepts.

Am I on the right track?

_________________
Image
(Common Answers) - New Tutorials Forum - Humongous FAQ


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 16th, 2009, 7:30 am 
Firstly, thank you engunneer for your reply. I am glad you have answered.

engunneer wrote:
Let's look at your problem a different way - you are trying to do the following, I think: - you have a range of sequential files (Buy1 to BuyN and Sell1 to SellN)

- you want to hit a hotkey (or something) causing your script to do something with the file Buy1.


That is correct – I have a total of 40 files – 20 for the Buy side and 20 for the Sell side. Both the Buy and Sell side files are named the same - 01.xls, 02.xls --- 20.xls but placed in different directories on my hard drive, which is what differentiates them. I access these files from their respective directory and then load them in the program I use for trading.

I use the code assigned to the F9 and F10 Hotkeys, only for loading these files in the program. Currently, F9 loads the Buy side files and F10 loads the sell side files. Like for example, if I want to load file number 05.xls for the Buy side, I would press the F9 key, wait for the Input Box, type 5 in it and on pressing the Enter button it would load the 05.xls file from the C:\TradeFiles\Buy\ directory. Similarly, if I want to load file number 18.xls for the Sell side, I would press the F10 key, wait for the Input Box, type 18 in it and on pressing the Enter button it would load the 18.xls file from the C:\TradeFiles\Sell\ directory.

Loading the file either via the F9 or F10 Hotkeys is something I do to kick-start my trading process when I want to load the initial file for execution – either for the Buy or Sell side.

Once this file is loaded (like in my example - either No.5 for Buy or No.18 for Sell) it will stay loaded and ready for execution till an opportunity arises to execute it. The F9 and F10 Hotkeys are used only to load or switch between the Buy or Sell side files – either for the very first time or if in between trading hours I feel that I would like to change the file number and not for executing the files.

Thereafter the code assigned to the NumpadEnter Hotkey takes over. As and when I see an opportunity I press the NumpadEnter Hotkey and it executes the loaded file and then loads the next file in numeric sequence either in the ascending (Buy side) or descending (Sell side) order relevant to the initially loaded file that it has just executed. So say if I am dealing with the Buy side file and 05.xls is loaded and ready to execute, the NumpadEnter Hotkey will execute it and auto-load 06.xls (ascending order) and keep that file ready to execute. Similarly, if I execute 18.xls for the Sell side then 17.xls will auto-load (descending order) and be ready to execute.

At this juncture, let me be a bit more specific by citing an example. Say if at 10am, I load the Buy side 05.xls file via the F9 key (it will load and just stay there in the program) and at 10:05am I see an opportunity to execute it, then I will press the NumpadEnter key at 10:05am, which will execute 05.xls and load 06.xls immediately. Then at 10:15am, I see an opportunity to execute 06.xls, I will follow the same steps as given above and now at 10:15am, file 07.xls is loaded. At 10:20am I see an opportunity for the Sell side and want to switch from Buy to Sell, so I press the F10 key and load file 18.xls and press the NumpadEnter key, which after executing this file will load 17.xls.

From the above you will understand that I use the F9 and F10 keys to simply load the Buy or Sell files and the NumpadEnter key to execute whichever file is loaded in the program and load the next file in sequence.

Currently, my code assigned to NumpadEnter key only allows me to auto-load the Buy files in an ascending order and the Sell files in a descending order.

I will expand a bit on the ascending and descending order pattern but before that I will answer what engunneer had asked to increase clarity.

engunneer wrote:
At the same time, Sell1 gets queued up, in case you decide to Sell. Also, Buy2 is queued up in case you decide to buy.

That is incorrect – The Buy and Sell files do not need to work in tandem as I have highlighted above. There is no queuing up needed for either the subsequent or converse file. They are loaded as per my requirement and then executed individually with a provision to auto-load the next file upon the loaded file being executed.

So from the above it is clear that the NumpadEnter key will keep auto-loading the files in a loop (ascending for Buy and descending for Sell) and the F9 and F10 keys will allow me to switch in between them. The code assigned to the NumpadEnter key for the Buy side file allows the next file to auto-load in the ascending order through the variable xx++ and variable xx-- allows the next file to auto-load in the descending order for the Sell side.

All of the above I have successfully managed thus far. Now let me explain what I haven’t been able to do.

- Presume I am following the ascending order for the Buy side files and file number 20.xls has been loaded. After executing the same the code under the NumpadEnter key will attempt to load the next file, which by default would mean 21.xls but 21.xls does not exist. At this point, I would like the code to loop back to file number 01.xls as I am only working with file numbers ranging from 01.xls to 20.xls. Similarly, for the Sell side once it has executed 01.xls it will attempt loading 00.xls, which does not exist, which is when I would like the code to loop back and re-load 20.xls.

Okay presuming that this code to move only between files 01.xls to 20.xls can be achieved by someone here on the forum, my next problem would be that thus far I have only managed to move forward for the Buy side files and downward for the Sell side files. I would like to have a code whereby I can reverse the ascending and descending order (on-the-fly) for the Buy and Sell side files – that is – the Buy side files move in a descending order instead of the ascending order and the Sell side files move in an ascending order instead of the descending order.

I think this can only be possible via a custom GUI where there is a CheckBox feature in the F9 and F10 Hotkeys allowing me to choose which pattern I want for the Buy side or Sell side files and the code then thereafter, perhaps via a Label or something is included under the NumpadEnter Hotkey.

So it would be something like – press the F9 key and a custom GUI pops-up with the Edit space to input the file number to load. Say I press file number 05.xls for the Buy side. In the same GUI, two checkboxes should feature to choose either the ascending or descending order. If I choose the descending order then it should retain that setting till I unmark it and choose otherwise and both checkboxes should not be able to get marked together. If the descending checkbox is marked then the ascending checkbox should get automatically unmarked.

As it is the NumpadEnter Hotkey that executes the file and then attempts to load the next file in sequence, the code for the Checkbox included in the F9 and F10 Hotkeys for either the ascending or descending order must feature here, perhaps via a Label or something.

For my example above, I have pressed the F9 key, chosen file number 05.xls and via the Checkbox chosen the descending order in the F9 GUI. File number 05.xls will get loaded with the descending order parameter. Thereafter when I press the NumpadEnter key to execute file number 05.xls, a code under this Hotkey which is linked to the descending order Checkbox on the Buy side will auto-load file number 04.xls for the Buy side.

I think the above more or less covers everything and I feel I will stop here. If some can please help me through this it would be greatly appreciated. Perhaps we can start with the code to loop between the files first and then step wise solve the rest of the problem.

Please assist...


Report this post
Top
  
Reply with quote  
 Post subject: Please Help...
PostPosted: August 17th, 2009, 9:44 am 
Okay, I know I have made two valiant but thus far futile attempts in the past five days to get one of the AHK gurus to assist me with my problem so I am quite at my wits end as to what to do next. It is very easy for a post to be quickly buried here due to the volume of new queries that keeping pouring in.

Please, please, please fellow users – I know it is a tedious effort to first read through my problem and then offer a solution and I am sorry if I have been too explicit in my post but it is only to project my query in its entirety. I felt if I did not give the problem in its entirety it would be difficult to give a solution.

Someone please assist me with at least something so that I can try implementing it and then maybe query again.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: August 17th, 2009, 10:11 am 
Offline
User avatar

Joined: August 30th, 2005, 8:43 pm
Posts: 8666
Location: Salem, MA
For just two checkboxes, I would not use a Gui.

One other thing, I'd like clarification on: you said in your timed sequence of events (which was helpful) that you were doing some buying, THEN you loaded file 18 to do some selling. Am I correct then to understand that if you have a buy file loaded, you cannot sell without loading a sell file first? Another way to ask the same question: wheter buying or selling, you can have only one file loaded at a time? You can't have a current one for each?

Here is my proposed solution for you:
Code:
DetectHiddenWindows, On
#NoEnv
#SingleInstance Force
#WinActivateForce
SetBatchLines, -1
SetControlDelay, 0

IncrementMode = "Normal"

SetTitleMatchMode, RegEx
#IfWinActive, SACTP

$F9::
;queues up a buy file
InputBox, BuyFileNumber, Enter File Number (BUY), Please enter the File number that you want to BUY, , 200, 150,, %BuyFileNumber%

If ErrorLevel
{
  WinActivate, SACTP
  Return
}

Else

  FileType := "Buy"
  LoadFile(BuyFileNumber, FileType)


Return

$F10::
;queues up a Sell file
InputBox, SellFileNumber, Enter File Number (BUY), Please enter the File number that you want to BUY, , 200, 150,, %SellFileNumber%

If ErrorLevel
  {
    WinActivate, SACTP
    Return
  }

Else
{
  FileType := "Sell"
  LoadFile(SellFileNumber, FileType)

}
Return

$F11::
;switch increment modes
If (IncrementMode = "Normal")
  IncrementMode := "Reversed"
Else
  IncrementMode := "Normal"
  ToolTip, Current mode is %IncrementMode%
  SetTimer, ClearTooltip, -3000
Return

#IfWinActive

SetTitleMatchMode, 3
#IfWinActive, Paper Order - SACTP

NumpadEnter:: ;Please see No.1 below

WinWaitActive, Paper Order - SACTP
MsgBox, 4129,File Entry,CONFIRM?,
IfMsgBox, Cancel
Return

SendInput, !i ; Please see No.4 below

ControlGetText, YY, Edit7, Paper Order – SACTP ; Please see No.5 below

LoadNextFile(FileNumber, FileType, IncrementMode)

Return

ClearTooltip:
Tooltip,
Return

LoadFile(FileNumber, FileType)
{
  global IncrementMode

  If (FileNumber >= 1 and FileNumber <= 9)
    FiletoLoad := "C:\TradeFiles\" FileType "\0" FileNumber ".xls"
  Else If (FileNumber >= 10 and FileNumber <= 20)
    FiletoLoad := "C:\TradeFiles\" FileType "\" FileNumber ".xls"
  Else
  {
    MsgBox, You have entered an Incorrect File Number
    Return
  }



  SendInput, !b
  WinWaitActive, Open
  SendInput, % FiletoLoad

  ToolTip, %FileType% file %FiletoLoad% Loaded.`nCurrent mode is %IncrementMode%
  SetTimer, ClearTooltip, -3000
  Return
}


LoadNextFile(FileNumber, FileType, IncrementMode)
{
  If (IncrementMode = "Normal")
  {
    If (FileType = "Buy")
      FileNumber++
    Else
      FileNumber--
  }
  Else
  {
    If (FileType = "Buy")
      FileNumber--
    Else
      FileNumber++
  }

  If (FileNumber > 20)
    FileNumber = 1

  If (FileNumber < 1)
    FileNumber = 20

  LoadFile(FileNumber, FileType)

}


I tried to take into account many of your requests. Hit F11 to switch increment modes.

I moved all the file loading code to a single subroutine, so if your target program changes, you only have to change it on one place.

It can be generalized and simplified a lot more, but I didn't want to change it too much from your existing code.

Please test it, since I have not.

_________________
Image
(Common Answers) - New Tutorials Forum - Humongous FAQ


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Re: Please Help...
PostPosted: August 17th, 2009, 10:23 am 
Offline
User avatar

Joined: August 30th, 2005, 8:43 pm
Posts: 8666
Location: Salem, MA
Aditi wrote:
Okay, ....


While you were writing this, I was writing my post to you which took a fair amount of time. I went specifically looking for your post this morning to follow up. I don't have internet at home (or worth speaking of anyway), so I was not able to get back to your request before today.


I also will say that a extra long post does frighten most users. I'm glad it was well researched, but most users have a hard time with a post that long. Sometimes only the first question is needed. Note that I didn't do anything about your GUI, though I will if you need me to. It's best to start with only one or two questions, then flesh out the problems along whichever path the code takes.

Please have a look at the code I wrote for you. If there is a problem we are still able to help.

Lastly, if you sign up for a user account, you can get an email notifying you when someone has replied, which makes the back and forth quite a bit faster.

HTH

_________________
Image
(Common Answers) - New Tutorials Forum - Humongous FAQ


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Re: Please Help...
PostPosted: August 17th, 2009, 11:08 am 
@engunneer – Thank You so very much… I still haven’t tried out the new code offered by you and will do so right after I finish posting this.

engunneer wrote:
For just two checkboxes, I would not use a Gui.

Hey! You’re the boss :) – Whichever method you suggest as long as it works… 8)

engunneer wrote:
One other thing, I'd like clarification on: you said in your timed sequence of events (which was helpful) that you were doing some buying, THEN you loaded file 18 to do some selling. Am I correct then to understand that if you have a buy file loaded, you cannot sell without loading a sell file first? Another way to ask the same question: Whether buying or selling, you can have only one file loaded at a time? You can't have a current one for each?


That is correct – To Buy, I must have a Buy file loaded with all it’s Buy contents and similarly to Sell, I must have a Sell file loaded with all it’s Sell contents. And Yes! whether I am buying or selling, I can have only one file loaded at a time without having a current one for each. It is either Buy or Sell, never both together.

engunneer wrote:
I tried to take into account many of your requests. Hit F11 to switch increment modes.
I moved all the file loading code to a single subroutine, so if your target program changes, you only have to change it on one place.
It can be generalized and simplified a lot more, but I didn't want to change it too much from your existing code.
Please test it, since I have not.


As excited as I am to try your code and post back immediately, I am going to request you to please give me two days to post back with any difficulties that I might have. This will allow me to use it more extensively and take it from there. I will let you know how things have turned out and then at your leisure you can generalize and / or simplify the code if you feel the need to fine tune it.

engunneer wrote:
While you were writing this, I was writing my post to you which took a fair amount of time. I went specifically looking for your post this morning to follow up. I don't have internet at home (or worth speaking of anyway), so I was not able to get back to your request before today.


All I can say is that my gratitude to you is boundless. I truly appreciate your time and effort spent towards working out a solution for my problem. Thank you…

engunneer wrote:
I also will say that a extra long post does frighten most users. I'm glad it was well researched, but most users have a hard time with a post that long. Sometimes only the first question is needed. It's best to start with only one or two questions, then flesh out the problems along whichever path the code takes.


:oops: and Sorry!

engunneer wrote:
Note that I didn't do anything about your GUI, though I will if you need me to. Please have a look at the code I wrote for you. If there is a problem we are still able to help.

Sincere thanks for the support. Please allow me a couple of days – actually a few, till 21/Aug/2009 to test your code and then I will let you know for any desired changes

engunneer wrote:
Lastly, if you sign up for a user account, you can get an email notifying you when someone has replied, which makes the back and forth quite a bit faster.

Done deal – will do so later this evening…


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: August 18th, 2009, 10:11 am 
Offline

Joined: August 18th, 2009, 4:08 am
Posts: 6
Sigh! The code seems to be going all haywire. Now let me start at the beginning. I am going to try and highlight everything that I have noticed thus far – be it small or big. Firstly, I added the code SendInput, !o after your (@engunneer) line SendInput, % FiletoLoad to allow the file to open. Then for the F9 key, I put the code FileType := "Buy" LoadFile(BuyFileNumber, FileType) between braces since you (@engunneer) had done so for the F10 key – I hope that was a correct change. I have sort-of understood what you (@engunneer) meant when you mentioned - Hit F11 to switch increment modes. I suppose this is how you switch between the ascending and descending order pattern for the F9 and F10 keys. (Unfortunately the code does not work as desired so I cannot be 100% sure whether the code for the F11 key is correct).

@engunneer - I moved all the file loading to a single subroutine, so if your target program changes, you have to change it on one place only. Yes! I noticed how you have grouped it together.

Now here are the quirks that I am facing –

For the Normal Mode on the Buy Side Files -

First via the F11 Hotkey, I selected the Current mode as Normal (which I presume is equal to the Ascending order). Then by pressing the F9 key I loaded file number 01.xls on the Buy side, which loaded perfectly. So far no hitch. Thereafter via the NumpadEnter key, I executed 01.xls, which got executed but instead of loading file number 02.xls, it simply retained file number 01.xls. Then to test the code further, retaining all of the above settings of current mode as Normal, I loaded file number 02.xls via the F9 key, which loaded fine, got executed via the NumpadEnter key but here too instead of loading file number 03.xls next, it loaded 01.xls. I tried this for all files through to 20.xls and it did the exact same thing. So effectively it can be ascertained that the code loops back to 01.xls for any / all files, that are both loaded via the F9 Hotkey and then executed and / or for those that are simply just executed by the NumpadEnter Hotkey.

As per what I desire, considering that the Ascending order has been selected (presumably what you imply by Normal mode), after file number 01.xls has been loaded by the F9 key and executed by the NumpadEnter key, the next file to auto-load should be 02.xls. This pattern should continue till file number 20.xls is executed, which is the only time when it should loop back to auto-load 01.xls.

The loop should be 01.xls executed then 02.xls to be auto-loaded, 02.xls executed then 03.xls to be auto-loaded till --- 20.xls is executed, which is when it should go back to 01.xls, 02.xls, 03.xls --- 20.xls

For the Reverse Mode on the Buy Side Files -

Thereafter, via the F11 Hotkey I selected the Current Mode as Reversed (which is what I presume you refer to as Descending order) and pressed the F9 key to load file number 20.xls on the Buy side, which loaded perfectly. So far no hitch. Thereafter via the NumpadEnter key, I executed 20.xls, which got executed but instead of loading file number 19.xls, it simply retained file number 20.xls. Then to test the code further, retaining all of the above settings of current mode as Reversed, I loaded file number 19.xls via the F9 key, which loaded fine, got executed via the NumpadEnter key but here too instead of loading file number 18.xls next, it loaded 20.xls. I tried this for all files through to 01.xls and it did the exact same thing. So effectively it can be ascertained that the code loops back to 20.xls for any / all files, that are both loaded via the F9 Hotkey and then executed and / or for those that are simply just executed by the NumpadEnter Hotkey.

As per what I desire, considering that the Descending order has been selected (presumably what you imply by Reversed mode), after file number 20.xls has been loaded by the F9 key and executed by the NumpadEnter key, the next file to auto-load should be 19.xls. This pattern should continue till file number 01.xls is executed, which is the only time when it should loop back to auto-load 20.xls.

The loop should be 20.xls executed then 19.xls to be auto-loaded, 19.xls executed then 18.xls to be auto-loaded till --- 01.xls is executed, which is when it should go back to 20.xls, 19.xls, 18.xls --- 01.xls

For the Normal Mode on the Sell Side Files -

As desired by me, if I would have selected the Normal Mode, the Buy Side files should move in an Ascending order pattern and the Sell side files should move in a Descending order pattern. With this mode selected, I pressed the F10 Hotkey to load file number 20.xls on the Sell side, which loaded perfectly. So far no hitch. Thereafter via the NumpadEnter key, I executed 20.xls, which got executed but instead of loading file number 19.xls, it simply retained file number 20.xls. Then to test the code further, retaining all of the above settings of current mode as Normal, I loaded file number 19.xls via the F10 key, which loaded fine, got executed via the NumpadEnter key but here too instead of loading file number 18.xls next, it loaded 20.xls. I tried this for all files through to 01.xls and it did the exact same thing. So effectively it can be ascertained that the code loops back to 20.xls for any / all files, that are both loaded via the F10 Hotkey and then executed and / or for those that are simply just executed by the NumpadEnter Hotkey.

As per what I desire, considering that the Ascending order has been selected (presumably what you imply by Normal mode), the Buy side files must move in an Ascending order and the Sell side files must move in a Descending order. Therefore, after file number 20.xls has been loaded by the F10 key and executed by the NumpadEnter key, the next file to auto-load should be 19.xls. This pattern should continue till file number 01.xls is executed, which is the only time when it should loop back to auto-load 20.xls.

The loop should be 20.xls executed then 19.xls to be auto-loaded, 19.xls executed then 18.xls to be auto-loaded till --- 01.xls is executed, which is when it should go back to 20.xls, 19.xls, 18.xls --- 01.xls

For the Reverse Mode on the Sell Side Files -

Now when the Reverse mode is selected the Buy side files would be moving in a Descending order pattern and the Sell side files would be moving in an Ascending order pattern. With this mode selected, I pressed the F10 Hotkey to load file number 01.xls on the Sell side, which loaded perfectly. So far no hitch. Thereafter via the NumpadEnter key, I executed 01.xls, which got executed but instead of loading file number 02.xls, it simply retained file number 01.xls. Then to test the code further, retaining all of the above settings of current mode as Normal, I loaded file number 02.xls via the F10 key, which loaded fine, got executed via the NumpadEnter key but here too instead of loading file number 03.xls next, it loaded 01.xls. I tried this for all files through to 20.xls and it did the exact same thing. So effectively it can be ascertained that the code loops back to 01.xls for any / all files, that are both loaded via the F10 Hotkey and then executed and / or for those that are simply just executed by the NumpadEnter Hotkey.

As per what I desire, considering that the Ascending order has been selected (presumably what you imply by Normal mode), the Buy side files must move in an Ascending order and the Sell side files must move in a Descending order. Therefore, after file number 20.xls has been loaded by the F10 key and executed by the NumpadEnter key, the next file to auto-load should be 19.xls. This pattern should continue till file number 01.xls is executed, which is the only time when it should loop back to auto-load 20.xls.

The loop should be 20.xls executed then 19.xls to be auto-loaded, 19.xls executed then 18.xls to be auto-loaded till --- 01.xls is executed, which is when it should go back to 20.xls, 19.xls, 18.xls --- 01.xls

One thing I noticed in your (@engunneer) code is that you did not use the ControlGetText command (ControlGetText, YY, Edit7, Paper Order – SACTP) that I had used. The reason I had used it in my code was that once the NumpadEnter key executed the file, the code via the ControlGetText command variable (YY) could identify, which side file was just executed as the entire path and file name (it looks like C:\TradeFiles\Buy\01.xls) is available from this Edit field and it could then auto-load the next file in sequence. Hence in my code it says If YY contains Buy then do blah, blah or If YY contains Sell then do blah, blah. Thought I would mention this as it might help in solving the problem.

Another thing I noticed was that after executing a file the Input box very often opened at a higher level on the Screen whereas for the (simpleton) code that I had put together it used to always open in the middle. Does this have something to do with the Tooltip?; else I would prefer it opening in the middle every time.

I know that the code is almost there and it requires just a few changes to make it work, which unfortunately I am incapable of doing. In the Normal (Ascending) mode, the code should be able to load the next Buy file upwards and on reaching 20.xls should loop back to 01.xls. Whilst this mode is in force, the Sell side files should load downwards and on reaching 01.xls it should loop back to 20.xls. Similar for the Reverse mode selected.

I hope it can be rectified to function as desired and once again, thank you engunneer for all your help thus far…


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 18th, 2009, 11:02 am 
Offline
User avatar

Joined: August 30th, 2005, 8:43 pm
Posts: 8666
Location: Salem, MA
I fixed a few bugs.

I still have not done any testing.

Code:
DetectHiddenWindows, On
#NoEnv
#SingleInstance Force
#WinActivateForce
SetBatchLines, -1
SetControlDelay, 0

IncrementMode = "Normal"

SetTitleMatchMode, RegEx
#IfWinActive, SACTP

$F9::
;queues up a buy file
InputBox, FileNumber, Enter File Number (BUY), Please enter the File number that you want to BUY, , 200, 150

If ErrorLevel
{
  WinActivate, SACTP
  Return
}

Else
{
  FileType := "Buy"
  LoadFile(FileNumber, FileType)
}

Return

$F10::
;queues up a Sell file
InputBox, FileNumber, Enter File Number (BUY), Please enter the File number that you want to BUY, , 200, 150

If ErrorLevel
  {
    WinActivate, SACTP
    Return
  }

Else
{
  FileType := "Sell"
  LoadFile(FileNumber, FileType)

}
Return

$F11::
;switch increment modes
If (IncrementMode = "Normal")
  IncrementMode := "Reversed"
Else
  IncrementMode := "Normal"
ToolTip, Current mode is %IncrementMode%
SetTimer, ClearTooltip, -3000
Return

#IfWinActive

SetTitleMatchMode, 3
#IfWinActive, Paper Order - SACTP

NumpadEnter:: ;Please see No.1 below

WinWaitActive, Paper Order - SACTP
MsgBox, 4129,File Entry,CONFIRM?,
IfMsgBox, Cancel
Return

SendInput, !i ; Please see No.4 below

LoadNextFile(byref FileNumber, FileType, IncrementMode)

Return

ClearTooltip:
Tooltip,
Return

LoadFile(FileNumber, FileType)
{
  global IncrementMode

  If (FileNumber >= 1 and FileNumber <= 9)
    FiletoLoad := "C:\TradeFiles\" FileType "\0" FileNumber ".xls"
  Else If (FileNumber >= 10 and FileNumber <= 20)
    FiletoLoad := "C:\TradeFiles\" FileType "\" FileNumber ".xls"
  Else
  {
    MsgBox, You have entered an Incorrect File Number
    Return
  }



  SendInput, !b
  WinWaitActive, Open
  SendInput, % FiletoLoad

  ToolTip, %FileType% file %FiletoLoad% Loaded.`nCurrent mode is %IncrementMode%
  SetTimer, ClearTooltip, -3000
  Return
}


LoadNextFile(byref FileNumber, FileType, IncrementMode)
{
  If (IncrementMode = "Normal")
  {
    If (FileType = "Buy")
      FileNumber++
    Else
      FileNumber--
  }
  Else
  {
    If (FileType = "Buy")
      FileNumber--
    Else
      FileNumber++
  }

  If (FileNumber > 20)
    FileNumber = 1

  If (FileNumber < 1)
    FileNumber = 20

  LoadFile(FileNumber, FileType)

}


I used Normal and Reversed because Ascending and Decending don't make sense. Normal means the Buy is Asc while the Sell is Desc.

I wouldn't call it all haywire. It was a few simple bugs.

_________________
Image
(Common Answers) - New Tutorials Forum - Humongous FAQ


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 18th, 2009, 12:04 pm 
Offline

Joined: August 18th, 2009, 4:08 am
Posts: 6
engunneer wrote:
I used Normal and Reversed because Ascending and Descending don't make sense. Normal means the Buy is Asc while the Sell is Desc.

I guess you are correct when you put it that way – it’s just that I have been too used to referring it to Ascending and Descending that it seems to have been ingrained in me.

engunneer wrote:
I wouldn't call it all haywire. It was a few simple bugs.

Sorry! I did not mean it that way – perhaps I am going all haywire… :)

Having said that, unfortunately the code still does not work. Now for both modes – Normal and Reversed, once a file is loaded, either via the F9 or F10 Hotkey and then executed by the NumpadEnter Hotkey, it just stops after executing the loaded file. It does not load the next line in sequence for either of the modes. I obviously cannot tell if the loop back or forward works as it currently just does not go ahead in loading the next file.

Once again, engunneer, Thank You for all your help…


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 18th, 2009, 12:17 pm 
Offline
User avatar

Joined: August 30th, 2005, 8:43 pm
Posts: 8666
Location: Salem, MA
It's time for you to learn a little autohotkey debugging so you can show me what is happening.

you can put the following types of things to help see the status all the time

Code:
listvars
pause

This will show all the variables in the script (and pause it). To continue, hit the Pause key on your keyboard in the AHK variables window

Code:
Masgbox %Variable%

This shows you a msgbox with the value of a Variable (Called Variable in this case). It also pauses the script until you hit OK.

Code:
ToolTip, %Variable%

This shows a tooltip near the mouse. The tooltip will not go away until a blank tooltip command is used. it does NOT pause the script

for msgbox and tooltip, you can put more complicated things like
Code:
Msgbox, Var1 is %Variable1%`nVar2 is %Variable2%`nVar3 is %Variable3%

This shows you a result like this (but in a msgbox)
Code:
Var1 is 6
Var2 is Buy
Var3 is


I usually add markers so you can see the difference between a blank variable and a space
Code:
Msgbox, Var1 is (%Variable1%)`nVar2 is >%Variable2%<`nVar3 is '%Variable3%'

This shows you a result like this (but in a msgbox)
Code:
Var1 is (6)
Var2 is >Buy<
Var3 is ''



between these, and a little careful placement, you can usually figure out what is happening.

Put a msgbox befor and after certain things, and you can see if the desired action occured, like
Code:
Msbox, BEFORE:`n`n IncrementMode: %IncrementMode%`n FileType : % FileType %`n FileNumber: % FileNumber%
  If (IncrementMode = "Normal")
  {
    If (FileType = "Buy")
      FileNumber++
    Else
      FileNumber--
  }
  Else
  {
    If (FileType = "Buy")
      FileNumber--
    Else
      FileNumber++
  }

  If (FileNumber > 20)
    FileNumber = 1

  If (FileNumber < 1)
    FileNumber = 20
Msbox, AFTER:`n`n IncrementMode: %IncrementMode%`n FileType : % FileType %`n FileNumber: % FileNumber%



Please try these to make sure the functions are getting the right values :)

_________________
Image
(Common Answers) - New Tutorials Forum - Humongous FAQ


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 18th, 2009, 12:30 pm 
Offline
User avatar

Joined: August 30th, 2005, 8:43 pm
Posts: 8666
Location: Salem, MA
I found my mistake.

Here is my tested version.
Anything marked with ;; is supposed to be uncommented, but I commented it since I don't have your program

Code:
DetectHiddenWindows, On
#NoEnv
#SingleInstance Force
#WinActivateForce
SetBatchLines, -1
SetControlDelay, 0

IncrementMode := "Normal"

;;SetTitleMatchMode, RegEx
;;#IfWinActive, SACTP

$F9::
;queues up a buy file
InputBox, FileNumber, Enter File Number (BUY), Please enter the File number that you want to BUY, , 200, 150

If ErrorLevel
{
;;  WinActivate, SACTP
  Return
}

Else
{
  FileType := "Buy"
  LoadFile(FileNumber, FileType)
}

Return

$F10::
;queues up a Sell file
InputBox, FileNumber, Enter File Number (BUY), Please enter the File number that you want to BUY, , 200, 150

If ErrorLevel
  {
;;    WinActivate, SACTP
    Return
  }

Else
{
  FileType := "Sell"
  LoadFile(FileNumber, FileType)

}
Return

$F11::
;switch increment modes
If (IncrementMode = "Normal")
  IncrementMode := "Reversed"
Else
  IncrementMode := "Normal"
ToolTip, Current mode is %IncrementMode%
SetTimer, ClearTooltip, -3000
Return

;;#IfWinActive

;;SetTitleMatchMode, 3
;;#IfWinActive, Paper Order - SACTP

NumpadEnter::

;;WinWaitActive, Paper Order - SACTP
MsgBox, 4129,File Entry,CONFIRM?,
  IfMsgBox, Cancel
    Return

;;SendInput, !i

LoadNextFile(FileNumber, FileType, IncrementMode)

Return

ClearTooltip:
Tooltip,
Return

LoadFile(byref FileNumber, FileType)
{
  global IncrementMode

  If (FileNumber >= 1 and FileNumber <= 9)
    FiletoLoad := "C:\TradeFiles\" FileType "\0" FileNumber ".xls"
  Else If (FileNumber >= 10 and FileNumber <= 20)
    FiletoLoad := "C:\TradeFiles\" FileType "\" FileNumber ".xls"
  Else
  {
    MsgBox, You have entered an Incorrect File Number
    Return
  }



;;  SendInput, !b
;;  WinWaitActive, Open
;;  SendInput, % FiletoLoad "!o"

  ToolTip, %FileType% file %FiletoLoad% Loaded.`nCurrent mode is %IncrementMode%
  SetTimer, ClearTooltip, -3000
  Return
}


LoadNextFile(byref FileNumber, FileType, IncrementMode)
{

  If (IncrementMode = "Normal")
  {
    If (FileType = "Buy")
      FileNumber++
    Else
      FileNumber--
  }
  Else
  {
    If (FileType = "Buy")
      FileNumber--
    Else
      FileNumber++
  }

  If (FileNumber > 20)
    FileNumber = 1

  If (FileNumber < 1)
    FileNumber = 20

  LoadFile(FileNumber, FileType)

}

_________________
Image
(Common Answers) - New Tutorials Forum - Humongous FAQ


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 18th, 2009, 2:38 pm 
Offline

Joined: August 18th, 2009, 4:08 am
Posts: 6
engunneer – you are the man – simply brilliant… :D :D :D

Honestly, at the onset of this post I never imagined that this would / could get done but your patience / perseverance and assistance has truly seen this one through. Thank you so very, very much…

engunneer wrote:
Anything marked with ;; is supposed to be uncommented, but I commented it since I don't have your program

I know through and through that this is your code but this isn’t what did it – I feel… In your previous post containing the whole code at line number 74, just after the command SendInput, !i, you had written LoadNextFile(byref FileNumber, FileType, IncrementMode) and in the last (revised) post – the one that works - you have given LoadNextFile(FileNumber, FileType, IncrementMode). Then at line number 82, just after the ClearTooltip: Tooltip, Return series of commands you had written LoadNextFile(FileNumber, FileType) and in the new post you have given it as LoadNextFile(byref FileNumber, FileType). I think this is what did the trick.

Ideally, I would like the NumpadEnter Hotkey to only work when the Paper Order – SACTP window were active so to have removed the #IfWinActive command would have caused me real problems.

It’s seems all good now…

Engunneer – With your assistance – Can I get a bit greedy? The only thing that seems a bit amiss (not from the functionality point of view) is that – Can I in someone way offer better visibility to the mode that has been selected and is in operation. Say if Normal is running then can it be permanently displayed in the Right hand corner of the screen, say till I switch to the Reversed mode (which should then get displayed) or until I exit the script.

Prima facie the script is doing wonders – if I face any errors in the next few days – I will let you know…


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 18th, 2009, 2:46 pm 
Offline
User avatar

Joined: August 30th, 2005, 8:43 pm
Posts: 8666
Location: Salem, MA
yes, you can modify the tooltip commands to place them where you want.

You can also remove the SetTimerCommand, or otherwise modify the notifications you get. I encourage you to experiment with this a bit. You can use the 'test' version for experimenting, since it won't harm your real application.

If you need help modifying the tooltip, let me know, but the help file explains it pretty well.

and yes, I had the byref in the wrong place. Its job in life is to make sure that the LoadNextFile function sends the new FileNumber back to the rest of the script, which was an earlier problem. Another problem was my initial setup of IncrementMode, where I used = instead of :=. That was a rookie mistake on my part.

I also encourage you to learn what the proper flow of this script is, in the event you need to change it. I'll be happy to answer any technical question about why it does what it does.

You can also use a GUI to display status, I just felt it wasn't needed right away.

Lastly, you can get in the habit of pressing F11 twice, and it will show you the current mode.

Code:
$F11::
;switch increment modes
If (IncrementMode = "Normal")
  IncrementMode := "Reversed"
Else
  IncrementMode := "Normal"
;there is no Return here on purpose. The program will flow into the next section.
$F12::
ToolTip, Current mode is %IncrementMode%
SetTimer, ClearTooltip, -3000
Return


Now F12 is a 'reminder'

Change the hotkeys as you like.

_________________
Image
(Common Answers) - New Tutorials Forum - Humongous FAQ


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 21 posts ]  Go to page 1, 2  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], BrandonHotkey, Pulover, SKAN, StepO and 59 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group