Key Wizard Q Language Basics

Source: Internet
Author: User
Tags integer division transparent color droplist

First, the data type
1.1 Data types
A type that can represent everything variant
Logical Type: Boolean (True,false)
Math Type:
Integer: Byte (0-255), Integer ( -32768-32767), long (-2.1 billion-2.1 billion)
Decimal: Single,double,currency (currency type, contains 4 decimal places, -922337203685477.5808-922337203685477.5807)
Text Type: string
Date Type: Date (time)
Other types: null (empty) empty (revoked or uninitialized) object (any object)

1.2 Type conversions
"123" + "456" = "123456"
"123" +456=579
True→-1 flase→0
Command: (CAST)
Cbool,cbyte,cint,clong,csng,cdbl,ccur,cdate,cstr
Mathematical type to Boolean type, not 0 true

1.3 Representation of the data
Logic type: True,flase
Math Type:
Integers: 123456
Decimals: 3.1415926
Octal: &o12345
Hex: &h1a2b3 (&h prefix)
Number of E: 3.14E10
Text type: ""
Time Type:
Compact data, 2014/6/5 22:25:00 traceprint now ()
Format # #之间填入 Example: #1/1/2000 02:25:00#
Special case: Traceprint CDate (1/1/2000-02:25:00)
Command: Hex turn hex Oct to octal

Second, language norms
Naming rules:
Identifiers must be unique
Identifiers are only allowed to start with letters or Chinese characters
Identifiers consist of letters, Chinese characters, numbers, underscores
Case insensitive to identifiers with letters
Identifiers are allowed to be up to 255 characters in length and no more than 59 words in Chinese
The identifier cannot be the same as the keyword
Syntax and morphology:
Note://back, ' behind,//* Middle * *
Definition: Dim definition Variable, Dim aa (10) definition array, const definition constant
Expression: result = expression, +-*/
Command: Call command name (parameter), command name parameter, result = command name (parameter)

Operator:
Mathematical operations: +-*/\ (integer division) ^ MoD (remainder)
Text operations: + & (Text collage)
Logical Operations:=<> > < >= <= and with OR or XOR Eqv equivalent imp implication
Unary operation:-Negative not non
Array: Dim A (5)//Unlike other languages, there are 6
A=array (0,1,2,3,5,8)
Ubonund (a) +1 get array subscript
Dynamic array: Dim A ()
ReDim A (2)//Before data is clear
ReDim Preserve A (5)//reserved before data

Third, the statement
3.1 A structured statement that can generate an associated statement is made into a structured statement.
Sequential structure jump structure selection structure cycle structure

Rem tag command, can be commented, can also be a goto jump mark
3.2If statements
If 1+1=2 Then
Traceprint "Expression Set"
Else
Traceprint "not established"
End If
Single-line: If 1+1=2 then traceprint "Expression set"
3.3Select statement executes only one case block
Select CASE Expression
Case value
Statement block
......
Case Else

End Select
3.4For statements
For number
Statement block
Next

For i=2 to 4 Step 1 does not write step default is 1
Statement block
Next
3.5Do statements
Do
Statement block
Loop

Do and conditional expressions
Statement block
Loop

Do Util conditions
Statement block
Loop

Do
Statement block
Loop while condition

Do
Statement block
Loop Util Conditions

3.6 Ways to do the commands
Identifier
Identifier parameter 1, parameter 2,......
Call identifier (parameter 1, parameter 2,......)
Call identifier ()
identifier = identifier (parameter 1, parameter 2,......)
Traceprint identifier (parameter 1, parameter 2,......)

3.7 Sub-procedures
Sub identifiers (parameters, parameters ...)
code block
End Sub

3.8 a function//function can have a return value, and a sub-procedure may not
Function identifiers (parameters, parameters ...)
code block
End Function

Four, the front desk
4.1 Foreground mouse Commands
MoveTo 100,200//Move the mouse to (100,200) on this point
MoveR 200,300//After the mouse is moved to the (100+200,100+300) place, which is the coordinates (300,400)
Leftclick 5//Click the left mouse button 5 times at the current mouse position
Leftdown 1//Press the left mouse button at the current mouse position
Leftup 1//Play the left mouse button at the current mouse position
Leftdoubleclick 5//Click the left mouse button 5 times at the current mouse position
RightClick 5
Rightdown 1
Rightup 1
Rightdoubleclick 5
Middleclick 5//Click the middle mouse button 5 times in the position of the current mouse
MouseWheel 1//Scroll the mouse wheel up 1
Lockmouse//Lock mouse position
Unlockmouse//unlock mouse position
Waitclick//Press any mouse button to continue left 32769 (press) Right 32773 (press) Wheel 32777 (press)
Getlastclick//Detect last pressed mouse button left 32770 (bounce) Right 32774 (bounce) Roller 32778 (Bounce)
GetCursorPos mx,my//Put the x and Y coordinates of the current mouse position in the variables MX and my
Getcursorshape//Get the shape characteristics of the current mouse
Setsimmode//Set analog mode (0 normal-to-hardware-super)
4.1 Foreground keyboard commands
KeyPress 65,1//65 is a key key code, the above statement means press a key 1 times
KeyDown 65,1//keyboard hold down a key 1 times
KeyUp 65,1//release a key 1 times
Key=waitkey ()
Key=getlastkey ()//Detect last Keystroke
4.2 Front desk looking for diagram command
Findpic//Find a picture of the specified similarity in the screen area
Findpic x-coordinate, upper-left corner y-coordinate, lower-right x, lower-right corner y,bmp format picture path, similarity, return x, return y
If Intx>=0 Then
Code
End If
Path: 24-bit bitmap
Absolute path C:\Windows\notepad.exe
Relative path. \ current Path: \ upper Level
Annex Attachment:\
Resolution Plugin.Sys.GetScRX Plugin.Sys.GetScRY

Transparent color to find a picture
Figure out how to find more pictures
Function to find multiple graphs (picture path)
Picture =split (Picture path, "|")
For i=0 to UBound (image)
Findpic 0,0,plugin.sys.getscrx-1,plugin.sys.getscry-1, "attachment:\" & Picture Path, 1,intx,inty
If Intx>=0 Then
Find more images = i+1
Exit for
End If
Next
End Function
4.3 Foreground color command
Cr1=getpixelcolor (x, y) to get the specified point color
Findcolor 0,0,800,600, "0000FF", x, y find color
Findcentercolor//Find the specified color in the screen area starting from the center
Findcolorex 0,0,800,600, "0000FF", find way, 0.8,x,y//blur in the screen area to find the specified color,//Find the way. 0 for from the top down, from left to right, 1 for from the center to the periphery to find
4.4 Other Commands
Delay how many milliseconds
MsgBox Popup dialog box
InputBox pop-up window, return input
Traceprint Debug output
saystring input Text
Putattachment to expand the attachments contained in the current script to the specified path
RunApp "notepad.exe" Start a program or open a file
Exitscript script quits running
Restartscript Restart script Run
4.5 Windows
Window Handle =plugin.window.find ("Notepad", 0)//Find window class name ("Notepad") or caption (0), return the found handle HWND
Window Handle =plugin.window.search ("notepad")//traversal of the handle to the window caption ("notepad") is saved to the array (Hwndex)
Window handle =plugin.window.foreground ()//Get the current front window handle
Window handle =plugin.window.mousepoint ()//The following sentence is the window handle that gets the mouse pointer
Call Plugin.Window.Active (Window handle)//activation window
Call Plugin.Window.Max (Window handle)//maximized
Call Plugin.Window.Min (Window handle)//minimized
Call Plugin.Window.Restore (Window handle)//Restore window
Call Plugin.Window.Close (Window handle)//close window
Call Plugin.Window.Show (Window handle)//display window
Call Plugin.Window.Hide (Window handle)//Hide window
Call Plugin.Window.Top (window handle, 0)//top or Cancel, 0 = (pre), 1 = (pre-reset)
Call Plugin.Window.Move (window handle, horizontal axis, ordinate)//Move window
Call Plugin.Window.Size (window handle, width, height)//Change window size
Window caption =plugin.window.gettext (window handle)//Get title
Call Plugin.Window.SetText (Window handle, "new title")//Set Caption
Window class name =plugin.window.getclass (Window handle)//Get class name
File path =plugin.window.getexepath (window handle)//Get program file path
Window Rectangle =plugin.window.getwindowrect (Window handle)//Gets the rectangle of the screen where the window is located
Client area Rectangle =plugin.window.getclientrect (Window handle)//Gets the rectangle of the screen where the client area of the window is located
Call Plugin.Window.SetClentSize (window handle, width, height)//Change window client area size
Call Plugin.Window.SendString (window handle, input text)//Enter a string for the specified window

Five, backstage
Front-Office operation, is the direct simulation of the device to the operating system to send the action, reported to the window by the operating system, a clear feature of this way is that he and we usually operate the keyboard and mouse almost exactly the same, will have an impact on the entire system, and stability is poor, Because we're not sure if the system will disappear into the window we want to post to.
Background operation is to simulate the system directly to the target window to send messages, stable, efficient, does not affect the foreground operation.
Keyboard simulation
Call Plugin.Bkgnd.KeyPress (Hwnd, 65)
Call Plugin.Bkgnd.KeyDown (Hwnd, 65)
Call Plugin.Bkgnd.KeyUp (Hwnd, 65)
Mouse Simulation
Call Plugin.Bkgnd.LeftClick (hwnd,10, 10)//coordinates
Call Plugin.Bkgnd.RightClick (hwnd,10, 10)
Call Plugin.Bkgnd.MiddleClick (hwnd,10, 10)
Call Plugin.Bkgnd.LeftDoubleClick (hwnd,10, 10)
Call Plugin.Bkgnd.LeftDown (Hwnd, 10, 10)
Call Plugin.Bkgnd.LeftUp (hwnd,10, 10)
Call Plugin.Bkgnd.RightDown (Hwnd, 10, 10)
Call Plugin.Bkgnd.RightUp (Hwnd, 10, 10)
Call Plugin.Bkgnd.MoveTo (Hwnd, 10, 10)
Look for a picture to find color
XY = Plugin.Bkgnd.FindColor (Hwnd, 0, 0, 1024x768, 768, "0000FF")
GetColor = Plugin.Bkgnd.GetPixelColor (Hwnd, 0, 0)//Get specified point color
XY = Plugin.Bkgnd.FindColorEx (Hwnd, 0, 0, 1024x768, 768, "0000FF", 0, 0.9)//Blur color finding
XY = Plugin.Bkgnd.FindCenterColor (Hwnd, 0, 0, 1024x768, 768, "0000FF")//Center Find color
XY = Plugin.Bkgnd.FindPic (Hwnd, 0, 0, 1024x768, 768, "C:\PIC.bmp", find direction, 0.9)//Find direction: 0: From left to right, from top to bottom 1: From left to right, bottom to top 2: Right to left, top to bottom 3: from Right to left, bottom to top
XY = Plugin.Bkgnd.FindMultiPic (Hwnd, 0, 0, 1024x768, 768, "c:\pic1.bmp| D:\pic2.bmp ", 0, 0.9)//area Find more images
Icoord = Plugin.Bkgnd.FindWordShape (hwnd,0,0,1024,768, "My Computer", "Arial", font size, find direction, 1.0)//area Find word
Icoord = Plugin.Bkgnd.FindColorBlock (hwnd,0,0,1024,768, "0000FF", color block width, color block height, find direction, 1.0)//area seek color block

Vi. Documents
Call Plugin.File.WriteINI ("Bar name", "Key Name", "Key value", "C:\Config.ini")
Key value = Plugin.File.ReadINI ("Bar name", "Key Name", "C:\Config.ini")
Text = Plugin.File.ReadFileEx ("C:\Config.txt")//read out textual content
Call Plugin.File.WriteFileEx ("C:\Config.txt", "content")
Call Plugin.File.CopyFile ("C:\Config.ini", "D:\Config.ini")
Call Plugin.File.DeleteFile ("C:\Config.ini")
Call Plugin.File.MoveFile ("D:\Config.ini", "C:\Config.ini")
Call Plugin.File.ReNameFile ("C:\Config.ini", "C:\Config.txt")
Isfile = Plugin.File.IsFileExist ("C:\Config.ini")
Call Plugin.File.CreateFolder ("C:\Plugin")
Call Plugin.File.DeleteFolder ("C:\Plugin")

Vii. interaction
User-defined variable sprites are displayed and can be modified
Uservar var1=30 "When hp< how much, use red medicine"//format: Uservar {variable}={default} {comment}
Uservar var2= "Content" "text"
Uservar va3=droplist{"first title": "First value" | " Second Item title ":" Second Item value "}= default option" Comment "
Uservar va4=droplist{"first title": 111| " Second heading ": 222}=1" comment

Key Wizard Q Language Basics

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.