Leaderboard
Popular Content
Showing content with the highest reputation on 10/25/2019 in all areas
-
Help with parsing JSON
FrancescoDiMuro and one other reacted to TheXman for a topic
You were close. The json_dump() function is always helpful in trying to figure out the correct notation for accessing values. As it is named, it dumps all of the values with their corresponding, dot notation, accessors. Below, I slightly modified your code to show you how to use the json_dump() function and how to access your values using both bracket and dot notation. I hope that helps. #include "Json.au3" $response = '{"raw":{},"class":[{"name":"infer","value":"88.1"}],"ref":"ver1","ex":null,"pr":null,"n":null,"re":null,"res":null}' $oJSON = Json_Decode($response) ; Dump the json values Json_Dump($response) ; Bracket notation ConsoleWrite("name = " & json_Get($oJSON, '["class"][0]["name"]') & @CRLF) ConsoleWrite("value = " & json_Get($oJSON, '["class"][0]["value"]') & @CRLF) ; Dot notation ConsoleWrite("name = " & json_Get($oJSON, '.class[0].name') & @CRLF) ConsoleWrite("value = " & json_Get($oJSON, '.class[0].value') & @CRLF) Output: +-> .class[0].name =infer +-> .class[0].value =88.1 +-> .ref =ver1 +-> .ex =Null +-> .pr =Null +-> .n =Null +-> .re =Null +-> .res =Null name = infer value = 88.1 name = infer value = 88.12 points -
hello. In your tab even redraw the listviews like this: Switch GUICtrlRead($idTab) Case 0 _Tab_Check($idTab) _WinAPI_RedrawWindow(GUICtrlGetHandle($ListView1)) Case 1 _Tab_Check($idTab) _WinAPI_RedrawWindow(GUICtrlGetHandle($ListView2)) EndSwitch Saludos2 points
-
And done: https://www.autoitscript.com/trac/autoit/ticket/3737#comment:1 M232 points
-
Update system time based on NTP server time
pixelsearch and one other reacted to Nine for a topic
Here a modern way to get date/time from all over the world : #include <Constants.au3> Local $String = BinaryToString(InetRead ("http://worldtimeapi.org/api/timezone/America/Toronto.txt",1)) MsgBox (0,"",$String) ;Local $String = BinaryToString(InetRead ( "http://worldtimeapi.org/api/timezone/Europe/Amsterdam",1)) Local $Time = StringRegExp ($String,'datetime: (.+?)T(\d+:\d+:\d+)', $STR_REGEXPARRAYMATCH) MsgBox ($MB_SYSTEMMODAL,"",$Time[0] & " " & $Time[1])2 points -
Tab, Listview and Color
pixelsearch reacted to jugador for a topic
Example taken from this thread listview-item-subitem-background-colour Not able to get focus of current Listview when changing Tab. Color getting mixed up. so, how I do it without using Virtual Listview. #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <WindowsConstants.au3> #include <MsgBoxConstants.au3> #include <TabConstants.au3> #include <GuiTab.au3> $iRows = 3 $iCols = 3 Global $hListView Global $ListView1,$ListView2 Global $aColors[$iRows][$iCols] _Example_1() ; #FUNCTION# =================== ; _Example_1() ; ============================== Func _Example_1() Local $iGui_Width = 350 Local $iGui_Height = 250 Local $Form1 = GUICreate("Form1", $iGui_Width, $iGui_Height, -1, -1) Local $idTab = GUICtrlCreateTab(2, 2, $iGui_Width - 5, $iGui_Height - 78) ;;Tab1 GUICtrlCreateTabItem("Tab1") $ListView1 = GUICtrlCreateListView("Header|Header|Header", 3, 22, $iGui_Width - 10, $iGui_Height - 100) GuiCtrlCreateListViewItem('White|White|White',$ListView1) GuiCtrlCreateListViewItem('Green|Pink|Green',$ListView1) GuiCtrlCreateListViewItem('White|White|White',$ListView1) Local $btn = GuiCtrlCreateButton('button', 20, 210, 50, 25) ;;Tab2 GUICtrlCreateTabItem("Tab2") $ListView2 = GUICtrlCreateListView("Number|Number|Number", 3, 22, $iGui_Width - 10, $iGui_Height - 100) GuiCtrlCreateListViewItem('1|1|1',$ListView2) GuiCtrlCreateListViewItem('2|2|2',$ListView2) GuiCtrlCreateListViewItem('3|3|3',$ListView2) GUICtrlCreateTabItem("") ; end tabitem definition _Tab_Check($idTab) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $idTab Switch GUICtrlRead($idTab) Case 0 _Tab_Check($idTab) Case 1 _Tab_Check($idTab) EndSwitch Case $btn ;;MsgBox("", "", " Button is clicked") EndSwitch WEnd EndFunc ; #FUNCTION# =================== ; _Tab_Check ; ============================== ;;this not working color getting mixed up Func _Tab_Check($mdTab) If GUICtrlRead($mdTab) = 0 Then $aColors[1][1] = 0xffaaff $hListView = GUICtrlGetHandle ( $ListView1 ) Else $aColors[1][2] = 0x00aa00 $hListView = GUICtrlGetHandle ( $ListView2 ) EndIf EndFunc ; #FUNCTION# =================== ; WM_NOTIFY ; ============================== Func WM_NOTIFY($hWnd, $Msg, $wParam, $lParam) Local $tNMHDR, $hWndFrom, $iCode $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $hWndFrom = DllStructGetData($tNMHDR, "hWndFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hListView Switch $iCode Case $NM_CUSTOMDRAW Local $tCustDraw = DllStructCreate($tagNMLVCUSTOMDRAW, $lParam) Local $iDrawStage = DllStructGetData($tCustDraw, "dwDrawStage") If $iDrawStage = $CDDS_PREPAINT Then Return $CDRF_NOTIFYITEMDRAW If $iDrawStage = $CDDS_ITEMPREPAINT Then Return $CDRF_NOTIFYSUBITEMDRAW Local $iSubItem = DllStructGetData($tCustDraw, "iSubItem") Local $iItem = DllStructGetData($tCustDraw, "dwItemSpec") If $aColors[$iItem][$iSubItem] <> "" Then DllStructSetData($tCustDraw, "clrTextBk", $aColors[$iItem][$iSubItem]) Else DllStructSetData($tCustDraw, "clrTextBk", 0xFFFFFF) ;white EndIf Return $CDRF_NEWFONT EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY1 point -
I was just "playing" as moving it where it belongs (chat) doesn't help the OP as he won't be able to see it yet. Jos1 point
-
Tab, Listview and Color
jugador reacted to pixelsearch for a topic
Thank you jugador but you know, I have few knowledge in AutoIt compared to many others posters. Just like you, I try actually to improve my knowledge concerning ListView and study, one by one, the different useful events that can be used with WM_NOTIFY, like the whole gang found in the help file example, topic _GUICtrlListView_Create() Ideally, I would like to be able to easily edit any subitem (there are several posts concerning this), or move through subitems using the 4 directions keys, change any subitem color easily (maybe with a right click and context menu), think about what Enter should do (probably start editing the subitem), what should double click do on any subitem etc... The question is why script all this and not use an Excel sheet which actually is designed to do the same ? I guess it's more a challenge than a real need in fact, plus it may help me (or you) to learn more about AutoIt. Anyway, a few minutes ago, I found a good script written by Melba23 (again) showing how to Select subitems (like when you select a single cell in Excel) and it works nicely. This could be a good start to learn that $LVN_ITEMCHANGED he scripted in WM_NOTIFY, also $NM_CUSTOMDRAW is used in his script. In case you test it, it requires the file "edit-zoom_step_av_value.csv" found just before Melba's 23 script. But I don't know why he used : $aInfo = _GUICtrlListView_SubItemHitTest($hListview, $aInfo[0] - 24, $aInfo[1] - 100) ; Upper left position of ListView within GUI - so must match actual position When I tried it in a simpler way (after quickly reading the help file concerning this function), what follows seems to do same, but I have to check more because I'm certainly mistaken : $aInfo = _GUICtrlListView_SubItemHitTest($hListview, -1, -1) Also, during his $NM_CUSTOMDRAW, for all other "cells" (except the selected one), changing his backcolor from White to $CLR_DEFAULT (like shown in my precedent post) gives good results on my computer because my windows background are grey. But all this requires a lot of time... I see you're a member for 10 months now (it's 1 year and a half for me) and it's a strange feeling when you look at some members posts, dated 12-13 years of more, then you look into their profiles and you see they were members here during several years, then they disappeared in 2013 or 2014... and other new members arrive... just like what happens in real life (unfortunately). I wish they were all here again !1 point -
Creating a "brushed up" Task Scheduler UDF?
seadoggie01 reacted to water for a topic
Here is the updated _TS_TaskPropertiesGet. When you pass the Task Definition object as returned by _TS_TaskCreate you will get all properties of the unregistered task. ; #FUNCTION# ==================================================================================================================== ; Name...........: _TS_TaskPropertiesGet ; Description ...: List all properties of a Task or Task Definition and return an array or write the properties to the console. ; Syntax.........: _TS_TaskPropertiesGet($oService, $vTask[, $iFormat = 1[, $bIgnoreNoValues = False]]) ; Parameters ....: $oService - Task Scheduler Service object as returned by _TS_Open ; $vTask - The path and name of the Task to process or a Task Definition object ; $iFormat - Format of the output. Can be one of the following values ; |1 - User friendly format (default) ; |2 - Format you can use as input to _TS_TaskPropertiesSet (just the content of the array) ; |3 - Format you can use as input to _TS_TaskPropertiesSet (full AutoIt syntax to define the array - without XML and written to the console) ; $bIgnoreNoValues - if set to True properties without a value do not get returned ; Return values .: Success - For $iFormat=1 or 2: Zero based two-dimensional array with the following information ; | 0 - Section related to a COM object ; | 1 - Property name ; | 2 - Property value ; | 3 - Comment ; Success - For $iFormat=3: Writes the AutoIt array definition to the console ; Failure - Returns "" and sets @error ; |1 - Error returned by _TS_TaskGet. @extended is set to the COM error code. Most probably the Task could not be found ; Author ........: water ; Modified.......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: Yes ; =============================================================================================================================== Func _TS_TaskPropertiesGet($oTaskService, $vTask, $iFormat = Default, $bIgnoreNoValues = Default) Local $oTask, $sTaskState, $sObjectType Local $oTaskDefinition, $cActions, $oTaskAction Local $oPrincipal, $oRegistrationInfo, $oTaskSettings, $oIdleSettings, $oTaskNetworkSettings Local $cTaskTriggers, $oTaskTrigger, $oTaskRepitition, $cAttachments, $cHeaderfields Local $iIndex = 0, $sSection If $iFormat = Default Then $iFormat = 1 If $bIgnoreNoValues = Default Then $bIgnoreNoValues = False If $iFormat = 1 Then Local $aProperties[1000][4] Else Local $aProperties[1000] EndIf If IsObj($vTask) Then ; Task Definition object $oTask = $vTask ; Dummy. Just to make sure $oTask is set. Else the function would crash for a Task Definition $oTaskDefinition = $vTask $sObjectType = "Task Definition" Else $oTask = _TS_TaskGet($oTaskService, $vTask) If @error Then Return SetError(1, @error, "") $sObjectType = "Task" EndIf With $oTask If $sObjectType = "Task" Then $sSection = "TASK" __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "Name", .Name) __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "Enabled", .Enabled) __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "LastRunTime", .LastRunTime) __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "LastTaskResult", .LastTaskResult) __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "NextRunTime", .NextRunTime) __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "NumberOfMissedRuns", .NumberOfMissedRuns) __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "Path", .Path) Switch (.State) Case $TASK_STATE_UNKNOWN $sTaskState = "Unknown" Case $TASK_STATE_DISABLED $sTaskState = "Disabled" Case $TASK_STATE_QUEUED $sTaskState = "Queued" Case $TASK_STATE_QUEUED $sTaskState = "Ready" Case $TASK_STATE_RUNNING $sTaskState = "Running" EndSwitch __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "State", .State, $sTaskState) If $iFormat <> 3 Then __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "XML", .XML) $oTaskDefinition = .Definition EndIf $sSection = "DEFINITION" With $oTaskDefinition __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "Data", .Data) $cActions = $oTaskDefinition.Actions For $oTaskAction In $cActions With $oTaskAction $sSection = "ACTIONS" __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "ID", .Id) Switch (.Type) Case $TASK_ACTION_EXEC __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "Type", .Type, "Execute / Command Line Operation") __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "Arguments ", .Arguments) __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "Path", .Path) __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "WorkingDirectory", .WorkingDirectory) Case $TASK_ACTION_COM_HANDLER __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "Type", .Type, "Handler") __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "ClassId", .ClassId) __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "Data", .Data) Case $TASK_ACTION_SEND_EMAIL __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "Type", .Type, "Email Message") __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "From", .From) __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "ReplyTo", .ReplyTo) __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "To", .To) __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "Cc", .Cc) __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "Bcc", .Bcc) __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "Subject", .Subject) __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "Body", .Body) __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "Server", .Server) ; ==> CHECK $cAttachments = .Attachments $sSection = "ATTACHMENTS" For $sAttachment In $cAttachments __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "Attachment", $sAttachment) Next $cHeaderfields = .HeaderFields $sSection = "HEADERFIELDS" For $oHeaderPair In $cHeaderfields __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "HeaderName|Value", $oHeaderPair.Name & "|" & $oHeaderPair.Value) Next Case $TASK_ACTION_SHOW_MESSAGE __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "Type", .Type, "Message Box") __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "Title", .Title) __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "MessageBody", .MessageBody) EndSwitch EndWith ; oTaskAction Next ; objTaskAction $oPrincipal = .Principal $sSection = "PRINCIPAL" With $oPrincipal __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "ID", .Id) __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "DisplayName", .DisplayName) __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "GroupId", .GroupId) Switch (.LogonType) Case $TASK_LOGON_NONE __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "LogonType", .LogonType, "None") Case $TASK_LOGON_PASSWORD __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "LogonType", .LogonType, "Password") Case $TASK_LOGON_S4U __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "LogonType", .LogonType, "Service 4 Users") Case $TASK_LOGON_INTERACTIVE_TOKEN __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "LogonType", .LogonType, "Interactive (User must be logged in)") Case $TASK_LOGON_GROUP __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "LogonType", .LogonType, "Group") Case $TASK_LOGON_SERVICE_ACCOUNT __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "LogonType", .LogonType, "Local $Service/System or Network Service") Case $TASK_LOGON_INTERACTIVE_TOKEN_OR_PASSWORD __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "LogonType", .LogonType, "Interactive Token then Try Password") EndSwitch Switch (.RunLevel) Case $TASK_RUNLEVEL_LUA __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "RunLevel", .RunLevel, "Least Privileges (LUA)") Case $TASK_RUNLEVEL_HIGHEST __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "RunLevel", .RunLevel, "Highest Privileges") EndSwitch __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "UserId", .UserId) EndWith ; oPrincipal $oRegistrationInfo = .RegistrationInfo $sSection = "REGISTRATIONINFO" With $oRegistrationInfo __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "Author", .Author) __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "Date", .Date) __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "Description", .Description) __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "Date", .Date) __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "Documentation", .Documentation) __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "SecurityDescriptor", .SecurityDescriptor) __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "Source", .Source) __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "URI", .URI) __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "Version", .Version) EndWith ; oRegistrationInfo $oTaskSettings = .Settings $sSection = "SETTINGS" With $oTaskSettings __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "AllowDemandStart", .AllowDemandStart) __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "AllowHardTerminate", .AllowHardTerminate) Switch (.Compatibility) Case $TASK_COMPATIBILITY_AT __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "Compatibility", .Compatibility, "compatible with the AT command") Case $TASK_COMPATIBILITY_V1 __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "Compatibility", .Compatibility, "compatible with Task Scheduler 1.0") Case $TASK_COMPATIBILITY_V2 __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "Compatibility", .Compatibility, "compatible with Task Scheduler 2.0 (Windows Vista / Windows 2008)") Case 3 ; Not Documented __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "Compatibility", .Compatibility, "compatible with Task Scheduler 2.0 (Windows 7 / Windows 2008 R2)") EndSwitch __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "DeleteExpiredTaskAfter", .DeleteExpiredTaskAfter) __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "DisallowStartIfOnBatteries", .DisallowStartIfOnBatteries) __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "Enabled", .Enabled) __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "ExecutionTimeLimit", .ExecutionTimeLimit) __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "Hidden", .Hidden) Switch (.MultipleInstances) Case $TASK_INSTANCES_PARALLEL __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "MultipleInstances", .MultipleInstances, "Run in parallel") Case $TASK_INSTANCES_QUEUE __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "MultipleInstances", .MultipleInstances, "Add to queue") Case $TASK_INSTANCES_IGNORE_NEW __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "MultipleInstances", .MultipleInstances, "Ignore new") Case $TASK_INSTANCES_STOP_EXISTING __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "MultipleInstances", .MultipleInstances, "Stop existing task") EndSwitch __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "Priority", .Priority, "(0=High / 10=Low)") __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "RestartCount", .RestartCount) __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "RestartInterval", .RestartInterval) __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "RunOnlyIfIdle", .RunOnlyIfIdle) __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "RunOnlyIfNetworkAvailable", .RunOnlyIfNetworkAvailable) __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "StartWhenAvailable", .StartWhenAvailable) __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "StopIfGoingOnBatteries", .StopIfGoingOnBatteries) __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "WakeToRun", .WakeToRun) $oIdleSettings = .IdleSettings $sSection = "IDLESETTINGS" With $oIdleSettings __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "IdleDuration", .IdleDuration) __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "RestartOnIdle", .RestartOnIdle) __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "StopOnIdleEnd", .StopOnIdleEnd) __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "WaitTimeout", .WaitTimeout) EndWith ; oIdleSettings $oTaskNetworkSettings = .NetworkSettings $sSection = "NETWORKSETTINGS" With $oTaskNetworkSettings __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "ID", .Id) __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "Name", .Name) EndWith ; oTaskNetworkSettings EndWith ; oTaskSettings $cTaskTriggers = .Triggers $sSection = "TRIGGERS" For $oTaskTrigger In $cTaskTriggers With $oTaskTrigger __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "Enabled", .Enabled) __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "Id", .Id) __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "StartBoundary", .StartBoundary) __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "EndBoundary", .EndBoundary) __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "ExecutionTimeLimit", .ExecutionTimeLimit) Switch (.Type) Case $TASK_TRIGGER_EVENT __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "Type", .Type, " Event") __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "Delay", .Delay) __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "Subscription ", .Subscription) Case $TASK_TRIGGER_TIME __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "Type", .Type, " Time") Case $TASK_TRIGGER_DAILY __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "Type", .Type, " Daily") __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "DaysInterval", .DaysInterval) Case $TASK_TRIGGER_WEEKLY __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "Type", .Type, " Weekly") __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "WeeksInterval", .WeeksInterval) __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "DaysOfWeek", .DaysOfWeek, "=" & __TS_ConvertDaysOfWeek(.DaysOfWeek)) Case $TASK_TRIGGER_MONTHLY __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "Type", .Type, "Monthly") __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "DaysOfMonth", .DaysOfMonth, "=" & __TS_ConvertDaysOfMonth(.DaysOfMonth)) __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "MonthsOfYear", .MonthsOfYear, "=" & __TS_ConvertMonthsOfYear(.MonthsOfYear)) __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "RandomDelay", .RandomDelay) __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "RunOnLastDayOfMonth ", .RunOnLastDayOfMonth) Case $TASK_TRIGGER_MONTHLYDOW __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "Type", .Type, "Monthly on Specific Day") __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "DaysOfWeek", .DaysOfWeek, "=" & __TS_ConvertDaysOfWeek(.DaysOfWeek)) __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "MonthsOfYear", .MonthsOfYear, "=" & __TS_ConvertMonthsOfYear(.MonthsOfYear)) __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "RandomDelay", .RandomDelay) __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "RunOnLastWeekOfMonth ", .RunOnLastWeekOfMonth) __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "WeeksOfMonth", .WeeksOfMonth, "=" & __TS_ConvertWeeksOfMonth(.WeeksOfMonth)) Case $TASK_TRIGGER_IDLE __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "Type", .Type, "When computer is idle") Case $TASK_TRIGGER_REGISTRATION __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "Type", .Type, "When task is registered") __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "Delay", .Delay) Case $TASK_TRIGGER_BOOT __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "Type", .Type, "Boot") __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "Delay", .Delay) Case $TASK_TRIGGER_LOGON __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "Type", .Type, "Logon") __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "Delay", .Delay) __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "UserId", .UserId) Case $TASK_TRIGGER_SESSION_STATE_CHANGE __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "Type", .Type, "Session State Change") Switch (.StateChange) Case 0 __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "LogonType", .StateChange, "None") Case $TASK_CONSOLE_CONNECT __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "LogonType", .StateChange, "User session connect to local computer") Case $TASK_CONSOLE_DISCONNECT __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "LogonType", .StateChange, "User session disconnect from local computer") Case $TASK_REMOTE_CONNECT __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "LogonType", .StateChange, "User session connect to remote computer") Case $TASK_REMOTE_DISCONNECT __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "LogonType", .StateChange, "User session disconnect from remote computer") Case $TASK_SESSION_LOCK __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "LogonType", .StateChange, "On workstation lock") Case $TASK_SESSION_UNLOCK __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "LogonType", .StateChange, "On workstation unlock") EndSwitch __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "Delay", .Delay) __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "UserId", .UserId) EndSwitch $oTaskRepitition = .Repetition $sSection = "REPETITION" With $oTaskRepitition __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "Duration", .Duration) __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "Interval", .Interval) __TS_PropertyGetWrite($aProperties, $iIndex, $sSection, $iFormat, $bIgnoreNoValues, "StopAtDurationEnd", .StopAtDurationEnd) EndWith ; oTaskRepitition EndWith ; oTaskTrigger Next ; oTaskTrigger EndWith ; oTaskDefinition EndWith ; oTask If $iFormat = 1 Then ReDim $aProperties[$iIndex][4] Else ReDim $aProperties[$iIndex] EndIf If $iFormat = 3 Then Local $iLastIndex = UBound($aProperties) - 1 ConsoleWrite("Global $aProperties[] = [ _" & @CRLF) For $i = 0 To $iLastIndex $aProperties[$i] = StringReplace($aProperties[$i], @LF, '" & @CRLF & "') If $i = $iLastIndex Then ConsoleWrite('"' & $aProperties[$i] & '" _' & @CRLF) Else ConsoleWrite('"' & $aProperties[$i] & '", _' & @CRLF) EndIf Next ConsoleWrite('"]' & @CRLF) Return 1 Else Return $aProperties EndIf EndFunc ;==>_TS_TaskPropertiesGet If you find any bugs, please let me know1 point -
Check if Win10 system is LEGACY or UEFI installed
coffeeturtle reacted to ModemJunki for a topic
I think that @coffeeturtle is trying to access UEFI shell or settings in BIOS, but I'm not sure by the description. You don't need a HDD connected for accessing the UEFI part of firmware.1 point -
Tab, Listview and Color
jugador reacted to pixelsearch for a topic
Hi Nine, we did it the same way Jugador, in case you want all other cells to have the default background, no matter the user's Windows theme (each user getting a different background color), this seems to work nicely : Else ; DllStructSetData($tCustDraw, "clrTextBk", 0xFFFFFF) ;white DllStructSetData($tCustDraw, "clrTextBk", 0xFF000000) ; $CLR_DEFAULT EndIf1 point -
Here one way you could do it : #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <WindowsConstants.au3> #include <MsgBoxConstants.au3> #include <TabConstants.au3> #include <GuiTab.au3> Const $iTab = 2 Const $iRows = 3 Const $iCols = 3 Global $hListView, $idTab Global $ListView1,$ListView2 Global $aColors[$iTab][$iRows][$iCols] _Example_1() ; #FUNCTION# =================== ; _Example_1() ; ============================== Func _Example_1() Local $iGui_Width = 350 Local $iGui_Height = 250 Local $Form1 = GUICreate("Form1", $iGui_Width, $iGui_Height, -1, -1) Local $idTab = GUICtrlCreateTab(2, 2, $iGui_Width - 5, $iGui_Height - 78) ;;Tab1 GUICtrlCreateTabItem("Tab1") $ListView1 = GUICtrlCreateListView("Header|Header|Header", 3, 22, $iGui_Width - 10, $iGui_Height - 100) GuiCtrlCreateListViewItem('White|White|White',$ListView1) GuiCtrlCreateListViewItem('Green|Pink|Green',$ListView1) GuiCtrlCreateListViewItem('White|White|White',$ListView1) Local $btn = GuiCtrlCreateButton('button', 20, 210, 50, 25) ;;Tab2 GUICtrlCreateTabItem("Tab2") $ListView2 = GUICtrlCreateListView("Number|Number|Number", 3, 22, $iGui_Width - 10, $iGui_Height - 100) GuiCtrlCreateListViewItem('1|1|1',$ListView2) GuiCtrlCreateListViewItem('2|2|2',$ListView2) GuiCtrlCreateListViewItem('3|3|3',$ListView2) GUICtrlCreateTabItem("") ; end tabitem definition ;init background colors $aColors[0][1][1] = 0xffaaff $aColors[1][1][2] = 0x00aa00 _Tab_Check($idTab) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $idTab Switch GUICtrlRead($idTab) Case 0 _Tab_Check($idTab) _WinAPI_RedrawWindow(GUICtrlGetHandle($ListView1)) Case 1 _Tab_Check($idTab) _WinAPI_RedrawWindow(GUICtrlGetHandle($ListView2)) EndSwitch Case $btn ;;MsgBox("", "", " Button is clicked") EndSwitch WEnd EndFunc ; #FUNCTION# =================== ; _Tab_Check ; ============================== ;;this not working color getting mixed up Func _Tab_Check($mdTab) $idTab = GUICtrlRead($mdTab) If $idTab = 0 Then $hListView = GUICtrlGetHandle ( $ListView1 ) Else $hListView = GUICtrlGetHandle ( $ListView2 ) EndIf EndFunc ; #FUNCTION# =================== ; WM_NOTIFY ; ============================== Func WM_NOTIFY($hWnd, $Msg, $wParam, $lParam) Local $tNMHDR, $hWndFrom, $iCode $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $hWndFrom = DllStructGetData($tNMHDR, "hWndFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hListView Switch $iCode Case $NM_CUSTOMDRAW Local $tCustDraw = DllStructCreate($tagNMLVCUSTOMDRAW, $lParam) Local $iDrawStage = DllStructGetData($tCustDraw, "dwDrawStage") If $iDrawStage = $CDDS_PREPAINT Then Return $CDRF_NOTIFYITEMDRAW If $iDrawStage = $CDDS_ITEMPREPAINT Then Return $CDRF_NOTIFYSUBITEMDRAW Local $iSubItem = DllStructGetData($tCustDraw, "iSubItem") Local $iItem = DllStructGetData($tCustDraw, "dwItemSpec") If $aColors[$idTab][$iItem][$iSubItem] <> "" Then DllStructSetData($tCustDraw, "clrTextBk", $aColors[$idTab][$iItem][$iSubItem]) Else DllStructSetData($tCustDraw, "clrTextBk", 0xFFFFFF) ;white EndIf Return $CDRF_NEWFONT EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY1 point
-
Tab, Listview and Color
jugador reacted to pixelsearch for a topic
Hi jugador Not sure I took the easiest way, adding a 3rd dimension to get a set of colors per tab : #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <WindowsConstants.au3> #include <MsgBoxConstants.au3> #include <TabConstants.au3> #include <GuiTab.au3> $iRows = 3 $iCols = 3 Global $hListView, $iIndex_TabItem Global $ListView1,$ListView2 Global $aColors[2][$iRows][$iCols] _Example_1() ; #FUNCTION# =================== ; _Example_1() ; ============================== Func _Example_1() Local $iGui_Width = 350 Local $iGui_Height = 250 Local $Form1 = GUICreate("Form1", $iGui_Width, $iGui_Height, -1, -1) Local $idTab = GUICtrlCreateTab(2, 2, $iGui_Width - 5, $iGui_Height - 78) ;;Tab1 GUICtrlCreateTabItem("Tab1") $ListView1 = GUICtrlCreateListView("Header|Header|Header", 3, 22, $iGui_Width - 10, $iGui_Height - 100) GuiCtrlCreateListViewItem('White|White|White',$ListView1) GuiCtrlCreateListViewItem('Green|Pink|Green',$ListView1) GuiCtrlCreateListViewItem('White|White|White',$ListView1) Local $btn = GuiCtrlCreateButton('button', 20, 210, 50, 25) ;;Tab2 GUICtrlCreateTabItem("Tab2") $ListView2 = GUICtrlCreateListView("Number|Number|Number", 3, 22, $iGui_Width - 10, $iGui_Height - 100) GuiCtrlCreateListViewItem('1|1|1',$ListView2) GuiCtrlCreateListViewItem('2|2|2',$ListView2) GuiCtrlCreateListViewItem('3|3|3',$ListView2) GUICtrlCreateTabItem("") ; end tabitem definition _Tab_Check($idTab) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $idTab $iIndex_TabItem = GUICtrlRead($idTab) Switch $iIndex_TabItem Case 0 _Tab_Check($idTab) _WinAPI_RedrawWindow(GUICtrlGetHandle($ListView1)) Case 1 _Tab_Check($idTab) _WinAPI_RedrawWindow(GUICtrlGetHandle($ListView2)) EndSwitch Case $btn MsgBox("", "", " Button is clicked") EndSwitch WEnd EndFunc ; #FUNCTION# =================== ; _Tab_Check ; ============================== Func _Tab_Check($mdTab) If GUICtrlRead($mdTab) = 0 Then $aColors[0][1][1] = 0xffaaff ; pink $hListView = GUICtrlGetHandle ( $ListView1 ) Else $aColors[1][1][2] = 0x00aa00 ; dark green $hListView = GUICtrlGetHandle ( $ListView2 ) EndIf EndFunc ; #FUNCTION# =================== ; WM_NOTIFY ; ============================== Func WM_NOTIFY($hWnd, $Msg, $wParam, $lParam) Local $tNMHDR, $hWndFrom, $iCode $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $hWndFrom = DllStructGetData($tNMHDR, "hWndFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hListView Switch $iCode Case $NM_CUSTOMDRAW Local $tCustDraw = DllStructCreate($tagNMLVCUSTOMDRAW, $lParam) Local $iDrawStage = DllStructGetData($tCustDraw, "dwDrawStage") If $iDrawStage = $CDDS_PREPAINT Then Return $CDRF_NOTIFYITEMDRAW If $iDrawStage = $CDDS_ITEMPREPAINT Then Return $CDRF_NOTIFYSUBITEMDRAW Local $iSubItem = DllStructGetData($tCustDraw, "iSubItem") Local $iItem = DllStructGetData($tCustDraw, "dwItemSpec") If $aColors[$iIndex_TabItem][$iItem][$iSubItem] <> "" Then DllStructSetData($tCustDraw, "clrTextBk", $aColors[$iIndex_TabItem][$iItem][$iSubItem]) Else DllStructSetData($tCustDraw, "clrTextBk", 0xFFFFFF) ;white EndIf Return $CDRF_NEWFONT EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY1 point -
mixim, When AutoIt is "compiled" all that actually happens is that a version of your script (all cleaned up and tokenised) is added to the resource table of an AutoIt interpreter - which, as water has pointed out is written in C++. So it is hardly surprising that the executable shows that the "compiled" AutoIt script is written in C++. Clearer now? M231 point
-
I assume that the AutoIt exe which interprets your script is written in Visual C++1 point
-
Image not found
Polistotele reacted to pixelsearch for a topic
@Musashi: thanks for the confirmation. @Polistotele: after googling on the sentence "If IsArray($Variable) = True", I wonder where you found this erroneous syntax in your script because you apply it to _ImageSearch() which will never return an Array. I didn't find your syntax in any post related to _ImageSearch() $Variable = _ImageSearch(...) Or _ImageSearch(...) If IsArray($Variable) = True Then ; this will never happen ... Else $Variable = _ImageSearch(...) Or _ImageSearch(...) If IsArray($Variable) = True Then ; impossible too ... EndIf EndIf When BrewmanNH used this kind of nesting in Dec 2011, he applied it to $Variable = PixelSearch(...) as we can see here and it was correct because PixelSearch(...) returns an Array when successful. This is BrewmanNH's code : $Variable = PixelSearch(...) If IsArray($Variable) = True Then ; correct ... Else $Variable = PixelSearch(...) If IsArray($Variable) = True Then ; correct ... EndIf EndIf Maybe one did copy his script, thinking he could apply it to _ImageSearch() without any other change... wrong try ! To solve this 1st issue, you should do what all other posters did in their scripts, testing only one image per line, then testing if the Return is 1 (success) : $Variable = _ImageSearch(...) If $Variable = 1 Then Here are a few interesting links I found in AutoIt concerning _ImageSearch() LINK1 : 8 pages of comments, OP is Centrally (thread created in 2013) . The whole pages should be read when you got an issue to see how other posters solved it (or at least tried to) . You would have immediately noticed how Centrally scripted, in his 1st post : global $y = 0, $x = 0 ; always good to write Global (especially on $x & $y) Func checkForImage() Local $search = _ImageSearch(...) If $search = 1 Then LINK2 : tbodine88's code shows exactly what Nine asked you to do in his upper post (testing all DllCall possible error values) as it may help solve your #2 issue LINK3 : JohnOne's about #include <ImageSearch.au3> vs #include "ImageSearch.au3" LINK4 : guestscripter's (2015) whole package "ImageSearch2015.zip" which seems to solve a lot of issues. And for all other posters whining later in the same thread that his additional link "ImageSearch15.au3" wasn't working anymore (a version of ImageSearch Library without the built-in Example and Debugging) ... he pasted that additional script "ImageSearch15.au3" at the very end of his post, the same day he wrote it ! LINK5 : guestscripter's again (2018) showing he didn't modify his precedent download package (good news !) : 10.659 downloads. LINK6 : BrewmanNH's "That's probably one of the worst reasons for using ImageSearch I've seen yet." Impossible not to smile (at least) when reading this sentence I guess many posters who created an account to ask for help used the function for game automation, invoking disguised reasons... which will make JLogan3o13 react : LINK7 : JLogan3o13's "I was curious how long this thread would go after being resurrected before someone ruined it for everyone." LINK8 : kangkeng's original thread (2008) : 13 pages of comments You may also google on "Miguel7" "AutoHotKey" "ImageSearch" which links to 10 ImageSearch Tips & Tricks (2014) that could help you. Good luck with all these various dll's from 2008 / 2010 / 2012, let's hope they can be trusted without any danger.1 point -
Help with simple script
SkysLastChance reacted to water for a topic
NB: No need to translate $y to a string. It is already a string as InputBox returns a string. You can test with something like ConsoleWrite(VarGetType($y) & @CRLF)1 point -
Check if Win10 system is LEGACY or UEFI installed
coffeeturtle reacted to TheDcoder for a topic
GPT is a must if you ever want to use UEFI, this is one of the first things you do when planning to install UEFI-based OSes1 point -
Use Au3Info tool for getting ClassName, CotrolID of that window/button. "C:\Program Files (x86)\AutoIt3\Au3Info.exe" In AutoIt use ControlClick(...) + AdlibRegister() EDIT: something like this AdlibRegister("MyAdLibFunc", 30000) ; 30 min While 1 Sleep(100) WEnd Func MyAdLibFunc() ControlClick('pdftotext.exe', '', "[TEXT: &Don't Send]") EndFunc1 point
-
Modify Side mouse button behaviour
coffeeturtle reacted to Inpho for a topic
Hi All, A co-worker complained that the side keys on his mouse (back and forward) were getting in the way. This script allows you to disable/re-purpose those buttons. Have only tested with a Delux M618 mouse. Haven't tested under Windows 10. This is the standalone version of the script so it will look ugly. The (cleaner) version we're using has a bunch of server calls and auto-update checks. Please report any problems here; even if you fix them yourself. Learning curve etc. #include <Misc.au3> #include <WinAPI.au3> #include <GuiComboBoxEx.au3> #include <ComboConstants.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Global $gLastHotKeyPressed = ""; Last Hot key pressed Global $gLastHotKeyType = "" ; Last Hot key pressed type Global Const $MSLLHOOKSTRUCT = $tagPOINT & ";dword mouseData;dword flags;dword time;ulong_ptr dwExtraInfo" Global Const $MOUSETRAPEVENT_DUMMY = "_MouseTrapEvent_Dummy" Global $currentEvent[2] Global $currentDownEvent[2] Global $lastEvent = "" Global $iLBUTTONDOWN = 0 Global $iRBUTTONDOWN = 0 Global $iMBUTTONDOWN = 0 Global $iXBUTTONDOWNNumber = 0 ; 1 or 2 xtra buttons Global $LRClickStatus = 0 Global $RLClickStatus = 0 Global $LRDrag = 0 Global $RLDrag = 0 Global $LMDrag = 0 Global $RMDrag = 0 Global $doubleClickTime = 400 Global $gLastMouseEventPressed = "" ; Added for HotKeySetEx UDF ;Global $gLastHotKeyPressed = ""; Last Hot key pressed Added for HotKeySetEx UDF ;Global $gLastHotKeyType = "" ; Last Hot key pressed type Added for HotKeySetEx UDF ; Mouse On event variables Global $a__MSOE_Events[1][1] Global $a__MSOE_DblClk_Data = __MouseTrapEvent_GetDoubleClickData() $doubleClickTime = $a__MSOE_DblClk_Data[0] + 50 Global $hKey_Proc Global $hM_Module Global $hM_Hook If _Singleton("MouseKeyModifier.exe", 1) = 0 Then MsgBox(0, "Warning", "Mouse Key Modifier is already running.") Exit EndIf TrayTip("MKM", "MouseKeyModifier is running. Click here for options", 30) Global $sHotKeyBack = "" Global $sHotKeyForward = "" Opt("TrayMenuMode", 1) Main() Func Main() HotKeySetEx("{XClick12}", "_FuncDummy", 1) Local $tMsg Local Static $aArray = _MouseKeyModifierTrayCreate() Local Static $cTraySettings = $aArray[1] Local Static $cTrayBehaviour = $aArray[2] Local Static $cTrayBehaviourStandard = $aArray[3] Local Static $cTrayBehaviourCustom = $aArray[4] Local Static $cTrayBehaviourStartup = $aArray[5] Local Static $cTrayQuickDisable = $aArray[6] Local Static $cTrayExit = $aArray[7] Local Static $sCurrentBehaviour = IniRead(@ScriptDir & "\config.ini", "DefaultBehaviour", "Hotkey", "Standard") If $sCurrentBehaviour = "Standard" Then TrayItemSetState($cTrayBehaviourStandard, 1) ElseIf $sCurrentBehaviour = "Custom" Then TrayItemSetState($cTrayBehaviourCustom, 1) _HotKeysSet() ElseIf $sCurrentBehaviour = "Disable" Then TrayItemSetState($cTrayQuickDisable, 1) _HotKeysQuickDisable(True) EndIf While 1 $tMsg = TrayGetMsg() Switch $tMsg Case $cTraySettings TraySetState(2) TrayItemSetState($cTraySettings, 4) _HotKeysUpdateSettingsGuiLoop($sCurrentBehaviour) TraySetState(1) Case $cTrayBehaviourStandard _HotKeysQuickDisable(False) TrayItemSetState($cTrayQuickDisable, 4) TrayItemSetState($cTrayBehaviourStandard, 1) TrayItemSetState($cTrayBehaviourCustom, 4) $sCurrentBehaviour = "Standard" Case $cTrayBehaviourCustom _HotKeysQuickDisable(False) TrayItemSetState($cTrayQuickDisable, 4) TrayItemSetState($cTrayBehaviourStandard, 4) TrayItemSetState($cTrayBehaviourCustom, 1) $sCurrentBehaviour = "Custom" _HotKeysSet() Case $cTrayQuickDisable If BitAND(TrayItemGetState($cTrayQuickDisable), 1) = 1 Then _HotKeysQuickDisable(True) TrayItemSetState($cTrayQuickDisable, 1) TrayItemSetState($cTrayBehaviourStandard, 4) TrayItemSetState($cTrayBehaviourCustom, 4) ElseIf BitAND(TrayItemGetState($cTrayQuickDisable), 4) = 4 Then _HotKeysQuickDisable(False) TrayItemSetState($cTrayQuickDisable, 4) If $sCurrentBehaviour = "Standard" Then TrayItemSetState($cTrayBehaviourStandard, 1) TrayItemSetState($cTrayBehaviourCustom, 4) ElseIf $sCurrentBehaviour = "Custom" Then TrayItemSetState($cTrayBehaviourStandard, 4) TrayItemSetState($cTrayBehaviourCustom, 1) _HotKeysSet() ElseIf $sCurrentBehaviour = "Disable" Then $sCurrentBehaviour = "Standard" TrayItemSetState($cTrayBehaviourStandard, 1) TrayItemSetState($cTrayBehaviourCustom, 4) EndIf EndIf Case $cTrayBehaviourStartup TraySetState(2) If BitAND(TrayItemGetState($cTrayBehaviourStandard), 1) = 1 Then IniWrite(@ScriptDir & "\config.ini", "DefaultBehaviour", "Hotkey", "Standard") MsgBox(0, "Success", "'Standard' set as default at startup.") ElseIf BitAND(TrayItemGetState($cTrayBehaviourCustom), 1) = 1 Then IniWrite(@ScriptDir & "\config.ini", "DefaultBehaviour", "Hotkey", "Custom") MsgBox(0, "Success", "'Custom' set as default at startup.") ElseIf BitAND(TrayItemGetState($cTrayQuickDisable), 1) = 1 Then IniWrite(@ScriptDir & "\config.ini", "DefaultBehaviour", "Hotkey", "Disable") MsgBox(0, "Success", "'Disabled' set as default at startup.") EndIf TraySetState(1) TrayItemSetState($cTrayBehaviourStartup, 4) Case $cTrayExit Exit EndSwitch WEnd EndFunc ;==>Main Func _CheckDeselect($cFrom, $cTo) Local $i For $i = $cFrom To $cTo GUICtrlSetState($i, 4) Next Return (1) EndFunc ;==>_CheckDeselect Func _CheckToString($cCheckWin, $cCheckCtrl, $cCheckAlt, $cCheckShift) Local $sReturn = "" Local $i If GUICtrlRead($cCheckWin) = 1 Then $sReturn &= "#" If GUICtrlRead($cCheckCtrl) = 1 Then $sReturn &= "^" If GUICtrlRead($cCheckAlt) = 1 Then $sReturn &= "!" If GUICtrlRead($cCheckShift) = 1 Then $sReturn &= "+" Return ($sReturn) EndFunc ;==>_CheckToString Func _ComboDeselect($hWnd, $cControl) ControlCommand($hWnd, "", $cControl, "SetCurrentSelection", "-1") Return (1) EndFunc ;==>_ComboDeselect Func _ControlDisable($cFrom, $cTo, $bDisable = True) Local $i For $i = $cFrom To $cTo If $bDisable = True Then GUICtrlSetState($i, 4 + 128) Else GUICtrlSetState($i, 4 + 64) EndIf Next Return (1) EndFunc ;==>_ControlDisable Func _FuncDummy() Return (1) EndFunc ;==>_FuncDummy Func _FuncHotKeyBack() Send($sHotKeyBack) Return (1) EndFunc ;==>_FuncHotKeyBack Func _FuncHotKeyForward() Send($sHotKeyForward) Return (1) EndFunc ;==>_FuncHotKeyForward Func _HotKeysAssign($sMouseButton, $sString) If $sMouseButton = "Back" Then HotKeySetEx("{XClick1}", "_FuncHotKeyBack", 1) HotKeySetEx("{XDClick1}", "_FuncHotKeyBack", 1) ElseIf $sMouseButton = "Forward" Then HotKeySetEx("{XClick2}", "_FuncHotKeyForward", 1) HotKeySetEx("{XDClick2}", "_FuncHotKeyForward", 1) EndIf Return (1) EndFunc ;==>_HotKeysAssign Func _HotKeysUpdateSettingsGuiLoop($sCurrentBehaviour) Local Static $aArray = _MouseKeyModifierSettingsGuiCreate() Local Static $cGui = $aArray[1] Local Static $cComboButton = $aArray[2] Local Static $cCheckWin = $aArray[3] Local Static $cCheckCtrl = $aArray[4] Local Static $cCheckAlt = $aArray[5] Local Static $cCheckShift = $aArray[6] Local Static $cComboCharacter = $aArray[7] Local Static $cCheckDisable = $aArray[8] Local Static $cButtonSave = $aArray[9] Local Static $cButtonCancel = $aArray[10] GUICtrlSetState($cCheckWin, 4) GUICtrlSetState($cCheckCtrl, 4) GUICtrlSetState($cCheckAlt, 4) GUICtrlSetState($cCheckShift, 4) _ComboDeselect($cGui, $cComboButton) _ComboDeselect($cGui, $cComboCharacter) Local $sStringToSave = "", $sButtonToSave = "" Local $iIndex GUISetState(@SW_SHOW, $cGui) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case -3, $cButtonCancel GUISetState(@SW_HIDE, $cGui) Return Case $cComboButton ConsoleWrite(GUICtrlRead($cComboButton) & @CRLF) _ComboDeselect($cGui, $cComboCharacter) _HotKeysUpdateSettingsGuiControls(GUICtrlRead($cComboButton), $cCheckWin, $cCheckCtrl, $cCheckAlt, $cCheckShift, $cComboCharacter) Case $cCheckDisable ConsoleWrite(GUICtrlRead($cCheckDisable) & @CRLF) If GUICtrlRead($cCheckDisable) = 1 Then _ControlDisable($cCheckWin, $cComboCharacter, True) _ComboDeselect($cGui, $cComboCharacter) ElseIf GUICtrlRead($cCheckDisable) = 4 Then _ControlDisable($cCheckWin, $cComboCharacter, False) EndIf Case $cButtonSave $sButtonToSave = GUICtrlRead($cComboButton) If $sButtonToSave = "" Then MsgBox(0, "Error", "You must select a button to modify.", 0, $cGui) ContinueLoop EndIf If GUICtrlRead($cCheckDisable) = 1 Then _HotKeysSaveToFile($sButtonToSave, "{EMPTY}") Else $sStringToSave = _CheckToString($cCheckWin, $cCheckCtrl, $cCheckAlt, $cCheckShift) $iIndex = _GUICtrlComboBox_GetCurSel($cComboCharacter) If $iIndex <> -1 Then $sStringToSave &= GUICtrlRead($cComboCharacter) If $sStringToSave = "" Then $sStringToSave = "{EMPTY}" _HotKeysSaveToFile($sButtonToSave, $sStringToSave) EndIf _CheckDeselect($cCheckWin, $cCheckShift) _CheckDeselect($cCheckDisable, $cCheckDisable) _ComboDeselect($cGui, $cComboButton) _ComboDeselect($cGui, $cComboCharacter) If $sCurrentBehaviour = "Custom" Then _HotKeysSet() EndSwitch WEnd EndFunc ;==>_HotKeysUpdateSettingsGuiLoop Func _HotKeysUpdateSettingsGuiControls($sButton, $cCheckWin, $cCheckCtrl, $cCheckAlt, $cCheckShift, $cComboCharacter) Local $sHotKey = _HotKeysGet($sButton) GUICtrlSetState($cCheckWin, 4) GUICtrlSetState($cCheckCtrl, 4) GUICtrlSetState($cCheckAlt, 4) GUICtrlSetState($cCheckShift, 4) If StringInStr($sHotKey, "#") <> 0 Then GUICtrlSetState($cCheckWin, 1) If StringInStr($sHotKey, "^") <> 0 Then GUICtrlSetState($cCheckCtrl, 1) If StringInStr($sHotKey, "!") <> 0 Then GUICtrlSetState($cCheckAlt, 1) If StringInStr($sHotKey, "+") <> 0 Then GUICtrlSetState($cCheckShift, 1) $sHotKey = StringReplace($sHotKey, "#", "") $sHotKey = StringReplace($sHotKey, "^", "") $sHotKey = StringReplace($sHotKey, "!", "") $sHotKey = StringReplace($sHotKey, "+", "") $sHotKey = StringLower($sHotKey) If $sHotKey <> "" Then If StringLen($sHotKey) > 1 Then Return (SetError(-1, 0, "")) ConsoleWrite($sHotKey & @CRLF) If Asc($sHotKey) < 97 Or Asc($sHotKey) > 122 Then Return (SetError(-2, 0, "")) EndIf Local $iIndex = _GUICtrlComboBox_SelectString($cComboCharacter, $sHotKey) Return (1) EndFunc ;==>_HotKeysUpdateSettingsGuiControls Func _HotKeysGet($sButton) Local $sHotKey = IniRead(@ScriptDir & "\config.ini", $sButton, "Hotkey", "*") If @error Or $sHotKey = "*" Then Return (SetError(-1, 0, "{EMPTY}")) Return ($sHotKey) EndFunc ;==>_HotKeysGet Func _HotKeysQuickDisable($bDisable = True) If $bDisable = True Then HotKeySetEx("{XClick1}", "_FuncDummy", 1) HotKeySetEx("{XClick2}", "_FuncDummy", 1) HotKeySetEx("{XDClick1}", "_FuncDummy", 1) HotKeySetEx("{XDClick2}", "_FuncDummy", 1) Else HotKeySetEx("{XClick1}", "") HotKeySetEx("{XClick2}", "") HotKeySetEx("{XDClick1}", "") HotKeySetEx("{XDClick2}", "") EndIf EndFunc ;==>_HotKeysQuickDisable Func _HotKeysSaveToFile($sMouseButton, $sString) IniWrite(@ScriptDir & "\config.ini", $sMouseButton, "Hotkey", $sString) Return (1) EndFunc ;==>_HotKeysSaveToFile Func _HotKeysSet() Local $sHotKey = _HotKeysGet("Back") If $sHotKey <> "{EMPTY}" Then _HotKeysAssign("Back", $sHotKey) $sHotKeyBack = $sHotKey $sHotKey = _HotKeysGet("Forward") If $sHotKey <> "{EMPTY}" Then _HotKeysAssign("Forward", $sHotKey) $sHotKeyForward = $sHotKey Return (1) EndFunc ;==>_HotKeysSet Func _MouseKeyModifierTrayCreate() Local $aArray[8] = [7] $aArray[1] = TrayCreateItem("Settings") $aArray[2] = TrayCreateMenu("Behaviour") $aArray[3] = TrayCreateItem("Standard", $aArray[2]) $aArray[4] = TrayCreateItem("Custom", $aArray[2]) TrayCreateItem("", $aArray[2]) $aArray[5] = TrayCreateItem("Set at Startup", $aArray[2]) $aArray[6] = TrayCreateItem("Quick disable") $aArray[7] = TrayCreateItem("Exit") Return ($aArray) EndFunc ;==>_MouseKeyModifierTrayCreate Func _MouseKeyModifierSettingsGuiCreate() Local $aArray[11] = [10] $aArray[1] = GUICreate("Settings", 276, 171) $aArray[2] = GUICtrlCreateCombo("", 20, 19, 236, 21, BitOR(0x0003, 0x00200000)) GUICtrlSetData(-1, "Back|Forward") $aArray[3] = GUICtrlCreateCheckbox("Win", 20, 54, 38, 20) $aArray[4] = GUICtrlCreateCheckbox("Ctrl", 65, 54, 38, 20) $aArray[5] = GUICtrlCreateCheckbox("Alt", 110, 54, 38, 20) $aArray[6] = GUICtrlCreateCheckbox("Shift", 155, 54, 41, 20) GUICtrlCreateLabel("", 20, 87, 237, 1, 0x10, -1) GUICtrlSetBkColor(-1, "-2") $aArray[7] = GUICtrlCreateCombo("", 207, 53, 50, 21, BitOR(0x0003, 0x00200000)) GUICtrlSetData(-1, _AlphabetGenerate()) $aArray[8] = GUICtrlCreateCheckbox("Disable button", 96, 100, 86, 20) $aArray[9] = GUICtrlCreateButton("Save", 20, 134, 76, 25) $aArray[10] = GUICtrlCreateButton("Cancel", 181, 134, 76, 25) Return ($aArray) EndFunc ;==>_MouseKeyModifierSettingsGuiCreate Func _AlphabetGenerate($sSeparator = "|") Local $sReturn = "" Local $i For $i = 97 To 122 $sReturn &= Chr($i) If $i <> 122 Then $sReturn &= $sSeparator Next ConsoleWrite($sReturn & @CRLF) Return ($sReturn) EndFunc ;==>_AlphabetGenerate Func HotKeySetEx($hotkey, $fun, $block = 1) ; default 1 block 0 intercept allow normal behavour and only for mouse events ; if the the hot key name contains the word CLICK then its a mouse button. If StringInStr(StringUpper($hotkey), "CLICK") > 0 Then ; Mouse hot key Dim $mouseHotKey ; local $mouseHotKey = $hotkey $mouseHotKey = StringReplace($mouseHotKey, "{", "") ; remove { } for mousetrap interface $mouseHotKey = StringReplace($mouseHotKey, "}", "") If $fun = "" Then _MouseTrapEvent($mouseHotKey) ; deregister Else _MouseTrapEvent($mouseHotKey, $fun, $block) ; 1 = block action and redirect to $fun EndIf Else HotKeySet($hotkey, $fun) ; normal AutoIt EndIf EndFunc ;==>HotKeySetEx Func getLastHotKey() ; call this in your function. Equivalent to @HotKeyPressed see example script setLastHotKey() Return $gLastHotKeyPressed ; EndFunc ;==>getLastHotKey Func getLastHotKeyType() ; call this in your function. Optional if you want type KEYBOARD or MOUSE setLastHotKey() Return $gLastHotKeyType ; EndFunc ;==>getLastHotKeyType Func setLastHotKey() ; Dim $sLastMouseEventPressed $sLastMouseEventPressed = __MouseTrapEvent_getLastMouseEventPressed() If $sLastMouseEventPressed <> "" Then $gLastHotKeyPressed = "{" & $sLastMouseEventPressed & "}" $gLastHotKeyType = "Mouse" Else $gLastHotKeyPressed = @HotKeyPressed $gLastHotKeyType = "Keyboard" EndIf Return $gLastHotKeyPressed ; EndFunc ;==>setLastHotKey ; #FUNCTION# ==================================================================================================== ; Name...........: _MouseTrapEvent ; Description....: Set an events handler (a hook) for Mouse device based on MouseSetEvent.udf. ; Syntax.........: _MouseTrapEvent($iEvent, $sFuncName = "", $hTargetWnd = 0, $iBlockDefProc = -1, $vParam = "") ; Parameters.....: $sEvent - The event to set, here is the list of ; supported event stings:- Case InSensitive! ; ; single clicks ; LClick - left button click (Primary) ; MClick - middle button click (Wheel click) ; RClick - right button click (Secondary) ; XClick1 - Xtra button 1 click (usually 'back navigaton') ; XClick2 - Xtra button 2 click (usually 'forward navigaton') ; double clicks ; LDClick - left button (Primary) ; MDClick - middle button (Wheel click) ; RDClick - right button (Secondary) ; XDClick1 - Xtra button 1 (usually 'back navigaton') ; XDClick2 - Xtra button 2 (usually 'forward navigaton') ; psuedo double clicks ('chords') - ; XClick12 - Xtra button 1&2 pressed at the same time. ; ; OTHER EVENTS you'll have to work out yourself eg mouse wheel scroll - see code. ; $sFuncName - [Optional] Function name to call when the event is triggered. ; If this parameter is empty string ("") or omited, the function will *unset* the $iEvent. ; ; $iBlockDefProc - [Optional] Defines if the up event should be blocked (actualy block the mouse action). ; If this parameter = ; -1 (default), user defined event function defines whether to block or not ; 1 (call function and block) ; 0 (call function and continue normal mouse behaviour). ; Note for all click and double click events the down event is always blocked to prevent hanging. ; ; ; $vParam - [Optional] Parameter to pass to the event function ($sFuncName). ; ; Return values..: Success - If the event is set in the first time, or when the event is unset properly, the return is 1, ; if it's set on existing event, the return is 2. ; Failure - Returns 0 on UnSet event mode when there is no set events yet. ; Author.........: credits G.Sandler (Mr)CreatoR ; Remarks........: ; 2) Blocking of $sFuncName function by window messages with commands ; such as "Msgbox()" can lead to unexpected behavior, the return to the system should be as fast as possible! ; Related........: MouseSetEvent.udf ; Link...........: ; Example........: Yes. ; =============================================================================================================== Func _MouseTrapEvent($iEvent, $sFuncName = "", $iBlockDefProc = -1, $vParam = "") Local $i Local $iUserEventCount = 0 Local $hTargetWnd = 0 ; not used $iEvent = StringReplace(StringUpper($iEvent), "CLICK", "Click") ; make case insensitive, to do Drag and Wheel and Up Down If $sFuncName = "" Then ;Unset Event If $a__MSOE_Events[0][0] < 1 Then Return 0 EndIf Local $aTmp_Mouse_Events[1][1] = [[0]] For $i = 1 To $a__MSOE_Events[0][0] ; keep events that don't match or internal dummy events used for double clicks. If $a__MSOE_Events[$i][0] <> $iEvent Or $a__MSOE_Events[$i][1] = $MOUSETRAPEVENT_DUMMY Then $aTmp_Mouse_Events[0][0] += 1 ReDim $aTmp_Mouse_Events[$aTmp_Mouse_Events[0][0] + 1][5] $aTmp_Mouse_Events[$aTmp_Mouse_Events[0][0]][0] = $a__MSOE_Events[$i][0] $aTmp_Mouse_Events[$aTmp_Mouse_Events[0][0]][1] = $a__MSOE_Events[$i][1] $aTmp_Mouse_Events[$aTmp_Mouse_Events[0][0]][2] = $a__MSOE_Events[$i][2] $aTmp_Mouse_Events[$aTmp_Mouse_Events[0][0]][3] = $a__MSOE_Events[$i][3] $aTmp_Mouse_Events[$aTmp_Mouse_Events[0][0]][4] = $a__MSOE_Events[$i][4] If $a__MSOE_Events[$i][1] <> $MOUSETRAPEVENT_DUMMY Then $iUserEventCount += 1 EndIf EndIf Next $a__MSOE_Events = $aTmp_Mouse_Events If $iUserEventCount < 1 Then __MouseTrapEvent_Close() EndIf Return 1 EndIf ;First event If $a__MSOE_Events[0][0] < 1 Then ;Register callback $hKey_Proc = DllCallbackRegister("_MouseTrapEvent_MouseProc", "int", "int;ptr;ptr") $hM_Module = DllCall("kernel32.dll", "hwnd", "GetModuleHandle", "ptr", 0) $hM_Hook = DllCall("user32.dll", "hwnd", "SetWindowsHookEx", "int", $WH_MOUSE_LL, "ptr", DllCallbackGetPtr($hKey_Proc), "hwnd", $hM_Module[0], "dword", 0) EndIf ;Search thru events, and if the event already set, we just (re)set the new function and other parameters For $i = 1 To $a__MSOE_Events[0][0] If $a__MSOE_Events[$i][0] = $iEvent Then If $sFuncName = $MOUSETRAPEVENT_DUMMY Then ; event already handled by user - no need for dummy event Return 1 EndIf $a__MSOE_Events[$i][0] = $iEvent $a__MSOE_Events[$i][1] = $sFuncName $a__MSOE_Events[$i][2] = $hTargetWnd $a__MSOE_Events[$i][3] = $iBlockDefProc $a__MSOE_Events[$i][4] = $vParam Return 2 EndIf Next $a__MSOE_Events[0][0] += 1 ReDim $a__MSOE_Events[$a__MSOE_Events[0][0] + 1][5] $a__MSOE_Events[$a__MSOE_Events[0][0]][0] = $iEvent $a__MSOE_Events[$a__MSOE_Events[0][0]][1] = $sFuncName $a__MSOE_Events[$a__MSOE_Events[0][0]][2] = $hTargetWnd $a__MSOE_Events[$a__MSOE_Events[0][0]][3] = $iBlockDefProc $a__MSOE_Events[$a__MSOE_Events[0][0]][4] = $vParam ; if double click event - attempt to register a dummmy event for single click if one dosen't exist- to prevent hanging If StringInStr($iEvent, "DClick") > 0 Then _MouseTrapEvent(StringReplace($iEvent, "DClick", "Click"), $MOUSETRAPEVENT_DUMMY, 0, 0) EndIf ; if multi button click event - attempt to register a dummmy single click event for each button - to prevent hanging If $iEvent = "XClick12" Then _MouseTrapEvent("XClick1", $MOUSETRAPEVENT_DUMMY, 0, 0) _MouseTrapEvent("XClick2", $MOUSETRAPEVENT_DUMMY, 0, 0) EndIf Return 1 EndFunc ;==>_MouseTrapEvent Func _MouseTrapEvent_Dummy() ; dummy function for unregistered click events of double clicks Return 0; EndFunc ;==>_MouseTrapEvent_Dummy Func _MouseTrapEvent_MouseProc($nCode, $wParam, $lParam) Local $info, $mouseData, $time, $timeDiff If $nCode < 0 Then $ret = DllCall("user32.dll", "long", "CallNextHookEx", "hwnd", $hM_Hook[0], _ "int", $nCode, "ptr", $wParam, "ptr", $lParam) Return $ret[0] EndIf $info = DllStructCreate($MSLLHOOKSTRUCT, $lParam) $mouseData = DllStructGetData($info, 3) $time = DllStructGetData($info, 5) $timeDiff = $time - $currentEvent[1] Select Case $wParam = $WM_MOUSEMOVE ;Test for Drag in here If $currentEvent[0] <> "LDrag" Or $currentEvent[0] <> "LRDrag" Or $currentEvent[0] <> "LMDrag" Then If $iLBUTTONDOWN = 1 Then $currentEvent[0] = "LDrag" If $iRBUTTONDOWN = 1 Then $currentEvent[0] = "LRDrag" $LRDrag = 2 EndIf EndIf EndIf If $currentEvent[0] <> "RDrag" Or $currentEvent[0] <> "RMDrag" Or $currentEvent[0] <> "LRDrag" Then If $iRBUTTONDOWN = 1 Then $currentEvent[0] = "RDrag" EndIf EndIf If $currentEvent[0] <> "MDrag" Then If $iMBUTTONDOWN = 1 Then $currentEvent[0] = "MDrag" $currentEvent[1] = $time EndIf EndIf If $iRBUTTONDOWN = 1 And $iMBUTTONDOWN = 1 And $currentEvent[0] <> "RMDrag" Then $RMDrag = 2 $currentEvent[0] = "RMDrag" $currentEvent[1] = $time EndIf If $iLBUTTONDOWN = 1 And $iMBUTTONDOWN = 1 And $currentEvent[0] <> "LMDrag" Then $LMDrag = 2 $currentEvent[0] = "LMDrag" $currentEvent[1] = $time EndIf Case $wParam = $WM_MOUSEWHEEL If _WinAPI_HiWord($mouseData) > 0 Then ;Wheel Up $currentEvent[0] = "WheelUp" $currentEvent[1] = $time Else ;Wheel Down $currentEvent[0] = "WheelDown" $currentEvent[1] = $time EndIf Case $wParam = $WM_LBUTTONDOWN ;Register Button Down, check for Right/Left If $currentEvent[0] = "RClick" Then $LRClickStatus = 1 EndIf $iLBUTTONDOWN = 1 $currentDownEvent[0] = 'LClick' Case $wParam = $WM_LBUTTONUP ;Update $iLBUTTONDOWN $iLBUTTONDOWN = 0 $currentDownEvent[0] = '' ;Test for Right/Left Click If $RLClickStatus = 1 And ($timeDiff) < $doubleClickTime Then $currentEvent[0] = "RLClick" $currentEvent[1] = $time EndIf If $lastEvent = "LClick" And ($timeDiff) < $doubleClickTime Then $currentEvent[0] = "LDClick" $currentEvent[1] = $time EndIf ;Test for Drops If $currentEvent[0] = "LDrag" Then $currentEvent[0] = "LDrop" $currentEvent[1] = $time EndIf If $LRDrag = 2 And $iRBUTTONDOWN = 1 Then $LRDrag = 1 ; Denote $LRDrag as still having one button clicked, need to register the drop on RButton up EndIf If $LRDrag = 1 And $iRBUTTONDOWN = 0 Then $currentEvent[0] = "LRDrop" $currentEvent[1] = $time $LRDrag = 0 EndIf If $LMDrag = 2 And $iMBUTTONDOWN = 1 Then $LMDrag = 1 ; Denote $LMDrag as still having one button clicked, need to register the drop on MButton up EndIf If $LMDrag = 1 And $iMBUTTONDOWN = 0 Then $currentEvent[0] = "LMDrop" $currentEvent[1] = $time $LMDrag = 0 EndIf ;Set LClick if other events haven't fired If $currentEvent[1] <> $time Then $currentEvent[0] = "LClick" $currentEvent[1] = $time EndIf ;Negate $LRClickStatus $RLClickStatus = 0 Case $wParam = $WM_RBUTTONDOWN ;Register Button Down If $currentEvent[0] = "LClick" Then $RLClickStatus = 1 EndIf $iRBUTTONDOWN = 1 $currentDownEvent[0] = 'RClick' Case $wParam = $WM_RBUTTONUP ;Test for Left, Right, and Right Doubleclick here ;Update $iRBUTTONDOWN $iRBUTTONDOWN = 0 $currentDownEvent[0] = ''; ;Test for Right/Left Click If $LRClickStatus = 1 And ($timeDiff) < $doubleClickTime Then $currentEvent[0] = "LRClick" $currentEvent[1] = $time EndIf If $lastEvent = "RClick" And ($timeDiff) < $doubleClickTime Then $currentEvent[0] = "RDClick" $currentEvent[1] = $time EndIf ;Test for Drops If $currentEvent[0] = "RDrag" Then $currentEvent[0] = "RDrop" $currentEvent[1] = $time EndIf If $LRDrag = 2 And $iLBUTTONDOWN = 1 Then $LRDrag = 1 ; Denote $LRDrag as still having one button clicked, need to register the drop on RButton up EndIf If $LRDrag = 1 And $iLBUTTONDOWN = 0 Then $currentEvent[0] = "LRDrop" $currentEvent[1] = $time $LRDrag = 0 EndIf If $RMDrag = 2 And $iMBUTTONDOWN = 1 Then $RMDrag = 1 ; Denote $LMDrag as still having one button clicked, need to register the drop on MButton up EndIf If $RMDrag = 1 And $iMBUTTONDOWN = 0 Then $currentEvent[0] = "RMDrop" $currentEvent[1] = $time $RMDrag = 0 EndIf ;Set LClick if other events haven't fired If $currentEvent[1] <> $time Then $currentEvent[0] = "RClick" $currentEvent[1] = $time EndIf ;Negate $LRClickStatus $LRClickStatus = 0 Case $wParam = $WM_MBUTTONDOWN ;Register Button Down $iMBUTTONDOWN = 1 $currentDownEvent[0] = 'MClick' Case $wParam = $WM_MBUTTONUP ;Test for Middle Double Click here ;Update $iRBUTTONDOWN $iMBUTTONDOWN = 0 $currentDownEvent[0] = '' ;Test for Right/Left Click If $lastEvent = "MClick" And ($timeDiff) < $doubleClickTime Then $currentEvent[0] = "MDClick" $currentEvent[1] = $time EndIf ;Test for Drops If $currentEvent[0] = "MDrag" Then $currentEvent[0] = "MDrop" $currentEvent[1] = $time EndIf If $LMDrag = 2 And $iLBUTTONDOWN = 1 Then $LMDrag = 1 ; Denote $LRDrag as still having one button clicked, need to register the drop on RButton up EndIf If $LMDrag = 1 And $iLBUTTONDOWN = 0 Then $currentEvent[0] = "LMDrop" $currentEvent[1] = $time $LMDrag = 0 EndIf If $RMDrag = 2 And $iRBUTTONDOWN = 1 Then $RMDrag = 1 ; Denote $LMDrag as still having one button clicked, need to register the drop on MButton up EndIf If $RMDrag = 1 And $iRBUTTONDOWN = 0 Then $currentEvent[0] = "RMDrop" $currentEvent[1] = $time $RMDrag = 0 EndIf ;Set MClick if other events haven't fired If $currentEvent[1] <> $time Then $currentEvent[0] = "MClick" $currentEvent[1] = $time EndIf Case $wParam = $WM_XBUTTONDOWN $iXBUTTONDOWNNumber = _WinAPI_HiWord($mouseData) $currentDownEvent[0] = 'XClick' & $iXBUTTONDOWNNumber Case $wParam = $WM_XBUTTONUP Local $iXbuttonNumber = _WinAPI_HiWord($mouseData) If ($lastEvent = "XClick1" Or $lastEvent = "XClick2") And ($timeDiff) < $doubleClickTime Then If StringRight($lastEvent, 1) = $iXBUTTONDOWNNumber Then $currentEvent[0] = "XDClick" & $iXbuttonNumber $currentEvent[1] = $time Else $currentEvent[0] = "XClick12" ; both X buttons pressed simultaneously $currentEvent[1] = $time EndIf EndIf ;Set XClick if other events haven't fired If $currentEvent[1] <> $time Then If $iXbuttonNumber > 0 Then ;standard win 2000+ Xtra button pressed, append 1 or 2 to event name $currentEvent[0] = "XClick" & $iXbuttonNumber $currentEvent[1] = $time EndIf EndIf $iXBUTTONDOWNNumber = 0 ; reset $currentDownEvent[0] = '' EndSelect If $currentEvent[0] <> "" Then $lastEvent = $currentEvent[0] EndIf If __MouseTrapEvent_Remap($currentEvent[0]) = 1 Then Return 1; EndIf $ret = DllCall("user32.dll", "long", "CallNextHookEx", "hwnd", $hM_Hook[0], _ "int", $nCode, "ptr", $wParam, "ptr", $lParam) Return $ret[0] EndFunc ;==>_MouseTrapEvent_MouseProc ; local function - not user callable Func __MouseTrapEvent_Remap($sEvent) ;search for event to block For $i = 1 To $a__MSOE_Events[0][0] ;Handle / block down events - done to prevent lock ups If $a__MSOE_Events[$i][0] = $currentDownEvent[0] Then Return 1; block handle event EndIf ; handle click - up events. If $a__MSOE_Events[$i][0] = $sEvent Then ;Handle events Local $iBlockDefProc_Ret = $a__MSOE_Events[$i][3] Local $sFuncName = $a__MSOE_Events[$i][1] $iRet = Call($sFuncName, $sEvent, $a__MSOE_Events[$i][4]) If @error Then $iRet = Call($sFuncName, $sEvent) If @error Then $iRet = Call($sFuncName) EndIf EndIf If $iBlockDefProc_Ret = -1 Then $iBlockDefProc_Ret = $iRet EndIf $currentEvent[0] = "" Return $iBlockDefProc_Ret ;Block default processing (or not :)) EndIf Next Return 0 ; don't bypass EndFunc ;==>__MouseTrapEvent_Remap ; call this from HotKeySetEx for mouse hotkeys. Func __MouseTrapEvent_getLastMouseEventPressed() For $i = 1 To $a__MSOE_Events[0][0] Local $sFuncName = $a__MSOE_Events[$i][1] ; If current event a registered hotkey then it will be the last pressed If $a__MSOE_Events[$i][0] = $currentEvent[0] And $sFuncName <> "" And $sFuncName <> $MOUSETRAPEVENT_DUMMY Then Return $currentEvent[0]; hot key found EndIf Next Return "" EndFunc ;==>__MouseTrapEvent_getLastMouseEventPressed ; called this to shut down without having to deregister all events. Func __MouseTrapEvent_Close() DllCall("user32.dll", "int", "UnhookWindowsHookEx", "hwnd", $hM_Hook[0]) $hM_Hook[0] = 0 DllCallbackFree($hKey_Proc) $hKey_Proc = 0 ; clear all events Dim $a__MSOE_Events[1][1] EndFunc ;==>__MouseTrapEvent_Close Func __MouseTrapEvent_GetDoubleClickData() Local $aRet[3] = _ [ _ RegRead('HKEY_CURRENT_USER\Control Panel\Mouse', 'DoubleClickSpeed'), _ RegRead('HKEY_CURRENT_USER\Control Panel\Mouse', 'DoubleClickWidth'), _ RegRead('HKEY_CURRENT_USER\Control Panel\Mouse', 'DoubleClickHeight') _ ] Local $aGDCT = DllCall('User32.dll', 'uint', 'GetDoubleClickTime') If Not @error And $aGDCT[0] > 0 Then $aRet[0] = $aGDCT[0] EndIf Return $aRet EndFunc ;==>__MouseTrapEvent_GetDoubleClickData1 point -
Here is an old goodie from ms demonstrating concepts behind multithreading and using mutexes to control sharing the screen. Its unfortunately just a console application so you have to press compile (f7) to run (can get annoying if you want to play with the code) but still pretty cool :). Each little question mark box (could be any character (used to be a smiley face in win 7)) is its own thread keeping track of its own coordinates. Each thread shares the screenmutex by kinda waiting in line for ownership of it. When the thread gains control it updates the screen, then releases the mutex for the next thread. First I wrote it in pure autoit to confirm all working as expected. The Console functions actually threw me for a loop. They actual want the whole value of the coord structs and not a ptr to it so that "struct" without a * was a little uncommon. Below au3 code is just the lonely cell bouncing around. Func _BounceAU3() ;set a random starting id. we use this to rotate the colors Local $iMyID = Random(1, 15, 1) Local $tMyCell = DllStructCreate('char mc'), $tOldCell = DllStructCreate('char oc') Local $tMyAttrib = DllStructCreate('word ma'), $tOldAttrib = DllStructCreate('word oa') Local $tCoords = DllStructCreate($tagCOORD), $tOld = DllStructCreate($tagCOORD) Local $tDelta = DllStructCreate($tagCOORD) ;Random start and delta values $tCoords.X = Random(0, 119, 1) $tCoords.Y = Random(0, 29, 1) $tDelta.X = Random(-3, 3, 1) $tDelta.Y = Random(-3, 3, 1) ;set character/cell attributes $tMyCell.mc = $iMyID > 16 ? 0x01 : 0x02 ; doesnt seem to make a differnce in windows 10 $tMyAttrib.ma = BitAND($iMyID, 0x0F) ; Set the character color Do ;check the last position values DllCall('kernel32.dll', "bool", "ReadConsoleOutputCharacter", "handle", $g_hStdHandle, "struct*", $tOldCell, "dword", 1, "struct", $tOld, "dword*", 0) DllCall('kernel32.dll', "bool", "ReadConsoleOutputAttribute", "handle", $g_hStdHandle, "struct*", $tOldAttrib, "dword", 1, "struct", $tOld, "dword*", 0) ;if the last postion was this cell, blank/empty the cell. (Otherwise its been taken over by another thread) If ($tOldCell.oc = $tMyCell.mc) And ($tOldAttrib.oa = $tMyAttrib.ma) Then DllCall('kernel32.dll', "bool", "WriteConsoleOutputCharacter", "handle", $g_hStdHandle, "byte*", 0x20, "dword", 1, "struct", $tOld, "dword*", 0) EndIf ;write the current cell DllCall('kernel32.dll', "bool", "WriteConsoleOutputCharacter", "handle", $g_hStdHandle, "struct*", $tMyCell, "dword", 1, "struct", $tCoords, "dword*", 0) DllCall('kernel32.dll', "bool", "WriteConsoleOutputAttribute", "handle", $g_hStdHandle, "struct*", $tMyAttrib, "dword", 1, "struct", $tCoords, "dword*", 0) ;update coords $tOld.X = $tCoords.X $tOld.Y = $tCoords.Y $tCoords.X += $tDelta.X $tCoords.Y += $tDelta.Y ;change directions if we are out of bounds If $tCoords.X < 0 Or $tCoords.X >= 120 Then $tDelta.X *= -1 If $tCoords.Y < 0 Or $tCoords.Y >= 30 Then $tDelta.Y *= -1 Sleep(75) Until GUIGetMsg() = -3 EndFunc ;==>_BounceAU3 From there the that function converted into assembly so we can call as a thread. The only real differences are the extra parameters we passing as a structure and I also generate the random starting values in autoit instead, then pass them to the function. Here is what the main assembly function looks like. I added comments for each peice of code from au3 that we are translating: _('procf _Bounce uses ebx, pParms') ; ; create the local variables _(' locals') _(' BlankCell db 32') ; this first group covers the variables from the original script _(' MyCell db ?') _(' OldCell db ?') _(' MyAtt dw ?') _(' OldAtt dw ?') _(' tCoords COORD') _(' tDelta COORD') _(' tOld COORD') _(' bytesread dw ?') ; _(' iMyID dw ?') ; this group of local vars cover holding all the other paramerters we are passing in tParms _(' g_hScreenMutex dd ?') _(' g_hRunMutex dd ?') _(' g_hStdHandle dd ?') _(' pfWaitForSingleObject dd ?') _(' pfReleaseMutex dd ?') _(' pfReadChar dd ?') _(' pfReadAttr dd ?') _(' pfWriteChar dd ?') _(' pfWriteAttr dd ?') _(' endl') ; ;all of these push/pops are to transfer the rest of variables from tParms structure to the local variables we created ;first mov the structure address into ebx _(' mov ebx, [pParms]') ; ; now push and pop the values into the variables ; use _winapi_displaystruct() to view all the offsets being used in the [ebx+offset] lines _(' pushw [ebx]') ; _(' popw word[tCoords+COORD.X]') _(' pushw word[ebx+2]') ; _(' popw word[tCoords+COORD.Y]') _(' pushw word[ebx+4]') ; _(' popw word[tDelta+COORD.X]') _(' pushw word[ebx+6]') ; _(' popw word[tDelta+COORD.Y]') _(' pushw word[ebx+8]') ; _(' popw word[iMyID]') _(' push dword[ebx+12]') ; _(' pop dword[g_hScreenMutex]') _(' push dword[ebx+16]') ; _(' pop dword[g_hRunMutex]') _(' push dword[ebx+20]') ; _(' pop dword[g_hStdHandle]') _(' push dword[ebx+24]') ; _(' pop dword[pfWaitForSingleObject]') _(' push dword[ebx+28]') ; _(' pop dword[pfReleaseMutex]') _(' push dword[ebx+32]') ; _(' pop dword[pfReadChar]') _(' push dword[ebx+36]') ; _(' pop dword[pfReadAttr]') _(' push dword[ebx+40]') ; _(' pop dword[pfWriteChar]') _(' push dword[ebx+44]') ; _(' pop dword[pfWriteAttr]') _('.if word[iMyID] > 16') ; $tMyCell.mc = $iMyID > 16 ? 0x01 : 0x02 (no difference in windows 10) _(' mov word[MyCell], 1') _('.else') _(' mov word[MyCell], 2') _('.endif') ; _('pushw word[iMyID]') ; $tMyAttrib.ma = BitAND($iMyID, 0x0F) _('popw word[MyAtt]') _('and word[MyAtt], 15') ; _('.repeat') ; do ; ; Wait infinetly for the screen mutex to be available, then take ownership _(' invoke pfWaitForSingleObject, [g_hScreenMutex], -1') ; ; DllCall('kernel32.dll', "bool", "WriteConsoleOutputCharacter", "handle", $hStdHandle, "byte*", 0x20, "dword", 1, "struct", $tOld, "dword*", 0) _(' invoke pfReadChar, [g_hStdHandle], addr OldCell, 1, dword[tOld], addr bytesread') ; _(' invoke pfReadAttr, [g_hStdHandle], addr OldAtt, 1, dword[tOld], addr bytesread') ; ; _(' mov al, byte[MyCell]') ;If ($tOldCell.oc = $tMyCell.mc) And ($tOldAttrib.oa = $tMyAttrib.ma) Then _(' mov cl, byte[MyAtt]') _(' .if (byte[OldCell] = al) & (byte[OldAtt] = cl)') _(' invoke pfWriteChar, [g_hStdHandle], addr BlankCell, 1, dword[tOld], addr bytesread') _(' .endif') ; ; DllCall('kernel32.dll', "bool", "WriteConsoleOutputCharacter", "handle", $hStdHandle, "struct*", $tMyCell, "dword", 1, "struct", $tCoords, "dword*", 0) _(' invoke pfWriteChar, [g_hStdHandle], addr MyCell, 1, dword[tCoords], addr bytesread') _(' invoke pfWriteAttr, [g_hStdHandle], addr MyAtt, 1, dword[tCoords], addr bytesread') ; _(' pushw word[tCoords+COORD.X]') ;$tOld.X = $tCoords.X _(' popw word[tOld+COORD.X]') ; _(' pushw word[tCoords+COORD.Y]') ;$tOld.Y = $tCoords.Y _(' popw word[tOld+COORD.Y]') _(' mov ax, word[tDelta+COORD.X]') ; $tCoords.X += $tDelta.X _(' add word[tCoords+COORD.X], ax') ; _(' mov ax, word[tDelta+COORD.Y]') ; $tCoords.Y += $tDelta.Y _(' add word[tCoords+COORD.Y], ax') ; ; If $tCoords.X < 0 Or $tCoords.X >= 120 Then $tDelta.X *= -1 _(' .if (word[tCoords+COORD.X] < 0 | word[tCoords+COORD.X] >= 120)') _(' neg word[tDelta+COORD.X]') _(' .endif') _(' .if (word[tCoords+COORD.Y] < 0 | word[tCoords+COORD.Y] >= 30)') _(' neg word[tDelta+COORD.Y]') _(' .endif') ; ; release the screen mutex _(' invoke pfReleaseMutex, [g_hScreenMutex]') ; ; wait 100 ms for the Runmutex to be available. _(' invoke pfWaitForSingleObject, [g_hRunMutex], 100') ; ; a return of 258 means it timed out waiting and that the run mutex (owned by the main autoit thread) is still alive. ; when the run mutex handle gets closed this will return a fail or abandonded. _('.until eax <> 258') ; ;exit thread _(' ret') _('endp') And finally how we call that assembled function from autoit to create the theads: ;create mutex for sharing the screen thats not owned by main thread Global $g_hScreenMutex = _WinAPI_CreateMutex('', False) ; ;create mutex that tells the threads to exit that is owned by main thread Global $g_hRunMutex = _WinAPI_CreateMutex('', True) ... ... ;assemble function Local $tBinExec = _fasmg_Assemble($g_sFasm, False) ;Local $tBinExec = _fasmg_CompileAu3($g_sFasm) If @error Then Exit (ConsoleWrite($tBinExec & @CRLF)) ;this is struct is for all the values Im passing to the thread. ;this will hold are random start x,y,delta values, handles, and pointers to functions called within the thread $tParms = DllStructCreate('short start[4];word myid;dword hands[3];ptr funcs[6]') $tParms.start(1) = Random(0, 119, 1) $tParms.start(2) = Random(0, 29, 1) $tParms.start(3) = Random(-3, 3, 1) $tParms.start(4) = Random(-3, 3, 1) $tParms.myid = 1 $tParms.hands(1) = $g_hScreenMutex $tParms.hands(2) = $g_hRunMutex $tParms.hands(3) = $g_hStdHandle $tParms.funcs(1) = _GPA('kernel32.dll', 'WaitForSingleObject') $tParms.funcs(2) = _GPA('kernel32.dll', 'ReleaseMutex') $tParms.funcs(3) = _GPA('kernel32.dll', 'ReadConsoleOutputCharacterA') $tParms.funcs(4) = _GPA('kernel32.dll', 'ReadConsoleOutputAttribute') $tParms.funcs(5) = _GPA('kernel32.dll', 'WriteConsoleOutputCharacterA') $tParms.funcs(6) = _GPA('kernel32.dll', 'WriteConsoleOutputAttribute') ;create 128 threads with different start values and colors for each one For $i = 1 To 128 $tParms.myid = $i $tParms.start(1) = Random(0, 119, 1) $tParms.start(2) = Random(0, 29, 1) $tParms.start(3) = Random(-3, 3, 1) $tParms.start(4) = Random(-3, 3, 1) If $tParms.start(3) + $tParms.start(4) = 0 Then $tParms.start(3) = (Mod(@MSEC, 2) ? 1 : -1) ; adjusting non-moving (0,0) delta values.. DllCall("kernel32.dll", "hwnd", "CreateThread", "ptr", 0, "dword", 0, "struct*", $tBinExec, "struct*", $tParms, "dword", 0, "dword*", 0) Sleep(50) Next MsgBox(262144, '', '128 Threads Created') ;Close the run mutex handle. This will cause all the threads to exit _WinAPI_CloseHandle($g_hRunMutex) _WinAPI_CloseHandle($g_hScreenMutex) MsgBox(262144, '', 'Mutex handles closed. All Threads should have exited') Exit The attachment below contains both the compiled and source assembly. To play with the assembly source you need to add the fasmg udf in my sig. The compiled version should not need anything. Let me know if you have any issues. Special thanks to @trancexx for teaching me this with her clock example Bounce.zip1 point
-
AutoUpdate
KeeperOfTheReaper reacted to Luigi for a topic
Greetings... Yes... I know... Have a lot fo autoupdate's scripts... But I made one with two special options, not writed yet... self-update (ok) self install from any location (ok) run only in work folder (ok) check self version from repository (not ready) update all dependents files and check md5 file and/or version (not ready) work with remote drive (mount/unmount) (not ready) Tips... Create a folder: C:\Repository Save the scripts in folder C:\Repository Compile app.au3 Run from C:\Repository Close app.exe Copy to another folder... Run app.exe Recompile app.exe again... Re-run app.exe again... The script always run from C:\ProgramData\Luigi\app.exe... with the last version... AutoUpdate.au3 app.au31 point -
Version 1.2
29,306 downloads
I wrote an introductory text for new programmers to learn how to code using AutoIt. It follows along with the help file for the most part – but provides additional context and attempts to connect all the information in a cohesive way for someone without any programming experience. I find the help file to be an AMAZING resource and the text I wrote in no way reflects any opinion to the contrary. Rather, it was created from the perspective of someone who struggled early on with the most basic concepts and thought that a hand-holding guide could be useful. I was also inspired by code.org who is trying to encourage people to learn to code. I thought – what better way than to use free tools that you can download at any time with access to an amazing community? If only there was a guide to walk people through it … Full discussion about the file can be found here: https://www.autoitscript.com/forum/topic/174205-introductory-learn-to-program-text-using-au3/1 point -
newniman, The problem was that you had not correctly set the position of the ListView within the GUI - see line #55 of this amended script: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <File.au3> #include <GuiListView.au3> Global $hGUI, $hListview, $aHit[2] = [-1, -1] ; $aHit contains row & col of marked cell Local $PIPEFILE = "edit-zoom_step_av_value.csv" Local $aRetArray _FileReadToArray($PIPEFILE, $aRetArray, $FRTA_NOCOUNT);, "|") ; As the delimiters are already "!" why bother to split the lines? <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $hGUI = GUICreate("Mark Cell in Listview", 1040, 590) Local $cListview = GUICtrlCreateListView("Zoom Step|F3.4|F4.0|F4.5|F5.0|F5.6|F6.3|F7.1|F8.0", 24, 100, 472, 300, $LVS_REPORT, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT)) $hListview = GUICtrlGetHandle($cListview) GUICtrlSetFont($cListview, 8, 800, 0, "MS Sans Serif") For $x = 0 To UBound($aRetArray, $UBOUND_ROWS) - 1 ; As the "|" are already in place, this is much easier to write! <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< GUICtrlCreateListViewItem($aRetArray[$x], $cListview) Next Local $cButton = GUICtrlCreateButton("Value?", 150, 430, 70, 20) GUISetState(@SW_SHOW) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY"); good tutorial @ https://www.autoitscript.com/wiki/Tutorial_GUIRegisterMsg While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cButton MsgBox(0, "Info", "Cell selected: " & _GUICtrlListView_GetItemText($hListview, $aHit[0], $aHit[1]) & @CR, 0, $hGUI) ;MsgBox(0, "Info", "zoom_step selected: " & $aHit[0] & " --> Aperture column selected: " & $aHit[1], 0, $hGUI) EndSwitch WEnd Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam ; Used by au3check to tell it not to report on "variable not used" when using the parameter "-w 5" - Correct <<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Local $tNMHDR, $hWndFrom, $iCode $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hListview Switch $iCode Case $LVN_ITEMCHANGED Local $tNMLISTVIEW, $iItem, $aInfo $tNMLISTVIEW = DllStructCreate($tagNMLISTVIEW, $lParam) $iItem = DllStructGetData($tNMLISTVIEW, "Item") _GUICtrlListView_SetItemSelected($hListview, $iItem, False) Local $aInfo = GUIGetCursorInfo($hGUI) If $aInfo[2] Then $aInfo = _GUICtrlListView_SubItemHitTest($hListview, $aInfo[0] - 24, $aInfo[1] - 100) ; Upper left position of ListView within GUI - so must match actual position If $aInfo[0] > -1 And $aInfo[1] > -1 And $aInfo[0] = $iItem Then If $aHit[0] > -1 Then _GUICtrlListView_RedrawItems($hListview, $aHit[0], $aHit[0]) If $aHit[0] <> $aInfo[0] Or $aHit[1] <> $aInfo[1] Then $aHit[0] = $aInfo[0] ; Row $aHit[1] = $aInfo[1] ; Col Else $aHit[0] = -1 ; Row $aHit[1] = -1 ; Col EndIf _GUICtrlListView_RedrawItems($hListview, $iItem, $iItem) EndIf EndIf Case $NM_CUSTOMDRAW Local $tNMLVCUSTOMDRAW = DllStructCreate($tagNMLVCUSTOMDRAW, $lParam) Local $dwDrawStage = DllStructGetData($tNMLVCUSTOMDRAW, "dwDrawStage") Switch $dwDrawStage ; Holds a value that specifies the drawing stage Case $CDDS_PREPAINT ; Before the paint cycle begins Return $CDRF_NOTIFYITEMDRAW ; Notify the parent window of any ITEM-related drawing operations Case $CDDS_ITEMPREPAINT ; Before painting an item Return $CDRF_NOTIFYSUBITEMDRAW ; Notify the parent window of any SUBITEM-related drawing operations Case BitOR($CDDS_ITEMPREPAINT, $CDDS_SUBITEM) ; Before painting a subitem Local $dwItemSpec = DllStructGetData($tNMLVCUSTOMDRAW, "dwItemSpec") ; Item index Local $iSubItem = DllStructGetData($tNMLVCUSTOMDRAW, "iSubItem") ; Subitem index Local $uItemState = DllStructGetData($tNMLVCUSTOMDRAW, "uItemState") ; Item state If $dwItemSpec = $aHit[0] Then ; Marked row Switch $iSubItem Case $aHit[1] ; Marked column DllStructSetData($tNMLVCUSTOMDRAW, "ClrText", 0xFFFFFF) ; Forecolor white DllStructSetData($tNMLVCUSTOMDRAW, "clrTextBk", 0xCC6600) ; Backcolor dark blue, BGR Case Else ; Other columns DllStructSetData($tNMLVCUSTOMDRAW, "ClrText", 0x000000) ; Forecolor black DllStructSetData($tNMLVCUSTOMDRAW, "ClrTextBk", 0xFFFFFF) ; Backcolor white EndSwitch Else ; Other rows DllStructSetData($tNMLVCUSTOMDRAW, "ClrText", 0x000000) DllStructSetData($tNMLVCUSTOMDRAW, "ClrTextBk", 0xFFFFFF) EndIf Return $CDRF_NEWFONT ; $CDRF_NEWFONT must be returned after changing font or colors EndSwitch EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY I also removed most of the include files (which were not all necessary) and cleaned up the _FileReadToArray code which makes creating the ListView items much easier. M231 point
-
Good coding practices in AutoIt
pixelsearch reacted to this-is-me for a topic
The way that has worked for me is totally using Enum and Arrays. The only "problem" with my method is that you have to declare the enum values globally (which for some reason a few don't want to do). I've even begun to use them to help me describe built-in functions. Example: Enum $fontFace, $fontWeight, $fontSize, _ $fontMax Global $font[$fontMax] Example() Func Example() $font[$fontFace] = "Tahoma" $font[$fontWeight] = "Bold" $font[$fontSize] = 8.5 MsgBox(0, "", GetFontWeight()) EndFunc Func GetFontWeight() Return $font[$fontWeight] EndFunc Example with built-in function: Enum $posLeft, $posTop, $posWidth, $posHeight MsgBox(0,"",GetPosition("Untitled - Notepad")[$posLeft]) Func GetPosition($title) Return WinGetPos($title) EndFunc1 point -
Good coding practices in AutoIt
pixelsearch reacted to guinness for a topic
Someone who cares about learning and incidentally my first post is called "Why using Dim over Local/Global is not always a good option:".1 point -
Good coding practices in AutoIt
pixelsearch reacted to AZJIO for a topic
The use of local variables in the global scope only confuses1 point -
Good coding practices in AutoIt
pixelsearch reacted to BrewManNH for a topic
In this instance I think he's wrong. As I said before, it's not local to the current scope, because AutoIt doesn't have that kind of scoping, it's a global variable and calling it something else doesn't make any sense.1 point -
Software Installer
abberration reacted to Chimaera for a topic
Its a nice piece of code and a usefull tool Many Thanks1 point