
iAmNewbe
Active Members-
Posts
212 -
Joined
Content Type
Forums
Downloads
Forum Articles
Events
Everything posted by iAmNewbe
-
Basically you just put two controls next to each other and color one, one color and another something else. I was writing a question about this on HOW to do this and in the process I figured it out. Since I wrote most of it already I just finished it into a little tutorial for those not already in the know on this. I am sure I will forget this and will need at sometime to rediscover so this is also a tutorial for my future self when I forget. There used to be a tutorial or scripts section in the forums, I am not able to find it or would put it there instead of here. Since it is GUI related I posted to the GUI Help and Support section.
-
Full Code Sample #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <TrayConstants.au3> ; Required for the $TRAY_ICONSTATE_SHOW constant. Opt("TrayMenuMode", 3) ; The default tray menu items will not be shown and items are not checked when selected. These are options 1 and 2 for TrayMenuMode. HotKeySet("{ESC}", "close") Example() Func Example() Global $hGui = GUICreate("Example", 200, 120, -1, -1) GUISetState(@SW_SHOW, $hGui) #Region ;~ Vertical Separator GUICtrlCreateLabel("", 30, 20, 1, 90) ; L T W H GUICtrlSetBKColor(-1, 0xD5DFE5) GUICtrlCreateLabel("", 31, 20, 1, 90) ; L T W H GUICtrlSetBKColor(-1, 0xFFFFFF) #EndRegion #Region ;~ Horizontal Separator GUICtrlCreateLabel("", 32, 40, 150, 1) ; L T W H GUICtrlSetBKColor(-1, 0xD5DFE5) GUICtrlCreateLabel("", 32, 41, 150, 1) ; L T W H GUICtrlSetBKColor(-1, 0xFFFFFF) #EndRegion GUICtrlCreateLabel("Separator Lines Example", 32, 55, 150, 20, $SS_CENTER) ; L T W H Style StyleEX #Region ;~ Horizontal Separator GUICtrlCreateLabel("", 32, 81, 150, 1) ; L T W H GUICtrlSetBKColor(-1, 0xD5DFE5) GUICtrlCreateLabel("", 32, 82, 150, 1) ; L T W H GUICtrlSetBKColor(-1, 0xFFFFFF) #EndRegion #Region ;~ Tray Menu TrayCreateItem("") ; Create a separator line. TrayCreateItem("Separator Lines Example") TrayCreateItem("") ; Create a separator line. #EndRegion Local $idExit = TrayCreateItem("Exit") TraySetState($TRAY_ICONSTATE_SHOW) ; Show the tray menu. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE close() EndSwitch Switch TrayGetMsg() Case $idExit ; Exit the loop. close() EndSwitch WEnd EndFunc ;==>Example Func close() GUIDelete($hGui) Exit EndFunc
-
This may or may not be useful and comes in play if you are not using a UDF or the built-in methods or 3rd party code for creating menus and layouts. I wrote this with the assumption the reader is new to the language and doesn't have a lot of experience yet. Possible Reasons 1: You are writing Gui elements yourself from scratch. Why? because you just desire to. 2: Need for something to work a specific way that the built-in methods do not allow for. 3: You just want a learning exercise. I was trying to figure out how to recreate the separators you see in tray menus with that same style inside a GUI using Label Controls. You know those single lines that separate menu items when you use TrayCreateItem("") ; Create a separator line. See Attached Image Either there is no single GUI control to allow for the exact styling of separator lines seen in the Tray Menu OR I haven't discovered it yet. My solution: The color codes in RGB HEX 0xD5DFE5 ;~ A light blue grey color 0xFFFFFF ;~ Color white When you insert your Label Control leave the "text" part empty and do not use any option flags. Some of the Style and Ex Style options prevent coloring and sizing the control. GUICtrlCreateLabel("", LEFT, TOP, WIDTH, HEIGHT) You need TWO controls and TWO background color settings Horizontal Separator - White Color goes on bottom GUICtrlCreateLabel("", LEFT, TOP, WIDTH, HEIGHT) ;~ Empty Label Control GUICtrlSetBKColor(-1, 0xD5DFE5) ;~ Background Color Setting for previous Label Control GUICtrlCreateLabel("", LEFT, TOP + 1, WIDTH, HEIGHT) ;~ Second Label Control needs to be distanced one away from previous Label Control GUICtrlSetBKColor(-1, 0xFFFFFF) Vertical Separator - White Color is on INSIDE or to the Right of the grey line GUICtrlCreateLabel("", LEFT, TOP, HEIGHT, WIDTH) ;~ Reverse Width and Height GUICtrlSetBKColor(-1, 0xD5DFE5) GUICtrlCreateLabel("", LEFT + 1, TOP, HEIGHT, WIDTH) ;~ Add ONE to the LEFT not the TOP GUICtrlSetBKColor(-1, 0xFFFFFF) This will MATCH the Tray Menu separators in color and look.
-
Thank you for the suggestion. I tried it and it does not work, I am not able to get control of any application that is launched via a chain as described previously. The applications run and operate normally I just can't gain control of them when launched deeper than a first child process. The only solution I have come up with that does work is using a scheduled task to run manually that launches app2.exe. Instead of linking the executable directly from App1, I run the task. It's a work around until some magic happens that I don't have to do that. If these were console applications I would like to try the Run option to start the console app in it's own process but these are not currently. If the parent process MUST also be a console application then it won't work for me anyway.
-
In same situation but NOT web browser I open NotePad++ and try to inject log data into window control with same 3rd party application. Same issue, it won't paste into the text window. When chain loading. I don't know... I wanted to have everything accessible via ONE location, if i run them manually it all works. I just have to click three to four shortcut links. I wanted to click one via my development helper app.
-
App1 runApp2() Func runApp2() ShellExecute('app2.exe') EndFunc While 1 Sleep(30000) Exit WEnd App2 runExe() Func runExe() ShellExecute('chrome.exe', 'https://www.autoitscript.com/forum/topic/208655-is-it-possible-to-start-an-application-in-own-process') EndFunc Exit I don't have an AutoIT script for accessing a text editor or manipulating html, javascript for web development. I use something else. The forum rules from my understanding prevent sharing those things in code, manipulating web pages, forms, drop down options etc... The examples above just duplicate the chaining opening of applications. On my end this application runs until I exit the application but the samples above I just timed App1 to close after 30 seconds. App2 runs then closes. My problem is with access of applications opened by App2 when chain opened by App1 App1 runs App2 App2 runs browser or ide or image editor etc... 3rd Party program fails to access in example above chrome but can also be notepad++ or any other application If I just run App2 by itself this works The "fix" in this situation is to run App2 via a sheduled task set to manual run only Then App1 runs the task task runs App2 I don't know why I have to do this... it shouldn't matter but one way works, one way doesn't.
-
Can't change the Google Chrome window title (app mode)
iAmNewbe replied to SEKOMD's topic in AutoIt General Help and Support
Is this for internal use where you work or for yourself? Does it need to be part of an application that is distributed to users? If this is something you use yourself then you need to create a plugin for chrome and then access that plugin via your autoIT app to inject javascript into the page to make any changes. This is ONE way. Chrome has or did have a developer tool that allowed you to take control of chrome but I think they stopped developing it. You should be able to do an internet search and you will either find the tool in an archive some place or it could still be developed or an alternative to it. When it comes to Chrome or any browser you need a helper to access the internals that you then access in some way externally to command the browser. -
Best practices for function return values
iAmNewbe replied to HurleyShanabarger's topic in AutoIt General Help and Support
You are asking the best way to return values from a function? The best way depends on what you are intending to do with the values after the function does whatever it does. Do you intend to display the value? Insert it into a database or external file of some sort to be used later? Use the output of the function to complete an operation or algorithm? Or you may not even need to return a value and instead just export it within the function. If you are going to pass it to another function for processing or return back to a calling function then you do need to use 'return.' Usually if you are concerned with best practices then modular thinking needs to be used and keep functions to ONE purpose and one purpose only. Not do something THEN also do something else. You do one thing then return the data to somewhere or send the data to another function to do the next thing. You can RETURN or use Global variables when passing values out of a function or send directly to an external file or database. Pretty much what I can think of to answer your question. The variables can be string, numeric, array etc... the type matters to what you are doing with the processing of the value within your application. -
AutoIT 3.3.14.5 / 3.3.15 ------------------------------------- I need to open a chain of applications where one application opens the next one without these becoming child processes. I have looked in the manual but can't find a ready solution. None of these are console applications. The applications open fine but the ability to control or access controls does not seem to work correctly for some 3rd party applications I use. app 1 |-> executable ; Works app 1 | - > app 2 | - > executable ; No access to window controls I have tried running app 2 from app 1 using ShellExecute($app2) ShellExecute($app2) ShellExecute($app2, '', '', 'open') Run($app2) Run(@ComSpec & " /c " & $app2, "", @SW_HIDE) ; Command Prompt All of these open app2 into a child process of app1 and then the final executable is a grand child of app 1. I guess this is what is going on. I just want to open app2 from app1 and have it be it's own thing running in it's own process exactly if it were run by clicking directly on the application exectuable file or shortcut. This chaining of opening applications seems to some how lock or prevent access to controls, via 3rd party applications. I do not know why or how. I just know NOT chaining like this it works and chaining the opening of these executables when one opens another that opens another, access to application controls stop working. It is specific to what I am doing and does not seem to prevent any normal operation. Ideas how to start an application from within an AutoIT application as it's own process without being a child of the parent? -- Due to possible rules violation with description of the exact situation I find things not working I have rewrote this post to be generic.
-
I created a new compiler directive. It works though the color in the au3 file is not changing in Scite. I have looked in every file having to do with this and I can not find where the coloring occurs. How can I associate this new directive to the same color as the rest of the directives? The new directive temporarily removes some console writes from the normal output to minimize scrolling and adds spacing lines for easy reading of output my scripts create. The color is not being matched though, I am not sure where this occurs. I just want the color to match the built-in directives. Anyone that can share how to do this? I am using the full AutoIT version of Scite 4.12 with AutoIT 3.3.14.5
-
Screen Capture causing CPU Spikes
iAmNewbe replied to iAmNewbe's topic in AutoIt General Help and Support
I created a Toggle switch to turn on and off the screen capture via the space bar. Doesn't solve the problem but allows for opting to not run or "pause" the screen capture. Global $toggle = 0 HotKeySet("{SPACE}","toggleScreenCap") While 1 If $toggle = 0 Then capture() ;Sleep(40) WEnd Func toggleScreenCap() If $toggle = 1 Then $toggle = 0 ElseIf $toggle = 0 Then $toggle = 1 EndIf EndFunc -
Problem with Getting Color Shades
iAmNewbe replied to iAmNewbe's topic in AutoIt GUI Help and Support
GUICtrlSetBkColor($color_block0, '0x00' & $originalColor) GUICtrlSetBkColor($color_block0, '0x' & $originalColor) In the last code above I see no difference in sending the above to the Label Control for the colors. The first two digits are for the transparency but I see no difference with either version above. I should though, technically. In other code I have written it is important to add the first two 00's.. some controls you have to use FF's I guess the transparency values are reversed on some controls? But if you do this GUICtrlSetBkColor($color_block0, $originalColor) Color is WAY off. Interesting experiment results. -
Problem with Getting Color Shades
iAmNewbe replied to iAmNewbe's topic in AutoIt GUI Help and Support
$shadeV = 0.15 works well Nice! -
Problem with Getting Color Shades
iAmNewbe replied to iAmNewbe's topic in AutoIt GUI Help and Support
#AutoIt3Wrapper_Au3Check_Parameters=-q -d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7 #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Array.au3> #include <Color.au3> #include <ColorConstants.au3> HotKeySet("{ESC}","close") #Region GUI Create Global $GUI = GUICreate("", 570, 165, -1, -1, $WS_BORDER) Global $color_block0 = GUICtrlCreateLabel('', 10, 20, 100, 100) Global $color_block1 = GUICtrlCreateLabel('', 120, 20, 100, 100) Global $color_block2 = GUICtrlCreateLabel('', 230, 20, 100, 100) Global $color_block3 = GUICtrlCreateLabel('', 340, 20, 100, 100) Global $color_block4 = GUICtrlCreateLabel('', 450, 20, 100, 100) GUISetState(@SW_SHOW) #EndRegion GUI Create Global $CR, $CB, $CG Func getColor() Local $getMPos, $originalColor Local $shade[5], $shadeV Local $rgb ;~ Get Color $getMPos = MouseGetPos() $originalColor = Hex(PixelGetColor($getMPos[0], $getMPos[1]), 6) $rgb = _ColorGetRGB('0x' & $originalColor) ;~ Get Color Shades $shadeV = 0.2 $shade[0] = calcRGB($rgb[0], $rgb[1], $rgb[2], $shadeV) For $i = 1 To 4 Step 1 $shade[$i] = calcRGB($CR, $CG, $CB, $shadeV) Next ;~ Apply Color Shades GUICtrlSetBkColor($color_block0, '0x00' & $originalColor) GUICtrlSetBkColor($color_block1, '0x00' & $shade[1]) GUICtrlSetBkColor($color_block2, '0x00' & $shade[2]) GUICtrlSetBkColor($color_block3, '0x00' & $shade[3]) GUICtrlSetBkColor($color_block4, '0x00' & $shade[4]) EndFunc ;==>getColor Func CalcRGB($r, $g, $b, $shade) $CR = $r + int((255-$r) * $shade) $CG = $g + int((255-$g) * $shade) $CB = $b + int((255-$b) * $shade) If $CR > 255 Then $CR = 255 If $CG > 255 Then $CG = 255 If $CB > 255 Then $CB = 255 If $CR < 0 Then $CR = 0 If $CG < 0 Then $CG = 0 If $CB < 0 Then $CB = 0 Return Hex($CR, 2) & Hex($CG, 2) & Hex($CB, 2) EndFunc ;==>CalcRGB While 1 getColor() Sleep(150) WEnd Func close() Exit EndFunc Variation on Dan_555 code, converted to the code I wrote above with getting color under mouse pointer. This seems to work Dan_555. I like your Do It button that makes lighter and lighter shades... Nice! At first glance Pure White 255, 255, 255 OR #FFFFFF does not give shades but I did not console write the shades color. Slight variation off of PURE White does give shades.. I like this.. is a nice proof of concept. Thank you Dan_555. -
Screen Capture causing CPU Spikes
iAmNewbe replied to iAmNewbe's topic in AutoIt General Help and Support
I opened Task Manager and looked at the Processes tab. Comparing your version to the original I don't see any change in the CPU column or how often it jumps to 01 for the process. I compiled it out to EXE and watched that. Also switching to the Performance Tab you see the increase activity everytime the capture() function runs. I don't know. Maybe it is not fixable in this use case? I can survive it, where I will be using this won't be active for very long so it won't be a long term stress, just when needing to see what is directly under the cursor. Like a Color, or for absolute positioning an element say on a web page, or setting points between locations on a screen for comparing distance or whatever. Thanks for your help. -
Problem with Getting Color Shades
iAmNewbe replied to iAmNewbe's topic in AutoIt GUI Help and Support
I will look at your playing with the code next. Dan_555 Thanks. -
Problem with Getting Color Shades
iAmNewbe replied to iAmNewbe's topic in AutoIt GUI Help and Support
I cleaned up the code and put the color pick and shading in a function Based off of Shark007's code. Also set the color pick to the position of the mouse pointer for easy testing. #AutoIt3Wrapper_Au3Check_Parameters=-q -d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7 #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Array.au3> #include <Color.au3> #include <ColorConstants.au3> HotKeySet("{ESC}","close") #Region GUI Create Global $GUI = GUICreate("", 570, 165, -1, -1, $WS_BORDER) Global $color_block0 = GUICtrlCreateLabel('', 10, 20, 100, 100) Global $color_block1 = GUICtrlCreateLabel('', 120, 20, 100, 100) Global $color_block2 = GUICtrlCreateLabel('', 230, 20, 100, 100) Global $color_block3 = GUICtrlCreateLabel('', 340, 20, 100, 100) Global $color_block4 = GUICtrlCreateLabel('', 450, 20, 100, 100) GUISetState(@SW_SHOW) #EndRegion GUI Create Func getColor() Local $getMPos, $originalColor Local $shade[5], $shadeV Local $rgb, $redDec, $greenDec, $blueDec $getMPos = MouseGetPos() $originalColor = Hex(PixelGetColor($getMPos[0], $getMPos[1]), 6) $rgb = _ColorGetRGB('0x00' & $originalColor) ;~ Color Shades $shadeV = 30 For $i = 1 To 4 Step 1 $redDec = Dec($rgb[0]) + $shadeV $greenDec = Dec($rgb[1]) + $shadeV $blueDec = Dec($rgb[2]) + $shadeV $shade[$i] = Hex($redDec, 2) & Hex($greenDec, 2) & Hex($blueDec, 2) $shadeV += 30 Next ;~ End Color Shades GUICtrlSetBkColor($color_block0, '0x00' & $originalColor) GUICtrlSetBkColor($color_block1, '0x00' & $shade[1]) GUICtrlSetBkColor($color_block2, '0x00' & $shade[2]) GUICtrlSetBkColor($color_block3, '0x00' & $shade[3]) GUICtrlSetBkColor($color_block4, '0x00' & $shade[4]) EndFunc While 1 getColor() Sleep(50) WEnd Func close() Exit EndFunc This seems to mostly work with Darker colors. Lighter colors don't do well with the shading. -
Screen Capture causing CPU Spikes
iAmNewbe replied to iAmNewbe's topic in AutoIt General Help and Support
Still not sure about the CPU Spiking though.. Has to do with the GDI+ ??? -
Screen Capture causing CPU Spikes
iAmNewbe replied to iAmNewbe's topic in AutoIt General Help and Support
Will look at the links, thank you. The Screenshot example above does update on the fly via a loop and capturing around the mouse pointer so maybe it does need it? I don't know. -
How can Parse JSON / XML with vanilla AutoIT?
iAmNewbe replied to iAmNewbe's topic in AutoIt General Help and Support
Thank you for being helpful. -
Screen Capture causing CPU Spikes
iAmNewbe replied to iAmNewbe's topic in AutoIt General Help and Support
Local $hScrn1 = _ScreenCapture_Capture("", $getMPos[0] - 80, $getMPos[1] - 80, $getMPos[0] + 80, $getMPos[1] + 80, False) Local $cap1 = _GDIPlus_BitmapCreateFromHBITMAP($hScrn1) _GDIPlus_GraphicsDrawImage($gObj, $cap1, 180, 20) _GDIPlus_GraphicsDrawImage($gObj, $cap1, 180, 20) In this example... Is this double buffering? You said one gets drawn to then the other received the finished drawing. But the above is just drawing over the other simultaneously. I thought that the "Buffer" was stored in memory and used like a temporary cache. I am not understanding this yet. -
Screen Capture causing CPU Spikes
iAmNewbe replied to iAmNewbe's topic in AutoIt General Help and Support
In my code example there is no flickering so I don't need to use double buffering in my use case? I am looking for way to reduce the CPU spiking. -
How can Parse JSON / XML with vanilla AutoIT?
iAmNewbe replied to iAmNewbe's topic in AutoIt General Help and Support
I do not want to use one that is already written. I was looking for some guidance on starting this that others here may be aware of though I do not want to use something already completed. I have enough file parsing experience to figure it out. I prefer to come up with my own solution though I am not sure of a starting approach. Have you ever just wanted to write something to see if you can do it and help you understand things better? I want to learn by doing and not have something done by others that may have their own approach. I call it being creative. I have never parsed JSON / XML using AutoIT.. I have done it with other languages that have built-in methods to do that. AutoIT does not seem to have this, I am not sure where to start. I am searching other places for ideas. I may post results of what I am doing depending on rudeness level of responses. Thank you for your concern.