Jump to content
Sign in to follow this  
MyEarth

Help me to convert a C code

Recommended Posts

MyEarth

Hello,

There is a way o someone for convert this to autoit? It's only a few lines

std::wcout << "Ready"; 
        _iconParentHwnd = FindWindow(_T("Shell_TrayWnd"), NULL); 
        _iconHwnd = FindWindowEx(_iconParentHwnd, NULL, _T("Start"), NULL); 
        LRESULT _iconHdl = SendMessage(_iconHwnd, WM_CLOSE, NULL, NULL); 
        signed int _reVal = static_cast<int>(_iconHdl); 
        if (_reVal == 0)
        {
            std::wcout << "\n\succes"; 
        }
        else
            {
                std::wcout << "\n\nFailed Error: " << GetLastError() << ")";
                std::getwchar();
            }
        }
                     endif

I have see there in autoit:

_WinAPI_FindWindow

_SendMessage

But i don't have understand that _T(), NULL i think is = "" but we don't have a function called FindWindowEx

Thanks for help to archivie this ;)

Edited by MyEarth

Share this post


Link to post
Share on other sites
FireFox

Hi,

FindWindow is WinGetHandle in autoit.

WinGetHandle("[CLASS:Shell_TrayWnd]")

Br, FireFox.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
martin

I think it would translate to something like this but whether the logic of the code is correct I can't say.

#include <WindowsConstants.au3>
#include <SendMessage.au3>

$iconParentHwnd = WinGetHandle("Shell_TrayWnd");
$iconHwnd = WinGetHandle($iconParentHwnd, "start"); must not have upper case 's' if you're looking for the 'start' button?
$iconHdl = _SendMessage($iconHwnd, $WM_CLOSE);

If ($iconHdl = 0) Then
    MsgBox(262144, "Result", "Success!")
Else
    MsgBox(262144, "Result", "Failed!")
EndIf
 
Edited by martin

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites
MyEarth

Well, the code give me "Success" but not the expected result. I want to hide the orb of Windows 7. i have try many method, always failed:

ControlCommand
ControlHide
 _WinAPI_ShowWindow

There are plenty of example in C#, but i'm not very good to convert it ( and before this post i have try it, lost hours for try to do the same ) like:

Link 1 ( check the comment of Simon B. 22-Aug-12 11:34 for hide only the orb )

Link 2

The taskbar in his "totally" is easy to hide with Autoit, the orb not. Thanks guys for the help, i'll really apprecciate it :D

Edited by MyEarth

Share this post


Link to post
Share on other sites
FireFox

and... I can see in a link you provided that the orb is still visible but the taskbar is hidden.

Actually, there is an orb on the taskbar and a hover orb, you can either hide this hover orb or hide the taskbar and its orb.

Br, FireFox.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
MyEarth

and... I can see in a link you provided that the orb is still visible but the taskbar is hidden.

Actually, there is an orb on the taskbar and a hover orb, you can either hide this hover orb or hide the taskbar and its orb.

Br, FireFox.

 

There are software can hide it:

Start Killer

and

Start Orb Mover ( P.S There are 2 exe's in Start Orb MoverAppFiles, HideIt and ShowIt and both work )

So:

If the question is: Is Possible to hide only the orb? The answer is Yes

If the question is: How? Then answer is: I don't know :D

Jocking apart, i'll continue the research but if you guys have an idea please post it

I'm guessing you don't even know if that c code works.

 

You have right, but in part. I have tested both codes and they hide completely the taskbar, but i think can be "edit" for hide only the orb, the problem is i don't know C-C# so i don't know how to start

 

Edited by MyEarth

Share this post


Link to post
Share on other sites
MyEarth

Another code but in VB6, untested because i can't find any trial of VB6, but from the word of the author "seems" work

'**************************************
' Name: Hide - Show the "Start" Button windows Vista and 7
' Description: Knowledge belongs to all.
' Wherever you look on the internet you can not find how to do hide
' the "Start Button" and "Shell tray" on windows Vista and 7 do not find a solution other than "startkiller"
' The following code solves the problem.
' By: Diomidis
'
'
' Inputs:None
'
' Returns:None
'
' Assumes:None
'
' Side Effects:None
' This code is copyrighted and has limited warranties
' Please see http://www.Planet-Source-Code.com/xq/ASP/txtCodeId.74343/lngWId.1/qx/vb/scripts/ShowCode.htm
' for details.
'**************************************

Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long

Public Declare Function ShowWindow Lib "user32.dll" (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long

Public Function ShowTaskbar(ByVal IsLock As Boolean)
    If IsLock = False Then
        ShowWindow FindWindow("shell_traywnd", vbNullString), 1
        'only Vista-7
        ShowWindow FindWindowEx(FindWindow("Desktop", ""), 0, "Button", vbNullString), 1
    Else
        ShowWindow FindWindow("shell_traywnd", vbNullString), 0
        'only Vista-7
        ShowWindow FindWindowEx(FindWindow("Desktop", ""), 0, "Button", vbNullString), 0
    End If
End Function

If someone what to check it out i'll appreciate

Share this post


Link to post
Share on other sites
FireFox

#include <WinAPIEx.au3>
 
ShowTaskbar(True)
 
Func ShowTaskbar($fIsLock)
    If $fIsLock = False Then
        _WinAPI_ShowWindow(_WinAPI_FindWindow("shell_traywnd", ""), 1)
        ;only Vista-7
        _WinAPI_ShowWindow(_WinAPI_FindWindowEx(_WinAPI_FindWindow("Desktop", ""), 0, "Button", ""), 1)
    Else
        _WinAPI_ShowWindow(_WinAPI_FindWindow("shell_traywnd", ""), 0)
        ;only Vista-7
        _WinAPI_ShowWindow(_WinAPI_FindWindowEx(_WinAPI_FindWindow("Desktop", ""), 0, "Button", ""), 0)
    EndIf
EndFunc   ;==>ShowTaskbar
 
Func _WinAPI_FindWindowEx($hParent, $hChildAfter, $sClassName, $sWindowName)
    Local $aResult = DllCall("user32.dll", "hwnd", "FindWindowEx", "hwnd", $hParent, "hwnd", $hChildAfter, "wstr", $sClassName, "wstr", $sWindowName)
    If @error Then Return SetError(@error, @extended, 0)
    Return $aResult[0]
EndFunc   ;==>_WinAPI_FindWindowEx

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
MyEarth

FireFox again thank. I have tested the code and work at "half" ( P.S. Change <WinAPIEx.au3> with <WinAPI.au3> )

This line correctly hide the taskbar:

_WinAPI_ShowWindow(_WinAPI_FindWindow("shell_traywnd", ""), 1)

But this, for hide the orb, not work. Very strange:

_WinAPI_ShowWindow(_WinAPI_FindWindowEx(_WinAPI_FindWindow("Desktop", ""), 0, "Button", ""), 1)

I have try also to convert the first script using _WinAPI_FindWindowEx:

#include <WindowsConstants.au3>
#include <SendMessage.au3>
#include <WinAPI.au3>

$_iconParentHwnd = _WinAPI_FindWindow("shell_traywnd", "")
$_iconHwnd = _WinAPI_FindWindowEx($_iconParentHwnd, "", "Start", "")
$iconHdl = _SendMessage($_iconHwnd, $WM_CLOSE) ; same for _WinAPI_ShowWindow

If ($iconHdl = 0) Then
    MsgBox(262144, "Result", "Success!")
Else
    MsgBox(262144, "Result", "Failed!")
EndIf

Func _WinAPI_FindWindowEx($hParent, $hChildAfter, $sClassName, $sWindowName)
    Local $aResult = DllCall("user32.dll", "hwnd", "FindWindowEx", "hwnd", $hParent, "hwnd", $hChildAfter, "wstr", $sClassName, "wstr", $sWindowName)
    If @error Then Return SetError(@error, @extended, 0)
    Return $aResult[0]
EndFunc   ;==>_WinAPI_FindWindowEx

Result is "Success" but don't do nothing. What is the "secret"?

Other useful information:

The start "orb" in Windows Vista is actually a separate top-level window
rather than a child of the taskbar, as it needs to be shaped for its overhang
from a single-row task bar and Microsoft did not want to incur a penalty for
shaping the entire task bar.

I don't remember its details off the top of my head, but if you use Spy++
you should be able to locate it. It can be shown/hidden independently of the
rest of the task bar.

It's definitely doable -- one of our applications does it :-)

-----------------

I can't paste the code itself, but we do it like this:

1. Find the task bar itself.

2. Get the process ID of the Explorer process that owns the task bar.

3. Enumerate all top-level windows.

4. For each window, get its process ID.

5. If it is the same as Explorer's, get the window text.

6. If the window text is "Start", it's our button.

I don't know if this works on localized versions of Windows Vista.

Hopefully this is something you can adapt to your needs :-)

Enjoy,

-----------------

Instead of trying to close it, try just hiding and showing it. In our
application, it responds to ShowWindow with SW_HIDE.

The window cannot be identified by class name. You must first find the
process ID of the owner of the task bar itself (which you *can* find with a
simple FindWindow call), and then enumerate the windows and follow the
procedure I outlined to locate the other top-level windows owned by the same
process. One of those other windows is the start orb.

 

Link

Edited by MyEarth

Share this post


Link to post
Share on other sites
MyEarth

Damn i have do everything that post say ( our software work blablabla i can't post the code blablabla), why not work for me? :pirate:

#include <WinAPI.au3>
#include <Array.au3>
;~ #include <SendMessage.au3>
;~ #include <WindowsConstants.au3>

Local $Explorer_Handle, $Explorer_ID, $Start_Button, $Start_Handle

$Explorer = ProcessList("explorer.exe")
For $i = 1 To $Explorer[0][0]
    $Explorer_ID = $Explorer[$i][1]
Next

MsgBox(0, "ID", $Explorer_ID)
$Explorer_Handle = _GetHwndFromPID($Explorer_ID)
MsgBox(0, "HANDLE", $Explorer_Handle)

$Start_Button = WinList()

For $i = 1 To $Start_Button[0][0]
    If $Start_Button[$i][0] = "Start" And $Start_Button[$i][1] = $Explorer_Handle Then
        MsgBox(0, "Details", "Title=" & $Start_Button[$i][0] & @LF & "Handle=" & $Start_Button[$i][1])
        $Start_Handle = $Start_Button[$i][1]
    EndIf
Next

_WinAPI_ShowWindow($Start_Handle, @SW_HIDE)
;~ _SendMessage($Start_Handle, $WM_CLOSE)

Func _GetHwndFromPID($PID)
    $hWnd = 0
    $stPID = DllStructCreate("int")
    Do
        $winlist2 = WinList()
        For $i = 1 To $winlist2[0][0]
            If $winlist2[$i][0] <> "" Then
                DllCall("user32.dll", "int", "GetWindowThreadProcessId", "hwnd", $winlist2[$i][1], "ptr", DllStructGetPtr($stPID))
                If DllStructGetData($stPID, 1) = $PID Then
                    $hWnd = $winlist2[$i][1]
                    ExitLoop
                EndIf
            EndIf
        Next
        Sleep(100)
    Until $hWnd <> 0
    Return $hWnd
EndFunc   ;==>_GetHwndFromPID
Edited by MyEarth

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Similar Content

    • ufukreis1212
      By ufukreis1212
      Hello, I am new members. Help me please. I want vbs convert to au3 .
      This vbs code : 
      'deneme Set SystemSet = GetObject("winmgmts:").InstancesOf ("Win32_OperatingSystem") strOSArch = GetObject("winmgmts:root\cimv2:Win32_OperatingSystem=@").OSArchitecture Set objNetwork = CreateObject("Wscript.Network") Set wshShell = CreateObject( "WScript.Shell" ) strComputerName = wshShell.ExpandEnvironmentStrings( "%COMPUTERNAME%" ) Set oShell = WScript.CreateObject("WScript.Shell") proc_arch = oShell.ExpandEnvironmentStrings("%PROCESSOR_ARCHITECTURE%") Set oEnv = oShell.Environment("SYSTEM") strComputer = "." Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2") Set colMB = objWMIService.ExecQuery("Select * from Win32_BaseBoard") Set colCSes = objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystem") Set colProcessors = objWMIService.ExecQuery("Select * from Win32_Processor") Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2") Set colItemsx = objWMIService.ExecQuery( _ "SELECT * FROM Win32_VideoController",,48) '------------------------------------------------------------------- Set obj = GetObject("winmgmts:").InstancesOf("Win32_PhysicalMemory") i = 1 For Each obj2 In obj memTmp1 = obj2.capacity / 1024 / 1024 TotalRam = TotalRam + memTmp1 i = i +1 Next '-------------------------------------------------------------------- Dim objWMIService : Set objWMIService = GetObject("winmgmts:\\.\root\cimv2") Set colItems = objWMIService.ExecQuery("Select Architecture from Win32_Processor") For Each objItem in colItems if objItem.Architecture = 0 then strArchitecture = "x86" end if if objItem.Architecture = 9 then strArchitecture = "x64" end if next '-------------------------------------------------------------------- strComputer = "." ' Local computer strMemory = "" i = 1 set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") set colItems = objWMIService.ExecQuery("Select * from Win32_PhysicalMemory") For Each objItem In colItems if strMemory <> "" then strMemory = strMemory & vbcrlf strMemory = strMemory & "Bank" & i & " : " & (objItem.Capacity /1024 /1024) & " Mb" i = i + 1 Next installedModules = i - 1 Set colItems = objWMIService.ExecQuery("Select * from Win32_PhysicalMemoryArray") For Each objItem in colItems totalSlots = objItem.MemoryDevices Next '---------------------------------------------------------------------- Set objWMISvc = GetObject( "winmgmts:\\.\root\cimv2" ) Set colItems = objWMISvc.ExecQuery( "Select * from Win32_ComputerSystem" ) For Each objItem in colItems strComputerDomain = objItem.Domain Next for each System in SystemSet For Each objItem in colItemsx For Each objProcessor in colProcessors For Each bbType In colMB MbVendor = bbType.Manufacturer MbModel = bbType.Product MsgBox "İşletim Sistemi : " & System.Caption & vbNewLine & _ "İşletim Sistemi Versionu : " & + System.Version & vbNewLine & _ "Windows Mimari Yapısı: " & strOSArch & vbNewLine & _ "Kullanıcı isminiz: " & objNetwork.UserName & vbNewLine & _ "Bilgisayar ismi: " & strComputerName & vbNewLine & _ "Çalışma Grubu: " & strComputerDomain & vbNewLine & _ "--------------------------------------" & vbNewLine & _ "Anakart: " & MbVendor & " " & "[" & MbModel & "]" & vbNewLine & _ "--------------------------------------" & vbNewLine & _ "Grafik Kartı: " & objItem.Caption & vbNewLine & _ "Driver Version: " & objItem.DriverVersion & vbNewLine & _ "--------------------------------------" & vbNewLine & _ "İşlemci Üreticisi: " & objProcessor.Manufacturer & vbNewLine & _ "İşlemci İsmi: " & objProcessor.Name & vbNewLine & _ "CPU Mimarisi: " & strArchitecture & vbNewLine & _ "İşlemci Çekirdek sayısı: " & oEnv("NUMBER_OF_PROCESSORS") & vbNewLine & _ "--------------------------------------" & vbNewLine & _ "Toplam RAM: " & TotalRam & " MB" & vbNewLine & _ "Toplam Slot: " & totalSlots & vbNewLine & _ "Boş Slot: " & (totalSlots - installedModules) & vbNewLine & _ "Ramlerin bulunduğu slotlar:" & vbcrlf & strMemory,0,"deneme" Next Next Next Next please help me , thanks.
    • JuanFelipe
      By JuanFelipe
       
      Hello friends, I have a query, it happens that I have a matrix nxn, the first column of this contains each cell a number with 21 digits, when I pass this matrix to Excel I obviously write that number as 1,10016E + 20, I solved it by adding a * at the end of each cell, but I want it to be written as a text so that I do not have to remove that *, I searched in Google but could not find an effective solution, thanks in advance. 
    • Puls3
      By Puls3
      Hi, This is my first post on the AutoIt Forums, I most of the time was able to get help from this community by merely searching though google and have been able to solve hundreds of problems this way, though in this case I was incapable of finding a solution to my problem. I am quite confident that it is a user error (And my fault) but I haven't been able to determine what I did wrong, any and all help would be greatly appreciated! I have uploaded my whole script pardon passwords to provide as much information as possible.
      I declared a global array at the top of the script and am having issues when I try to set it's value, and I fail to understand why.
      Error Message:
      "D:\Projects\AutoIt\Arena\Base.au3" (270) : ==> Subscript used on non-accessible variable.:
      $ExpMax[$i] = IniRead($TempSavePath, "Combatant" & $i, "ExpMax", $ExpMax[0])
      $ExpMax^ ERROR
      ConsoleWrite Log:
      Ran.
      Checking launch parameters.
      No launch parameters.
      Initiating load.
      Checking for save file.
      Save file not found.
      Load canceled.
      Loading or creating Combatant 1
      Base.au3
    • RamDemon
      By RamDemon
      Hi,
      Did anyone tried to  use Redis  with AutoIT as store DB ?
       Redis <-- more about it
      Mladen
    • nooneclose
      By nooneclose
      Hey. I'm working on a new project and was wondering if there is a better way to "update" my Column E array. 
      Here is my code: 
      Local $nI  = 0                                                            ;Creates a name index of 0: nI = Name index Local $nII = 1                                                            ;Creates a name index of 1 for second loop: nII = Name Index 2 For    $iN = 0 To $IndexRows Step 1                                       ;Checks the roster for any names that appear twice      For $iN2 = 0 To $IndexRows Step 1          if $d_Names[$nI] == $d_Names[$nII] And $d_Names[$nII] <> "" Then              Local $timeSheetName = _ArraySearch($e_Names, $d_Names[$nI], 0, 0, 0, 0, 1)              ;MsgBox($MB_SYSTEMMODAL, "Found it", $d_Names[$nI] & " In column E on Row " & $timeSheetName)              Local $eI  = $timeSheetName + 1              ;ConsoleWrite($timeSheetName & @CRLF)              ;ConsoleWrite($eI & @CRLF)              ;ConsoleWrite(@CRLF)              _Excel_RangeInsert($OpenWorkbook.ActiveSheet, "E" & $eI & ":F" & $eI, $xlShiftDown)                                                                          ;Inserts a empty cell in columns E and F.              _Excel_RangeWrite($OpenWorkbook, $OpenWorkbook.ActiveSheet, $d_Names[$nII], "E" & $eI)                                                                         ;Fills the empty cell in columns E with the doubled name              $aArray_Index = 2                                           ;Array element counter              For $Index = 2 To $IndexRows Step 1                        ;Loops through every row in the Excel file unto no rows are found or a null row is found                  $Array_Value_E = _Excel_RangeRead($OpenWorkbook, Default, "E"&$Index)                  $e_names[$aArray_Index] = $Array_Value_E                ;While the code loops every value in column E is stored in the E array (updating the array)                  $aArray_Index += 1              Next              ExitLoop          EndIf      Next      $nI  += 1      $nII += 1 Next Basically, It checks a roster for people whose name appears twice then inserts a new "row" for that person because they work in two different departments.
      I have to find that name however in Column E if two appear in column D. My code works but I think it is not as efficient as it could be. 
      Any ideas on how to improve the "update" for my array?
      (once it finds the double names in Column D it then searches for that name by going name by name in the Column E array and once it finds it inserts a new row. However, the E array doesn't have that new row stored in it so I have to "update" the array to properly find the next name)
      Any and all tips would be greatly appreciated. 
       
      NOTE: Just assume I'm opening the excel file properly please do not add that code in, it only complicates your answer. 
×