Jump to content

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

What do you do with AutoHotKey? give your idea here


  • Please log in to reply
42 replies to this topic
wooly_sammoth
  • Members
  • 644 posts
  • Last active: Jul 03 2013 08:08 PM
  • Joined: 12 May 2009
We're still running the physical copies along side testing the new digital system,or at least will be for while. The security is a minor concern as the data that is collected is public domain information anyway so there would be no need to hack into the system. The main concern of my superiours is that digital information can be lost in a system crash. I've built redundancy into the system so that the data is stored simultaniously in several locations at the moment all the original paper records are stored in one location which a fire couldjust as easily wipe out.

Tx RPh
  • Guests
  • Last active:
  • Joined: --
I'm a pharmacist as well & I use AHK every day at my pharmacy (shout out to Tomo_Uehara). No real computer programming training to speak of. My 1st big project was to create GUI interface via AHK that I use to record telephone Rx's phoned to my pharmacy from MD offices--way better than trying to write them out by hand!!
(Thanks Autohotkey).

tomoe_uehara
  • Members
  • 2166 posts
  • Last active: Jun 11 2015 05:33 PM
  • Joined: 05 Sep 2009

is Tx you tomoe? or a buddy?

Well.. That's just another user who uses ahk in the real life =)

And that's good to hear another pharmacist who also use ahk too.. Posted Image


OceanMachine
  • Members
  • 790 posts
  • Last active: Aug 23 2013 02:10 PM
  • Joined: 15 Oct 2007

i pull data from several telnet sessions a web site and an odbc connection into a common web interface


@tank: if you don't mind me asking, what method do use for telnet with AKH? I have tried the send/expect from DerRaphael, and I can't seem to get it to work*... "Well post in that thread then" you might think, but I just wanted to check whether you were using that kind of thing, or whether you were using another program or some other cool trick to pull stuff out of a box via telnet... and have you had any luck (or had the need to use) SSH to perform the same thing? Our boxes are being slowly hardened one-by-one, so it would be nice to know whether someone else has gotten a similar thing working via SSH before I attempt it.

I noticed you said you also used ODBC - again, I think I would probably be able to do this via PHP and then get the info back into AHK, or maybe use a separate exe to do the actual querying, or a number of other (much more messy and unreliable) ways, but I was wondering about this also, do you use something similar to the ADO COM thread to do this directly in AHK? Not sure if you use oracle databases or something less commercial or not, so it maybe depends on the database being used?

I'm not asking you to give away all your tricks, or write me a load of code, I just wondered about the methods so I can try to learn, and at least I will be spending my time and effort in a potentially fruitful way :)



Anyway, back on topic - I use AHK whenever I can at work, I have made a touch-screen based app to control a web page with automatic printer installation for some web terminal users, log file cleaning/parsing and sql-generating scripts, a script that creates custom Code-128 and EAN-13 barcodes using postscript, another that pulls data out of XML files, another that reads data from a bluetooth COM port for a barcode scanner and captures barcodes, an app that checks a wireless connection and the state of a scanner and reconnects automatically when the connection fails, and at the moment I am working on a monitoring application to monitor states of servers and databaes, count orders, etc (hence my questions above!), and loads of other small apps.

Nothing as fancy as tank, and not as special as most of the stuff that gets posted on here by the real pros, but they work really well. Most of it has been helped by the great community and example scripts that people post on this forum! I love how you can check the forum most weeks and it seems there is something new someone has found a way to do in AHK :)


*by the way, I can get the actual connection to work (no winsock errors), and I get the initial "ÿû" characters (sometimes only 2, sometimes a load of them), but I can't seem to get the initial 'prompt' (expect) to work, and when I try to send a string back as per the examples, nothing happens... I will probably enquire a bit more on that thread. It also seems that I must do something else special to get that to work with SSH...

tank
  • Administrators
  • 4345 posts
  • AutoHotkey Foundation
  • Last active: Oct 13 2016 01:04 AM
  • Joined: 21 Dec 2007
the telnet sessions are don thru shell windows that are com accessable so as far as true telnet i cant offer much help

I use javascript executed via COM_ScriptControl to interact with odbc you can find many examples

sCode=
(
	var strConnection = "Data Source=[color=red]HYDRA[/color];User Id=%A_UserName%;Password=%pass%;";
	var param1="%param1%";
	var param2="%param2%";
	var param3="%param3%";
	var ErrorLevel=false;
	var conn = new ActiveXObject("ADODB.Connection");
	var rs = new ActiveXObject("ADODB.Recordset");
	
	connect();
	result = exec_query(param1, param2, param3);
	close_conn();
	
	function connect(){
		try{
			conn.open(strConnection, "", "");
		}//end try
		catch(e){
			ErrorLevel="Couldn't connect error: " + e.description;
		}//end catch
	}//end function

	function close_conn(){
		try{
			conn.close();
		}//end try
		catch(e){
			//do nothing
		}//end catch
	}//end function

	function exec_query(param1, param2, param3){
		 
		var query="sql statement"
		try{
		rs.open(query, conn);
		}
		catch(e){
			ErrorLevel="Couldn't Query error: " + e.description;
			// this js error would need to be handled
		}//end catch
		
		if(!rs.bof) {
			rs.MoveFirst();
			var results="";
			while(!rs.eof) { 			  results+=rs.fields("feild_name").value;				rs.MoveNext();
			}
		rs.close();
		return	results;

	}//end function

	
	result=result+"";
)
	If	InStr(r:=COM_ScriptControl(sCode, "JScript", 1),"Couldn't connect error:")
	;;some action in ahk
;~ 	r will be the result of the function
Obviously the above is more demonstration and isnt working code one could do this with com and ahk but havent had a need to convert it

setting up an oracle connection in odbc uses the following ahk
RegWrite,REG_SZ,HKLM,SOFTWARE\ODBC\ODBC.INI\[color=red]hydra[/color],Driver,C:\WINNT\system32\msorcl32.dll
RegWrite,REG_SZ,HKLM,SOFTWARE\ODBC\ODBC.INI\[color=red]hydra[/color],DSN,[color=red]hydra[/color]
RegWrite,REG_SZ,HKLM,SOFTWARE\ODBC\ODBC.INI\[color=red]hydra[/color],Description,
RegWrite,REG_SZ,HKLM,SOFTWARE\ODBC\ODBC.INI\[color=red]hydra[/color],UID,[color=red]username here[/color]
RegWrite,REG_SZ,HKLM,SOFTWARE\ODBC\ODBC.INI\[color=red]hydra[/color],PWD,
RegWrite,REG_SZ,HKLM,SOFTWARE\ODBC\ODBC.INI\[color=red]hydra[/color],SERVER,[color=red]db.table[/color]
RegWrite,REG_SZ,HKLM,SOFTWARE\ODBC\ODBC.INI\[color=red]hydra[/color],BufferSize,65535
RegWrite,REG_SZ,HKLM,SOFTWARE\ODBC\ODBC.INI\[color=red]hydra[/color],SynonymColumns,1
RegWrite,REG_SZ,HKLM,SOFTWARE\ODBC\ODBC.INI\[color=red]hydra[/color],Remarks,0
RegWrite,REG_SZ,HKLM,SOFTWARE\ODBC\ODBC.INI\[color=red]hydra[/color],StdDayOfWeek,1
RegWrite,REG_SZ,HKLM,SOFTWARE\ODBC\ODBC.INI\[color=red]hydra[/color],GuessTheColDef,0
RegWrite,REG_SZ,HKLM,SOFTWARE\ODBC\ODBC.INI\[color=red]hydra[/color],StripTrailingZero,0
same disclamer better edit the red before using

Yes you can also do with php
<?
	
	@$odbccnx = odbc_connect("connectiondsn","usernames","password");
	$query = "sql";
	
	$result = odbc_exec($odbccnx,$query);
	
	//opend the file
	$the_file = "output.csv";
	$fh = fopen($the_file, 'w') or die("can't open file");
	
	while ($data[] = odbc_fetch_array($result));
	
	odbc_free_result($result);
	foreach($data as $value){
		if(!empty($value)){
			fwrite($fh, $value["feildname"]."\r\n");
		}//end if
	}//end foreach
	unset($data);
	
	fclose($fh); ?>
dont seel yourself short any one who uses ahk in an enterprise endeavor successfully small or big is pitting earning potential against failure. this isnt the work of idiots so if your suing it in your livelyhood you have earned your rights
:p
Never lose.
WIN or LEARN.

OceanMachine
  • Members
  • 790 posts
  • Last active: Aug 23 2013 02:10 PM
  • Joined: 15 Oct 2007

the telnet sessions are don thru shell windows that are com accessable so as far as true telnet i cant offer much help

Ah OK, so you're scraping the actual console window, rather than using some win32 API call to do it? Well, I guess if it works reliably for you, I should look into doing it that way!

I use javascript executed via COM_ScriptControl to interact with odbc you can find many examples

sCode=
(
	var strConnection = "Data Source=[color=red]HYDRA[/color];User Id=%A_UserName%;Password=%pass%;";
	var param1="%param1%";
	var param2="%param2%";
	var param3="%param3%";
	var ErrorLevel=false;
	var conn = new ActiveXObject("ADODB.Connection");
	var rs = new ActiveXObject("ADODB.Recordset");
	
	connect();
	result = exec_query(param1, param2, param3);
	close_conn();
	
	function connect(){
		try{
			conn.open(strConnection, "", "");
		}//end try
		catch(e){
			ErrorLevel="Couldn't connect error: " + e.description;
		}//end catch
	}//end function

	function close_conn(){
		try{
			conn.close();
		}//end try
		catch(e){
			//do nothing
		}//end catch
	}//end function

	function exec_query(param1, param2, param3){
		 
		var query="sql statement"
		try{
		rs.open(query, conn);
		}
		catch(e){
			ErrorLevel="Couldn't Query error: " + e.description;
			// this js error would need to be handled
		}//end catch
		
		if(!rs.bof) {
			rs.MoveFirst();
			var results="";
			while(!rs.eof) { 			  results+=rs.fields("feild_name").value;				rs.MoveNext();
			}
		rs.close();
		return	results;

	}//end function

	
	result=result+"";
)
	If	InStr(r:=COM_ScriptControl(sCode, "JScript", 1),"Couldn't connect error:")
	;;some action in ahk
;~ 	r will be the result of the function
Obviously the above is more demonstration and isnt working code one could do this with com and ahk but havent had a need to convert it


Ah I see, I have used the execScript side of COM_Invoke before, but didn't see the COM_ScriptControl - you can just execute JS in there without setting up a browser object or anything like that? Interesting... :)

setting up an oracle connection in odbc uses the following ahk

RegWrite,REG_SZ,HKLM,SOFTWARE\ODBC\ODBC.INI\[color=red]hydra[/color],Driver,C:\WINNT\system32\msorcl32.dll
RegWrite,REG_SZ,HKLM,SOFTWARE\ODBC\ODBC.INI\[color=red]hydra[/color],DSN,[color=red]hydra[/color]
RegWrite,REG_SZ,HKLM,SOFTWARE\ODBC\ODBC.INI\[color=red]hydra[/color],Description,
RegWrite,REG_SZ,HKLM,SOFTWARE\ODBC\ODBC.INI\[color=red]hydra[/color],UID,[color=red]username here[/color]
RegWrite,REG_SZ,HKLM,SOFTWARE\ODBC\ODBC.INI\[color=red]hydra[/color],PWD,
RegWrite,REG_SZ,HKLM,SOFTWARE\ODBC\ODBC.INI\[color=red]hydra[/color],SERVER,[color=red]db.table[/color]
RegWrite,REG_SZ,HKLM,SOFTWARE\ODBC\ODBC.INI\[color=red]hydra[/color],BufferSize,65535
RegWrite,REG_SZ,HKLM,SOFTWARE\ODBC\ODBC.INI\[color=red]hydra[/color],SynonymColumns,1
RegWrite,REG_SZ,HKLM,SOFTWARE\ODBC\ODBC.INI\[color=red]hydra[/color],Remarks,0
RegWrite,REG_SZ,HKLM,SOFTWARE\ODBC\ODBC.INI\[color=red]hydra[/color],StdDayOfWeek,1
RegWrite,REG_SZ,HKLM,SOFTWARE\ODBC\ODBC.INI\[color=red]hydra[/color],GuessTheColDef,0
RegWrite,REG_SZ,HKLM,SOFTWARE\ODBC\ODBC.INI\[color=red]hydra[/color],StripTrailingZero,0
same disclamer better edit the red before using

OK, thanks for that. I assume I could just use a system DSN that already exists on the machine instead? (oracle 10g forced drivers, unfortunately) - I will have to have a play with that. I realise the connection string will probably be completely different too :)

Yes you can also do with php

Yeah I have made a few php scripts that query stuff so the users can run them and see whats going on for certain things, and I guess I could run those and get the data out of the browser using COM/iWeb, etc, but I would prefer to find a nice reliable way of doing it without relying on IE, directly via AHK/COM, so I'll give the JavaScript business above a shot, see what happens.

dont seel yourself short any one who uses ahk in an enterprise endeavor successfully small or big is pitting earning potential against failure. this isnt the work of idiots so if your suing it in your livelyhood you have earned your rights
:p


Appreciate that :D I know how difficult it can be sometimes to get stuff working correctly and reliably in the first place, but once it is working, it's rock solid - that's another thing I love about AHK! Some (non-programmer) colleagues of mine keep insisting that AHK is going to take over the business because I keep automating repetitive boring tasks, or if someone says 'we need this', I can say 'I'll just write a quick script to do that', (I'm sure you get the same kinda thing) but then I get addicted to adding new features and just can't put it down until the next little project is complete!

Thanks again for the tips, I'll have to see how I get on :D

answer4u
  • Guests
  • Last active:
  • Joined: --

Too bad there aren't any good advanced tutorials like cool Win API examples and Com.

As far as WIN API, there are examples in the forum. However, AHK is designed for windows scripting - hence many of the built-in commands already use the WIN API.

As far as COM, how about this or that?

  • Guests
  • Last active:
  • Joined: --
I am a new Autohotkey user with no scripting experience, but i was able to learn it quick and automate a 13 page test procedure written originally in Python. Thank you all for your cooperation. Let us keep helping one another.

slemma
  • Members
  • 45 posts
  • Last active: Aug 05 2013 11:24 PM
  • Joined: 24 Aug 2011
I am a new Autohotkey user with no scripting experience, but i was able to learn it quick and automate a 13 page test procedure written originally in Python. Thank you all for your cooperation. Let us keep helping one another.

dedemouse
  • Members
  • 1 posts
  • Last active: Mar 15 2012 10:49 PM
  • Joined: 31 Jan 2012
It's very useful for gaming. like haxing without need a hax program :lol:

abhishek lodha
  • Members
  • 2 posts
  • Last active: Feb 17 2014 08:03 PM
  • Joined: 17 Feb 2014

I use this to on/off my torrent client when i surf internet....

also to use volume up down....



abhishek lodha
  • Members
  • 2 posts
  • Last active: Feb 17 2014 08:03 PM
  • Joined: 17 Feb 2014

I use this to on/off my torrent client when i surf internet....

also to use volume up down....

 

F6::Run F:\Bitlord\BitLord.exe
F7::Process,Close,BITLORD.EXE
F8::run "D:\Program Files\FirefoxPortable\nircmd.exe" cmdwait 1000 monitor off
^SPACE:: Winset, Alwaysontop, , A
^!n::
IfWinExist Untitled - Notepad
    WinActivate
else
    Run Notepad
return
F10::Send {Volume_Up 1}
F9::Send {Volume_Down 1}
F12::Send {Volume_mute}

; Caps lock always off
CapsLock::SetCapsLockState, Off

+capslock::Setcapslockstate, on
 



The war II
  • Members
  • 28 posts
  • Last active: Oct 15 2018 10:05 AM
  • Joined: 01 Jun 2013

i LOVE ahk

i did it a lot of now, i can't think what would i need to do with it.