Jump to content

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

nubAHK


  • Please log in to reply
31 replies to this topic
derRaphael
  • Members
  • 872 posts
  • Last active: Mar 19 2013 04:42 PM
  • Joined: 23 Nov 2007
Posted Image

Posted ImageVisit nubAHK wiki today. It's online and open for discussions


well, since the ongoing discussion which ahk to prefer (chris ahk basic, or the all new ahk_l) wont find an end soon, i decided to start with something new.

its called nubAHK (pronounce new AHK). it comes with an all new syntax which is very non programming people oriented. here is a very first proof of concept script which translates a simple nubscript to ahk or ahk_l whatever will make the race :)

to try it out, save the script below as demo.nub
here is how the nubscript looks like:
hotkey "CTRL+X"
	you type "I CAN HAS HOTKEYZ AND AUTOTYPER!"
done with hotkey

hotkey "ESCAPE"
done with script

hotkey "CTRL+SPACEBAR"
	repeat 3 times from here
		you type "YEAH BABY!" 
		wait for 1 second
		you type "I SAY YEA BABY!"
		wait for 0.5 second
	to here
done with hotkey

when i type "LOL" you type "ROFL"

here is a very simple parser which translates aboves nubscript (demo.nub) into plain old ahk but this may be later changed to whatever syntax you'll prefer, such as ahk_l, ia and who knows what else.

fileread, nub, demo.nub
FileAppend,% n2a( nub ),% A_ScriptDir "\t.ahk"
runwait % """" A_AhkPath """ /ErrorStdOut """ A_ScriptDir "\t.ahk"""
If ( FileExist( A_ScriptDir "\t.ahk" ) )
	FileDelete, % A_ScriptDir "\t.ahk"

n2a( nub ) {
	global ahk
	
	ahk := "; nub2ahk PoC v 0.1 prealpha`n"
	nub := RegExReplace( nub, "sm)^(\t| )*", "" )
	nub := RegExReplace( nub, "i)from here", "`n{" )
	nub := RegExReplace( nub, "i)to here", "`n}`n" )
	nub := RegExReplace( nub, "i)you type ""((""""|[^""])+)""", "send, % ""$1""" )

	Loop,Parse,nub,`n,`r
		if ( RegExMatch( A_LoopField, "i)^\s*hotkey\b[^""]""([^""]+)""", hk ) )	{
			hk1 := RegExReplace( hk1, "i)(BAR|APE|DOWS)\b", "" )
			hk1 := RegExReplace( hk1, "i)\bCTRL\b", "^" )
			hk1 := RegExReplace( hk1, "i)\bALT\b", "!" )
			hk1 := RegExReplace( hk1, "i)\bWIN?\b", "#" )
			hk1 := RegExReplace( hk1, "\s*\+\s*", "" )
			ahk .= _( RegExReplace(hk1,"(.*)","$L1") "::" ) 
		} else if ( RegExMatch( A_LoopField, "i)^done with hotkey$" ) ) {
			ahk .= _( "return" ) 
		} else if ( RegExMatch( A_LoopField, "i)^done with script$" ) ) {
			ahk .= _( "exitapp" ) 
		} else if ( RegExMatch( A_LoopField, "i)^wait for (?P<time>\d+(\.\d+)?) (?P<unit>(sec(ond(s)?)?|min(utes)?|hours|hrs))", m ) ) {
			ahk .= _( "sleep, % " mtime " * " ( InStr( munit,"sec" ) ? "1000" : InStr( munit,"min" ) ? " 60 * 1000" : " 60 * 60 * 1000" ) ) 
		} else if ( RegExMatch( A_LoopField, "i)^when i type[^""]""([^""]+)"" send, %[^""]""([^""]+)""", m ) ) {
			ahk .= _( "::" m1 "::" m2 )
		} else if ( RegExMatch( A_LoopField, "i)^repeat (?P<rounds>\d+) times", m ) ) {
			ahk .= _( "Loop, " mrounds ) 
		} else 
			ahk .= _( A_LoopField ) 

	return ahk
}

_(t){
	global ahk
	return t ( strlen(ahk) == 0 ? "" : "`n" )
}

at the moment only simple (read basic) hotkeys, loops, sleeps, and hotstrings are supported.

tell me what you think about it.

greets
dR

All scripts, unless otherwise noted, are hereby released under CC-BY

tomoe_uehara
  • Members
  • 2166 posts
  • Last active: Jun 11 2015 05:33 PM
  • Joined: 05 Sep 2009
Oh so nubAHK doesn't pronounced as newbie AHK?
Btw, when I read your script, it reminds me of this
The lolcat translator :roll:

derRaphael
  • Members
  • 872 posts
  • Last active: Mar 19 2013 04:42 PM
  • Joined: 23 Nov 2007
the idea was to create a "more natural" syntax which is less technical looking therefore more n00b-friendly

dont think, only cuz it says "I CAN HAS ... " its comparable to lolcode.

the string is actually transformed into a send command and nothing else

above's scripts match a working set

imho a new user finds it easier to read hotkey "ctrl+x" instead of "^x" also the from here ... to here syntax is somewhat more friendly than {...}

All scripts, unless otherwise noted, are hereby released under CC-BY

Tuncay
  • Members
  • 1945 posts
  • Last active: Feb 08 2015 03:49 PM
  • Joined: 07 Nov 2006
How often did thought about such a concept.
A new *programming-automation* language written with AutoHotkey.

I have one project that is ini file oriented (dynamically with labels, instead new file). Example script would look like:
[event_onstart]
action=showmessage

[event_onexit]
action=exec

[gui]
height=128
width=256
title=Hallo Welt
control=mytext,ok,exit

; CONTROL

[control_mytext]
type=text
content=Look what I have done.

[control_ok]
type=button
action=exec,write

[control_exit]
type=button
content=close script
action=exit

; ACTION

[action_exec]
type=exec
content=run,notepad.exe
action=wait

[action_showmessage]
type=msgbox

[action_exit]
type=exitapp

[action_wait]
type=wait
content=0.5

[action_write]
type=send
content=hallo welt
I gave up this project for now.

No signature.


derRaphael
  • Members
  • 872 posts
  • Last active: Mar 19 2013 04:42 PM
  • Joined: 23 Nov 2007
that is the actual output from that nub code
; nub2ahk PoC v 0.1 prealpha
^x::
send, % "I CAN HAS AUTOTYPER!"
return

esc::
exitapp

^space::
Loop, 3
{
send, % "YEAH BABY!" 
sleep, % 1 * 1000
send, % "I SAY YEA BABY!"
sleep, % 0.5 * 1000

}

return

::LOL::ROFL


All scripts, unless otherwise noted, are hereby released under CC-BY

Tuncay
  • Members
  • 1945 posts
  • Last active: Feb 08 2015 03:49 PM
  • Joined: 07 Nov 2006
How many keywords are planned?
And what commands are planned to be supported?

What about variables? What features would you support?

The idea of the project is good and could help non programmers to infiltrate ahk :D

No signature.


derRaphael
  • Members
  • 872 posts
  • Last active: Mar 19 2013 04:42 PM
  • Joined: 23 Nov 2007
for now the focus lays on usability. instead of overloading it with features, i think the effort should be made to keep things even simpler

i could imagine a syntax like this:

click button "ok" in window "myprogramm"

or

load page "http://some.url/page.html" with browser
enter username "myname" and password "mypass"
see the text "new mail"
alert me "you have new mails"
done with load page

stuff like that. keep it simpler. (that is no typo)

variables? well i dont know yet not am i sure about gui support

i just wanted toget back to ahk's root. simple usage and controlling of apps not overloading it with functionality and more custom options. people interested in that may use an ahk flavour directly.

for now i thought about controlling apps by button names, if thats not possible then having a simple to use wizard to grab all that nasty technical info and present it to the user in a beautified way ( eg 4th button in window "programm" ) or one feature which is a real complex thing is automated webpage control with very simple commands (as in the sample) without that brainsurgery knowhow of com - even if that means "Your browser XYZ is not compatible"

atm i am not too sure about which commands to use or to support. but i am open for suggestions

All scripts, unless otherwise noted, are hereby released under CC-BY

fincs
  • Moderators
  • 1662 posts
  • Last active:
  • Joined: 05 May 2007
This is a really nice idea :)

Uberi
  • Moderators
  • 1119 posts
  • Last active: May 02 2015 06:05 PM
  • Joined: 23 Aug 2010
Excellent work! The syntax reminds me of AppleScript, simple and friendly.

Chicken Pie 4 Tea
  • Members
  • 379 posts
  • Last active: Dec 12 2014 06:46 PM
  • Joined: 18 Aug 2009
I think you are on to a good idea.
this is part of a statement made by Chris in the Anouncement thread.

My original motivation for starting the AutoHotkey project was to empower users, including non-programmers, to do automation and hotkeys. I wanted the scripting language to be kept simple yet flexible. I didn't want it to become a full-blown programming language.

After a few years it became clear that the user community, at least those most active, wanted AutoHotkey to focus more on programming features like arrays and objects. In hindsight it was then that I began to lose interest


At the moment I think in time AHK_L will take over as the main program and so It would be great to have another variety with a completely different focus.
I think it would have the potential to be more popular than any before it as I think most people would like a very simple to use program to automate stuff and are not really wanting to get into real programming.
ps I prefer the name simpleAHK
"Choose your parents wisely"

SoLong&Thx4AllTheFish
  • Members
  • 4999 posts
  • Last active:
  • Joined: 27 May 2007
Somewhat related for reference: <!-- m -->http://www.autohotke... ... ht=haskell<!-- m -->

derRaphael
  • Members
  • 872 posts
  • Last active: Mar 19 2013 04:42 PM
  • Joined: 23 Nov 2007

Somewhat related for reference: <!-- m -->http://www.autohotke... ... ht=haskell<!-- m -->


i think its not related to literal haskell. from what i understood the aspect of literal haskell was to have natural text which works pretty much the same way comments do (except its not marked as comment) and have some function calls.

with nubAHK i think the goal is to have a more descriptive language which eases the process of scriptcreation, since the syntax is not intended to be technical.

All scripts, unless otherwise noted, are hereby released under CC-BY

SoLong&Thx4AllTheFish
  • Members
  • 4999 posts
  • Last active:
  • Joined: 27 May 2007

i think its not related to literal haskell

True, although one might learn more from a literal AutoHotkey script which is indeed just a well commented AutoHotkey script. I think nubAHK will still leave room for errors. But looks fun none the less.

Another "entirely unrelated" project (just for those interested in easy scripting)

Easy Script Block Editor:
<!-- m -->http://www.autohotke...pic.php?t=61752<!-- m -->

derRaphael
  • Members
  • 872 posts
  • Last active: Mar 19 2013 04:42 PM
  • Joined: 23 Nov 2007
i like the idea of visual programming ( in a manner which is completely visual ) - not that already existing stuff.

but imho such an IDE should be 3d based and each block folds/unfolds upon interaction. but besides i like this one ;)

All scripts, unless otherwise noted, are hereby released under CC-BY

Chicken Pie 4 Tea
  • Members
  • 379 posts
  • Last active: Dec 12 2014 06:46 PM
  • Joined: 18 Aug 2009
it would be good if there was a post on this in the Ask Questions section as that's where people who are finding the basic AHK sometimes difficult go - including myself
"Choose your parents wisely"