NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

; This script detect F8 in Global POS and accepts input with specific format
; if correct fill the remark and discount accordingly
; computer required autohotkey installed
; version: 0.1 initial release
; version: 0.1.1 check control ID changes for discount and remark
; version: 0.1.2 for 3.5.0 037

#Persistent
#IfWinActive Global POS

F9::
ScriptName := "coupon-reader"
settingFile := A_ScriptDir "" ScriptName ".ini"
IniRead remarkControl1, %settingFile%, Main, remark1, WindowsForms10.EDIT.app.0.329445b_r9_ad112
IniRead remarkControl2, %settingFile%, Main, remark2, WindowsForms10.EDIT.app.0.329445b_r9_ad111
IniRead discountControl1, %settingFile%, Main, discount1, WindowsForms10.EDIT.app.0.329445b_r9_ad19
IniRead discountControl2, %settingFile%, Main, discount2, WindowsForms10.EDIT.app.0.329445b_r9_ad18

; TrayTip Membership coupon, %remarkControl1%, 3, 17

ControlGet, remark1Visible, Visible, , %remarkControl1%

IfNotEqual, remark1Visible, 1
{
remarkControl := remarkControl2
} else {
remarkControl := remarkControl1
}

IfNotEqual, remark1Visible, 1
{
discountControl := discountControl2
} else {
discountControl := discountControl1
}
TrayTip Membership coupon,%discountControl% - %remarkControl%, 3, 17
return

F8::
ScriptName := "coupon-reader"
settingFile := A_ScriptDir "" ScriptName ".ini"
IniRead remarkControl1, %settingFile%, Main, remark1, WindowsForms10.EDIT.app.0.329445b_r9_ad112
IniRead remarkControl2, %settingFile%, Main, remark2, WindowsForms10.EDIT.app.0.329445b_r9_ad111
IniRead discountControl1, %settingFile%, Main, discount, WindowsForms10.EDIT.app.0.329445b_r9_ad19
IniRead discountControl2, %settingFile%, Main, discount, WindowsForms10.EDIT.app.0.329445b_r9_ad18
IniRead url, %settingFile%, Main, url, https://maxmia-api.herokuapp.com/public/api/v1/redeems/
LogFile := A_ScriptDir "" ScriptName ".log"

ControlGet, remark1Visible, Visible, , %remarkControl1%

IfNotEqual, remark1Visible, 1
{
remarkControl := remarkControl2
} else {
remarkControl := remarkControl1
}
; TrayTip Membership coupon, F9 pressed %remarkControl%, 3, 17

; ControlGet, discount1Visible, Visible, , %discountControl1%

IfNotEqual, remark1Visible, 1
{
discountControl := discountControl2
} else {
discountControl := discountControl1
}
;TrayTip Membership coupon, F9 pressed %discountControl%, 3, 17

InputBox, coupon, Membership System, Read coupon code with scanner

if ErrorLevel {
; TrayTip Membership coupon, Cancel was pressed., 3, 17
return
} else {

code := StrSplit(coupon, ":")
length := code.Length()
value := 0

IfNotEqual, length, 3
{
TrayTip Membership coupon, Coupon code format is incorrect., 3, 18
return
}

value := code[3]
remark := code[1] . ":" . code[2]

; check validity
; NOTE: requires internet connection
url := url . code[2] . "/valid"
FormatTime, TimeString,, yyyy-MM-dd'T'HH:mm:ss
FileAppend, %TimeString% `t, %LogFile%
FileAppend, %url% `n, %LogFile%
valid := UrlDownloadToVar(url)
FormatTime, TimeString,, yyyy-MM-dd'T'HH:mm:ss
FileAppend, %TimeString% `t, %LogFile%
FileAppend, %valid% `n, %LogFile%
if (valid != "true")
{
TrayTip Membership coupon, Redeem code not exists on server. (%valid%), 3, 18
}

MouseGetPos,,,id,NN
; get remark
ControlGetText, existingRemark, %remarkControl%, ahk_id %id%
if existingRemark {
remark = %existingRemark% `n %remark%
}
ControlSetText, %remarkControl%, %remark%, ahk_id %id%

ControlGetText, existingDiscount, %discountControl%, ahk_id %id%

discountAmount := existingDiscount + value

ControlSetText, %discountControl%, %discountAmount%, ahk_id %id%
}
return
#IfWinActive

;; usage
;; msgbox % checknet()
;; msgbox % checknet(x) ? "good connection" : "poor or no connection"
;; msgbox % x
checknet(ByRef verb:="") {
Runwait %comspec% /c ping google.com | clip,,hide
regexmatch(gp := clipboard,"Lost = (d+)",oVar1)
Runwait %comspec% /c ping yahoo.com | clip,,hide
regexmatch(yp := clipboard,"Lost = (d+)",oVar2)
verb := gp "`n" yp
return ovar11 + ovar21 = 0 ? 1:0
}

;; html := UrlDownloadToVar("http://www.google.com")
;; if html
;; MsgBox connected to the internet
UrlDownloadToVar(URL) {
ComObjError(false)
WebRequest := ComObjCreate("WinHttp.WinHttpRequest.5.1")
WebRequest.Open("GET", URL)
WebRequest.SetRequestHeader("Accept", "application/vnd.com.sys-city.loyaltyapp.v1+json")
WebRequest.SetRequestHeader("Content-Type", "application/json")
WebRequest.Send()

Return WebRequest.ResponseText
}
     
 
what is notes.io
 

Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 14 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.