Develop desktop application using html/javascript!
PowerChrome is a portable Chromium-base (cef) web browser for html/javascript desktop application development.
Run Shell Commands
- Run notepad.exe. ``pb.run('notepad.exe')`` => ``pb.api('run','notepad.exe')`` => ``pb.api('run?notepad.exe')``
- Run notepad.exe (max/wait mode) ``pb.run('notepad.exe pwoerchrome.html','','max')``, ``pb.run('notepad.exe','','wait')``
- Run notepad2.exe from folder c:/temp. ``pb.run('notepad2.exe', 'c:/temp')``
- shell: open folder/file. ``pb.shell('c:/temp')``, ``pb.shell('powerchrome.html')``
- shell: execute with parm. ``pb.shell('notepad.exe','powerchrome.html')``
- shell: print file. ``pb.shell('c:/temp/output.pdf', '', '','print')``
- Send keystrokes. ``pb.sendkeys('run=notepad.exe/title=Untitled - Notepad/s=1/this is a test!\n/s=3/hello!')``
HTML Dialog
- popup html dialog ``pb.popup('https://news.ycombinator.com/')``
- popup html, set width/height. ``pb.popup('https://dev.to/', {width:1024, height:700} )``
- popup html, set x, y, width ``pb.popup('https://news.ycombinator.com/', {left:200, top:300, width:400, height:200})``
- popup html, save to file ``pb.popup( 'https://news.ycombinator.com/', {save:'hackernews.html', select:'table'} )``
- min dialog, save to PDF ``pb.popup( 'https://news.ycombinator.com/', {save:'./hackernews.pdf', mode:'min'} )``
- Crawl selected html for url ``pb.popup( 'https://news.ycombinator.com/front', {select:'table'} )``
- Open dialog, return string when close. ``pb.popup( 'sample-dialog.html' )``
- render html page by string ``pb.popup( pb('sub-page').innerHTML, { width:500, height:300 } )``
- inject javascript ``pb.popup( 'sample-dialog.html', {script:"pb.alert('welcome')"} )``
- import js file ``pb.popup( 'sample-dialog.html', {import:"sample-dialog.js"} )``
Http Request
- get source of url ``'<xmp>' + pb.httpSource('https://casualwriter.github.io') + '</xmp>'``
- get json data ``rs = pb.httpSource('https://hacker-news.firebaseio.com/v0/item/2921983.json')``
- get http Request ``'<xmp>' + pb.httpRequest('GET','https://www.google.com/search?q=html') + '</xmp>'``
Work with Database
- connect MS Access (ODBC). ``pb.dbConnect('ODBC',"connectstring='DRIVER={Microsoft Access Driver (*.mdb)};DBQ=sample.mdb'")``
- connect oracle (native). ``pb.dbConnect('O90', '', 'PROFILE', 'scott', 'tiger')``
- Connect oracle (JDBC). ``pb.dbConnect('JDBC',"Driver='oracle.jdbc.driver.OracleDriver',URL='jdbc:oracle:thin:user/password@db-server:1521/xe'",'','','')``
- disconnect, commit, rollback. ``pb.dbDisconnect()``, ``pb.dbCommit()``, ``pb.dbRollback()``
- SQL query, return json string. ``pb.dbQuery("select * from categories")``
- SQL query, get json. ``rs = JSON.parse(pb.dbQuery('select * from categories')); rs.rowCount``
- SQL query, return html table. ``pb.dbTable('select * from categories')``
- Insert Record. ``pb.dbExecute("insert into categories values (99, 'PowerChrome', 'Test Record', '')")``
- Update Record. ``pb.dbExecute("update categories set remarks='English,繁體,简体' where CategoryName='PowerChrome'")``
- Delete Record. ``pb.dbExecute("delete from categories where CategoryName like 'PowerChrome%'")``
Access File System
- Append text to file. ``pb.fileAppend('sample.txt', 'this is a sample file\n\ntest for file functions')``
- Read text from file. ``pb.fileRead('sample.txt')``
- Copy file. ``pb.fileCopy( 'sample.txt', 'sample1.txt' )``
- Move file. ``pb.fileMove( 'sample.txt', 'sample2.txt' )``
- Delete file. ``pb.fileDelete('sample1.txt')``, ``pb.fileDelete('sample2.txt')``
- Select file for open ``pb.fileOpenDialog()``, for save ``pb.fileSaveDialog('Save File','c:\\temp\\*.txt','Text File(*.txt),*.txt')``
- file/dir Exists ``pb.fileExists('sample.txt')``, ``pb.dirExists('c:/temp')``
- show current folder ``pb.dir()``, select folder ``pb.dirSelect('Select folder for testing')``
- change directory ``pb.dirChange('tempfolder')``, ``pb.dirChange('..')``, ``pb.dirChange(pb.property('app.path'))``
- create/delete directory ``pb.dirCreate('tempfolder')``, ``pb.dirDelete('tempfolder')``
Application Property and Session Variables
- App Title: ``pb.property('app.title')``, ``pb.property('app.title', 'window title: name of your application.')``,
- App About: ``pb.property('app.about')``, ``pb.property('app.about', 'about: description of your application!')``,
- App Version: ``pb.property('app.version')``, ``pb.property('app.version', '0.32 updated on 2022/11/10')``,
- Watch Options: ``pb.property('app.watch')``, ``pb.property('app.watch', '[debug][api]')``
- App Icon: ``pb.property('app.icon')``, ``pb.property('app.icon', 'menu!')``,
- get Env variable: ``pb.property('env.JAVA_HOME')``, ``pb.property('env.CLASSPATH')``,
- Session variable: ``pb.session('name','casualwriter')``, ``pb.session('name')``
Work with Powerbuilder
- open w_about dialog. ``pb.window('w_about')`` => ``pb.api('window','w_about')``
- login by window account ``pb.window('w_login')`` => ``pb.api('window','w_login')``
- open window with parameters. ``pb.window('w_power_chrome', 'https://news.ycombinator.com/')``
- open dialog with parameters. ``pb.popup('https://news.ycombinator.com/')``
- * retrieve datawindow (reprot) ``pb.datawindow('element-id', 'parameters')``
Console and Message
- console support. ``pb.console('hello world!')`` is same as ``console.log('hello world again!')``
- status message, microhelp. ``pb.status('ready')``, ``pb.error('404','File not found!')``
- alert, message dialog. ``pb.alert('good day!')``, ``pb.msgbox('hello','good day!')``
- message dialog with options. ``pb.msgbox('','Save data?','yes,no')``, ``pb.msgbox('title..','close?','ok,cancel')``
Print, PDF, Misc
- Print, PrintSetup: ``window.print()``, ``pb.print()``, ``pb.printSetup()``
- Save to PDF/HTML: ``pb.saveas('c:/temp/output.pdf')``, ``pb.saveas('c:/temp/output.html')``
- Window Position: ``pb.api('position' ,'max')``, ``pb.api('position', {top:200, left:80, width:1024, height:700})``
- Show/hide console: ``pb.api('console','show')``, ``pb.api('console','hide')``, ``pb.api('console','500px')``, ``pb.api('console')``
- Mini Button ``pb.api('minibutton','clear')``, ``pb.api('minibutton',{script:'about', title:'About', icon:'toolkitabout!'})``
- Close window: ``pb.close()`` => ``pb.api('close')``, Close with return: ``pb.api('close','return result')``
- Sleep (ms): ``pb.sleep(2500)``