chelo32 Posted January 24, 2022 Share Posted January 24, 2022 Help I go to those who know, I've been thinking about it for a long time, I have problems with this code that I can't get to change the image according to what I read in a registry chain, I already tried with swich and it didn't work, I don't know what to do From already thank you very much expandcollapse popup#include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Local $img1 = @ScriptDir & "\Gigabyte.jpg" Local $img2 = @ScriptDir & "\Biostar.jpg" Local $img3 = @ScriptDir & "\Intel_inside.jpg" Local $img4 = @ScriptDir & "\Lenovo.jpg" Local $img5 = @ScriptDir & "\MSI.jpg" Local $img6 = @ScriptDir & "\AsRock.jpg" Local $img7 = @ScriptDir & "\asus.jpg" Local $img8 = @ScriptDir & "\Intel.jpg" Local $img9 = @ScriptDir & "\amd.jpg" $objWMIService = objget("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2") $colCPU = $objWMIService.ExecQuery("Select * from CIM_Processor") For $object in $colCPU $CPU1 = StringStripWS($object.Name,1) Next Local $Mother0 = RegRead("HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\BIOS", "BaseBoardManufacturer") #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 862, 437, 814, 393) $Pic1 = GUICtrlCreatePic("", 664, 32, 153, 105) $Pic2 = GUICtrlCreatePic("", 672, 168, 161, 105) $Pic3 = GUICtrlCreatePic("", 672, 312, 145, 97) $Label2 = GUICtrlCreateLabel($Mother0, 24, 96, 500, 17) $Label3 = GUICtrlCreateLabel($CPU1, 24, 144, 500, 17) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### if GUICtrlRead ($Mother0) = "Gigabyte" Then GUICtrlSetImage($Pic2, $img1) ElseIf GUICtrlRead ($Mother0) = "Biostar" Then GUICtrlSetImage($Pic2, $img2) Elseif GUICtrlRead ($Mother0) = "Intel" Then GUICtrlSetImage($Pic2, $img3) Elseif GUICtrlRead ($Mother0) = "Lenovo" Then GUICtrlSetImage($Pic2, $img4) Elseif GUICtrlRead ($Mother0) = "MSI" Then GUICtrlSetImage($Pic2, $img5) Elseif GUICtrlRead ($Mother0) = "AsRock" Then GUICtrlSetImage($Pic2, $img6) Elseif GUICtrlRead ($Mother0) = "asus" Then GUICtrlSetImage($Pic2, $img7) EndIf if GUICtrlRead ($CPU1) = "AMD" Then GUICtrlSetImage($Pic1, $img9) ElseIf GUICtrlRead ($CPU1) = "Intel" Then GUICtrlSetImage($Pic1, $img8) EndIf While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Link to comment Share on other sites More sharing options...
ad777 Posted January 24, 2022 Share Posted January 24, 2022 (edited) chelo GuiCtrlRead:Read state or data of a control just replace: GuiCtrlRead with $Mother0 Edited January 24, 2022 by ad777 iam ِAutoit programmer. best thing in life is to use your Brain to Achieve everything you want. Link to comment Share on other sites More sharing options...
Nine Posted January 24, 2022 Share Posted January 24, 2022 (edited) That is working well for me : #include <GUIConstants.au3> Example() Func Example() GUICreate("Test") $Pic1 = GUICtrlCreatePic("", 10, 10, 100, 100) GUISetState(@SW_SHOW) GUICtrlSetImage($Pic1, "Check.bmp") Sleep(5000) GUICtrlSetImage($Pic1, "Torus.jpg") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd EndFunc ;==>Example Maybe the path of the file ( or file name ) is wrong. edit : @ad777 Nailed it ... Edited January 24, 2022 by Nine “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
chelo32 Posted January 25, 2022 Author Share Posted January 25, 2022 20 hours ago, ad777 said: chelo GuiCtrlRead:Read state or data of a control just replace: GuiCtrlRead with $Mother0 it gives me expression error Link to comment Share on other sites More sharing options...
Nine Posted January 25, 2022 Share Posted January 25, 2022 Provide the script “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
chelo32 Posted January 25, 2022 Author Share Posted January 25, 2022 20 hours ago, Nine said: That is working well for me : #include <GUIConstants.au3> Example() Func Example() GUICreate("Test") $Pic1 = GUICtrlCreatePic("", 10, 10, 100, 100) GUISetState(@SW_SHOW) GUICtrlSetImage($Pic1, "Check.bmp") Sleep(5000) GUICtrlSetImage($Pic1, "Torus.jpg") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd EndFunc ;==>Example Maybe the path of the file ( or file name ) is wrong. edit : @ad777 Nailed it ... This code changes one after 5 seconds, thank you, it is not what I referred to Link to comment Share on other sites More sharing options...
Nine Posted January 25, 2022 Share Posted January 25, 2022 4 minutes ago, chelo32 said: it gives me expression error I meant the script that gives you that error “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
chelo32 Posted January 25, 2022 Author Share Posted January 25, 2022 3 minutes ago, Nine said: Provide the script expandcollapse popup#include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Local $img1 = @ScriptDir & "\Gigabyte.jpg" Local $img2 = @ScriptDir & "\Biostar.jpg" Local $img3 = @ScriptDir & "\Intel_inside.jpg" Local $img4 = @ScriptDir & "\Lenovo.jpg" Local $img5 = @ScriptDir & "\MSI.jpg" Local $img6 = @ScriptDir & "\AsRock.jpg" Local $img7 = @ScriptDir & "\asus.jpg" Local $img8 = @ScriptDir & "\Intel.jpg" Local $img9 = @ScriptDir & "\amd.jpg" $objWMIService = objget("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2") $colCPU = $objWMIService.ExecQuery("Select * from CIM_Processor") For $object in $colCPU $CPU1 = StringStripWS($object.Name,1) Next Local $Mother0 = RegRead("HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\BIOS", "BaseBoardManufacturer") #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 862, 437, 814, 393) $Pic1 = GUICtrlCreatePic("", 664, 32, 153, 105) $Pic2 = GUICtrlCreatePic("", 672, 168, 161, 105) $Pic3 = GUICtrlCreatePic("", 672, 312, 145, 97) $Label2 = GUICtrlCreateLabel($Mother0, 24, 96, 500, 17) $Label3 = GUICtrlCreateLabel($CPU1, 24, 144, 500, 17) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### if GUICtrlRead ($Mother0) = "Gigabyte" Then GUICtrlSetImage($Pic2, $img1) ElseIf GUICtrlRead ($Mother0) = "Biostar" Then GUICtrlSetImage($Pic2, $img2) Elseif GUICtrlRead ($Mother0) = "Intel" Then GUICtrlSetImage($Pic2, $img3) Elseif GUICtrlRead ($Mother0) = "Lenovo" Then GUICtrlSetImage($Pic2, $img4) Elseif GUICtrlRead ($Mother0) = "MSI" Then GUICtrlSetImage($Pic2, $img5) Elseif GUICtrlRead ($Mother0) = "AsRock" Then GUICtrlSetImage($Pic2, $img6) Elseif GUICtrlRead ($Mother0) = "asus" Then GUICtrlSetImage($Pic2, $img7) EndIf if GUICtrlRead ($CPU1) = "AMD" Then GUICtrlSetImage($Pic1, $img9) ElseIf GUICtrlRead ($CPU1) = "Intel" Then GUICtrlSetImage($Pic1, $img8) EndIf While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Link to comment Share on other sites More sharing options...
Solution Nine Posted January 25, 2022 Solution Share Posted January 25, 2022 Alright, I gonna provide the code : If $Mother0 = "Gigabyte" Then GUICtrlSetImage($Pic2, $img1) ElseIf $Mother0 = "Biostar" Then GUICtrlSetImage($Pic2, $img2) ElseIf $Mother0 = "Intel" Then GUICtrlSetImage($Pic2, $img3) ElseIf $Mother0 = "Lenovo" Then GUICtrlSetImage($Pic2, $img4) ElseIf $Mother0 = "MSI" Then GUICtrlSetImage($Pic2, $img5) ElseIf $Mother0 = "AsRock" Then GUICtrlSetImage($Pic2, $img6) ElseIf $Mother0 = "asus" Then GUICtrlSetImage($Pic2, $img7) EndIf If $CPU1 = "AMD" Then GUICtrlSetImage($Pic1, $img9) ElseIf $CPU1 = "Intel" Then GUICtrlSetImage($Pic1, $img8) EndIf chelo32 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
chelo32 Posted January 26, 2022 Author Share Posted January 26, 2022 16 hours ago, Nine said: Alright, I gonna provide the code : If $Mother0 = "Gigabyte" Then GUICtrlSetImage($Pic2, $img1) ElseIf $Mother0 = "Biostar" Then GUICtrlSetImage($Pic2, $img2) ElseIf $Mother0 = "Intel" Then GUICtrlSetImage($Pic2, $img3) ElseIf $Mother0 = "Lenovo" Then GUICtrlSetImage($Pic2, $img4) ElseIf $Mother0 = "MSI" Then GUICtrlSetImage($Pic2, $img5) ElseIf $Mother0 = "AsRock" Then GUICtrlSetImage($Pic2, $img6) ElseIf $Mother0 = "asus" Then GUICtrlSetImage($Pic2, $img7) EndIf If $CPU1 = "AMD" Then GUICtrlSetImage($Pic1, $img9) ElseIf $CPU1 = "Intel" Then GUICtrlSetImage($Pic1, $img8) EndIf NINE Thank you very much for your solution, as something so simple can drive someone crazy, I leave the modified code. truly THANK YOU expandcollapse popup#include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Local $img1 = @ScriptDir & "\Gigabyte.jpg" Local $img2 = @ScriptDir & "\Biostar.jpg" Local $img3 = @ScriptDir & "\Intel_inside.jpg" Local $img4 = @ScriptDir & "\Lenovo.jpg" Local $img5 = @ScriptDir & "\MSI.jpg" Local $img6 = @ScriptDir & "\AsRock.jpg" Local $img7 = @ScriptDir & "\asus.jpg" Local $img8 = @ScriptDir & "\Intel.jpg" Local $img9 = @ScriptDir & "\amd.jpg" $objWMIService = objget("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2") $colCPU = $objWMIService.ExecQuery("Select * from CIM_Processor") For $object in $colCPU $CPU1 = StringStripWS($object.Name,1) Next Local $Mother0 = RegRead("HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\BIOS", "BaseBoardManufacturer") #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 862, 437, 814, 393) $Pic1 = GUICtrlCreatePic("", 664, 32, 153, 105) $Pic2 = GUICtrlCreatePic("", 672, 168, 161, 105) $Pic3 = GUICtrlCreatePic("", 672, 312, 145, 97) $Label2 = GUICtrlCreateLabel($Mother0, 24, 96, 500, 17) $Label3 = GUICtrlCreateLabel($CPU1, 24, 144, 500, 17) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### $sString_Mother0 = StringLeft($Mother0, 4) If $sString_Mother0 = "Giga" Then GUICtrlSetImage($Pic2, $img1) ElseIf $sString_Mother0 = "Bios" Then GUICtrlSetImage($Pic2, $img2) ElseIf $sString_Mother0 = "Inte" Then GUICtrlSetImage($Pic2, $img3) ElseIf $sString_Mother0 = "Leno" Then GUICtrlSetImage($Pic2, $img4) ElseIf $sString_Mother0 = "MSI" Then GUICtrlSetImage($Pic2, $img5) ElseIf $sString_Mother0 = "AsRo" Then GUICtrlSetImage($Pic2, $img6) ElseIf $sString_Mother0 = "ASUS" Then GUICtrlSetImage($Pic2, $img7) EndIf $sString = StringLeft($CPU1, 3) If $sString = "AMD" Then GUICtrlSetImage($Pic1, $img9) ElseIf $sString = "Int" Then GUICtrlSetImage($Pic1, $img8) EndIf While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Link to comment Share on other sites More sharing options...
Nine Posted January 27, 2022 Share Posted January 27, 2022 One thing that would greatly compact your code is to name your images the same as the value of $Mother0, so you could simply use : GUICtrlSetImage($Pic2, @ScriptDir & "\" & $Mother0 & ".jpg") And the same goes for $CPU1... chelo32 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
chelo32 Posted January 28, 2022 Author Share Posted January 28, 2022 23 hours ago, Nine said: One thing that would greatly compact your code is to name your images the same as the value of $Mother0, so you could simply use : GUICtrlSetImage($Pic2, @ScriptDir & "\" & $Mother0 & ".jpg") And the same goes for $CPU1... Excellent idea, thank you very much you were a great help Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now