Collaborative topic for example/sample PMC files and tutorials
Posted: 30 Oct 2020, 09:29
by Pulover
Som people have requested me to create more example files for PMC, but I don't have much time for that. More video tutorials will be coming soon (done by someone else -- I suck at making videos) but in the meantime I thought some of the users might want to share examples to help each other get familiar with the tool. So I created this topic to point users to when they need them.
Video tutorials
To post your PMC code, open your *.pmc file with any text editor and copy the text, then paste it here inside a Codebox like this (remove the space in the tag Codebox tag):
Here are some examples I had created for the help file. You're welcome to post links to tutorial pages or video tutorials too, as well as suggesting improvements to the files below.
PMC Demonstration File:
Arrays:
Compare Variables:
Control Commands:
Dynamic Variables:
Functions:
Loop Types:
Random Function:
User-Defined Functions:
Variables:
Save PNG screenshots:
Video tutorials
To post your PMC code, open your *.pmc file with any text editor and copy the text, then paste it here inside a Codebox like this (remove the space in the tag Codebox tag):
This way you'll have a download button on top of the code.[ Codebox=pmc file=MyPMCExample.pmc]
[PMC Code v5.3.2]|F4||1|Window,2,Fast,0,1,Input,-1,-1,1|1|Macro1
Context=None||None|
Groups=Start:1
1|[MsgBox]|Hello world!|1|0|MsgBox|0||||1|
[/Codebox]
Here are some examples I had created for the help file. You're welcome to post links to tutorial pages or video tutorials too, as well as suggesting improvements to the files below.
PMC Demonstration File:
Spoiler
Code: Select all
[PMC Code v5.0.1]|F3||1|Window,2,Fast,0,1,Input,-1,-1,1|1|BasicDemo
Groups=New Group:1
1|SendMode|Event|1|0|SendMode|||||
2|SetKeyDelay|10|1|0|SetKeyDelay|||||
3|Run|Notepad, , , Npid|1|0|Run|||||
4|WinWait||1|333|WinWait||ahk_pid %Npid%|||
5|WinMove|400, 400, 800, 600|1|333|WinMove||ahk_pid %Npid%|||
6|[Text]|Hello`,`n`nThis is the demonstration macro for Pulover's Macro Creator.`n`n|1|0|SendRaw|||||
7|Run|Notepad, , , Npid2|1|0|Run|||||
8|WinWait||1|333|WinWait||ahk_pid %Npid2%|||
9|WinActivate||1|333|WinActivate||ahk_pid %Npid%|||
10|WinMove|0, 0, 800, 600|1|333|WinMove||ahk_pid %Npid2%|||
11|[Text]|Here we're using commonly used commands`, such as [Run]`, [WinActivate]`, [Send] and [Click].`n`nThis text was sent directly to the active window using [Send] from the [Text] command window.`n`n|1|0|SendRaw|||||
12|[Pause]||1|2000|Sleep|||||
13|[Text]|While this one was sent directly to the target control of a background window.`nCheck [Control] in the command window and use the [...] button to copy the information`nfrom a window to send commands directly to it.`n`n|1|0|ControlSendRaw|Edit1|ahk_pid %Npid2%|||
14|[Pause]||1|2000|Sleep|||||
15|[Text]|You can also set the text of the entire control...|1|0|ControlSendRaw|Edit1|ahk_pid %Npid2%|||
16|[Pause]||1|2000|Sleep|||||
17|[Text]|...LIKE THIS!!!|1|0|ControlSetText|Edit1|ahk_pid %Npid2%|||
18|[Pause]||1|2000|Sleep|||||
19|[Text]|{Control Down}{End}{Control UP}{Enter 2}Move the mouse cursor and click with any button{!}|1|0|ControlSend|Edit1|ahk_pid %Npid2%|||
20|Left Move & Click|-6, -122 Left, 1|1|10|Click|||||
21|[Pause]||1|2000|Sleep|||||
22|Left Move & Click|693, 293 Left, Down|1|10|Click|||||
23|[Pause]||1|300|Sleep|||||
24|Left Move & Click|12, 62 Left, Up|1|10|Click|||||
25|[Pause]||1|2000|Sleep|||||
26|[Text]|You can use [ControlClick] by checking the [Control] option`nin the [Mouse] command window to click on windows on the background...|1|0|SendRaw|||||
27|[Pause]||1|2000|Sleep|||||
28|Run|charmap|1|0|Run|||||
29|WinWait||1|333|WinWait||ahk_exe charmap.exe|||
30|WinMove|800, 0, , |1|333|WinMove||ahk_exe charmap.exe|||
31|WinActivate||1|333|WinActivate||ahk_pid %Npid2%|||
32|Left Click|Left, 1, x175 y63 NA|1|1000|ControlClick|CharGridWClass1|ahk_exe charmap.exe|||
33|Left Click|Left, 1, x106 y61 NA|1|1000|ControlClick|CharGridWClass1|ahk_exe charmap.exe|||
34|Left Click|Left, 1, x335 y36 NA|1|1000|ControlClick|CharGridWClass1|ahk_exe charmap.exe|||
35|[Pause]||1|2000|Sleep|||||
36|[Text]|`n`n...and the [Control] command window can be used to change`ndifferent things in a control or get informations from it...|1|0|SendRaw|||||
37|[Pause]||1|2000|Sleep|||||
38|[Control]|ChooseString`, Arial|1|0|Control|ComboBox3|ahk_exe charmap.exe|||
39|[Pause]||1|2000|Sleep|||||
40|[Control]|ChooseString`, Verdana|1|0|Control|ComboBox3|ahk_exe charmap.exe|||
41|[Pause]||1|2000|Sleep|||||
42|[Control]|Disable`, |1|0|Control|RICHEDIT50W1|ahk_exe charmap.exe|||
43|[Pause]||1|2000|Sleep|||||
44|[Control]|StaticText|1|0|ControlGetText|Static1|ahk_exe charmap.exe|||
45|[MsgBox]|Text from charmap static control:`n`n%StaticText%|1|0|MsgBox|0||||
46|[MsgBox]|Too fast? Play it again!`n`nYou can choose what commands you want to execute by unchecking the ones you don't want in the macro list.`n`nYou can also select to run only selected rows in [Macro > Playback options] and set a hotkey to play this macro step-by-step.`n`nThis was just a small demonstration`, PMC can do a lot more! Take some time to study the commands in this macro and learn what each one does.`n`nDownload more examples from the Help file in the [Tutorial] section and check out the video tutorials at https://www.macrocreator.com/help.`n`nWould like to see the videos now?`n|1|0|MsgBox|36||||
47|If Message Box|Yes|1|0|If_Statement|36||||
48|Run|https://www.macrocreator.com/help|1|0|Run|||||
49|[End If]|EndIf|1|0|If_Statement|||||
Arrays:
Spoiler
Code: Select all
[PMC Code v5.0.0]|F1||1|Window,2,Fast,0,1|1|Arrays1
Groups=Start:1
1|[Assign Variable]|N := [10, 20, 30]|1|0|Variable|Expression||||
02|Array|N := 10, 20, 30|1|0|Function|||Alternative way to assign arrays||
3|[LoopStart]|LoopStart|% N.Length()|0|Loop|||||
4|[MsgBox]|% N[A_Index]|1|0|MsgBox|262144||||
5|[LoopEnd]|LoopEnd|1|0|Loop|||||
6|[Assign Variable]|N[4] := New value|1|0|Variable|||||
7|[MsgBox]|% "N[4]: " N[4]|1|0|MsgBox|262144||||
8|Sqrt|FuncOut := N.1|1|0|Function|||||
9|[MsgBox]|Sqr Function with Array parameter: %FuncOut%|1|0|MsgBox|262144||||
[PMC Code v5.0.0]|F2||1|Window,2,Fast,0,1|1|Arrays2
Groups=Start:1
1|[Assign Variable]|String := ABCDE|1|0|Variable|||||
2|StrSplit|MyArray := String, ""|1|0|Function|||||
3|[LoopStart]|LoopStart|% MyArray.MaxIndex()|0|Loop|||||
4|[Assign Variable]|ArO := MyArray[A_Index]|1|0|Variable|Expression||||
5|[MsgBox]|Loop: %A_Index%`nMyArray[%A_Index%]: %ArO%|1|0|MsgBox|262144||||
6|[LoopEnd]|LoopEnd|1|0|Loop|||||
[PMC Code v5.0.0]|F3||1|Window,2,Fast,0,1|1|ForLoop
Groups=Start:1
1|[Assign Variable]|MyVar := This is a variable!|1|0|Variable|||||
2|[Assign Variable]|MyArray := ["a","b","c",MyVar,"d","e"]|1|0|Variable|Expression||||
3|[LoopStart]|MyArray`, key`, value|1|0|For|||||
4|[MsgBox]|%key% : %value%|1|0|MsgBox|262144||||
5|[LoopEnd]|LoopEnd|1|0|Loop|||||
[PMC Code v5.0.0]|F4||1|Window,2,Fast,0,1|1|MultiDim
Groups=Start:1
1|[Assign Variable]|N := ["Item 1"]|1|0|Variable|Expression||||
2|[MsgBox]|% N[1]|1|0|MsgBox|262144||||
3|[Assign Variable]|N[2] := []|1|0|Variable|Expression||||
4|[Assign Variable]|N[2][1] := Item 2.1: Multi dimensional array value.|1|0|Variable|||||
5|[MsgBox]|% N[2][1]|1|0|MsgBox|262144||||
6|Asc|N[2][2] := "A"|1|0|Function|||||
7|[Assign Variable]|ItemCopy := N[2][2]|1|0|Variable|Expression||||
8|[MsgBox]|Item 2.2: %ItemCopy%|1|0|MsgBox|262144||||
9|Push|_null := "Item 2.3"|1|0|Method|N.2||||
10|[MsgBox]|% N.2.3|1|0|MsgBox|262144||||
[PMC Code v5.0.0]|F5||1|Window,2,Fast,0,1|1|Methods
Groups=Start:1
1|[Assign Variable]|Values := |1|0|Variable|||||
2|[Assign Variable]|N := []|1|0|Variable|Expression||||
3|Push|_null := "A", "B", "D"|1|0|Method|N||||
4|[LoopStart]|N`, each`, value|1|0|For|||||
5|[Assign Variable]|Values .= %value%`, |1|0|Variable|||||
6|[LoopEnd]|LoopEnd|1|0|Loop|||||
7|[MsgBox]|%Values%|1|0|MsgBox|262144||||
8|InsertAt|_null := 3, "C"|1|0|Method|N||||
9|[Assign Variable]|Values := |1|0|Variable|||||
10|[LoopStart]|N`, each`, value|1|0|For|||||
11|[Assign Variable]|Values .= %value%`, |1|0|Variable|||||
12|[LoopEnd]|LoopEnd|1|0|Loop|||||
13|[MsgBox]|%Values%|1|0|MsgBox|262144||||
[PMC Code v5.0.0]|F6||1|Window,2,Fast,0,1|1|NamedKeys
Groups=Start:1
1|Object|N := |1|0|Function|||||
2|[Assign Variable]|N.keyA := Value of KeyA|1|0|Variable|||||
3|[MsgBox]|% N.keyA|1|0|MsgBox|0||||
4|[Assign Variable]|N["keyB"] := Value of KeyB|1|0|Variable|||||
5|[Assign Variable]|N["keyC"] := Value of keyC|1|0|Variable|||||
6|[Assign Variable]|N["keyC"] .= N["keyA"]|1|0|Variable|Expression||||
7|[LoopStart]|N`, each`, value|1|0|For|||||
8|[MsgBox]|%each%: %value%|1|0|MsgBox|262144||||
9|[LoopEnd]|LoopEnd|1|0|Loop|||||
[PMC Code v5.0.0]|F7||1|Window,2,Fast,0,1|1|AssociativeArray
Groups=Start:1
1|[Assign Variable]|person := {name: "John", surname: "Smith", age: 26, stats: [10,9,8.5,7,9.5,10]}|1|0|Variable|Expression||||
2|[LoopStart]|person`, key`, value|1|0|For|||||
3|[MsgBox]|%key%: %value%|1|0|MsgBox|0||||
4|[LoopStart]|value`, key`, value|1|0|For|||||
5|[MsgBox]|%key%: %value%|1|0|MsgBox|0||||
6|[LoopEnd]|LoopEnd|1|0|Loop|||||
7|[LoopEnd]|LoopEnd|1|0|Loop|||||
Compare Variables:
Spoiler
Code: Select all
[PMC Code v5.0.2]|F3||1|Window,2,Fast,0,1,Input,-1,-1,1|1|CompareVars
Groups=
1|Compare Variables|A_Hour > 11|1|0|If_Statement|||||
2|[MsgBox]|Good Afternoon`, %A_UserName%!|1|0|MsgBox|0||||
3|[Else]|Else|1|0|If_Statement|||||
4|[MsgBox]|Good Morning`, %A_UserName%!|1|0|MsgBox|0||||
5|[End If]|EndIf|1|0|If_Statement|||||
6|Compare Variables|A_WDay = 7|1|0|If_Statement|||||
7|[MsgBox]|Enjoying the Weendend`, huh?`nHave a nice day!|1|0|MsgBox|0||||
8|[ElseIf] Compare Variables|A_WDay between 2`n6|1|0|If_Statement|||||
9|[MsgBox]|Shouldn't you be working today?|1|0|MsgBox|0||||
10|[Else]|Else|1|0|If_Statement|||||
11|[MsgBox]|Enjoy the Sunday! You got work tomorrow`, don't you?|1|0|MsgBox|0||||
12|[End If]|EndIf|1|0|If_Statement|||||
13|If Window Exist|ahk_class Notepad|1|0|If_Statement|||||
14|WinGet|NpID, ID|1|0|WinGet||ahk_class Notepad|||
15|[MsgBox]|Notepad is open and the window ID is %NpID%.|1|0|MsgBox|0||||
16|[Else]|Else|1|0|If_Statement|||||
17|[MsgBox]|Notepad is not open.|1|0|MsgBox|0||||
18|[End If]|EndIf|1|0|If_Statement|||||
Control Commands:
Spoiler
Code: Select all
[PMC Code v5.0.0]|F4||1|Window,2,Fast,0,1|1|ControlCmd
Groups=
1|[MsgBox]|All Control Commands should work with the target window on the background (but not minimized).|1|0|MsgBox|64|Control commands demonstration on NotepadControl commands demonstration on Notepad|||
2|Run|notepad.exe|1|0|Run|||||
3|WinWait||1|333|WinWait||ahk_class Notepad|||
4|[MsgBox]|Setting text on notepad control...|1|0|MsgBox|64|Control commands demonstration on NotepadControl commands demonstration on Notepad|||
5|[Control]|Test Text Sample`n|1|0|ControlSetText|Edit1|ahk_class Notepad|||
6|[MsgBox]|Sending keys to notepad control...|1|0|MsgBox|64|Control commands demonstration on Notepad|||
7|Control + End|{Control Down}{End}{Control Up}|1|20|ControlSend|Edit1|ahk_class Notepad|||
8|F5|{F5}|1|20|ControlSend|Edit1|ahk_class Notepad|||
9|[Text]|^s|1|0|ControlSend|Edit1|ahk_class Notepad|||
10|WinWait||1|333|WinWait||ahk_class #32770|||
11|[MsgBox]|Setting text on dialog window...|1|0|MsgBox|64|Control commands demonstration on Notepad|||
12|[Control]|Test.txt|1|0|ControlSetText|Edit1|ahk_class #32770|||
13|[MsgBox]|Using control to choose 2nd option in dropdown list (Unicode)...|1|0|MsgBox|64|Control commands demonstration on Notepad|||
14|[Control]|Choose`, 2|1|0|Control|ComboBox3|ahk_class #32770|||
15|[MsgBox]|Retrieving text from notepad control...|1|0|MsgBox|64|Control commands demonstration on Notepad|||
16|[Control]|noteVar|1|0|ControlGetText|Edit1|ahk_class Notepad|||
17|[MsgBox]|%noteVar%|1|0|MsgBox|262144|Control commands demonstration on Notepad|||
Dynamic Variables:
Spoiler
Code: Select all
[PMC Code v5.0.0]|F1||1|Window,2,Fast,0,1|1|DynamicVars
Groups=
1|[Assign Variable]|TextVar := One-Two-Three|1|0|Variable|||||
2|StringSplit|OutVar, TextVar, -|1|0|StringSplit|||||
3|[LoopStart]|LoopStart|%OutVar0%|0|Loop|||||
4|[MsgBox]|% OutVar%A_Index%|1|0|MsgBox|0||||
5|[LoopEnd]|LoopEnd|1|0|Loop|||||
6|[MsgBox]|Finished!|1|0|MsgBox|0||||
[PMC Code v5.0.0]|F2||1|Window,2,Fast,0,1|1|Arrays
Groups=
1|[Assign Variable]|N := ["Item 1"]|1|0|Variable|Expression||||
2|[MsgBox]|% N[1]|1|0|MsgBox|262144||||
3|[Assign Variable]|N[2] := []|1|0|Variable|Expression||||
4|[Assign Variable]|N[2][1] := Item 2.1: Multi dimensional array value.|1|0|Variable|||||
5|[MsgBox]|% N[2][1]|1|0|MsgBox|262144||||
6|Asc|N[2][2] := "A"|1|0|Function|||||
7|[Assign Variable]|ItemCopy := N[2][2]|1|0|Variable|Expression||||
8|[MsgBox]|Item 2.2: %ItemCopy%|1|0|MsgBox|262144||||
9|Push|_null := Item 2.3|1|0|Method|N[2]||||
10|[MsgBox]|% N[2][3]|1|0|MsgBox|262144||||
11|SubStr|FuncOut := N[1], 6|1|0|Function|||||
12|[MsgBox]|SubString Function with Array parameter: %FuncOut%|1|0|MsgBox|262144||||
Functions:
Spoiler
Code: Select all
[PMC Code v5.0.0]|F4||1|Window,2,Fast,0,1|1|FuncCall
Groups=Start:1
1|[Assign Variable]|MyVar := one-two-three-four|1|0|Variable|||||
2|StrReplace|result := MyVar, "-", ", "|1|0|Function|||||
3|[MsgBox]|MyVar: %MyVar%`nResult: %result%|1|0|MsgBox|0||||
[PMC Code v5.0.0]|F6||1|Window,2,Fast,0,1|1|Dynamic
Groups=
1|[Assign Variable]|StringVar := One`, Two`, Three`, Go!|1|0|Variable|||||
2|[MsgBox]|% InStr(StringVar`, "Go")|1|0|MsgBox|0||Function using Variable||
3|[MsgBox]|% InStr("Let's Go, Ok?", "Ok")|1|0|MsgBox|0||Function using String and Literal Comma.||
4|[MsgBox]|% RegExReplace("This is a string`, not a variable"`, "not"`, "$u0")|1|0|MsgBox|0|% StrLen("AHK") + 17|||
Loop Types:
Spoiler
Code: Select all
[PMC Code v5.0.0]|F1||1|Window,2,Fast,0,1|1|Loop
Groups=Start:1
1|[CommentBlock]|Example #1|0|1|CommentBlock|||||
2|[LoopStart]|LoopStart|3|0|Loop|||||
3|[MsgBox]|Iteration number is %A_Index%.|1|0|MsgBox|0||||
4|[Pause]||1|100|Sleep|||||
5|[LoopEnd]|LoopEnd|1|0|Loop|||||
6|[CommentBlock]|Example #2|0|1|CommentBlock|||||
7|[LoopStart]|LoopStart|0|0|Loop|||||
8|Compare Variables|A_Index > 25|1|0|If_Statement|||||
9|Break||1|0|Break|||||
10|[End If]|EndIf|1|0|If_Statement|||||
11|Compare Variables|A_Index < 20|1|0|If_Statement|||||
12|Continue||1|0|Continue|||||
13|[End If]|EndIf|1|0|If_Statement|||||
14|[MsgBox]|a_index = %a_index%|1|0|MsgBox|0||||
15|[LoopEnd]|LoopEnd|1|0|Loop|||||
[PMC Code v5.0.0]|F2||1|Window,2,Fast,0,1|1|LoopFiles
Groups=Start:1
1|[LoopStart]|%A_ProgramFiles%\*.txt`, R|1|0|LoopFilePattern|||||
2|[MsgBox]|Filename = %A_LoopFileFullPath%`n`nContinue?|1|0|MsgBox|4||||
3|If Message Box|No|1|0|If_Statement|4||||
4|Break||1|0|Break|||||
5|[End If]|EndIf|1|0|If_Statement|||||
6|[LoopEnd]|LoopEnd|1|0|Loop|||||
[PMC Code v5.0.0]|F3||1|Window,2,Fast,0,1|1|LoopParse
Groups=Start:1
1|[Assign Variable]|Colors := red`,green`,blue|1|0|Variable|||||
2|[LoopStart]|Colors`, ``,`, |1|0|LoopParse|||||
3|[MsgBox]|Color number %A_Index% is %A_LoopField%.|1|0|MsgBox|0||||
4|[LoopEnd]|LoopEnd|1|0|Loop|||||
[PMC Code v5.0.0]|F4||1|Window,2,Fast,0,1|1|LoopRead
Groups=Start:1
1|FileDelete|%A_Temp%\LoopTest.txt|1|10|FileDelete|||||
2|[Assign Variable]|Folders := Line 1`nLine 2`nLine 3`nLine 4|1|0|Variable|||||
3|FileAppend|%Folders%, %A_Temp%\LoopTest.txt|1|10|FileAppend|||||
4|[LoopStart]|%A_Temp%\LoopTest.txt|1|0|LoopRead|||||
5|[MsgBox]|%A_LoopReadLine%|1|0|MsgBox|0||||
6|[LoopEnd]|LoopEnd|1|0|Loop|||||
7|FileDelete|%A_Temp%\LoopTest.txt|1|10|FileDelete|||||
8|[MsgBox]|Finished!|1|0|MsgBox|0||||
[PMC Code v5.0.0]|F5||1|Window,2,Fast,0,1|1|Combined
Groups=
1|FileDelete|%A_Temp%\LoopTest.txt|1|10|FileDelete|||||
2|[Assign Variable]|Folders := %A_Startup%`,%A_MyDocuments%`n%A_Desktop%`,%A_Programs%|1|0|Variable|||||
3|FileAppend|%Folders%, %A_Temp%\LoopTest.txt|1|10|FileAppend|||||
4|[LoopStart]|%A_Temp%\LoopTest.txt|1|0|LoopRead|||||
5|[LoopStart]|A_LoopReadLine`, ``,`, |1|0|LoopParse|||||
6|[Assign Variable]|cFolder := %A_LoopField%|1|0|Variable|||||
7|[LoopStart]|%A_LoopField%\*.*, FD|1|0|LoopFilePattern|||||
8|[MsgBox]|Folder:`n%cFolder%`n`nFile %A_Index%:`n%A_LoopFileName%`n`nContinue this folder?|1|0|MsgBox|3||||
9|If Message Box|No|1|0|If_Statement|||||
10|Break||1|0|Break|||||
11|[End If]|EndIf|1|0|If_Statement|||||
12|If Message Box|Cancel|1|0|If_Statement|||||
13|Break|3|1|0|Break|||||
14|[End If]|EndIf|1|0|If_Statement|||||
15|[LoopEnd]|LoopEnd|1|0|Loop|||||
16|[LoopEnd]|LoopEnd|1|0|Loop|||||
17|[LoopEnd]|LoopEnd|1|0|Loop|||||
18|FileDelete|%A_Temp%\LoopTest.txt|1|10|FileDelete|||||
19|[MsgBox]|Finished!|1|0|MsgBox|0||||
[PMC Code v5.0.0]|F6||1|Window,2,Fast,0,1|1|While
Groups=Start:1
1|[MsgBox]|Press OK then click and press and drag the left mouse button to display a ToolTip with the size of the region inside the drag-area.`n|1|0|MsgBox|0||||
2|CoordMode|Mouse, Screen|1|0|CoordMode|||||
3|KeyWait|LButton, D|1|0|KeyWait|||||
4|MouseGetPos|begin_x, begin_y|1|0|MouseGetPos|||||
5|[LoopStart]|GetKeyState("LButton")|1|0|While|||||
6|MouseGetPos|x, y|1|0|MouseGetPos|||||
7|ToolTip|% begin_x "``, " begin_y "`n" Abs(begin_x-x) " x " Abs(begin_y-y)|1|10|ToolTip|||||
8|[LoopEnd]|LoopEnd|1|0|Loop|||||
9|ToolTip||1|0|ToolTip|||||
[PMC Code v5.0.0]|F7||1|Window,2,Fast,0,1|1|ForLoop
Groups=Start:1
1|[Assign Variable]|str := |1|0|Variable|||||
2|Object|colours := "red", 0xFF0000, "blue", 0x0000FF, "green", 0x00FF00|1|0|Function|||||
3|[LoopStart]|colours`, k`, v|1|0|For|||||
4|[Concatenate Variable]|str .= k "=" v "`n"|1|0|Variable|Expression||||
5|[LoopEnd]|LoopEnd|1|0|Loop|||||
6|[MsgBox]|%str%|1|0|MsgBox|0||||
Random Function:
Spoiler
Code: Select all
[PMC Code v5.0.0]|F3||0|Window,2,Fast,0,1|1|Macro1
Groups=New Group:1
1|[MsgBox]|% RandCity()|1|0|MsgBox|1||||
2|If Message Box|Cancel|1|0|If_Statement|1||||
3|Return||1|0|Return|||||
4|[End If]|EndIf|1|0|If_Statement|||||
[PMC Code v5.0.0]|||1|Window,2,Fast,0,1|1|RandCity()
Groups=Start:1
1|[FunctionStart]|RandCity|1|0|UserFunction|Local| / |||
2|[Assign Variable]|Cities := ["New York", "Sao Paulo", "Tokyo", "Sydney", "Paris", "Berlin", "Beijing", "Madrid", "Buenos Aires", "Mexico City", "Tel Aviv", "Johannesburg"]|1|0|Variable|Expression||||
3|Random|RandV, 1, % Cities.Length()|1|0|Random|||||
4|[FuncReturn]|Cities[RandV]|1|0|FuncReturn|||||
User-Defined Functions:
Spoiler
Code: Select all
[PMC Code v5.0.0]|F1||1|Window,2,Fast,0,1|1|UserFunctionCalls
Groups=Start:1
1|[Assign Variable]|globalvar := Global value|1|0|Variable|||||
2|Sum|res := 100, A_Sec|1|0|Function|||||
3|[MsgBox]|Sum result:`n%res%|1|0|MsgBox|0||||
4|[Assign Variable]|LVar := left|1|0|Variable|||||
5|[Assign Variable]|RVar := right|1|0|Variable|||||
6|[MsgBox]|Before Swap:`nLVar: %LVar%`nRVar: %RVar%|1|0|MsgBox|0||||
7|Swap|_null := LVar, RVar|1|0|Function|||||
8|[MsgBox]|Swap result:`nLVar: %LVar%`nRVar: %RVar%|1|0|MsgBox|0||||
9|GlobalFunc|res := "one, parameter"|1|0|Function|||||
10|[MsgBox]|GlobalFunc result:`n%res%|1|0|MsgBox|0||||
11|[MsgBox]|% "Dynamic Function Call:`n" GlobalFunc("some value")|1|0|MsgBox|0||||
12|CreateArray|myarray := 9, "text param", globalvar, newObj|1|0|Function|||||
13|[LoopStart]|myarray`, key`, value|1|0|For|||||
14|[MsgBox]|myarray from CreateArray():`n%key%: %value%|1|0|MsgBox|0||||
15|[LoopEnd]|LoopEnd|1|0|Loop|||||
16|[LoopStart]|newObj`, key`, value|1|0|For|||||
17|[MsgBox]|newObj from CreateArray (ByRef parameter):`n%key%: %value%|1|0|MsgBox|0||||
18|[LoopEnd]|LoopEnd|1|0|Loop|||||
[PMC Code v5.0.0]|||1|Window,2,Fast,0,1|1|Sum()
Groups=Start:1
1|[FuncParameter]|VarA|1|0|FuncParameter|||||
2|[FuncParameter]|VarB|1|0|FuncParameter|||||
3|[FunctionStart]|Sum|1|0|UserFunction|Local|globalvar /|||
04|[LoopStart]|LoopStart|%VarA%|0|Loop|||||
05|Compare Variables|A_Index > 95|1|0|If_Statement|||||
06|Sum|res := 50, A_Sec|1|0|Function|||||
07|[MsgBox]|Recursive: %res%`nglobalvar: %globalvar%|1|0|MsgBox|0||||
08|[End If]|EndIf|1|0|If_Statement|||||
09|[LoopEnd]|LoopEnd|1|0|Loop|||||
10|[FuncReturn]|VarA + VarB|1|0|FuncReturn|||||
[PMC Code v5.0.0]|||1|Window,2,Fast,0,1|1|Swap()
Groups=Start:1
1|[FuncParameter]|Left|1|0|FuncParameter|ByRef||||
2|[FuncParameter]|Right|1|0|FuncParameter|ByRef||||
3|[FunctionStart]|Swap|1|0|UserFunction|Local| / MyStatic := 1|||
4|[Assign Variable]|MyStatic += 1|1|0|Variable|||||
05|[MsgBox]|MyStatic: %MyStatic%|1|0|MsgBox|0||||
6|[Assign Variable]|temp := %Left%|1|0|Variable|||||
7|[Assign Variable]|Left := %Right%|1|0|Variable|||||
8|[Assign Variable]|Right := %temp%|1|0|Variable|||||
[PMC Code v5.0.0]|||1|Window,2,Fast,0,1|1|GlobalFunc()
Groups=Start:1
1|[FuncParameter]|localparameter := "Parameter value"|1|0|FuncParameter|||||
2|[FunctionStart]|GlobalFunc|1|0|UserFunction|Global|localvar := "Local value" / |||
03|[MsgBox]|localvar: %localvar%`nglobalvar: %globalvar%`nlocalparameter: %localparameter%|1|0|MsgBox|0||||
4|[FuncReturn]|localvar "/" localparameter|1|0|FuncReturn|||||
[PMC Code v5.0.0]|||1|Window,2,Fast,0,1|1|CreateArray()
Groups=Start:1
1|[FuncParameter]|item1|1|0|FuncParameter|||||
2|[FuncParameter]|item2|1|0|FuncParameter|||||
3|[FuncParameter]|item3|1|0|FuncParameter|||||
4|[FuncParameter]|ref := "none"|1|0|FuncParameter|ByRef||||
5|[FunctionStart]|CreateArray|1|0|UserFunction|Local|/||0xFF80C0|
6|[Assign Variable]|ref := ["byrefvalue1", "byrevalue2"]|1|0|Variable|Expression||||
07|[MsgBox]|% ref[1] " x " ref[2]|1|0|MsgBox|0||||
8|[Assign Variable]|newarray := [item1, item2, item3]|1|0|Variable|Expression||||
9|[FuncReturn]|newarray|1|0|FuncReturn|||||
010|[FuncReturn]|[item1, item2, item3]|1|0|FuncReturn|||||
Variables:
Spoiler
Code: Select all
[PMC Code v5.0.0]|F1||1|Window,2,Fast,0,1|1|Variables
Groups=
1|CoordMode|Mouse, Window|1|0|CoordMode|||||
2|WinGetPos|WinPos_|1|20|WinGetPos||A|||
3|[Assign Variable]|X_Pos := WinPos_W / 2|1|0|Variable|Expression||||
4|[Assign Variable]|Y_Pos := WinPos_H / 2|1|0|Variable|Expression||||
5|Move|%X_Pos%, %Y_Pos%, 0|1|10|Click|||||
6|CoordMode|Mouse, Screen|1|0|CoordMode|||||
7|MouseGetPos|MouseX_Pos, MouseY_Pos|1|0|MouseGetPos|||||
8|ToolTip|Mouse is at %X_Pos% x %Y_Pos%, %WinPos_X%, %WinPos_Y%|1|0|ToolTip|||||
9|[MsgBox]|Today is %A_DDDD% and it's %A_Hour%:%A_Min%.`nThe active window is %WinPos_W% x %WinPos_H%.`nThe mouse cursor is at %MouseX_Pos% x %MouseY_Pos% relative to the screen.|1|0|MsgBox|0||||
10|ToolTip||1|0|ToolTip|||||
Save PNG screenshots:
Spoiler
Code: Select all
[PMC Code v5.0.2]|+F1||1|Window,2,Fast,0,1,Input,-1,-1,1|1|EntireScreen
Groups=Start:1
1|PrintScreen|{PrintScreen}|1|333|Send|||||
2|[Gosub]|SaveScreenshot|1|0|Gosub|||||
[PMC Code v5.0.2]|+F2||1|Window,2,Fast,0,1,Input,-1,-1,1|1|CurrentWindow
Groups=Start:1
1|Alt + PrintScreen|{Alt Down}{PrintScreen}{Alt Up}|1|333|Send|||||
2|[Gosub]|SaveScreenshot|1|0|Gosub|||||
[PMC Code v5.0.2]|+F3||1|Window,2,Fast,0,1,Input,-1,-1,1|1|SaveScreenshot
Groups=Start:1
1|Gdip_Startup|pToken := |1|0|Function|||||
2|Gdip_CreateBitmapFromClipboard|pBitmap := |1|0|Function|||||
3|Gdip_SaveBitmapToFile|sBitmap := pBitmap, A_MyDocuments "\" A_Now ".png", 100|1|0|Function|||||
4|Gdip_DisposeImage|dBitmap := pBitmap|1|0|Function|||||
5|Gdip_Shutdown|sToken := pToken|1|0|Function|||||