 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
gha1d
Joined: 10 Feb 2007 Posts: 15 Location: Sl
|
Posted: Sat Feb 10, 2007 2:43 am Post subject: Using a value on excel as a flag |
|
|
Need help on below script guys, Please HELP..
Run D:\Geoffrey\Time Test.xls
WinWait, Microsoft Excel - Time Test,
IfWinNotActive, Microsoft Excel - Time Test, , WinActivate, Microsoft Excel - Time Test,
WinWaitActive, Microsoft Excel - Time Test,
Send, {CTRLDOWN}g{CTRLUP}
WinWait, Go To,
IfWinNotActive, Go To, , WinActivate, Go To,
WinWaitActive, Go To,
Send, d1{ENTER}
What i need to know is how to run a program if the above mentioned cell d1 contains a value like 1 or 0,
Eg:
If the cell contains 1, then run c:\my documents\Test.ahk
If the cell contains 0, do nothing |
|
| Back to top |
|
 |
DJAnonimo
Joined: 10 Sep 2006 Posts: 157
|
Posted: Sat Feb 10, 2007 3:03 am Post subject: |
|
|
No way, its excel file, when you opet it as text its all crypted...
Better open it and retrieve the number, if you have a good PC
it will be fast, about a second  |
|
| Back to top |
|
 |
PhiLho
Joined: 27 Dec 2005 Posts: 6836 Location: France (near Paris)
|
Posted: Sat Feb 10, 2007 8:43 am Post subject: |
|
|
That's what he does...
I understand that you selected the D1 cell and suppose you succeeded. Then Send ^c to copy the value in the cell, and get its value in the Clipboard variable (might need to wait a bit). _________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2") |
|
| Back to top |
|
 |
Rabiator
Joined: 17 Apr 2005 Posts: 289 Location: Sauerland
|
Posted: Sat Feb 10, 2007 10:47 am Post subject: |
|
|
There is another way to manage it, with an additional vbscript.
With it you don't have to open the excel file at all, therefore it's faster.
To use vbscript, the Windows Script Host has to be activated.
Registry: HKEY_LOCAL_MACHINE\Software\Microsoft\Windows Script Host\Settings Enable=1.
Attention please, activating this is often deemed to be a securty risk!
Save the following vbscript e. g. in TEST.VBS.
It reads the cell contents and saves it to RESULT.TXT.
| Code: |
' VB script, Filename: TEST.VBS
Dim objXL
Dim Var
ExcelFile = "D:\Geoffrey\Time Test.xls"
Set FSO = WScript.CreateObject("Scripting.FileSystemObject")
Set objXL = WScript.CreateObject("Excel.Application")
If Fso.FileExists(ExcelFile) Then
objXL.Workbooks.Open(ExcelFile)
Else
WScript.Quit
End If
objXL.Range("D1").Select
Var = objXL.Selection.Value
objXL.Application.Quit
Set Data = Fso.OpenTextFile("Result.txt", 8, True)
Data.Write(Var)
Data.Close
|
With the following ahk script you run the above vbscript, evaluate the result and do further steps. Example:
| Code: | FileDelete, Result.txt
RunWait, Test.vbs
FileRead, Cell, Result.txt
If (Cell = 1)
run, c:\my documents\Test.ahk
|
__________________________________________
Created with BBCodeWriter 6.6 - the one and only  |
|
| Back to top |
|
 |
gha1d
Joined: 10 Feb 2007 Posts: 15 Location: Sl
|
Posted: Wed Feb 17, 2010 6:18 am Post subject: |
|
|
| I forget to thank you for this Rabiator, Good Luck.. |
|
| Back to top |
|
 |
Rabiator
Joined: 17 Apr 2005 Posts: 289 Location: Sauerland
|
Posted: Wed Feb 17, 2010 11:17 pm Post subject: |
|
|
Better late than never.  |
|
| Back to top |
|
 |
Jeremiah
Joined: 20 Apr 2009 Posts: 797 Location: North Dakota, USA
|
Posted: Thu Feb 18, 2010 12:42 am Post subject: |
|
|
Wow. Very helpful. I actually needed something like this. lol. Ironically. Thank you Rabiator. _________________ -Jeremiah |
|
| Back to top |
|
 |
jethrow
Joined: 24 May 2009 Posts: 1907 Location: Iowa, USA
|
Posted: Thu Feb 18, 2010 3:38 am Post subject: |
|
|
Helpful indeed - here's basically the same thing using AHKL & COM_L, now that we have more options : | Code: | If FileExist( ExcelFile := "D:\Geoffrey\Time Test.xls" ) {
pxl := COM_CreateObject( "Excel.Application" )
pxl.WorkBooks.Open( ExcelFile )
Cell := pxl.Range( "D1" ).Value
pxl.Quit()
If ( Cell = 1 )
Run, C:\My Documents\Test.ahk
} |
_________________
- in case I forgot to smile
Basic Webpage Controls
COM Object Reference |
|
| Back to top |
|
 |
tank
Joined: 21 Dec 2007 Posts: 3700 Location: Louisville KY USA
|
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|