## Develop desktop application using html/javascript! **PowerChrome** is a portable chromium-base web browser to enable fast and easy development of desktop applications using HTML and JavaScript. PowerChrome enables HTML pages to access the window shell, file system, and database, and provides additional application services by `PowerChrome JavaScript Interface` in **sync mode**. **Double-click** to run the sample code in the code-block, for the first impression of the API. ### 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 powerchrome.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/hello!\n/ms=800/Have a nice day!')`` * Run javascript with keystrokes. ``pb.sendkeys('run=notepad.exe/s=1/Hello/s=2/js=alert("hello world")')`` ### HTML Dialog * popup html dialog ``pb.popup('https://news.ycombinator.com/')`` * popup html, set width/height. ``pb.popup('https://html5test.com/', {width:1024, height:700} )`` * popup html, set x, y, width ``pb.popup('https://news.ycombinator.com/', {left:200, top:300, width:600, height:500})`` * 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 page by html 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')`` * send 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 * Write text to file. ``pb.fileWrite('sample.txt', 'Hello World!\n')`` * Append text to file. ``pb.fileAppend('sample.txt', '\nHello world again!\n')`` * 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('sample.txt')``, ``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 windows 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 (reproting) `pb.datawindow( 'element-id', 'parameters', 'not-ready-yet' )` ### 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)`` ### Work with Frameworks Essentially, PowerChrome is an enhanced chromium web browser (equivalent to Chrome 72). Feel free to use any javascript/css frameworks in your application! * Angular (v1.6.9) ``pb.popup( 'sample-angular.html' )``, source ``pb.run('notepad.exe sample-angular.html')`` * Boostrape (v5.2.3) ``pb.popup( 'sample-bootstrap.html' )``, source ``pb.run('notepad.exe sample-bootstrap.html')`` * React.js (v18.2) ``pb.popup( 'sample-react.html' )``, source ``pb.run('notepad.exe sample-react.html')`` * Vue3.js (v3) ``pb.popup( 'sample-vue3.html' )``, source ``pb.run('notepad.exe sample-vue3.html')``