Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 805
  • Last Modified:

AutoHotKey Help

Dear Guys,

I need help in formulating a autohotkey script that will read a text file that contains the following input and set two variables (startD and endD )to be send to the windows form,and save that (startD) as a filename.

Input:

1:M:S1/12/2009:E31/12/2009:T18:21;
2:M:S1/11/2009:E30/11/2009:T18:46;

and extract and set information only from the last line available in the input
startD :1/11/2009
endD:  30/11/2009

and then save the file as using the alt +F+a keyboard input with startD as the filename.

Thanks!

-T216

0
Talal216
Asked:
Talal216
  • 4
  • 3
1 Solution
 
LordArokhCommented:
Hi Talal216,

As far as I understand, you want a script which will run when you hit "alt +F+a".
The script will read the last line of the file and convert last line to :

startD :1/11/2009
endD:  30/11/2009

and save both lines to a file named with startD.

Am I right ?

Cheers
TK
0
 
Talal216Author Commented:
Yes
0
 
Talal216Author Commented:
The way i want it saved c:\reports\R1/11/2009.xls in the file save as window and press enter.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LordArokhCommented:
Here is your script.

it will ask you to choose a file. Then read till the list line. And get the last line. Extract Start and End date.
Create a file under "C:\REPORTS" folder with the name of startD.

Cheers
TK
Option Explicit

Dim lcLine
Dim startD
Dim endD
Dim oFSO:Set oFSO = CreateObject("Scripting.FileSystemObject")
Dim oDLG:Set oDLG = CreateObject("UserAccounts.CommonDialog")

Dim lbResult : lbResult = oDLG.ShowOpen

If lbResult=False Then 
	MsgBox "No files choosen.Quiting.....!"
	Call CleanUp
Else
	Dim lcFileName:lcFileName=oDLG.FileName
End If

Dim oFL:
Set oFL=oFSO.OpenTextFile(lcFileName,1,False)

If Not IsObject(oFL) Then 
	MsgBox "Target File Cannot be Opened.Quiting.....!"
	Call CleanUp
End If

Do While Not oFL.AtEndOfStream
	lcLine=oFL.ReadLine	
Loop

startD=Mid(lcLine,InStr(1,lcLine,":S")+2,InStr(1,lcLine,":E")-InStr(1,lcLine,":S")-2)
endD=Mid(lcLine,InStr(1,lcLine,":E")+2,InStr(1,lcLine,":T")-InStr(1,lcLine,":E")-2)

Dim oTFL,lcTFile
lcTFile="c:\reports\"& Replace(startD,"/",".")& ".xls"
Set oTFL=oFSO.CreateTextFile(lcTFile)

oTFL.WriteLine "startD :" &startD
oTFL.WriteLine "endD :" & endD

oTFL.Close

Call CleanUp

Public Sub CleanUp

	If IsObject (oFL) Then 
		Set oFL=Nothing
	End If
	If IsObject(oDLG) Then
		Set oDLG=Nothing
	End If
	If IsObject(oFSO) Then 
		Set oFSO=Nothing
	End If
	If IsObject(oTFL) Then
		Set oTFL=Nothing
	End If
	
	WScript.Quit
	
End Sub

Open in new window

0
 
Talal216Author Commented:
Hey i was looking for a auto hot key script the website for it is http://www.autohotkey.com.
0
 
LordArokhCommented:
If you want AUTOHOTKEY application just only for a key combination tot start the script, then you don't need an 3rd party application for it.

Put the VBS file which you created with the code above, in a folder and create a shortcut to that script. Then right click on that shortcut and select properties. You'll see a section called "SHORTCUT KEY". You can assign a short cut to your script from there.

For short cut unfortunately there is not lot different combination. You can only configure with "CTRL+ALT+ANY KEY" style.

In anyway it is better than using a 3rd party application.

Cheers,
TK
0
 
Talal216Author Commented:
Hey Thanks!

0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now